Automattic\WooCommerce\Internal\Admin\Settings

PaymentsRestController::get_schema_for_incentiveprivateWC 1.0

Get the schema for an incentive.

Method of the class: PaymentsRestController{}

No Hooks.

Returns

Array. The incentive schema.

Usage

// private - for code of main (parent) class only
$result = $this->get_schema_for_incentive(): array;

PaymentsRestController::get_schema_for_incentive() code WC 9.9.4

private function get_schema_for_incentive(): array {
	return array(
		'type'        => 'object',
		'description' => esc_html__( 'The active incentive for the provider.', 'woocommerce' ),
		'context'     => array( 'view', 'edit' ),
		'readonly'    => true,
		'properties'  => array(
			'id'                => array(
				'type'        => 'string',
				'description' => esc_html__( 'The incentive unique ID. This ID needs to be used for incentive dismissals.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'promo_id'          => array(
				'type'        => 'string',
				'description' => esc_html__( 'The incentive promo ID. This ID need to be fed into the onboarding flow.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'title'             => array(
				'type'        => 'string',
				'description' => esc_html__( 'The incentive title. It can contain stylistic HTML.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'description'       => array(
				'type'        => 'string',
				'description' => esc_html__( 'The incentive description. It can contain stylistic HTML.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'short_description' => array(
				'type'        => 'string',
				'description' => esc_html__( 'The short description of the incentive. It can contain stylistic HTML.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'cta_label'         => array(
				'type'        => 'string',
				'description' => esc_html__( 'The call to action label for the incentive.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'tc_url'            => array(
				'type'        => 'string',
				'description' => esc_html__( 'The URL to the terms and conditions for the incentive.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'badge'             => array(
				'type'        => 'string',
				'description' => esc_html__( 'The badge label for the incentive.', 'woocommerce' ),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'_dismissals'       => array(
				'type'        => 'array',
				'description' => esc_html__( 'The dismissals list for the incentive. Each dismissal entry includes a context and a timestamp. The `all` entry means the incentive was dismissed for all contexts.', 'woocommerce' ),
				'uniqueItems' => true,
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'context'   => array(
							'type'        => 'string',
							'description' => esc_html__( 'Context ID in which the incentive was dismissed.', 'woocommerce' ),
							'readonly'    => true,
						),
						'timestamp' => array(
							'type'        => 'integer',
							'description' => esc_html__( 'Unix timestamp representing when the incentive was dismissed.', 'woocommerce' ),
							'readonly'    => true,
						),
					),
				),
			),
			'_links'            => array(
				'type'       => 'object',
				'context'    => array( 'view', 'edit' ),
				'readonly'   => true,
				'properties' => array(
					'dismiss' => array(
						'type'        => 'object',
						'description' => esc_html__( 'The link to dismiss the incentive.', 'woocommerce' ),
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
						'properties'  => array(
							'href' => array(
								'type'        => 'string',
								'description' => esc_html__( 'The URL to dismiss the incentive.', 'woocommerce' ),
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
						),
					),
					'onboard' => array(
						'type'        => 'object',
						'description' => esc_html__( 'The start/continue onboarding link for the payment gateway.', 'woocommerce' ),
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
						'properties'  => array(
							'href' => array(
								'type'        => 'string',
								'description' => esc_html__( 'The URL to start/continue onboarding for the payment gateway.', 'woocommerce' ),
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
						),
					),
				),
			),
		),
	);
}