1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 05:36:54 +02:00

feat(endpoints): add Media endpoints #565

This commit is contained in:
Awilum
2021-08-14 14:02:10 +03:00
parent fa2e044be8
commit e8663b4e33

View File

@@ -0,0 +1,106 @@
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype;
use Flextype\Endpoints\Content;
/**
* Fetch media
*
* endpoint: GET /api/media
*
* Query:
* id - [REQUIRED] - Unique identifier of the media.
* token - [REQUIRED] - Valid public token.
* options - [OPTIONAL] - Select items in collection by given conditions.
*
* Returns:
* An array of media objects.
*/
app()->get('/api/media', [Content::class, 'fetch']);
/**
* Create media
*
* endpoint: POST /api/media
*
* Body:
* id - [REQUIRED] - Unique identifier of the media.
* token - [REQUIRED] - Valid public token.
* access_token - [REQUIRED] - Valid access token.
* data - [REQUIRED] - Data to store for the media.
*
* Returns:
* Returns the media object for the media that was just created.
*/
app()->post('/api/media', [Content::class, 'create']);
/**
* Update media
*
* endpoint: PATCH /api/media
*
* Body:
* id - [REQUIRED] - Unique identifier of the media.
* token - [REQUIRED] - Valid public token.
* access_token - [REQUIRED] - Valid access token.
* data - [REQUIRED] - Data to update for the media.
*
* Returns:
* Returns the media object for the media that was just updated.
*/
app()->patch('/api/media', [Content::class, 'update']);
/**
* Move media
*
* endpoint: PUT /api/media
*
* Body:
* id - [REQUIRED] - Unique identifier of the media.
* new_id - [REQUIRED] - New Unique identifier of the media.
* token - [REQUIRED] - Valid public token.
* access_token - [REQUIRED] - Valid access token.
*
* Returns:
* Returns the media object for the media that was just moved.
*/
app()->put('/api/media', [Content::class, 'move']);
/**
* Copy media
*
* endpoint: PUT /api/media/copy
*
* Body:
* id - [REQUIRED] - Unique identifier of the media.
* new_id - [REQUIRED] - New Unique identifier of the media.
* token - [REQUIRED] - Valid public token.
* access_token - [REQUIRED] - Valid access token.
*
* Returns:
* Returns the media object for the media that was just copied.
*/
app()->put('/api/media/copy', [Content::class, 'copy']);
/**
* Delete media
*
* endpoint: DELETE /api/media
*
* Body:
* id - [REQUIRED] - Unique identifier of the media.
* token - [REQUIRED] - Valid pulbic token.
* access_token - [REQUIRED] - Valid access token.
*
* Returns:
* Returns an empty body with HTTP status 204
*/
app()->delete('/api/media', [Content::class, 'delete']);