return $schema; } /** * Returns the arguments for the update request. * * @since 6.15.0 * * @return QueryArgumentCollection */ public function update_args(): QueryArgumentCollection { return new QueryArgumentCollection(); } /** * Returns the OpenAPI schema for updating an organizer. * * @since 6.15.0 * * @return OpenAPI_Schema */ public function update_schema(): OpenAPI_Schema { $collection = new RequestBodyCollection(); $definition = new Organizer_Request_Body_Definition(); $collection->set_example( $definition->get_example() ); $collection[] = new Definition_Parameter( $definition ); $schema = new OpenAPI_Schema( fn() => __( 'Update an Organizer', 'the-events-calendar' ), fn() => __( 'Updates an existing organizer', 'the-events-calendar' ), $this->get_operation_id( 'update' ), $this->get_tags(), $this->get_path_parameters(), null, $collection->set_description_provider( fn() => __( 'The organizer data to update.', 'the-events-calendar' ) )->set_required( true ), true ); $response = new Definition_Parameter( new Organizer_Definition() ); $schema->add_response( 200, fn() => __( 'Organizer updated successfully', 'the-events-calendar' ), null, 'application/json', $response, ); $schema->add_response( 400, fn() => __( 'Invalid request data', 'the-events-calendar' ), ); $schema->add_response( 401, fn() => __( 'You are not logged in', 'the-events-calendar' ), ); $schema->add_response( 403, fn() => __( 'You do not have permission to update this organizer', 'the-events-calendar' ), ); $schema->add_response( 404, fn() => __( 'The requested organizer was not found', 'the-events-calendar' ), ); $schema->add_response( 500, fn() => __( 'Failed to update the organizer', 'the-events-calendar' ), ); return $schema; } /** * Returns the OpenAPI schema for deleting an organizer. * * @since 6.15.0 * * @return OpenAPI_Schema */ public function delete_schema(): OpenAPI_Schema { $schema = new OpenAPI_Schema( fn() => __( 'Delete an Organizer', 'the-events-calendar' ), fn() => __( 'Deletes an existing organizer', 'the-events-calendar' ), $this->get_operation_id( 'delete' ), $this->get_tags(), $this->get_path_parameters(), $this->delete_args(), null, true ); $schema->add_response( 200, fn() => __( 'Organizer deleted successfully', 'the-events-calendar' ), ); $schema->add_response( 401, fn() => __( 'You are not logged in', 'the-events-calendar' ), ); $schema->add_response( 403, fn() => __( 'You do not have permission to delete this organizer', 'the-events-calendar' ), ); $schema->add_response( 404, fn() => __( 'The requested organizer was not found', 'the-events-calendar' ), ); $schema->add_response( 410, fn() => __( 'The organizer has already been trashed', 'the-events-calendar' ), ); $schema->add_response( 500, fn() => __( 'Failed to delete the organizer', 'the-events-calendar' ), ); $schema->add_response( 501, fn() => __( 'The organizer does not support trashing. Set force=true to delete', 'the-events-calendar' ), ); return $schema; } /** * Returns the tags for the endpoint. * * @since 6.15.0 * * @return Tag[] */ public function get_tags(): array { return [ tribe( TEC_Tag::class ) ]; } /** * Returns the operation ID for the endpoint. * * @since 6.15.0 * * @param string $operation The operation to get the operation ID for. * * @return string * * @throws InvalidArgumentException If the operation is invalid. */ public function get_operation_id( string $operation ): string { switch ( $operation ) { case 'read': return 'getOrganizer'; case 'update': return 'updateOrganizer'; case 'delete': return 'deleteOrganizer'; } throw new InvalidArgumentException( sprintf( 'Invalid operation: %s', $operation ) ); } }