-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jolelievre/first-endpoint
First endpoint for API Access
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |