Skip to content

Commit

Permalink
Merge pull request #2 from jolelievre/first-endpoint
Browse files Browse the repository at this point in the history
First endpoint for API Access
  • Loading branch information
jolelievre authored Oct 4, 2023
2 parents d13b965 + 50d8a11 commit 426dae6
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PHP tests
on: [push, pull_request]
jobs:
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 8.1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Checkout
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v3
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Install dependencies
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no
9 changes: 9 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$config = new PrestaShop\CodingStandards\CsFixer\Config();

/** @var \Symfony\Component\Finder\Finder $finder */
$finder = $config->setUsingCache(true)->getFinder();
$finder->in(__DIR__)->exclude('vendor');

return $config;
84 changes: 84 additions & 0 deletions src/ApiPlatform/Resources/ApiAccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Exception\ApiAccessNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\ApiAccess\Query\GetApiAccessForEditing;
use PrestaShopBundle\ApiPlatform\Provider\QueryProvider;

#[ApiResource(
operations: [
new Get(
uriTemplate: '/api-access/{apiAccessId}',
requirements: ['apiAccessId' => '\d+'],
openapiContext: [
'summary' => 'Get API Access details',
'description' => 'Get API Access public details only, sensitive informations like secrets are not returned',
'parameters' => [
[
'name' => 'id',
'in' => 'path',
'required' => true,
'schema' => [
'type' => 'string',
],
'description' => 'Id of the API Access you are requesting the details from',
],
[
'name' => 'Authorization',
'in' => 'scopes',
'description' => 'api_access_read',
],
],
],
exceptionToStatus: [ApiAccessNotFoundException::class => 404],
provider: QueryProvider::class,
extraProperties: [
'query' => GetApiAccessForEditing::class,
'scopes' => ['api_access_read'],
]
),
],
)]
class ApiAccess
{
#[ApiProperty(identifier: true)]
public int $apiAccessId;

public string $clientName;

public string $clientId;

public string $description;

public bool $enabled;
}

0 comments on commit 426dae6

Please sign in to comment.