Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions src/ApiPlatform/Resources/Carrier/CarrierSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?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 Academic Free License version 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/AFL-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 license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Carrier;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use PrestaShop\PrestaShop\Core\Domain\Carrier\Command\SetCarrierRangesCommand;
use PrestaShop\PrestaShop\Core\Domain\Carrier\Command\SetCarrierTaxRuleGroupCommand;
use PrestaShop\PrestaShop\Core\Domain\Carrier\Exception\CarrierConstraintException;
use PrestaShop\PrestaShop\Core\Domain\Carrier\Exception\CarrierNotFoundException;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSUpdate;
use Symfony\Component\HttpFoundation\Response;

#[ApiResource(
operations: [
new CQRSUpdate(
uriTemplate: '/carriers/{carrierId}/ranges',
requirements: ['carrierId' => '\d+'],
openapiContext: ['summary' => 'Set carrier ranges', 'description' => 'Sets the delivery ranges and prices for a carrier'],
CQRSCommand: SetCarrierRangesCommand::class,
scopes: [
'carrier_write',
],
CQRSCommandMapping: [
'[_context][shopConstraint]' => '[shopConstraint]',
],
),
new CQRSUpdate(
uriTemplate: '/carriers/{carrierId}/tax-rule-group',
requirements: ['carrierId' => '\d+'],
openapiContext: ['summary' => 'Set carrier tax rule group', 'description' => 'Sets the tax rule group for a carrier'],
CQRSCommand: SetCarrierTaxRuleGroupCommand::class,
scopes: [
'carrier_write',
],
CQRSCommandMapping: [
'[_context][shopConstraint]' => '[shopConstraint]',
],
),
],
exceptionToStatus: [
CarrierNotFoundException::class => Response::HTTP_NOT_FOUND,
CarrierConstraintException::class => Response::HTTP_UNPROCESSABLE_ENTITY,
],
)]
class CarrierSettings
{
#[ApiProperty(identifier: true)]
public int $carrierId;

#[ApiProperty(openapiContext: [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'id_zone' => ['type' => 'integer'],
'range_from' => ['type' => 'number'],
'range_to' => ['type' => 'number'],
'range_price' => ['type' => 'string'],
],
],
'example' => [
[
'id_zone' => 1,
'range_from' => 0,
'range_to' => 10,
'range_price' => '5.00',
],
],
])]
public array $ranges;

public int $carrierTaxRuleGroupId;
}
84 changes: 84 additions & 0 deletions src/ApiPlatform/Resources/Category/CategoryQueries.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 Academic Free License version 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/AFL-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 license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Category;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException;
use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoriesTree;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSCommand;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet;
use Symfony\Component\HttpFoundation\Response;

#[ApiResource(
operations: [
new CQRSGet(
uriTemplate: '/categories/tree',
openapiContext: ['summary' => 'Get categories tree', 'description' => 'Retrieves the full category tree for a given language and shop'],
CQRSQuery: GetCategoriesTree::class,
scopes: [
'category_read',
],
CQRSQueryMapping: [
'[_context][langId]' => '[languageId]',
'[_context][shopId]' => '[shopId]',
],
),
new CQRSCommand(
uriTemplate: '/categories/{categoryId}/position',
method: 'PATCH',
requirements: ['categoryId' => '\d+'],
openapiContext: ['summary' => 'Update category position', 'description' => 'Updates the position of a category within its parent'],
CQRSCommand: UpdateCategoryPositionCommand::class,
scopes: [
'category_write',
],
),
],
exceptionToStatus: [
CategoryNotFoundException::class => Response::HTTP_NOT_FOUND,
CategoryConstraintException::class => Response::HTTP_UNPROCESSABLE_ENTITY,
],
)]
class CategoryQueries
{
#[ApiProperty(identifier: true)]
public int $categoryId;

public int $parentCategoryId;

public int $way;

#[ApiProperty(openapiContext: [
'type' => 'array',
'items' => [
'type' => 'string',
],
'example' => ['1_0', '2_1', '3_2'],
])]
public array $positions;

public bool $foundFirst;
}
96 changes: 96 additions & 0 deletions src/ApiPlatform/Resources/Country/Country.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?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 Academic Free License version 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/AFL-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 license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Country;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use PrestaShop\PrestaShop\Core\Domain\Country\Command\EditCountryCommand;
use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException;
use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryForEditing;
use PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryRequiredFields;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSPartialUpdate;
use PrestaShopBundle\ApiPlatform\Metadata\LocalizedValue;
use Symfony\Component\HttpFoundation\Response;

#[ApiResource(
operations: [
new CQRSGet(
uriTemplate: '/countries/{countryId}/required-fields',
requirements: ['countryId' => '\d+'],
openapiContext: ['summary' => 'Get country required fields', 'description' => 'Retrieves the required fields for a country'],
CQRSQuery: GetCountryRequiredFields::class,
scopes: [
'country_read',
],
),
new CQRSPartialUpdate(
uriTemplate: '/countries/{countryId}',
requirements: ['countryId' => '\d+'],
openapiContext: ['summary' => 'Edit country', 'description' => 'Updates a country configuration'],
CQRSCommand: EditCountryCommand::class,
CQRSQuery: GetCountryForEditing::class,
scopes: [
'country_write',
],
),
],
exceptionToStatus: [
CountryNotFoundException::class => Response::HTTP_NOT_FOUND,
CountryConstraintException::class => Response::HTTP_UNPROCESSABLE_ENTITY,
],
)]
class Country
{
#[ApiProperty(identifier: true)]
public int $countryId;

#[LocalizedValue]
public array $localizedNames;

public string $isoCode;

public int $callPrefix;

public int $defaultCurrency;

public ?int $zoneId = null;

public bool $needZipCode;

public ?string $zipCodeFormat = null;

public string $addressFormat;

public bool $enabled;

public bool $containsStates;

public bool $needIdNumber;

public bool $displayTaxLabel;

#[ApiProperty(openapiContext: ['type' => 'array', 'items' => ['type' => 'integer'], 'example' => [1, 2]])]
public array $shopAssociation;
}
64 changes: 64 additions & 0 deletions src/ApiPlatform/Resources/Currency/CurrencyQueries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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 Academic Free License version 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/AFL-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 license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Currency;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\ExchangeRateNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate;
use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency;
use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet;
use Symfony\Component\HttpFoundation\Response;

#[ApiResource(
operations: [
new CQRSGet(
uriTemplate: '/currencies/exchange-rate/{isoCode}',
requirements: ['isoCode' => '[A-Z]{3}'],
openapiContext: ['summary' => 'Get currency exchange rate', 'description' => 'Retrieves the exchange rate for a currency compared to the default shop currency'],
CQRSQuery: GetCurrencyExchangeRate::class,
scopes: [
'currency_read',
],
),
new CQRSGet(
uriTemplate: '/currencies/reference/{isoCode}',
requirements: ['isoCode' => '[A-Z]{3}'],
openapiContext: ['summary' => 'Get reference currency', 'description' => 'Retrieves reference currency data from the CLDR database'],
CQRSQuery: GetReferenceCurrency::class,
scopes: [
'currency_read',
],
),
],
exceptionToStatus: [
CurrencyNotFoundException::class => Response::HTTP_NOT_FOUND,
ExchangeRateNotFoundException::class => Response::HTTP_NOT_FOUND,
],
)]
class CurrencyQueries
{
#[ApiProperty(identifier: true)]
public string $isoCode;
}
Loading