WC_REST_Webhooks_V2_Controller::get_item_schema()publicWC 1.0

Get the Webhook's schema, conforming to JSON Schema.

Method of the class: WC_REST_Webhooks_V2_Controller{}

No Hooks.

Return

Array.

Usage

$WC_REST_Webhooks_V2_Controller = new WC_REST_Webhooks_V2_Controller();
$WC_REST_Webhooks_V2_Controller->get_item_schema();

WC_REST_Webhooks_V2_Controller::get_item_schema() code WC 8.6.1

public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'webhook',
		'type'       => 'object',
		'properties' => array(
			'id'                => array(
				'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'name'              => array(
				'description' => __( 'A friendly name for the webhook.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'status'            => array(
				'description' => __( 'Webhook status.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'active',
				'enum'        => array_keys( wc_get_webhook_statuses() ),
				'context'     => array( 'view', 'edit' ),
			),
			'topic'             => array(
				'description' => __( 'Webhook topic.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'resource'          => array(
				'description' => __( 'Webhook resource.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'event'             => array(
				'description' => __( 'Webhook event.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'hooks'             => array(
				'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ),
				'type'        => 'array',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
				'items'       => array(
					'type' => 'string',
				),
			),
			'delivery_url'      => array(
				'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ),
				'type'        => 'string',
				'format'      => 'uri',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'secret'            => array(
				'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'edit' ),
			),
			'date_created'      => array(
				'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_created_gmt'  => array(
				'description' => __( 'The date the webhook was created, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_modified'     => array(
				'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_modified_gmt' => array(
				'description' => __( 'The date the webhook was last modified, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

	return $this->add_additional_fields_schema( $schema );
}