Skip to content

Commit

Permalink
csfix
Browse files Browse the repository at this point in the history
  • Loading branch information
gam6itko committed Jul 17, 2023
1 parent 00e7f74 commit 5d4321a
Show file tree
Hide file tree
Showing 29 changed files with 116 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .php_cs.dist.php → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRiskyAllowed(true)
->setRules($rules)
Expand Down
6 changes: 3 additions & 3 deletions bin/is_realized.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
'/v1/categories/{category_id}/attributes' => null,
'/v1/category/tree' => [CategoriesService::class, 'tree'],
'/v1/category/attribute' => [CategoriesService::class, 'attributes'],
'/v1/product/info/description' => null, //todo
'/v1/product/info/description' => null, // todo
'/v1/product/list/price' => [V1ProductService::class, 'price'],
'/v1/product/prepayment/set' => [V1ProductService::class, 'setPrepayment'],
'/v1/products/info/{product_id}' => [V1ProductService::class, 'info'],
Expand Down Expand Up @@ -69,7 +69,7 @@

echo "$path: ";

//mark as deprecated
// mark as deprecated
$conf = reset($confArr);
if (!empty($conf['deprecated']) && isDeprecated($path)) {
echo "\033[01;33mdeprecated \033[0m";
Expand All @@ -78,7 +78,7 @@
if (empty($classMethod)) {
echo "\033[01;31mNotRealized\033[0m";
} else {
//show class::method
// show class::method
echo "\033[01;32m".implode('::', $classMethod)."\033[0m";
}

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"require-dev": {
"ext-curl": "*",
"dg/bypass-finals": "^1.2",
"friendsofphp/php-cs-fixer": "^3.13",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^7.4||^8.0||^9.0",
"php-http/guzzle6-adapter": "^2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/v3.posting.fbs.list.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$list = $svc->unfulfilledList([
'filter' => [
'delivering_date_from' => '2019-08-24T14:15:22Z',
'delivering_date_to' => '2019-08-24T14:15:22Z'
]
'delivering_date_to' => '2019-08-24T14:15:22Z',
],
]);
var_dump($list);
10 changes: 5 additions & 5 deletions examples/v3.posting.fbs.ship.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
[
'exemplar_info' => [
[
'is_gtd_absent' => true
]
'is_gtd_absent' => true,
],
],
'quantity' => 1,
'product_id' => 2222222222,
]
],
];

$packages = [
[
'products' => $products
]
'products' => $products,
],
];

$response = $svc->ship($packages, '111111111-2222-3', ['additional_data' => true]);
Expand Down
5 changes: 1 addition & 4 deletions src/Service/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class AbstractService
/** @var StreamFactoryInterface */
protected $streamFactory;

public function __construct(array $config, ClientInterface $client, ?RequestFactoryInterface $requestFactory = null, ?StreamFactoryInterface $streamFactory = null)
public function __construct(array $config, ClientInterface $client, RequestFactoryInterface $requestFactory = null, StreamFactoryInterface $streamFactory = null)
{
$this->parseConfig($config);
$this->client = $client;
Expand Down Expand Up @@ -150,9 +150,6 @@ protected function request(string $method, string $uri = '', $body = null, bool
}
}

/**
* @param string $responseBodyContents
*/
protected function throwOzonException(string $responseBodyContents): void
{
/** @var TOzonErrorData $errorData */
Expand Down
14 changes: 7 additions & 7 deletions src/Service/V1/AnalyticsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function data(
): array {
$body = [
'date_from' => $dateFrom->format('Y-m-d'),
'date_to' => $dateTo->format('Y-m-d'),
'date_to' => $dateTo->format('Y-m-d'),
'dimension' => $dimension,
'metrics' => $metrics,
'offset' => $offset,
'limit' => $limit,
'filters' => $filters,
'sort' => $sort,
'metrics' => $metrics,
'offset' => $offset,
'limit' => $limit,
'filters' => $filters,
'sort' => $sort,
];

return $this->request('POST', "{$this->path}/data", $body);
Expand All @@ -48,7 +48,7 @@ public function stockOnWarehouses(int $offset = 0, int $limit = 10): array
{
$body = [
'offset' => $offset,
'limit' => $limit,
'limit' => $limit,
];

return $this->request(
Expand Down
2 changes: 1 addition & 1 deletion src/Service/V1/CategoriesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CategoriesService extends AbstractService
* @deprecated use V2\CategoryService::tree
* @see http://cb-api.ozonru.me/apiref/en/#t-title_get_categories_tree
*
* @param int $categoryId
* @param int $categoryId
* @param 'EN'|'RU' $language
*
* @return array
Expand Down
1 change: 0 additions & 1 deletion src/Service/V1/ChatService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* page?: int,
* page_size?: int,
* }
*
* @psalm-type THistoryQuery = array{
* from_message_id?: int,
* limit?: int,
Expand Down
33 changes: 9 additions & 24 deletions src/Service/V1/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* sku?: int,
* offer_id?: string
* }
*
* @psalm-type TPagination = array{page?: int, page_size?: int}
*/
class ProductService extends AbstractService
Expand Down Expand Up @@ -151,12 +150,11 @@ public function importInfo(int $taskId)
* @param int $productId Id of product in Ozon system
*
* @return array
* @deprecated use V2\ProductService::info
*
* Receive product info.
* @deprecated use V2\ProductService::info
*
* Receive product info
* @see http://cb-api.ozonru.me/apiref/en/#t-title_get_products_info
*
*/
public function info(int $productId)
{
Expand Down Expand Up @@ -187,10 +185,10 @@ public function infoBy(array $query)
* @param TPagination $pagination
*
* @return array
* @deprecated use V4\ProductService::infoPrices
*
* Receive products prices info.
* @deprecated use V4\ProductService::infoPrices
*
* Receive products prices info
* @see https://cb-api.ozonru.me/apiref/en/#t-title_get_product_info_prices
*/
public function infoPrices(array $pagination = [])
Expand All @@ -210,8 +208,7 @@ public function infoPrices(array $pagination = [])
*
* @deprecated use V3\ProductService::infoStocks
*
* Receive products stocks info.
*
* Receive products stocks info
* @deprecated
* @see https://cb-api.ozonru.me/apiref/en/#t-title_get_product_info_stocks
*/
Expand All @@ -235,7 +232,6 @@ public function infoStocks(array $pagination = [])
* [product_id] string|int|array,
* [visibility] string
* [page] int
*
* @see http://cb-api.ozonru.me/apiref/en/#t-title_get_products_list
*/
public function list(array $query = [], array $pagination = []): array
Expand Down Expand Up @@ -269,8 +265,6 @@ public function list(array $query = [], array $pagination = []): array
*
* @see http://cb-api.ozonru.me/apiref/en/#t-title_post_products_prices
*
* @param $input
*
* @return array
*/
public function importPrices(array $input)
Expand Down Expand Up @@ -326,15 +320,12 @@ public function importPrices(array $input)
}

/**
* @param $input
*
* @return array
* @deprecated use V2\ProductService::importStocks
*
* Update product stocks.
* @deprecated use V2\ProductService::importStocks
*
* Update product stocks
* @see http://cb-api.ozonru.me/apiref/en/#t-title_post_products_stocks
*
*/
public function importStocks(array $input)
{
Expand Down Expand Up @@ -571,8 +562,6 @@ public function picturesImport(array $query): array

/**
* @param string[]|string $productId
*
* @return array
*/
public function picturesInfo($productId): array
{
Expand All @@ -585,10 +574,6 @@ public function picturesInfo($productId): array
* Receive product content rating by sku.
*
* @see https://seller-edu.ozon.ru/docs/work-with-goods/content-rating.html
*
* @param array $query
*
* @return array
*/
public function ratingBySku(array $query): array
{
Expand All @@ -597,7 +582,7 @@ public function ratingBySku(array $query): array
'skus' => 'arrOfInt',
]);

return $this->request('POST', "/v1/product/rating-by-sku", $query);
return $this->request('POST', '/v1/product/rating-by-sku', $query);
}

/**
Expand All @@ -612,6 +597,6 @@ public function infoDescription(array $query): array
$query = ArrayHelper::pick($query, ['product_id', 'offer_id']);
$query = TypeCaster::castArr($query, ['product_id' => 'int', 'offer_id' => 'str']);

return $this->request('POST', "/v1/product/info/description", $query);
return $this->request('POST', '/v1/product/info/description', $query);
}
}
3 changes: 1 addition & 2 deletions src/Service/V2/CategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @author Alexander Strizhak <gam6itko@gmail.com>
*
* @psalm-type TAttributeQuery = array{attribute_type?: string, language?: string}
*
* @psalm-type TAttributeValuesQuery = array{
* category_id?: int,
* attribute_id?: int,
Expand Down Expand Up @@ -96,7 +95,7 @@ public function attributeValueByOption(string $language = 'RU', array $options =
/**
* @see https://api-seller.ozon.ru/v2/category/tree
*/
public function tree(?int $categoryId = null, string $language = 'DEFAULT')
public function tree(int $categoryId = null, string $language = 'DEFAULT')
{
$body = [
'language' => $language,
Expand Down
2 changes: 1 addition & 1 deletion src/Service/V2/Posting/CrossborderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function cancelReasons(): array
/**
* @see https://cb-api.ozonru.me/apiref/en/#t-fbs_ship
*
* @return array List of postings IDs.
* @return array list of postings IDs
*/
public function ship(string $postingNumber, string $track, int $shippingProviderId, array $items): array
{
Expand Down
16 changes: 15 additions & 1 deletion src/Service/V2/Posting/FboService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@
use Gam6itko\OzonSeller\Utils\ArrayHelper;
use Gam6itko\OzonSeller\Utils\WithResolver;

/**
* @psalm-type TListFilter = array{
* status?: string,
* since?: string|\DateTimeInterface,
* to?: string|\DateTimeInterface,
* }
* @psalm-type TListRequestData = array{
* filter?: TListFilter,
* dir: string,
* offset?: int,
* limit?: int,
* with?: array
* }
*/
class FboService extends AbstractService implements HasOrdersInterface, GetOrderInterface
{
private $path = '/v2/posting/fbo';

/**
* @see https://cb-api.ozonru.me/apiref/en/#t-fbo_list
*
* @param array $filter [since, to, status]
* @param TListRequestData $requestData
*/
public function list(array $requestData = []): array
{
Expand Down
25 changes: 19 additions & 6 deletions src/Service/V2/Posting/FbsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@
use Gam6itko\OzonSeller\Utils\ArrayHelper;
use Gam6itko\OzonSeller\Utils\WithResolver;

/**
* @psalm-type TListFilter = array{
* status?: string,
* since?: string|\DateTimeInterface,
* to?: string|\DateTimeInterface,
* }
* @psalm-type TListRequestData = array{
* filter?: TListFilter,
* dir: string,
* offset?: int,
* limit?: int,
* }
*/
class FbsService extends AbstractService implements HasOrdersInterface, HasUnfulfilledOrdersInterface, GetOrderInterface
{
private $path = '/v2/posting/fbs';

/**
* @param array $filter [since, to, status]
* @param TListRequestData $requestData
*
* @deprecated use V3\Posting\FbsService::list
* @see https://cb-api.ozonru.me/apiref/en/#t-fbs_list
Expand Down Expand Up @@ -156,7 +169,7 @@ public function cancel(string $postingNumber, int $cancelReasonId, string $cance

public function cancelReasons(): array
{
return $this->request('POST', "{$this->path}/cancel-reason/list", '{}'); //todo свериться с исправленной документацией
return $this->request('POST', "{$this->path}/cancel-reason/list", '{}'); // todo свериться с исправленной документацией
}

/**
Expand Down Expand Up @@ -184,7 +197,7 @@ public function getByBarcode(string $barcode): array
return $this->request('POST', "{$this->path}/get-by-barcode", ['barcode' => $barcode]);
}

//<editor-fold desc="/act">
// <editor-fold desc="/act">

/**
* @see https://docs.ozon.ru/api/seller/#operation/PostingAPI_PostingFBSActCreate
Expand Down Expand Up @@ -226,9 +239,9 @@ public function actGetContainerLabels(int $id): string
return $this->request('POST', "{$this->path}/act/get-container-labels", ['id' => $id], false);
}

//</editor-fold>
// </editor-fold>

//<editor-fold desc="/v2/fbs/posting">
// <editor-fold desc="/v2/fbs/posting">

/**
* @param array|string $postingNumber
Expand Down Expand Up @@ -295,5 +308,5 @@ public function setTrackingNumber(array $trackingNumbers): array
return $this->request('POST', '/v2/fbs/posting/tracking-number/set', $body);
}

//</editor-fold>
// </editor-fold>
}

0 comments on commit 5d4321a

Please sign in to comment.