Skip to content

Commit

Permalink
Merge pull request PrestaShop#6 from jolelievre/api-access-add-endpoints
Browse files Browse the repository at this point in the history
Add create and update endpoints for ApiAccess API
  • Loading branch information
matks authored Nov 28, 2023
2 parents 112089f + 3fdabc8 commit a93ad67
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/ApiPlatform/Resources/ApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Command\AddApiAccessCommand;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Command\DeleteApiAccessCommand;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Command\EditApiAccessCommand;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Exception\ApiAccessNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Query\GetApiAccessForEditing;
use PrestaShopBundle\ApiPlatform\Processor\CommandProcessor;
use PrestaShopBundle\ApiPlatform\Provider\QueryProvider;

#[ApiResource(
Expand Down Expand Up @@ -60,10 +67,10 @@
],
],
],
exceptionToStatus: [ApiAccessNotFoundException::class => 404],
provider: QueryProvider::class,
extraProperties: [
'query' => GetApiAccessForEditing::class,
'CQRSQuery' => GetApiAccessForEditing::class,
'scopes' => ['api_access_read'],
]
),
Expand All @@ -90,25 +97,54 @@
],
],
],
exceptionToStatus: [ApiAccessNotFoundException::class => 404],
provider: CommandProcessor::class,
output: false,
provider: QueryProvider::class,
extraProperties: [
'query' => DeleteApiAccessCommand::class,
'CQRSQuery' => DeleteApiAccessCommand::class,
'scopes' => ['api_access_write'],
]
),
new Post(
uriTemplate: '/api-access',
processor: CommandProcessor::class,
extraProperties: [
'command' => AddApiAccessCommand::class,
'CQRSCommand' => AddApiAccessCommand::class,
'scopes' => ['api_access_write'],
]
),
new Put(
uriTemplate: '/api-access/{apiAccessId}',
read: false,
processor: CommandProcessor::class,
extraProperties: [
'command' => EditApiAccessCommand::class,
'query' => GetApiAccessForEditing::class,
'CQRSCommand' => EditApiAccessCommand::class,
'CQRSQuery' => GetApiAccessForEditing::class,
'scopes' => ['api_access_write'],
]
),
],
exceptionToStatus: [ApiAccessNotFoundException::class => 404],
)]
class ApiAccess
{
#[ApiProperty(identifier: true)]
public int $apiAccessId;

public string $clientName;
public string $secret;

public string $clientId;
public string $apiClientId;

public string $clientName;

public string $description;

public bool $enabled;

public int $lifetime;

public array $scopes;
}

0 comments on commit a93ad67

Please sign in to comment.