Automattic\WooCommerce\Internal\PushNotifications\Controllers
PushTokenRestController::get_args
Get the accepted arguments for the POST request.
Method of the class: PushTokenRestController{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_args( ?string $context ): array;
- ?string $context
- .
Default:null
Changelog
| Since 10.6.0 | Introduced. |
PushTokenRestController::get_args() PushTokenRestController::get args code WC 10.8.1
private function get_args( ?string $context = null ): array {
$args = array(
'id' => array(
'description' => __( 'Push Token ID', 'woocommerce' ),
'type' => 'integer',
'required' => true,
'context' => array( 'delete' ),
'minimum' => 1,
'sanitize_callback' => 'absint',
'validate_callback' => array( $this, 'validate_argument' ),
),
'origin' => array(
'description' => __( 'Origin', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'enum' => PushToken::ORIGINS,
'validate_callback' => array( $this, 'validate_argument' ),
),
'device_uuid' => array(
'description' => __( 'Device UUID', 'woocommerce' ),
'default' => '',
'type' => 'string',
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'sanitize_text_field',
),
'device_locale' => array(
'description' => __( 'Device Locale', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'sanitize_text_field',
),
'platform' => array(
'description' => __( 'Platform', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'enum' => PushToken::PLATFORMS,
'validate_callback' => array( $this, 'validate_argument' ),
),
'token' => array(
'description' => __( 'Push Token', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'wp_unslash',
),
'metadata' => array(
'description' => __( 'Metadata', 'woocommerce' ),
'type' => 'object',
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'wp_unslash',
),
);
if ( $context ) {
$args = array_filter(
$args,
fn ( $arg ) => in_array( $context, $arg['context'], true )
);
}
return $args;
}