*/ protected function input_properties(): array { return array( 'id' => array( 'type' => 'integer', 'description' => __( 'Product id.', 'acrossai-abilities-manager' ) ), 'sale_price' => array( 'type' => 'string', 'description' => __( 'Sale price. Must be below the regular price.', 'acrossai-abilities-manager' ) ), 'from' => array( 'type' => 'string', 'description' => __( 'Start date, YYYY-MM-DD. Optional.', 'acrossai-abilities-manager' ) ), 'to' => array( 'type' => 'string', 'description' => __( 'End date, YYYY-MM-DD. Optional.', 'acrossai-abilities-manager' ) ), 'clear' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'End the sale and remove any schedule.', 'acrossai-abilities-manager' ) ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'product' => array( 'type' => 'object', 'additionalProperties' => true ), 'lookup_state' => array( 'type' => 'object', 'additionalProperties' => true ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $fields = $input; unset( $fields['id'] ); return Product_Repository::schedule_sale( (int) $input['id'], $fields ); } }