array( 'type' => 'string', 'description' => __( 'The organizer name.', 'acrossai-abilities-manager' ), ), 'status' => array( 'type' => 'string', 'enum' => array( 'draft', 'pending', 'private', 'publish' ), 'description' => __( 'Post status.', 'acrossai-abilities-manager' ), ), 'phone' => array( 'type' => 'string', 'description' => __( 'Phone number.', 'acrossai-abilities-manager' ), ), 'email' => array( 'type' => 'string', 'description' => __( 'Email address.', 'acrossai-abilities-manager' ), ), 'website' => array( 'type' => 'string', 'description' => __( 'Website URL.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'title' ); } protected function output_properties(): array { return array( 'organizer' => array( 'type' => 'object' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => false, ); } protected function run( array $input ) { $args = array(); foreach ( array( 'title' => 'organizer', 'status' => 'status', 'phone' => 'phone', 'email' => 'email', 'website' => 'website' ) as $in => $alias ) { if ( array_key_exists( $in, $input ) ) { $args[ $alias ] = $input[ $in ]; } } if ( ! isset( $args['status'] ) ) { $args['status'] = 'draft'; } $created = Event_Repository::create( 'organizer', $args ); if ( is_wp_error( $created ) ) { return $created; } return array( 'organizer' => Event_Repository::describe_linked( (int) $created->ID, 'organizer' ), 'message' => sprintf( /* translators: 1: name, 2: ID */ __( 'Created "%1$s" as organizer %2$d.', 'acrossai-abilities-manager' ), get_the_title( (int) $created->ID ), (int) $created->ID ), ); } }