From 8fbfadf07ef2f8b8f18d3fbf7bb2b35f726a372f Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Mon, 14 Jun 2021 17:36:24 +0700 Subject: [PATCH 01/89] Add clientV2 Add get authorization url --- composer.json | 10 +- phpunit.xml.dist | 19 -- src/Client.php | 1 + src/ClientV2.php | 312 ++++++++++++++++++++++++++++ src/Nodes/NodeAbstractV2.php | 39 ++++ src/Nodes/Shop/Authorization.php | 42 ++++ src/RequestParameters.php | 5 + src/SignatureGenerator.php | 49 +++++ src/SignatureGeneratorInterface.php | 7 +- tests/ClientTrait.php | 26 ++- tests/ClientV2Test.php | 234 +++++++++++++++++++++ 11 files changed, 719 insertions(+), 25 deletions(-) delete mode 100644 phpunit.xml.dist create mode 100644 src/ClientV2.php create mode 100644 src/Nodes/NodeAbstractV2.php create mode 100644 src/Nodes/Shop/Authorization.php create mode 100644 tests/ClientV2Test.php diff --git a/composer.json b/composer.json index ee316aa..589214e 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,16 @@ { - "name": "minchao/shopee-php", + "name": "upbase/shopee-php-sdk", "description": "Shopee Partner API PHP SDK", "type": "library", "keywords": [ "shopee", - "openapi" + "openapi", + "upbase" ], - "homepage": "https://github.com/minchao/shopee-php", + "homepage": "https://github.com/technology20nn/shopee-php", "license": "BSD-3-Clause", "support": { - "issues": "https://github.com/minchao/shopee-php/issues" + "issues": "https://github.com/technology20nn/shopee-php/issues" }, "require": { "php": ">=7.1", @@ -18,6 +19,7 @@ "psr/http-message": "^1.0" }, "require-dev": { + "mockery/mockery": "^1.4", "phpstan/phpstan": "^0.12.14", "phpunit/phpunit": "^7.5 || ^8.0 || ^9.0", "squizlabs/php_codesniffer": "^3.5" diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index ccb4086..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,19 +0,0 @@ - - - - - tests - - - - - src - - - diff --git a/src/Client.php b/src/Client.php index 7f55e62..d9999e8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -268,4 +268,5 @@ public function send(RequestInterface $request): ResponseInterface return $response; } + } diff --git a/src/ClientV2.php b/src/ClientV2.php new file mode 100644 index 0000000..01a276a --- /dev/null +++ b/src/ClientV2.php @@ -0,0 +1,312 @@ + null, + 'baseUrl' => self::DEFAULT_BASE_URL, + 'userAgent' => self::DEFAULT_USER_AGENT, + 'secret' => getenv(self::ENV_SECRET_NAME), + 'partner_id' => (int)getenv(self::ENV_PARTNER_ID_NAME), + 'shop_id' => (int)getenv(self::ENV_SHOP_ID_NAME), + 'access_token' => '', + 'api_type' => self::API_TYPE_PUBLIC, + 'merchant_id' => '', + SignatureGeneratorInterface::class => null, + ], $config); + + $this->httpClient = $config['httpClient'] ?: new HttpClient(); + $this->setBaseUrl($config['baseUrl']); + $this->setUserAgent($config['userAgent']); + $this->secret = $config['secret']; + $this->partnerId = $config['partner_id']; + $this->shopId = $config['shop_id']; + $this->accessToken = $config['access_token']; + $this->merchantId = $config['merchant_id']; + $this->apiType = $config['api_type']; + + $signatureGenerator = $config[SignatureGeneratorInterface::class]; + if (is_null($signatureGenerator)) { + $this->signatureGenerator = new SignatureGenerator($this->secret); + } elseif ($signatureGenerator instanceof SignatureGeneratorInterface) { + $this->signatureGenerator = $signatureGenerator; + } else { + throw new InvalidArgumentException('Signature generator not implement SignatureGeneratorInterface'); + } + + } + + public function __get(string $name) + { + if (!array_key_exists($name, $this->nodes)) { + throw new InvalidArgumentException(sprintf('Property "%s" not exists', $name)); + } + + return $this->nodes[$name]; + } + + public function getHttpClient(): ClientInterface + { + return $this->httpClient; + } + + /** + * @param ClientInterface $client + * @return $this + */ + public function setHttpClient(ClientInterface $client) + { + $this->httpClient = $client; + + return $this; + } + + public function getUserAgent(): string + { + return $this->userAgent; + } + + /** + * @param string $userAgent + * @return $this + */ + public function setUserAgent(string $userAgent) + { + $this->userAgent = $userAgent; + + return $this; + } + + public function getBaseUrl(): UriInterface + { + return $this->baseUrl; + } + + /** + * @param string $url + * @return $this + */ + public function setBaseUrl(string $url) + { + $this->baseUrl = new Uri($url); + + return $this; + } + + public function getDefaultParameters(): array + { + return [ + 'partner_id' => $this->partnerId, + 'shopid' => $this->shopId, + 'timestamp' => time(), // Put the current UNIX timestamp when making a request + ]; + } + + /** + * Create HTTP JSON body + * + * The HTTP body should contain a serialized JSON string only + * + * @param array $data + * @return string + */ + protected function createJsonBody(array $data): string + { + $data = array_merge($this->getDefaultParameters(), $data); + + return json_encode($data); + } + + /** + * Generate an HMAC-SHA256 signature for a HTTP request + * + * @param UriInterface $uri + * @param integer $api_type + * @return string + */ + protected function signature($uri, $api_type): string + { + switch ($api_type){ + case self::API_TYPE_PUBLIC: + return $auth_query = $this->signatureGenerator->generateSignaturePublicLevel($uri, $this->partnerId); + case self::API_TYPE_SHOP: + return $auth_query = $this->signatureGenerator->generateSignatureShopLevel($uri, $this->partnerId, $this->accessToken, $this->shopId); + case self::API_TYPE_MERCHANT: + return $auth_query = $this->signatureGenerator->generateSignatureMerchantLevel($uri, $this->partnerId, $this->accessToken, $this->merchantId); + default: + return ""; + } + } + + /** + * @param string|UriInterface $uri + * @param $api_type integer + * @param array $headers + * @param array $data + * @return RequestInterface + */ + public function newRequest($uri, $api_type, array $headers = [], $data = []): RequestInterface + { + $uri = Utils::uriFor($uri); + $auth_query = $this->signature($uri, $api_type); + $path = $this->baseUrl->getPath() . $uri->getPath(); + $uri = $uri + ->withScheme($this->baseUrl->getScheme()) + ->withUserInfo($this->baseUrl->getUserInfo()) + ->withHost($this->baseUrl->getHost()) + ->withPort($this->baseUrl->getPort()) + ->withPath($path) + ->withQuery($auth_query); + + $jsonBody = $this->createJsonBody($data); + + $headers['User-Agent'] = $this->userAgent; + $headers['Content-Type'] = 'application/json'; + + return new Request( + 'POST', // All APIs should use POST method + $uri, + $headers, + $jsonBody + ); + } + + public function send(RequestInterface $request): ResponseInterface + { + try { + $response = $this->httpClient->send($request); + } catch (GuzzleClientException $exception) { + switch ($exception->getCode()) { + case 400: + $className = BadRequestException::class; + break; + case 403: + $className = AuthException::class; + break; + default: + $className = ClientException::class; + } + + throw Factory::create($className, $exception); + } catch (GuzzleServerException $exception) { + throw Factory::create(ServerException::class, $exception); + } + + return $response; + } + + public function getAuthorizationUrl($redirect_url) + { + $uri = Utils::uriFor("/api/v2/shop/auth_partner"); + $auth_query = $this->signature($uri, self::API_TYPE_PUBLIC); + $uri = Utils::uriFor($uri); + $path = $this->baseUrl->getPath() . $uri->getPath(); + + $uri = $uri + ->withScheme($this->baseUrl->getScheme()) + ->withUserInfo($this->baseUrl->getUserInfo()) + ->withHost($this->baseUrl->getHost()) + ->withPort($this->baseUrl->getPort()) + ->withPath($path) + ->withQuery($auth_query); + $uri = Uri::withQueryValue($uri, 'redirect', $redirect_url); + return $uri->__toString(); + } + +} diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php new file mode 100644 index 0000000..1abc451 --- /dev/null +++ b/src/Nodes/NodeAbstractV2.php @@ -0,0 +1,39 @@ +client = $client; + } + + /** + * @param string|UriInterface $uri + * @param $type_api + * @param array $parameters + * @return ResponseData + */ + public function post($uri, $type_api, $parameters) + { + if ($parameters instanceof RequestParametersInterface) { + $parameters = $parameters->toArray(); + } + + $request = $this->client->newRequest($uri, $type_api, [], $parameters); + $response = $this->client->send($request); + + return new ResponseData($response); + } +} diff --git a/src/Nodes/Shop/Authorization.php b/src/Nodes/Shop/Authorization.php new file mode 100644 index 0000000..aa8aecd --- /dev/null +++ b/src/Nodes/Shop/Authorization.php @@ -0,0 +1,42 @@ +post('/api/v2/auth/token/get', ClientV2::API_TYPE_PUBLIC, [ + 'code' => $auth_code, + 'partner_id' => $partner_id + ]); + } + + /** + * Only for TW whitelisted shop.Use this API to set the installment status of shop. + * + * @param $auth_code + * @param $partner_id + * @return ResponseData + */ + public function refreshAccessToken($auth_code, $partner_id): ResponseData + { + return $this->post('/api/v2/auth/access_token/get', ClientV2::API_TYPE_PUBLIC, [ + 'code' => $auth_code, + 'partner_id' => $partner_id + ]); + } + +} diff --git a/src/RequestParameters.php b/src/RequestParameters.php index 2574946..b3bf654 100644 --- a/src/RequestParameters.php +++ b/src/RequestParameters.php @@ -18,6 +18,11 @@ abstract class RequestParameters implements RequestParametersInterface */ protected $parameters = []; + /** + * RequestParameters constructor. + * @param array $parameters + * @throws \ReflectionException + */ public function __construct(array $parameters = []) { $this->fromArray($parameters); diff --git a/src/SignatureGenerator.php b/src/SignatureGenerator.php index ce662fd..7f1dee3 100644 --- a/src/SignatureGenerator.php +++ b/src/SignatureGenerator.php @@ -2,7 +2,10 @@ namespace Shopee; +use GuzzleHttp\Psr7\Uri; +use GuzzleHttp\Psr7\Utils; use function hash_hmac; +use Psr\Http\Message\UriInterface; class SignatureGenerator implements SignatureGeneratorInterface { @@ -19,4 +22,50 @@ public function generateSignature(string $url, string $body): string return hash_hmac('sha256', $data, $this->partnerKey); } + + public function generateSignatureShopLevel(UriInterface $uri, string $partner_id, string $access_token, string $shop_id): string + { + $time_st = time(); + $path = $uri->getPath(); + $data = $partner_id . $path . $time_st . $access_token . $shop_id; + $sign = hash_hmac('sha256', $data, $this->partnerKey); + $path = Uri::withQueryValues($uri, [ + 'partner_id' => $partner_id, + 'shop_id' => $shop_id, + 'timestamp' => $time_st, + 'access_token' => $access_token, + 'sign' => $sign + ]); + return $path->getQuery(); + } + + public function generateSignatureMerchantLevel(UriInterface $uri, string $partner_id, string $access_token, string $merchant_id): string + { + $time_st = time(); + $path = $uri->getPath(); + $data = $partner_id . $path . $time_st . $access_token . $merchant_id; + $sign = hash_hmac('sha256', $data, $this->partnerKey); + $path = Uri::withQueryValues($uri, [ + 'partner_id' => $partner_id, + 'merchant_id' => $partner_id, + 'timestamp' => $time_st, + 'access_token' => $partner_id, + 'sign' => $sign + ]); + return $path->getQuery(); + } + + public function generateSignaturePublicLevel(UriInterface $uri, string $partner_id): string + { + $time_st = time(); + $path = $uri->getPath(); + $data = $partner_id . $path . $time_st; + $sign = hash_hmac('sha256', $data, $this->partnerKey); + $path = Uri::withQueryValues($uri, [ + 'partner_id' => $partner_id, + 'timestamp' => $time_st, + 'sign' => $sign + ]); + return $path->getQuery(); + } } diff --git a/src/SignatureGeneratorInterface.php b/src/SignatureGeneratorInterface.php index e9b21ca..20b1126 100644 --- a/src/SignatureGeneratorInterface.php +++ b/src/SignatureGeneratorInterface.php @@ -2,7 +2,12 @@ namespace Shopee; +use Psr\Http\Message\UriInterface; + interface SignatureGeneratorInterface { - public function generateSignature(string $url, string $body): string; + public function generateSignature(string $url, string $body): string; // Using for V1 + public function generateSignatureShopLevel(UriInterface $path, string $partner_id, string $access_token, string $shop_id): string; + public function generateSignatureMerchantLevel(UriInterface $path, string $partner_id, string $access_token, string $merchant_id): string; + public function generateSignaturePublicLevel(UriInterface $path, string $partner_id): string; } diff --git a/tests/ClientTrait.php b/tests/ClientTrait.php index 1e43962..b2c40f1 100644 --- a/tests/ClientTrait.php +++ b/tests/ClientTrait.php @@ -11,13 +11,14 @@ use function is_array; use function array_merge; +use Shopee\ClientV2; trait ClientTrait { protected $defaultConfig = [ 'secret' => '42', 'partner_id' => 1, - 'shopid' => 10000, + 'shop_id' => 10000, ]; /** @@ -57,4 +58,27 @@ public function createClient(array $config = [], HttpClient $httpClient = null): return new Client(array_merge($this->defaultConfig, $config)); } + + public function createClientV2(array $config = [], HttpClient $httpClient = null): ClientV2 + { + if ($httpClient !== null) { + $config['httpClient'] = $httpClient; + } + + return new ClientV2(array_merge($this->defaultConfig, $config)); + } + + /** + * @param array $config + * @param HttpClient|null $httpClient + * @return \Mockery\LegacyMockInterface|\Mockery\MockInterface|ClientV2 + */ + public function createClientV2Mock(array $config = [], HttpClient $httpClient = null) + { + if ($httpClient !== null) { + $config['httpClient'] = $httpClient; + } + + return \Mockery::mock(ClientV2::class, array_merge($this->defaultConfig, $config)); + } } diff --git a/tests/ClientV2Test.php b/tests/ClientV2Test.php new file mode 100644 index 0000000..d6402f6 --- /dev/null +++ b/tests/ClientV2Test.php @@ -0,0 +1,234 @@ +createClientV2(); + + $this->assertInstanceOf(ClientV2::class, $client); + $this->assertInstanceOf(ClientInterface::class, $client->getHttpClient()); + $this->assertInstanceOf(UriInterface::class, $client->getBaseUrl()); + $this->assertEquals(ClientV2::DEFAULT_BASE_URL, $client->getBaseUrl()->__toString()); + $this->assertEquals(ClientV2::DEFAULT_USER_AGENT, $client->getUserAgent()); + } + + public function testCreateClientWithConfig() + { + $config = [ + 'httpClient' => new HttpClient(['ping' => 'pong']), + 'baseUrl' => 'https://galaxy.com/', + 'userAgent' => 'HeartOfGold/Prototype', + ]; + + $client = $this->createClientV2($config); + + $this->assertInstanceOf(ClientInterface::class, $client->getHttpClient()); + $this->assertEquals('pong', $client->getHttpClient()->getConfig('ping')); + $this->assertInstanceOf(UriInterface::class, $client->getBaseUrl()); + $this->assertEquals($config['baseUrl'], $client->getBaseUrl()->__toString()); + $this->assertEquals($config['userAgent'], $client->getUserAgent()); + } + + public function testCreateClientWithInvalidSignatureGenerator() + { + $this->expectException(InvalidArgumentException::class); + + $this->createClientV2([ + SignatureGeneratorInterface::class => new stdClass(), + ]); + } + + public function testShouldBeOkWhenRequestWithCustomSignatureGenerator() + { + $signatureGenerator = new class ('PARTNER_KEY') extends SignatureGenerator + { + public function generateSignaturePublicLevel(UriInterface $url, string $body): string + { + return 'CUSTOM_SIGNATURE'; + } + }; + + $actual = $this->createClientV2([ + SignatureGeneratorInterface::class => $signatureGenerator, + ])->newRequest('/api/v1/orders/detail', ClientV2::API_TYPE_PUBLIC); + + $this->assertEquals('https://partner.shopeemobile.com/api/v1/orders/detail?CUSTOM_SIGNATURE', $actual->getUri()->__toString()); + } + + public function testShouldBeOkWhenNewRequest() + { + $expected = new Request( + 'POST', + ClientV2::DEFAULT_BASE_URL . '/api/v2/orders/detail?CUSTOM_SIGNATURE', + [ + 'User-Agent' => ClientV2::DEFAULT_USER_AGENT, + 'Content-Type' => 'application/json', + ], + '{"partner_id":1,"shopid":61299,"timestamp":1470198856,"ordersn":"160726152598865"}' + ); + + $signatureGenerator = new class ('PARTNER_KEY') extends SignatureGenerator + { + public function generateSignaturePublicLevel(UriInterface $url, string $body): string + { + return 'CUSTOM_SIGNATURE'; + } + }; + + $object_mock = $this->createClientV2([ + SignatureGeneratorInterface::class => $signatureGenerator + ]); + + $actual = $object_mock->newRequest( + '/api/v2/orders/detail', + ClientV2::API_TYPE_PUBLIC, + [], + [ + 'partner_id' => 1, + 'shopid' => 61299, + 'timestamp' => 1470198856, + 'ordersn' => '160726152598865', + ] + ); + + $this->assertEquals($expected->getMethod(), $actual->getMethod()); + $this->assertEquals($expected->getUri(), $actual->getUri()); + $this->assertEquals($expected->getHeaders(), $actual->getHeaders()); + $this->assertEquals($expected->getBody()->getContents(), $actual->getBody()->getContents()); + $this->assertEquals($expected->getProtocolVersion(), $actual->getProtocolVersion()); + } + + public function getRequestUriCases() + { + return [ + [ + 'https://galaxy.com/', + '', + 'https://galaxy.com/?test=TEST_SIGNATURE', + ], + [ + 'https://galaxy.com/', + 'milky-way', + 'https://galaxy.com/milky-way?test=TEST_SIGNATURE', + ], + [ + 'https://galaxy.com/', + 'milky-way/solar-system', + 'https://galaxy.com/milky-way/solar-system?test=TEST_SIGNATURE', + ], + [ + 'https://galaxy.com/milky-way/', + 'solar-system', + 'https://galaxy.com/milky-way/solar-system?test=TEST_SIGNATURE', + ], + [ + 'https://galaxy.com/', + 'milky-way/solar-system?planet=earth', + 'https://galaxy.com/milky-way/solar-system?planet=earth&test=TEST_SIGNATURE', + ], + ]; + } + + /** + * @dataProvider getRequestUriCases + * @param string $baseUri + * @param string $actualUri + * @param string $exceptedUri + * @throws \Exception + */ + public function testShouldBeOkWhenNewRequestWithUri(string $baseUri, string $actualUri, string $exceptedUri) + { + $signatureGenerator = new class ('PARTNER_KEY') extends SignatureGenerator + { + public function generateSignaturePublicLevel(UriInterface $url, string $body): string + { + return Uri::withQueryValues($url, [ + 'test' => 'TEST_SIGNATURE', + ])->getQuery(); + } + }; + + $client = $this->createClientV2([ + 'baseUrl' => $baseUri, + SignatureGeneratorInterface::class => $signatureGenerator + ]); + + $expected = Utils::uriFor($exceptedUri); + $actual = $client->newRequest($actualUri, ClientV2::API_TYPE_PUBLIC)->getUri(); + + $this->assertEquals($expected, $actual); + } + + public function getAuthorizationRequestUriCases() + { + return [ + [ + 'https://galaxy.com', + 'test', + 'https://galaxy.com/api/v2/shop/auth_partner?test=TEST_SIGNATURE&redirect=test', + ], + [ + 'https://galaxy.com', + 'https://sme.upbase.vn/channel/shopee', + 'https://galaxy.com/api/v2/shop/auth_partner?test=TEST_SIGNATURE&redirect=https://sme.upbase.vn/channel/shopee', + ], + [ + 'https://galaxy.com', + 'https://sme.upbase.vn/channel/shopee?channel_code=123', + 'https://galaxy.com/api/v2/shop/auth_partner?test=TEST_SIGNATURE&redirect=https://sme.upbase.vn/channel/shopee?channel_code%3D123', + ], + ]; + } + + /** + * @dataProvider getAuthorizationRequestUriCases + * @param string $baseUri + * @param string $callback_url + * @param string $exceptedUri + */ + public function testAuthorizationUrl(string $baseUri, string $callback_url, string $exceptedUri){ + $signatureGenerator = new class ('PARTNER_KEY') extends SignatureGenerator + { + public function generateSignaturePublicLevel(UriInterface $url, string $body): string + { + return Uri::withQueryValues($url, [ + 'test' => 'TEST_SIGNATURE', + ])->getQuery(); + } + }; + + $client = $this->createClientV2([ + 'baseUrl' => $baseUri, + SignatureGeneratorInterface::class => $signatureGenerator + ]); + + $actual = $client->getAuthorizationUrl($callback_url); + + $this->assertEquals($exceptedUri, $actual); + } + +} From b51181a74bf59ab88fdc8b932d4837d0fe4bc0ab Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 15 Jun 2021 08:56:36 +0700 Subject: [PATCH 02/89] Add author to clientV2 --- src/ClientV2.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 01a276a..35f083b 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -28,16 +28,7 @@ use function time; /** - * @property Nodes\Item\Item $item - * @property Nodes\Logistics\Logistics $logistics - * @property Nodes\Order\Order $order - * @property Nodes\Returns\Returns $returns - * @property Nodes\Shop\Shop $shop - * @property Nodes\Discount\Discount $discount - * @property Nodes\ShopCategory\ShopCategory $shopCategory - * @property Nodes\Image\Image $image - * @property Nodes\Push\Push $push - * @property Nodes\Payment\Payment $payment + * @property Nodes\Shop\Authorization $author */ class ClientV2 { @@ -130,6 +121,8 @@ public function __construct(array $config = []) throw new InvalidArgumentException('Signature generator not implement SignatureGeneratorInterface'); } + $this->nodes['author'] = new Nodes\Shop\Authorization($this); + } public function __get(string $name) From 45d3a2ab881d6d24a0d6cb520fa66c8cf045fc9b Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 15 Jun 2021 09:52:36 +0700 Subject: [PATCH 03/89] * Add get shopinfo * Add shop_id in authorization --- src/ClientV2.php | 6 ++--- src/Nodes/Shop/Authorization.php | 14 ++++++++--- src/Nodes/Shop/Shop.php | 42 +++++++++----------------------- 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 35f083b..58ca44c 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -70,14 +70,14 @@ class ClientV2 protected $partnerId; /** @var int */ - protected $shopId; + public $shopId; - protected $merchantId; + public $merchantId; /** * @var string */ - protected $accessToken; + public $accessToken; protected $apiType; diff --git a/src/Nodes/Shop/Authorization.php b/src/Nodes/Shop/Authorization.php index aa8aecd..9f4b573 100644 --- a/src/Nodes/Shop/Authorization.php +++ b/src/Nodes/Shop/Authorization.php @@ -14,13 +14,15 @@ class Authorization extends NodeAbstractV2 * * @param $auth_code * @param $partner_id + * @param $shop_id * @return ResponseData */ - public function getAccessToken($auth_code, $partner_id): ResponseData + public function getAccessToken($auth_code, $partner_id, $shop_id): ResponseData { return $this->post('/api/v2/auth/token/get', ClientV2::API_TYPE_PUBLIC, [ 'code' => $auth_code, - 'partner_id' => $partner_id + 'partner_id' => $partner_id, + 'shop_id' => $shop_id ]); } @@ -29,13 +31,17 @@ public function getAccessToken($auth_code, $partner_id): ResponseData * * @param $auth_code * @param $partner_id + * @param $shop_id + * @param $refresh_token * @return ResponseData */ - public function refreshAccessToken($auth_code, $partner_id): ResponseData + public function refreshAccessToken($auth_code, $partner_id, $shop_id, $refresh_token): ResponseData { return $this->post('/api/v2/auth/access_token/get', ClientV2::API_TYPE_PUBLIC, [ 'code' => $auth_code, - 'partner_id' => $partner_id + 'partner_id' => $partner_id, + 'shop_id' => $shop_id, + 'refresh_token' => $refresh_token ]); } diff --git a/src/Nodes/Shop/Shop.php b/src/Nodes/Shop/Shop.php index 6e7e430..f4f69a2 100644 --- a/src/Nodes/Shop/Shop.php +++ b/src/Nodes/Shop/Shop.php @@ -2,64 +2,44 @@ namespace Shopee\Nodes\Shop; -use Shopee\Nodes\NodeAbstract; +use Shopee\ClientV2; +use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Shop extends NodeAbstract +class Shop extends NodeAbstractV2 { /** * Use this call to get information of shop. - * + * https://open.shopee.com/documents?module=92&type=1&id=536&version=2 * @param array|RequestParametersInterface $parameters * @return ResponseData */ public function getShopInfo($parameters = []): ResponseData { - return $this->post('/api/v1/shop/get', $parameters); - } - - /** - * Shop performance includes the indexes from "My Performance" of Seller Center. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function performance($parameters = []): ResponseData - { - return $this->post('/api/v1/shop/performance', $parameters); + return $this->post('api/v2/shop/get_shop_info', ClientV2::API_TYPE_SHOP, $parameters); } /** - * Only for TW whitelisted shop.Use this API to set the installment status of shop. * + * https://open.shopee.com/documents?module=92&type=1&id=584&version=2 * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function setShopInstallmentStatus($parameters = []): ResponseData + public function getShopProfile($parameters = []): ResponseData { - return $this->post('/api/v1/shop/set_installment_status', $parameters); + return $this->post('/api/v2/shop/get_profile', ClientV2::API_TYPE_SHOP, $parameters); } /** - * Use this call to update information of shop. * + * https://open.shopee.com/documents?module=92&type=1&id=585&version=2 * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function updateShopInfo($parameters = []): ResponseData + public function updateShopProfile($parameters = []): ResponseData { - return $this->post('/api/v1/shop/update', $parameters); + return $this->post('/api/v2/shop/update_profile', ClientV2::API_TYPE_SHOP, $parameters); } - /** - * Use this call to get basic info of shops which have authorized to the partner. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getShopsByPartner($parameters = []): ResponseData - { - return $this->post('/api/v1/shop/get_partner_shop', $parameters); - } } From 5f075e63ef35c56eb8e2b0c44942e4819c42ad77 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 15 Jun 2021 09:58:23 +0700 Subject: [PATCH 04/89] * Add Shop item to clientV2 --- src/ClientV2.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ClientV2.php b/src/ClientV2.php index 58ca44c..79ce629 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -29,6 +29,7 @@ /** * @property Nodes\Shop\Authorization $author + * @property Nodes\Shop\Shop $shop */ class ClientV2 { @@ -122,6 +123,7 @@ public function __construct(array $config = []) } $this->nodes['author'] = new Nodes\Shop\Authorization($this); + $this->nodes['shop'] = new Nodes\Shop\Shop($this); } From db73a1031c7cc52a02f98f6f4d4aa82181aa68e9 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 15 Jun 2021 11:32:47 +0700 Subject: [PATCH 05/89] Fix shopinfo --- src/Nodes/NodeAbstractV2.php | 18 ++++++++++++++++++ src/Nodes/Shop/Shop.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index 1abc451..a55c432 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -36,4 +36,22 @@ public function post($uri, $type_api, $parameters) return new ResponseData($response); } + + /** + * @param string|UriInterface $uri + * @param $type_api + * @param array $parameters + * @return ResponseData + */ + public function get($uri, $type_api, $parameters) + { + if ($parameters instanceof RequestParametersInterface) { + $parameters = $parameters->toArray(); + } + + $request = $this->client->newRequest($uri, $type_api, [], $parameters)->withMethod('GET'); + $response = $this->client->send($request); + + return new ResponseData($response); + } } diff --git a/src/Nodes/Shop/Shop.php b/src/Nodes/Shop/Shop.php index f4f69a2..938badb 100644 --- a/src/Nodes/Shop/Shop.php +++ b/src/Nodes/Shop/Shop.php @@ -17,7 +17,7 @@ class Shop extends NodeAbstractV2 */ public function getShopInfo($parameters = []): ResponseData { - return $this->post('api/v2/shop/get_shop_info', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop/get_shop_info', ClientV2::API_TYPE_SHOP, $parameters); } /** From 969fdb84463b20b23ae6f15c9d5503e515b8ac2e Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 15 Jun 2021 12:52:39 +0700 Subject: [PATCH 06/89] Fix getshopinfo, getshopprofile --- src/Nodes/Shop/Shop.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Shop/Shop.php b/src/Nodes/Shop/Shop.php index 938badb..2285d9d 100644 --- a/src/Nodes/Shop/Shop.php +++ b/src/Nodes/Shop/Shop.php @@ -17,7 +17,7 @@ class Shop extends NodeAbstractV2 */ public function getShopInfo($parameters = []): ResponseData { - return $this->post('/api/v2/shop/get_shop_info', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/shop/get_shop_info', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -28,7 +28,7 @@ public function getShopInfo($parameters = []): ResponseData */ public function getShopProfile($parameters = []): ResponseData { - return $this->post('/api/v2/shop/get_profile', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/shop/get_profile', ClientV2::API_TYPE_SHOP, $parameters); } /** From 1f763fd8c6c617e1fe3f7d5f372ff1d3795a458f Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Fri, 25 Jun 2021 18:33:51 +0700 Subject: [PATCH 07/89] add category item to clientV2 --- src/ClientV2.php | 2 ++ src/Nodes/Item/Category.php | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 src/Nodes/Item/Category.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 79ce629..76f91dd 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -30,6 +30,7 @@ /** * @property Nodes\Shop\Authorization $author * @property Nodes\Shop\Shop $shop + * @property Nodes\Item\Category $category */ class ClientV2 { @@ -124,6 +125,7 @@ public function __construct(array $config = []) $this->nodes['author'] = new Nodes\Shop\Authorization($this); $this->nodes['shop'] = new Nodes\Shop\Shop($this); + $this->nodes['category'] = new Nodes\Item\Category($this); } diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php new file mode 100755 index 0000000..87373a6 --- /dev/null +++ b/src/Nodes/Item/Category.php @@ -0,0 +1,23 @@ +get('/api/v2/product/get_category', ClientV2::API_TYPE_SHOP, $parameters); + } + +} From c8f505cacb9266fab5454b2cc8147ece4d68dd58 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Wed, 30 Jun 2021 12:01:08 +0700 Subject: [PATCH 08/89] Ignore auth code --- src/Nodes/Shop/Authorization.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nodes/Shop/Authorization.php b/src/Nodes/Shop/Authorization.php index 9f4b573..b648c8c 100644 --- a/src/Nodes/Shop/Authorization.php +++ b/src/Nodes/Shop/Authorization.php @@ -29,16 +29,14 @@ public function getAccessToken($auth_code, $partner_id, $shop_id): ResponseData /** * Only for TW whitelisted shop.Use this API to set the installment status of shop. * - * @param $auth_code * @param $partner_id * @param $shop_id * @param $refresh_token * @return ResponseData */ - public function refreshAccessToken($auth_code, $partner_id, $shop_id, $refresh_token): ResponseData + public function refreshAccessToken($partner_id, $shop_id, $refresh_token): ResponseData { return $this->post('/api/v2/auth/access_token/get', ClientV2::API_TYPE_PUBLIC, [ - 'code' => $auth_code, 'partner_id' => $partner_id, 'shop_id' => $shop_id, 'refresh_token' => $refresh_token From fb3e4fd1ca6ddc47e6f704f4428d3a5761f1e718 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Wed, 30 Jun 2021 13:46:29 +0700 Subject: [PATCH 09/89] Update product item get api v2 --- src/Nodes/Item/Item.php | 204 +++++--------------- src/Nodes/Item/Parameters/GetItemDetail.php | 18 +- src/Nodes/Item/Parameters/GetItemsList.php | 34 +++- 3 files changed, 95 insertions(+), 161 deletions(-) diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index ed5107b..40909af 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -3,9 +3,10 @@ namespace Shopee\Nodes\Item; use Shopee\Nodes\NodeAbstract; +use Shopee\Nodes\NodeAbstractV2; use Shopee\ResponseData; -class Item extends NodeAbstract +class Item extends NodeAbstractV2 { /** * Use this call to add a product item. @@ -15,315 +16,210 @@ class Item extends NodeAbstract */ public function add($parameters = []): ResponseData { - return $this->post('/api/v1/item/add', $parameters); + return $this->post('/api/v2/product/add_item', $parameters); } - /** - * Use this call to add product item images. - * - * @param array|Parameters\AddItemImg $parameters - * @return ResponseData - */ - public function addItemImg($parameters = []): ResponseData - { - return $this->post('/api/v1/item/img/add', $parameters); - } /** * Use this call to add item variations. - * + * https://open.shopee.com/documents?module=89&type=1&id=618&version=2 * @param array|Parameters\AddVariations $parameters * @return ResponseData */ - public function addVariations($parameters = []): ResponseData + public function getModelList($parameters = []): ResponseData { - return $this->post('/api/v1/item/add_variations', $parameters); + return $this->post('/api/v2/product/get_model_list', $parameters); } /** * Use this api to boost multiple items at once. - * + * https://open.shopee.com/documents?module=89&type=1&id=624&version=2 * @param array $parameters * @return ResponseData */ public function boostItem($parameters = []): ResponseData { - return $this->post('/api/v1/items/boost', $parameters); + return $this->post('/api/v2/product/boost_item', $parameters); } /** * Use this call to delete a product item. - * + * https://open.shopee.com/documents?module=89&type=1&id=615&version=2 * @param array|Parameters\Delete $parameters * @return ResponseData */ public function delete($parameters = []): ResponseData { - return $this->post('/api/v1/item/delete', $parameters); - } - - /** - * Use this call to delete a product item image. - * - * @param array|Parameters\DeleteItemImg $parameters - * @return ResponseData - */ - public function deleteItemImg($parameters = []): ResponseData - { - return $this->post('/api/v1/item/img/delete', $parameters); + return $this->post('/api/v2/product/delete_item', $parameters); } /** * Use this call to delete item variation. - * + * https://open.shopee.com/documents?module=89&type=1&id=650&version=2 * @param array|Parameters\DeleteVariation $parameters * @return ResponseData */ - public function deleteVariation($parameters = []): ResponseData + public function deleteModel($parameters = []): ResponseData { - return $this->post('/api/v1/item/delete_variation', $parameters); + return $this->post('/api/v2/product/delete_model', $parameters); } /** * Use this call to get attributes of product item. - * + * https://open.shopee.com/documents?module=89&type=1&id=655&version=2 * @param array|Parameters\GetAttributes $parameters * @return ResponseData */ public function getAttributes($parameters = []): ResponseData { - return $this->post('/api/v1/item/attributes/get', $parameters); + return $this->post('/api/v2/product/get_attributes', $parameters); } /** * Use this api to get all boosted items. - * + * https://open.shopee.com/documents?module=89&type=1&id=626&version=2 * @param array $parameters * @return ResponseData */ public function getBoostedItems($parameters = []): ResponseData { - return $this->post('/api/v1/items/get_boosted', $parameters); + return $this->post('/api/v2/product/get_boosted_list', $parameters); } /** - * Use this call to get categories of product item. - * + * Use this api to get comment by + * https://open.shopee.com/documents?module=89&type=1&id=562&version=2 * @param array $parameters * @return ResponseData */ - public function getCategories($parameters = []): ResponseData + public function getComment($parameters = []): ResponseData { - return $this->post('/api/v1/item/categories/get', $parameters); + return $this->post('/api/v2/product/get_comment', $parameters); } /** - * Use this api to get comment by shopid/itemid/comment_id - * - * @param array $parameters + * Use this call to get detail of item. + * https://open.shopee.com/documents?module=89&type=1&id=612&version=2 + * @param array|Parameters\GetItemDetail $parameters * @return ResponseData */ - public function getComment($parameters = []): ResponseData + public function getItemBaseInfo($parameters = []): ResponseData { - return $this->post('/api/v1/items/comments/get', $parameters); + return $this->post('/api/v2/product/get_item_base_info', $parameters); } /** - * Use this call to get detail of item. - * + * https://open.shopee.com/documents?module=89&type=1&id=613&version=2 * @param array|Parameters\GetItemDetail $parameters * @return ResponseData */ - public function getItemDetail($parameters = []): ResponseData + public function getItemExtraInfo($parameters = []): ResponseData { - return $this->post('/api/v1/item/get', $parameters); + return $this->post('/api/v2/product/get_item_extra_info', $parameters); } /** * Use this call to get a list of items. - * + * https://open.shopee.com/documents?module=89&type=1&id=614&version=2 * @param array|Parameters\GetItemsList $parameters * @return ResponseData */ public function getItemsList($parameters = []): ResponseData { - return $this->post('/api/v1/items/get', $parameters); + return $this->post('/api/v2/product/get_item_list', $parameters); } /** * Use this api to get ongoing and upcoming promotions. - * + * https://open.shopee.com/documents?module=89&type=1&id=661&version=2 * @param array $parameters * @return ResponseData */ public function getPromotionInfo($parameters = []): ResponseData { - return $this->post('/api/v1/item/promotion/get', $parameters); + return $this->post('/api/v2/product/get_item_promotion', $parameters); } /** * Use this API to get recommended category ids according to item name. - * + * https://open.shopee.com/documents?module=89&type=1&id=702&version=2 * @param array $parameters * @return ResponseData */ public function getRecommendCats($parameters = []): ResponseData { - return $this->post('/api/v1/item/categories/get_recommend', $parameters); + return $this->post('/api/v2/product/category_recommend', $parameters); } - /** - * Use this call to add one item image in assigned position. - * - * @param array|Parameters\InsertItemImg $parameters - * @return ResponseData - */ - public function insertItemImg($parameters = []): ResponseData - { - return $this->post('/api/v1/item/img/insert', $parameters); - } /** * Use this api to reply comments from buyers in batch. - * + * https://open.shopee.com/documents?module=89&type=1&id=563&version=2 * @param array $parameters * @return ResponseData */ public function replyComments($parameters = []): ResponseData { - return $this->post('/api/v1/items/comments/reply', $parameters); + return $this->post('/api/v2/product/reply_comment', $parameters); } - /** - * Only for TW whitelisted shop. Use this API to set the installment tenures of items. - * - * @param array $parameters - * @return ResponseData - */ - public function setItemInstallmentTenures($parameters = []): ResponseData - { - return $this->post('/api/v1/item/installment/set', $parameters); - } /** * Use this call to update a product item. - * + * https://open.shopee.com/documents?module=89&type=1&id=617&version=2 * @param array|Parameters\UpdateItem $parameters * @return ResponseData */ public function updateItem($parameters = []): ResponseData { - return $this->post('/api/v1/item/update', $parameters); + return $this->post('/api/v2/product/update_item', $parameters); } - /** - * Override and update all the existing images of an item. - * - * @param array|Parameters\UpdateItemImg $parameters - * @return ResponseData - */ - public function updateItemImage($parameters = []): ResponseData - { - return $this->post('/api/v1/item/img/update', $parameters); - } /** * Use this call to update item price. - * + * https://open.shopee.com/documents?module=89&type=1&id=651&version=2 * @param array|Parameters\UpdatePrice $parameters * @return ResponseData */ public function updatePrice($parameters = []): ResponseData { - return $this->post('/api/v1/items/update_price', $parameters); - } - - /** - * Update items price in batch. - * - * @param array $parameters - * @return ResponseData - */ - public function updatePriceBatch($parameters = []): ResponseData - { - return $this->post('/api/v1/items/update/items_price', $parameters); + return $this->post('/api/v2/product/update_price', $parameters); } /** * Use this call to update item stock. - * + * https://open.shopee.com/documents?module=89&type=1&id=652&version=2 * @param array|Parameters\UpdateStock $parameters * @return ResponseData */ public function updateStock($parameters = []): ResponseData { - return $this->post('/api/v1/items/update_stock', $parameters); + return $this->post('/api/v2/product/update_stock', $parameters); } - /** - * Update items stock in batch. - * - * @param array $parameters - * @return ResponseData - */ - public function updateStockBatch($parameters = []): ResponseData - { - return $this->post('/api/v1/items/update/items_stock', $parameters); - } /** - * Use this call to update item variation price. - * + * Use this call to update Sip Item price. + * https://open.shopee.com/documents?module=89&type=1&id=662&version=2 * @param array|Parameters\UpdateVariationPrice $parameters * @return ResponseData */ - public function updateVariationPrice($parameters = []): ResponseData + public function updateSipItemPrice($parameters = []): ResponseData { - return $this->post('/api/v1/items/update_variation_price', $parameters); + return $this->post('/api/v2/product/update_sip_item_price', $parameters); } - /** - * Update variations price in batch. - * - * @param array $parameters - * @return ResponseData - */ - public function updateVariationPriceBatch($parameters = []): ResponseData - { - return $this->post('/api/v1/items/update/vars_price', $parameters); - } - - /** - * Use this call to update item variation stock. - * - * @param array|Parameters\UpdateVariationStock $parameters - * @return ResponseData - */ - public function updateVariationStock($parameters = []): ResponseData - { - return $this->post('/api/v1/items/update_variation_stock', $parameters); - } - - /** - * Update variations stock in batch. - * - * @param array $parameters - * @return ResponseData - */ - public function updateVariationStockBatch($parameters = []): ResponseData - { - return $this->post('/api/v1/items/update/vars_stock', $parameters); - } /** * Use this call to unlist or list items in batch. - * + * https://open.shopee.com/documents?module=89&type=1&id=622&version=2 * @param array|Parameters\UpdateVariationStock $parameters * @return ResponseData */ public function unlistItem($parameters = []): ResponseData { - return $this->post('/api/v1/items/unlist', $parameters); + return $this->post('/api/v2/product/unlist_item', $parameters); } /** @@ -334,6 +230,6 @@ public function unlistItem($parameters = []): ResponseData */ public function initTierVariation($parameters = []): ResponseData { - return $this->post('api/v1/item/tier_var/init', $parameters); + return $this->post('/api/v2/product/init_tier_variation', $parameters); } } diff --git a/src/Nodes/Item/Parameters/GetItemDetail.php b/src/Nodes/Item/Parameters/GetItemDetail.php index 2cc15ea..a0a6dd4 100644 --- a/src/Nodes/Item/Parameters/GetItemDetail.php +++ b/src/Nodes/Item/Parameters/GetItemDetail.php @@ -6,5 +6,21 @@ class GetItemDetail extends RequestParameters { - use ItemTrait; + public function getItemIdList(): int + { + return $this->parameters['item_id_list']; + } + + /** + * Set the Shopee's unique identifier for an item + * + * @param array $itemIdList + * @return $this + */ + public function setItemIdList(array $itemIdList) + { + $this->parameters['item_id_list'] = $itemIdList; + + return $this; + } } diff --git a/src/Nodes/Item/Parameters/GetItemsList.php b/src/Nodes/Item/Parameters/GetItemsList.php index 8a8ecc9..00b3302 100644 --- a/src/Nodes/Item/Parameters/GetItemsList.php +++ b/src/Nodes/Item/Parameters/GetItemsList.php @@ -6,14 +6,36 @@ class GetItemsList extends RequestParameters { + const NORMAL = "NORMAL"; + const BANNED = "BANNED"; + const DELETED = "DELETED"; + const UNLIST = "UNLIST"; + protected $parameters = [ - 'pagination_offset' => 0, - 'pagination_entries_per_page' => 100, + 'offset' => 0, + 'page_size' => 100, + 'item_status' => self::NORMAL ]; + public function getItemStatus(): int + { + return $this->parameters['item_status']; + } + + /** + * @param int $status + * @return $this + */ + public function setItemStatus(int $status) + { + $this->parameters['item_status'] = $status; + + return $this; + } + public function getPaginationOffset(): int { - return $this->parameters['pagination_offset']; + return $this->parameters['offset']; } /** @@ -25,14 +47,14 @@ public function getPaginationOffset(): int */ public function setPaginationOffset(int $offset) { - $this->parameters['pagination_offset'] = $offset; + $this->parameters['offset'] = $offset; return $this; } public function getPaginationEntriesPerPage(): int { - return $this->parameters['pagination_entries_per_page']; + return $this->parameters['page_size']; } /** @@ -46,7 +68,7 @@ public function getPaginationEntriesPerPage(): int */ public function setPaginationEntriesPerPage(int $perPage = 100) { - $this->parameters['pagination_entries_per_page'] = $perPage; + $this->parameters['page_size'] = $perPage; return $this; } From 5a266dab24bdf31b50ba31522d341cad3d1ab334 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Fri, 2 Jul 2021 17:27:39 +0700 Subject: [PATCH 10/89] update api get category --- src/Nodes/Item/Category.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php index 87373a6..ac6f428 100755 --- a/src/Nodes/Item/Category.php +++ b/src/Nodes/Item/Category.php @@ -2,22 +2,24 @@ namespace Shopee\Nodes\Item; +use GuzzleHttp\Psr7\Uri; +use GuzzleHttp\Psr7\Utils; use Shopee\ClientV2; use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Category extends NodeAbstractV2 -{ - /** - * Use this call to get information of shop. - * https://open.shopee.com/documents?module=92&type=1&id=536&version=2 - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getListCategory($parameters = []): ResponseData - { - return $this->get('/api/v2/product/get_category', ClientV2::API_TYPE_SHOP, $parameters); - } +class Category extends NodeAbstractV2 { + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents?module=92&type=1&id=536&version=2 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getListCategory($parameters = []): ResponseData { + $uri = Utils::uriFor('/api/v2/product/get_category'); + $path = Uri::withQueryValues($uri, $parameters); + return $this->get($path, ClientV2::API_TYPE_SHOP, $parameters); + } } From 347e18a24c45ac4ab5242c0dd59f1cb5ada441e7 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Mon, 5 Jul 2021 16:39:32 +0700 Subject: [PATCH 11/89] add brand --- src/ClientV2.php | 3 ++- src/Nodes/Item/Brand.php | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 src/Nodes/Item/Brand.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 76f91dd..de9cd48 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -31,6 +31,7 @@ * @property Nodes\Shop\Authorization $author * @property Nodes\Shop\Shop $shop * @property Nodes\Item\Category $category + * @property Nodes\Item\Brand $brand */ class ClientV2 { @@ -126,7 +127,7 @@ public function __construct(array $config = []) $this->nodes['author'] = new Nodes\Shop\Authorization($this); $this->nodes['shop'] = new Nodes\Shop\Shop($this); $this->nodes['category'] = new Nodes\Item\Category($this); - + $this->nodes['brand'] = new Nodes\Item\Brand($this); } public function __get(string $name) diff --git a/src/Nodes/Item/Brand.php b/src/Nodes/Item/Brand.php new file mode 100755 index 0000000..f966cbb --- /dev/null +++ b/src/Nodes/Item/Brand.php @@ -0,0 +1,26 @@ +get($path, ClientV2::API_TYPE_SHOP, $parameters); + } + +} From 5e24ea9793c0b55e32726af5ec43e2b942fdf616 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Fri, 9 Jul 2021 15:50:02 +0700 Subject: [PATCH 12/89] get list attribute --- src/ClientV2.php | 2 ++ src/Nodes/Item/Attribute.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 src/Nodes/Item/Attribute.php diff --git a/src/ClientV2.php b/src/ClientV2.php index de9cd48..eb2bb43 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -32,6 +32,7 @@ * @property Nodes\Shop\Shop $shop * @property Nodes\Item\Category $category * @property Nodes\Item\Brand $brand + * @property Nodes\Item\Attribute $attribute */ class ClientV2 { @@ -128,6 +129,7 @@ public function __construct(array $config = []) $this->nodes['shop'] = new Nodes\Shop\Shop($this); $this->nodes['category'] = new Nodes\Item\Category($this); $this->nodes['brand'] = new Nodes\Item\Brand($this); + $this->nodes['attribute'] = new Nodes\Item\Attribute($this); } public function __get(string $name) diff --git a/src/Nodes/Item/Attribute.php b/src/Nodes/Item/Attribute.php new file mode 100755 index 0000000..6ee78bb --- /dev/null +++ b/src/Nodes/Item/Attribute.php @@ -0,0 +1,25 @@ +get($path, ClientV2::API_TYPE_SHOP, $parameters); + } + +} From d5e72d4f18b65b10a4d48aadd4afe93682369def Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Sun, 11 Jul 2021 12:45:16 +0700 Subject: [PATCH 13/89] * Update get method * Add api product item --- src/ClientV2.php | 2 ++ src/Nodes/Item/Attribute.php | 4 +--- src/Nodes/Item/Brand.php | 4 +--- src/Nodes/Item/Category.php | 4 +--- src/Nodes/Item/Item.php | 41 ++++++++++++++++++------------------ src/Nodes/NodeAbstractV2.php | 6 +++++- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index eb2bb43..7ebdf0a 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -33,6 +33,7 @@ * @property Nodes\Item\Category $category * @property Nodes\Item\Brand $brand * @property Nodes\Item\Attribute $attribute + * @property Nodes\Item\Item $item */ class ClientV2 { @@ -130,6 +131,7 @@ public function __construct(array $config = []) $this->nodes['category'] = new Nodes\Item\Category($this); $this->nodes['brand'] = new Nodes\Item\Brand($this); $this->nodes['attribute'] = new Nodes\Item\Attribute($this); + $this->nodes['item'] = new Nodes\Item\Item($this); } public function __get(string $name) diff --git a/src/Nodes/Item/Attribute.php b/src/Nodes/Item/Attribute.php index 6ee78bb..af5fd0b 100755 --- a/src/Nodes/Item/Attribute.php +++ b/src/Nodes/Item/Attribute.php @@ -17,9 +17,7 @@ class Attribute extends NodeAbstractV2 { * @return ResponseData */ public function getAttributes($parameters = []): ResponseData { - $uri = Utils::uriFor('/api/v2/product/get_attributes'); - $path = Uri::withQueryValues($uri, $parameters); - return $this->get($path, ClientV2::API_TYPE_SHOP, $parameters); + return $this->get("/api/v2/product/get_attributes", ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/Item/Brand.php b/src/Nodes/Item/Brand.php index f966cbb..d7dd337 100755 --- a/src/Nodes/Item/Brand.php +++ b/src/Nodes/Item/Brand.php @@ -18,9 +18,7 @@ class Brand extends NodeAbstractV2 { */ public function getListBrandByCategory($parameters = []): ResponseData { - $uri = Utils::uriFor('/api/v2/product/get_brand_list'); - $path = Uri::withQueryValues($uri, $parameters); - return $this->get($path, ClientV2::API_TYPE_SHOP, $parameters); + return $this->get("/api/v2/product/get_brand_list", ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php index ac6f428..1204e0e 100755 --- a/src/Nodes/Item/Category.php +++ b/src/Nodes/Item/Category.php @@ -17,9 +17,7 @@ class Category extends NodeAbstractV2 { * @return ResponseData */ public function getListCategory($parameters = []): ResponseData { - $uri = Utils::uriFor('/api/v2/product/get_category'); - $path = Uri::withQueryValues($uri, $parameters); - return $this->get($path, ClientV2::API_TYPE_SHOP, $parameters); + return $this->get("/api/v2/product/get_category", ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index 40909af..17df045 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -2,6 +2,7 @@ namespace Shopee\Nodes\Item; +use Shopee\ClientV2; use Shopee\Nodes\NodeAbstract; use Shopee\Nodes\NodeAbstractV2; use Shopee\ResponseData; @@ -16,7 +17,7 @@ class Item extends NodeAbstractV2 */ public function add($parameters = []): ResponseData { - return $this->post('/api/v2/product/add_item', $parameters); + return $this->post('/api/v2/product/add_item', ClientV2::API_TYPE_SHOP, $parameters); } @@ -28,7 +29,7 @@ public function add($parameters = []): ResponseData */ public function getModelList($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_model_list', $parameters); + return $this->get('/api/v2/product/get_model_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -39,7 +40,7 @@ public function getModelList($parameters = []): ResponseData */ public function boostItem($parameters = []): ResponseData { - return $this->post('/api/v2/product/boost_item', $parameters); + return $this->post('/api/v2/product/boost_item', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -50,7 +51,7 @@ public function boostItem($parameters = []): ResponseData */ public function delete($parameters = []): ResponseData { - return $this->post('/api/v2/product/delete_item', $parameters); + return $this->post('/api/v2/product/delete_item', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -61,7 +62,7 @@ public function delete($parameters = []): ResponseData */ public function deleteModel($parameters = []): ResponseData { - return $this->post('/api/v2/product/delete_model', $parameters); + return $this->post('/api/v2/product/delete_model', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -72,7 +73,7 @@ public function deleteModel($parameters = []): ResponseData */ public function getAttributes($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_attributes', $parameters); + return $this->get('/api/v2/product/get_attributes', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -83,7 +84,7 @@ public function getAttributes($parameters = []): ResponseData */ public function getBoostedItems($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_boosted_list', $parameters); + return $this->get('/api/v2/product/get_boosted_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -94,7 +95,7 @@ public function getBoostedItems($parameters = []): ResponseData */ public function getComment($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_comment', $parameters); + return $this->get('/api/v2/product/get_comment', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -105,7 +106,7 @@ public function getComment($parameters = []): ResponseData */ public function getItemBaseInfo($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_item_base_info', $parameters); + return $this->get('/api/v2/product/get_item_base_info', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -115,7 +116,7 @@ public function getItemBaseInfo($parameters = []): ResponseData */ public function getItemExtraInfo($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_item_extra_info', $parameters); + return $this->get('/api/v2/product/get_item_extra_info', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -126,7 +127,7 @@ public function getItemExtraInfo($parameters = []): ResponseData */ public function getItemsList($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_item_list', $parameters); + return $this->get('/api/v2/product/get_item_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -137,7 +138,7 @@ public function getItemsList($parameters = []): ResponseData */ public function getPromotionInfo($parameters = []): ResponseData { - return $this->post('/api/v2/product/get_item_promotion', $parameters); + return $this->get('/api/v2/product/get_item_promotion', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -148,7 +149,7 @@ public function getPromotionInfo($parameters = []): ResponseData */ public function getRecommendCats($parameters = []): ResponseData { - return $this->post('/api/v2/product/category_recommend', $parameters); + return $this->get('/api/v2/product/category_recommend', ClientV2::API_TYPE_SHOP, $parameters); } @@ -160,7 +161,7 @@ public function getRecommendCats($parameters = []): ResponseData */ public function replyComments($parameters = []): ResponseData { - return $this->post('/api/v2/product/reply_comment', $parameters); + return $this->post('/api/v2/product/reply_comment', ClientV2::API_TYPE_SHOP, $parameters); } @@ -172,7 +173,7 @@ public function replyComments($parameters = []): ResponseData */ public function updateItem($parameters = []): ResponseData { - return $this->post('/api/v2/product/update_item', $parameters); + return $this->post('/api/v2/product/update_item', ClientV2::API_TYPE_SHOP, $parameters); } @@ -184,7 +185,7 @@ public function updateItem($parameters = []): ResponseData */ public function updatePrice($parameters = []): ResponseData { - return $this->post('/api/v2/product/update_price', $parameters); + return $this->post('/api/v2/product/update_price', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -195,7 +196,7 @@ public function updatePrice($parameters = []): ResponseData */ public function updateStock($parameters = []): ResponseData { - return $this->post('/api/v2/product/update_stock', $parameters); + return $this->post('/api/v2/product/update_stock', ClientV2::API_TYPE_SHOP, $parameters); } @@ -207,7 +208,7 @@ public function updateStock($parameters = []): ResponseData */ public function updateSipItemPrice($parameters = []): ResponseData { - return $this->post('/api/v2/product/update_sip_item_price', $parameters); + return $this->post('/api/v2/product/update_sip_item_price', ClientV2::API_TYPE_SHOP, $parameters); } @@ -219,7 +220,7 @@ public function updateSipItemPrice($parameters = []): ResponseData */ public function unlistItem($parameters = []): ResponseData { - return $this->post('/api/v2/product/unlist_item', $parameters); + return $this->post('/api/v2/product/unlist_item', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -230,6 +231,6 @@ public function unlistItem($parameters = []): ResponseData */ public function initTierVariation($parameters = []): ResponseData { - return $this->post('/api/v2/product/init_tier_variation', $parameters); + return $this->post('/api/v2/product/init_tier_variation', ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index a55c432..d4dfea0 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -2,6 +2,8 @@ namespace Shopee\Nodes; +use GuzzleHttp\Psr7\Uri; +use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\UriInterface; use Shopee\Client; use Shopee\ClientV2; @@ -48,8 +50,10 @@ public function get($uri, $type_api, $parameters) if ($parameters instanceof RequestParametersInterface) { $parameters = $parameters->toArray(); } + $uri = Utils::uriFor($uri); + $path = Uri::withQueryValues($uri, $parameters); - $request = $this->client->newRequest($uri, $type_api, [], $parameters)->withMethod('GET'); + $request = $this->client->newRequest($path, $type_api, [], $parameters)->withMethod('GET'); $response = $this->client->send($request); return new ResponseData($response); From 5f22a48972a449c9b4be7bc7e0bcfe77ae35d065 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Thu, 15 Jul 2021 22:43:53 +0700 Subject: [PATCH 14/89] * Fix get detail item --- src/Nodes/Item/Parameters/GetItemDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Item/Parameters/GetItemDetail.php b/src/Nodes/Item/Parameters/GetItemDetail.php index a0a6dd4..6079132 100644 --- a/src/Nodes/Item/Parameters/GetItemDetail.php +++ b/src/Nodes/Item/Parameters/GetItemDetail.php @@ -17,7 +17,7 @@ public function getItemIdList(): int * @param array $itemIdList * @return $this */ - public function setItemIdList(array $itemIdList) + public function setItemIdList($itemIdList) { $this->parameters['item_id_list'] = $itemIdList; From a71ff54fa6cef772baa5bd3c2e700d686283c8f5 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Wed, 11 Aug 2021 20:02:28 +0700 Subject: [PATCH 15/89] shopee get category recommend --- src/Nodes/Item/Category.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php index 1204e0e..4158df6 100755 --- a/src/Nodes/Item/Category.php +++ b/src/Nodes/Item/Category.php @@ -19,5 +19,13 @@ class Category extends NodeAbstractV2 { public function getListCategory($parameters = []): ResponseData { return $this->get("/api/v2/product/get_category", ClientV2::API_TYPE_SHOP, $parameters); } - + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents?module=89&type=1&id=702&version=2 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getCategoryRecommend($parameters = []): ResponseData { + return $this->get("/api/v2/product/category_recommend", ClientV2::API_TYPE_SHOP, $parameters); + } } From 0b21ebea867876945985631c876de84f53592134 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Wed, 11 Aug 2021 20:53:50 +0700 Subject: [PATCH 16/89] update query param --- src/Nodes/Item/Parameters/GetRecommendCats.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Nodes/Item/Parameters/GetRecommendCats.php b/src/Nodes/Item/Parameters/GetRecommendCats.php index 7378d00..49b7545 100644 --- a/src/Nodes/Item/Parameters/GetRecommendCats.php +++ b/src/Nodes/Item/Parameters/GetRecommendCats.php @@ -6,11 +6,10 @@ class GetRecommendCats extends RequestParameters { - use CategoryIdTrait; public function getName(): string { - return $this->parameters['name']; + return $this->parameters['item_name']; } /** @@ -21,7 +20,7 @@ public function getName(): string */ public function setName(string $name) { - $this->parameters['name'] = $name; + $this->parameters['item_name'] = $name; return $this; } From f895516131036e449db8c653aa657f0873350624 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Wed, 11 Aug 2021 21:29:12 +0700 Subject: [PATCH 17/89] Add model item params --- src/Nodes/Item/Parameters/Add.php | 125 +++++++++--------- src/Nodes/Item/Parameters/Attribute.php | 10 +- src/Nodes/Item/Parameters/AttributeValue.php | 56 ++++++++ .../Item/Parameters/AttributeValueList.php | 33 +++++ src/Nodes/Item/Parameters/Brand.php | 40 ++++++ src/Nodes/Item/Parameters/Dimension.php | 56 ++++++++ src/Nodes/Item/Parameters/Images.php | 21 +-- src/Nodes/Item/Parameters/Logistics.php | 1 + src/Nodes/Item/Parameters/PreOrder.php | 40 ++++++ src/Nodes/Item/Parameters/Wholesale.php | 8 +- src/Nodes/Item/Parameters/Wholesales.php | 1 + 11 files changed, 305 insertions(+), 86 deletions(-) create mode 100644 src/Nodes/Item/Parameters/AttributeValue.php create mode 100644 src/Nodes/Item/Parameters/AttributeValueList.php create mode 100644 src/Nodes/Item/Parameters/Brand.php create mode 100644 src/Nodes/Item/Parameters/Dimension.php create mode 100644 src/Nodes/Item/Parameters/PreOrder.php diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index b9d943e..181fc60 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -10,7 +10,7 @@ class Add extends RequestParameters public function getName(): string { - return $this->parameters['name']; + return $this->parameters['item_name']; } /** @@ -21,7 +21,7 @@ public function getName(): string */ public function setName(string $name) { - $this->parameters['name'] = $name; + $this->parameters['item_name'] = $name; return $this; } @@ -46,7 +46,7 @@ public function setDescription(string $description) public function getPrice(): float { - return $this->parameters['price']; + return $this->parameters['original_price']; } /** @@ -57,14 +57,14 @@ public function getPrice(): float */ public function setPrice(float $price) { - $this->parameters['price'] = $price; + $this->parameters['original_price'] = $price; return $this; } public function getStock(): int { - return $this->parameters['stock']; + return $this->parameters['normal_stock']; } /** @@ -75,11 +75,46 @@ public function getStock(): int */ public function setStock(int $stock) { - $this->parameters['stock'] = $stock; + $this->parameters['normal_stock'] = $stock; return $this; } + public function getStatus(): int + { + return $this->parameters['item_status']; + } + + /** + * The current stock quantity of the item. + * + * @param int $stock + * @return $this + */ + public function setStatus(int $stock) + { + $this->parameters['item_status'] = $stock; + + return $this; + } + + public function getDimension(): Dimension + { + return $this->parameters['dimension']; + } + + /** + * @param Dimension $dimension + * @return $this + */ + public function setDimension(Dimension $dimension) + { + $this->parameters['dimension'] = $dimension; + + return $this; + } + + public function getItemSku(): ?string { return $this->parameters['item_sku']; @@ -119,7 +154,7 @@ public function setVariations(Variations $variations) public function getImages(): Images { - return $this->parameters['images']; + return $this->parameters['image']; } /** @@ -131,7 +166,7 @@ public function getImages(): Images */ public function setImages(Images $images) { - $this->parameters['images'] = $images; + $this->parameters['image'] = $images; return $this; } @@ -156,7 +191,7 @@ public function setAttributes(Attributes $attributes) public function getLogistics(): ?Logistics { - return $this->parameters['logistics']; + return $this->parameters['logistic_info']; } /** @@ -167,7 +202,7 @@ public function getLogistics(): ?Logistics */ public function setLogistics(Logistics $logistics) { - $this->parameters['logistics'] = $logistics; + $this->parameters['logistic_info'] = $logistics; return $this; } @@ -190,91 +225,55 @@ public function setWeight(float $weight) return $this; } - public function getPackageLength(): ?int - { - return $this->parameters['package_length']; - } - - /** - * The height of package for this single item, the unit is CM. - * - * @param int $packageLength - * @return $this - */ - public function setPackageLength(int $packageLength) + public function getPreOrder(): ?PreOrder { - $this->parameters['package_length'] = $packageLength; - - return $this; - } - - public function getPackageWidth(): ?int - { - return $this->parameters['package_width']; + return $this->parameters['days_to_ship']; } /** - * The height of package for this single item, the unit is CM. + * The days to ship. Only work for pre-order, it means this value should be bigger than 7. * - * @param int $packageWidth - * @return $this - */ - public function setPackageWidth(int $packageWidth) - { - $this->parameters['package_width'] = $packageWidth; - - return $this; - } - - public function getPackageHeight(): ?int - { - return $this->parameters['package_height']; - } - - /** - * The height of package for this single item, the unit is CM. - * @param int $packageHeight + * @param PreOrder $preOrder * @return $this */ - public function setPackageHeight(int $packageHeight) + public function setPreOrder(PreOrder $preOrder) { - $this->parameters['package_height'] = $packageHeight; + $this->parameters['pre_order'] = $preOrder; return $this; } - public function getDaysToShip(): ?int + public function getWholesales(): ?Wholesales { - return $this->parameters['days_to_ship']; + return $this->parameters['wholesales']; } /** - * The days to ship. Only work for pre-order, it means this value should be bigger than 7. + * The wholesales tier list. Please put the wholesale tier info in order by min count. * - * @param int $daysToShip + * @param Wholesales $wholesales * @return $this */ - public function setDaysToShip(int $daysToShip) + public function setWholesales(Wholesales $wholesales) { - $this->parameters['days_to_ship'] = $daysToShip; + $this->parameters['wholesales'] = $wholesales; return $this; } - public function getWholesales(): ?Wholesales + public function getBrand(): ?Brand { - return $this->parameters['wholesales']; + return $this->parameters['brand']; } /** - * The wholesales tier list. Please put the wholesale tier info in order by min count. * - * @param Wholesales $wholesales + * @param Brand $brand * @return $this */ - public function setWholesales(Wholesales $wholesales) + public function setBrand(Brand $brand) { - $this->parameters['wholesales'] = $wholesales; + $this->parameters['brand'] = $brand; return $this; } diff --git a/src/Nodes/Item/Parameters/Attribute.php b/src/Nodes/Item/Parameters/Attribute.php index d9b665d..bc4ad29 100644 --- a/src/Nodes/Item/Parameters/Attribute.php +++ b/src/Nodes/Item/Parameters/Attribute.php @@ -22,18 +22,18 @@ public function setAttributeId(int $attributeId) return $this; } - public function getValue(): string + public function getValueList(): AttributeValueList { - return $this->parameters['value']; + return $this->parameters['attribute_value_list']; } /** - * @param string $value + * @param AttributeValueList $valueList * @return $this */ - public function setValue(string $value) + public function setValueList(AttributeValueList $valueList) { - $this->parameters['value'] = $value; + $this->parameters['attribute_value_list'] = $valueList; return $this; } diff --git a/src/Nodes/Item/Parameters/AttributeValue.php b/src/Nodes/Item/Parameters/AttributeValue.php new file mode 100644 index 0000000..53d6b3f --- /dev/null +++ b/src/Nodes/Item/Parameters/AttributeValue.php @@ -0,0 +1,56 @@ +parameters['value_id']; + } + + /** + * @param int $value_id + * @return $this + */ + public function setValueId(int $value_id) + { + $this->parameters['value_id'] = $value_id; + + return $this; + } + + public function getOriginalValueName(): string + { + return $this->parameters['original_value_name']; + } + + /** + * @param string $original_value_name + * @return $this + */ + public function setOriginalValueName(string $original_value_name) + { + $this->parameters['original_value_name'] = $original_value_name; + + return $this; + } + + public function getValueUnit(): string + { + return $this->parameters['value_unit']; + } + + /** + * @param string $unit + * @return $this + */ + public function setValueUnit(string $unit) + { + $this->parameters['value_unit'] = $unit; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/AttributeValueList.php b/src/Nodes/Item/Parameters/AttributeValueList.php new file mode 100644 index 0000000..49bb193 --- /dev/null +++ b/src/Nodes/Item/Parameters/AttributeValueList.php @@ -0,0 +1,33 @@ +add(new AttributeValue($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/Brand.php b/src/Nodes/Item/Parameters/Brand.php new file mode 100644 index 0000000..929e1d1 --- /dev/null +++ b/src/Nodes/Item/Parameters/Brand.php @@ -0,0 +1,40 @@ +parameters['brand_id']; + } + + /** + * @param int $brand_id + * @return $this + */ + public function setBrandId(int $brand_id) + { + $this->parameters['brand_id'] = $brand_id; + + return $this; + } + + public function getOriginalBrandName(): string + { + return $this->parameters['original_brand_name']; + } + + /** + * @param string $brand_name + * @return $this + */ + public function setOriginalBrandName(string $brand_name) + { + $this->parameters['original_brand_name'] = $brand_name; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/Dimension.php b/src/Nodes/Item/Parameters/Dimension.php new file mode 100644 index 0000000..cf13572 --- /dev/null +++ b/src/Nodes/Item/Parameters/Dimension.php @@ -0,0 +1,56 @@ +parameters['package_height']; + } + + /** + * @param int $height + * @return $this + */ + public function setPackageHeight(int $height) + { + $this->parameters['package_height'] = $height; + + return $this; + } + + public function getPackageLength(): int + { + return $this->parameters['package_length']; + } + + /** + * @param int $length + * @return $this + */ + public function setPackageLength(int $length) + { + $this->parameters['package_length'] = $length; + + return $this; + } + + public function getPackageWidth(): int + { + return $this->parameters['package_width']; + } + + /** + * @param int $width + * @return $this + */ + public function setPackageWidth(int $width) + { + $this->parameters['package_width'] = $width; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/Images.php b/src/Nodes/Item/Parameters/Images.php index e5bff20..d9e3217 100644 --- a/src/Nodes/Item/Parameters/Images.php +++ b/src/Nodes/Item/Parameters/Images.php @@ -3,30 +3,23 @@ namespace Shopee\Nodes\Item\Parameters; use Shopee\RequestParameterCollection; +use Shopee\RequestParameters; use Shopee\RequestParametersInterface; -class Images extends RequestParameterCollection +class Images extends RequestParameters { - /** - * @param Image|RequestParametersInterface $parameter - * @return $this - */ - public function add(RequestParametersInterface $parameter) + public function getImageIdList(): array { - parent::add($parameter); - - return $this; + return $this->parameters['image_id_list']; } /** - * @param array $parameters + * @param array $image_id_list * @return $this */ - public function fromArray(array $parameters) + public function setImageIdList(array $image_id_list) { - foreach ($parameters as $parameter) { - $this->add(new Image($parameter)); - } + $this->parameters['image_id_list'] = $image_id_list; return $this; } diff --git a/src/Nodes/Item/Parameters/Logistics.php b/src/Nodes/Item/Parameters/Logistics.php index c97c5dc..d7917be 100644 --- a/src/Nodes/Item/Parameters/Logistics.php +++ b/src/Nodes/Item/Parameters/Logistics.php @@ -21,6 +21,7 @@ public function add(RequestParametersInterface $parameter) /** * @param array $parameters * @return $this + * @throws \ReflectionException */ public function fromArray(array $parameters) { diff --git a/src/Nodes/Item/Parameters/PreOrder.php b/src/Nodes/Item/Parameters/PreOrder.php new file mode 100644 index 0000000..97fd0aa --- /dev/null +++ b/src/Nodes/Item/Parameters/PreOrder.php @@ -0,0 +1,40 @@ +parameters['is_pre_order']; + } + + /** + * @param bool $is_pre_order + * @return $this + */ + public function setIsPreOrder(bool $is_pre_order) + { + $this->parameters['is_pre_order'] = $is_pre_order; + + return $this; + } + + public function getDaysToShip(): int + { + return $this->parameters['days_to_ship']; + } + + /** + * @param int $days_to_ship + * @return $this + */ + public function setDaysToShip(int $days_to_ship) + { + $this->parameters['days_to_ship'] = $days_to_ship; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/Wholesale.php b/src/Nodes/Item/Parameters/Wholesale.php index b95b231..8f9f38a 100644 --- a/src/Nodes/Item/Parameters/Wholesale.php +++ b/src/Nodes/Item/Parameters/Wholesale.php @@ -8,7 +8,7 @@ class Wholesale extends RequestParameters { public function getMin(): int { - return $this->parameters['min']; + return $this->parameters['min_count']; } /** @@ -20,14 +20,14 @@ public function getMin(): int */ public function setMin(int $min) { - $this->parameters['min'] = $min; + $this->parameters['min_count'] = $min; return $this; } public function getMax(): int { - return $this->parameters['max']; + return $this->parameters['max_count']; } /** @@ -38,7 +38,7 @@ public function getMax(): int */ public function setMax(int $max) { - $this->parameters['max'] = $max; + $this->parameters['max_count'] = $max; return $this; } diff --git a/src/Nodes/Item/Parameters/Wholesales.php b/src/Nodes/Item/Parameters/Wholesales.php index 476b754..5304ae3 100644 --- a/src/Nodes/Item/Parameters/Wholesales.php +++ b/src/Nodes/Item/Parameters/Wholesales.php @@ -21,6 +21,7 @@ public function add(RequestParametersInterface $parameter) /** * @param array $parameters * @return $this + * @throws \ReflectionException */ public function fromArray(array $parameters) { From 6fe2e530069f8ed9d82aa31bbf29521278540c1b Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Fri, 13 Aug 2021 22:33:27 +0700 Subject: [PATCH 18/89] Added: add logic shopee sync push --- src/ClientV2.php | 74 ++++++++--- src/Nodes/Image/Image.php | 8 +- src/Nodes/Item/Item.php | 22 ++++ src/Nodes/Item/Parameters/Add.php | 23 +--- src/Nodes/Item/Parameters/Attribute.php | 4 +- src/Nodes/Item/Parameters/Image.php | 10 +- .../Item/Parameters/InitTierVariation.php | 19 ++- src/Nodes/Item/Parameters/TierVariant.php | 41 +++++++ .../Item/Parameters/TierVariantOption.php | 41 +++++++ .../Item/Parameters/TierVariantOptionList.php | 34 +++++ src/Nodes/Item/Parameters/TierVariants.php | 34 +++++ src/Nodes/Item/Parameters/UpdateItem.php | 116 +++++++++--------- .../Item/Parameters/UpdateTierVariation.php | 22 ++++ src/Nodes/Item/Parameters/UpdateVariation.php | 26 ++++ .../Item/Parameters/UpdateVariationModel.php | 22 ++++ .../Item/Parameters/UpdateVariations.php | 34 +++++ src/Nodes/Item/Parameters/Variation.php | 31 ++--- src/Nodes/Item/Parameters/Variations.php | 1 + src/Nodes/NodeAbstractV2.php | 14 +++ 19 files changed, 449 insertions(+), 127 deletions(-) create mode 100644 src/Nodes/Item/Parameters/TierVariant.php create mode 100644 src/Nodes/Item/Parameters/TierVariantOption.php create mode 100644 src/Nodes/Item/Parameters/TierVariantOptionList.php create mode 100644 src/Nodes/Item/Parameters/TierVariants.php create mode 100644 src/Nodes/Item/Parameters/UpdateTierVariation.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariation.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariationModel.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariations.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 7ebdf0a..93d741c 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -5,6 +5,7 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ClientException as GuzzleClientException; +use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\ServerException as GuzzleServerException; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Uri; @@ -34,6 +35,7 @@ * @property Nodes\Item\Brand $brand * @property Nodes\Item\Attribute $attribute * @property Nodes\Item\Item $item + * @property Nodes\Image\Image $image */ class ClientV2 { @@ -128,10 +130,11 @@ public function __construct(array $config = []) $this->nodes['author'] = new Nodes\Shop\Authorization($this); $this->nodes['shop'] = new Nodes\Shop\Shop($this); - $this->nodes['category'] = new Nodes\Item\Category($this); - $this->nodes['brand'] = new Nodes\Item\Brand($this); - $this->nodes['attribute'] = new Nodes\Item\Attribute($this); - $this->nodes['item'] = new Nodes\Item\Item($this); + $this->nodes['category'] = new Nodes\Item\Category($this); + $this->nodes['brand'] = new Nodes\Item\Brand($this); + $this->nodes['attribute'] = new Nodes\Item\Attribute($this); + $this->nodes['item'] = new Nodes\Item\Item($this); + $this->nodes['image'] = new Nodes\Image\Image($this); } public function __get(string $name) @@ -224,16 +227,16 @@ protected function createJsonBody(array $data): string */ protected function signature($uri, $api_type): string { - switch ($api_type){ - case self::API_TYPE_PUBLIC: - return $auth_query = $this->signatureGenerator->generateSignaturePublicLevel($uri, $this->partnerId); - case self::API_TYPE_SHOP: - return $auth_query = $this->signatureGenerator->generateSignatureShopLevel($uri, $this->partnerId, $this->accessToken, $this->shopId); - case self::API_TYPE_MERCHANT: - return $auth_query = $this->signatureGenerator->generateSignatureMerchantLevel($uri, $this->partnerId, $this->accessToken, $this->merchantId); - default: - return ""; - } + switch ($api_type) { + case self::API_TYPE_PUBLIC: + return $auth_query = $this->signatureGenerator->generateSignaturePublicLevel($uri, $this->partnerId); + case self::API_TYPE_SHOP: + return $auth_query = $this->signatureGenerator->generateSignatureShopLevel($uri, $this->partnerId, $this->accessToken, $this->shopId); + case self::API_TYPE_MERCHANT: + return $auth_query = $this->signatureGenerator->generateSignatureMerchantLevel($uri, $this->partnerId, $this->accessToken, $this->merchantId); + default: + return ""; + } } /** @@ -269,6 +272,40 @@ public function newRequest($uri, $api_type, array $headers = [], $data = []): Re ); } + public function upload(RequestInterface $request, $file_url): ResponseInterface + { + try { + list($tempImageDownload, $fileName) = $this->downloadFile($file_url); + $response = $this->httpClient->send($request, [ + 'multipart' => [ + [ + 'name' => 'image', + 'contents' => fopen($tempImageDownload,'r') + ], + ] + ]); + } catch (GuzzleClientException $exception) { + switch ($exception->getCode()) { + case 400: + $className = BadRequestException::class; + break; + case 403: + $className = AuthException::class; + break; + default: + $className = ClientException::class; + } + + throw Factory::create($className, $exception); + } catch (GuzzleServerException $exception) { + throw Factory::create(ServerException::class, $exception); + } catch (GuzzleException $exception) { + throw Factory::create(ServerException::class, $exception); + } + + return $response; + } + public function send(RequestInterface $request): ResponseInterface { try { @@ -311,4 +348,13 @@ public function getAuthorizationUrl($redirect_url) return $uri->__toString(); } + private function downloadFile($urlDownload) + { + $path_info = pathinfo($urlDownload); + $filename = $path_info['basename']; + $tempImage = tempnam(sys_get_temp_dir(), $filename); + copy($urlDownload, $tempImage); + return [$tempImage, $filename]; + } + } diff --git a/src/Nodes/Image/Image.php b/src/Nodes/Image/Image.php index 810b628..597cf14 100644 --- a/src/Nodes/Image/Image.php +++ b/src/Nodes/Image/Image.php @@ -2,10 +2,12 @@ namespace Shopee\Nodes\Image; +use Shopee\ClientV2; use Shopee\Nodes\NodeAbstract; +use Shopee\Nodes\NodeAbstractV2; use Shopee\ResponseData; -class Image extends NodeAbstract +class Image extends NodeAbstractV2 { /** * Use this optional API to pre-validate your image urls and convert them to Shopee image url to use in item @@ -14,8 +16,8 @@ class Image extends NodeAbstract * @param array $parameters * @return ResponseData */ - public function uploadImage($parameters = []): ResponseData + public function uploadImage($image_url): ResponseData { - return $this->post('/api/v1/image/upload', $parameters); + return $this->upload('/api/v2/media_space/upload_image', ClientV2::API_TYPE_PUBLIC, $image_url); } } diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index 17df045..8352206 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -233,4 +233,26 @@ public function initTierVariation($parameters = []): ResponseData { return $this->post('/api/v2/product/init_tier_variation', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * For adding 2-tier variations (Forked). + * + * @param array|Parameters\UpdateTierVariation $parameters + * @return ResponseData + */ + public function updateTierVariation($parameters = []): ResponseData + { + return $this->post('/api/v2/product/update_tier_variation', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * For adding 2-tier variations (Forked). + * + * @param array|Parameters\UpdateVariationModel $parameters + * @return ResponseData + */ + public function updateModel($parameters = []): ResponseData + { + return $this->post('/api/v2/product/update_model', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 181fc60..5a4544c 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -133,25 +133,6 @@ public function setItemSku(string $itemSku) return $this; } - public function getVariations(): ?Variations - { - return $this->parameters['variations']; - } - - /** - * The variation of item is to list out all models of this product, for example, - * iPhone has model of White and Black, then its variations includes "White iPhone" and "Black iPhone". - * - * @param Variations $variations - * @return $this - */ - public function setVariations(Variations $variations) - { - $this->parameters['variations'] = $variations; - - return $this; - } - public function getImages(): Images { return $this->parameters['image']; @@ -173,7 +154,7 @@ public function setImages(Images $images) public function getAttributes(): ?Attributes { - return $this->parameters['attributes']; + return $this->parameters['attribute_list']; } /** @@ -184,7 +165,7 @@ public function getAttributes(): ?Attributes */ public function setAttributes(Attributes $attributes) { - $this->parameters['attributes'] = $attributes; + $this->parameters['attribute_list'] = $attributes; return $this; } diff --git a/src/Nodes/Item/Parameters/Attribute.php b/src/Nodes/Item/Parameters/Attribute.php index bc4ad29..719c6e6 100644 --- a/src/Nodes/Item/Parameters/Attribute.php +++ b/src/Nodes/Item/Parameters/Attribute.php @@ -8,7 +8,7 @@ class Attribute extends RequestParameters { public function getAttributeId(): int { - return $this->parameters['attributes_id']; + return $this->parameters['attribute_id']; } /** @@ -17,7 +17,7 @@ public function getAttributeId(): int */ public function setAttributeId(int $attributeId) { - $this->parameters['attributes_id'] = $attributeId; + $this->parameters['attribute_id'] = $attributeId; return $this; } diff --git a/src/Nodes/Item/Parameters/Image.php b/src/Nodes/Item/Parameters/Image.php index 0c41aad..e9e44d5 100644 --- a/src/Nodes/Item/Parameters/Image.php +++ b/src/Nodes/Item/Parameters/Image.php @@ -6,18 +6,18 @@ class Image extends RequestParameters { - public function getUrl(): string + public function getImageId(): string { - return $this->parameters['url']; + return $this->parameters['image_id']; } /** - * @param string $url + * @param string $image_url * @return $this */ - public function setUrl(string $url) + public function setImageId(string $image_url) { - $this->parameters['url'] = $url; + $this->parameters['image_id'] = $image_url; return $this; } diff --git a/src/Nodes/Item/Parameters/InitTierVariation.php b/src/Nodes/Item/Parameters/InitTierVariation.php index a2567e3..a735567 100644 --- a/src/Nodes/Item/Parameters/InitTierVariation.php +++ b/src/Nodes/Item/Parameters/InitTierVariation.php @@ -6,15 +6,26 @@ class InitTierVariation extends RequestParameters { - use CategoryIdTrait; + use ItemTrait; - public function getTierVariation() + + public function getTierVariation(): TierVariants { return $this->parameters['tier_variation']; } - public function getVariation() + public function setTierVariation(TierVariants $tier_variants) + { + $this->parameters['tier_variation'] = $tier_variants; + } + + public function getModel(): Variations + { + return $this->parameters['model']; + } + + public function setModel(Variations $variations) { - return $this->parameters['variation']; + $this->parameters['model'] = $variations; } } diff --git a/src/Nodes/Item/Parameters/TierVariant.php b/src/Nodes/Item/Parameters/TierVariant.php new file mode 100644 index 0000000..fd87cf0 --- /dev/null +++ b/src/Nodes/Item/Parameters/TierVariant.php @@ -0,0 +1,41 @@ +parameters['name']; + } + + /** + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['name'] = $name; + + return $this; + } + + public function getOptionList(): TierVariantOptionList + { + return $this->parameters['option_list']; + } + + /** + * @param TierVariantOptionList $optionList + * @return $this + */ + public function setOptionList(TierVariantOptionList $optionList) + { + $this->parameters['option_list'] = $optionList; + + return $this; + } + +} diff --git a/src/Nodes/Item/Parameters/TierVariantOption.php b/src/Nodes/Item/Parameters/TierVariantOption.php new file mode 100644 index 0000000..ffd2313 --- /dev/null +++ b/src/Nodes/Item/Parameters/TierVariantOption.php @@ -0,0 +1,41 @@ +parameters['option']; + } + + /** + * @param string $name + * @return $this + */ + public function setOption(string $name) + { + $this->parameters['option'] = $name; + + return $this; + } + + public function getImage(): Image + { + return $this->parameters['image']; + } + + /** + * @param Image $image + * @return $this + */ + public function setImage(Image $image) + { + $this->parameters['image'] = $image; + + return $this; + } + +} diff --git a/src/Nodes/Item/Parameters/TierVariantOptionList.php b/src/Nodes/Item/Parameters/TierVariantOptionList.php new file mode 100644 index 0000000..8b6ecdc --- /dev/null +++ b/src/Nodes/Item/Parameters/TierVariantOptionList.php @@ -0,0 +1,34 @@ +add(new TierVariantOption($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/TierVariants.php b/src/Nodes/Item/Parameters/TierVariants.php new file mode 100644 index 0000000..a07f8ea --- /dev/null +++ b/src/Nodes/Item/Parameters/TierVariants.php @@ -0,0 +1,34 @@ +add(new TierVariant($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/UpdateItem.php b/src/Nodes/Item/Parameters/UpdateItem.php index cd746b7..44a6fbc 100644 --- a/src/Nodes/Item/Parameters/UpdateItem.php +++ b/src/Nodes/Item/Parameters/UpdateItem.php @@ -11,7 +11,7 @@ class UpdateItem extends RequestParameters public function getName(): string { - return $this->parameters['name']; + return $this->parameters['item_name']; } /** @@ -22,7 +22,7 @@ public function getName(): string */ public function setName(string $name) { - $this->parameters['name'] = $name; + $this->parameters['item_name'] = $name; return $this; } @@ -45,100 +45,100 @@ public function setDescription(string $description) return $this; } - public function getItemSku(): ?string + public function getStatus(): int { - return $this->parameters['item_sku']; + return $this->parameters['item_status']; } /** - * An item SKU (stock keeping unit) is an identifier defined by a seller, sometimes called parent SKU. - * Item SKU can be assigned to an item in Shopee Listings. - * @param string $itemSku + * The current stock quantity of the item. + * + * @param int $stock * @return $this */ - public function setItemSku(string $itemSku) + public function setStatus(int $stock) { - $this->parameters['item_sku'] = $itemSku; + $this->parameters['item_status'] = $stock; return $this; } - public function getVariations(): ?VariationsForUpdateItem + public function getDimension(): Dimension { - return $this->parameters['variations']; + return $this->parameters['dimension']; } /** - * The variation of item is to list out all models of this product, for example, - * iPhone has model of White and Black, then its variations includes "White iPhone" and "Black iPhone". - * - * @param VariationsForUpdateItem $variations + * @param Dimension $dimension * @return $this */ - public function setVariations(VariationsForUpdateItem $variations) + public function setDimension(Dimension $dimension) { - $this->parameters['variations'] = $variations; + $this->parameters['dimension'] = $dimension; return $this; } - public function getAttributes(): ?Attributes + + public function getItemSku(): ?string { - return $this->parameters['attributes']; + return $this->parameters['item_sku']; } /** - * Should call shopee.item.GetAttributes to get attribute first. Should contain all all mandatory attribute. - * - * @param Attributes $attributes + * An item SKU (stock keeping unit) is an identifier defined by a seller, sometimes called parent SKU. + * Item SKU can be assigned to an item in Shopee Listings. + * @param string $itemSku * @return $this */ - public function setAttributes(Attributes $attributes) + public function setItemSku(string $itemSku) { - $this->parameters['attributes'] = $attributes; + $this->parameters['item_sku'] = $itemSku; return $this; } - public function getDaysToShip(): ?int + + public function getImages(): Images { - return $this->parameters['days_to_ship']; + return $this->parameters['image']; } /** - * The days to ship. Only work for pre-order, it means this value should be bigger than 7. + * Image URLs of the item. Up to 9 images, max 2.0 MB each.Image format accepted: JPG, JPEG, PNG. + * Suggested dimension: 1024 x 1024 px. * - * @param int $daysToShip + * @param Images $images * @return $this */ - public function setDaysToShip(int $daysToShip) + public function setImages(Images $images) { - $this->parameters['days_to_ship'] = $daysToShip; + $this->parameters['image'] = $images; return $this; } - public function getWholesales(): ?Wholesales + public function getAttributes(): ?Attributes { - return $this->parameters['wholesales']; + return $this->parameters['attribute_list']; } /** - * The wholesales tier list. Please put the wholesale tier info in order by min count. + * Should call shopee.item.GetAttributes to get attribute first. Should contain all all mandatory attribute. * - * @param Wholesales $wholesales + * @param Attributes $attributes * @return $this */ - public function setWholesales(Wholesales $wholesales) + public function setAttributes(Attributes $attributes) { - $this->parameters['wholesales'] = $wholesales; + $this->parameters['attribute_list'] = $attributes; return $this; } - public function getLogistics(): Logistics + public function getLogistics(): ?Logistics { - return $this->parameters['logistics']; + return $this->parameters['logistic_info']; } /** @@ -149,12 +149,12 @@ public function getLogistics(): Logistics */ public function setLogistics(Logistics $logistics) { - $this->parameters['logistics'] = $logistics; + $this->parameters['logistic_info'] = $logistics; return $this; } - public function getWeight(): float + public function getWeight(): ?float { return $this->parameters['weight']; } @@ -172,55 +172,55 @@ public function setWeight(float $weight) return $this; } - public function getPackageLength(): ?int + public function getPreOrder(): ?PreOrder { - return $this->parameters['package_length']; + return $this->parameters['days_to_ship']; } /** - * The height of package for this single item, the unit is CM. + * The days to ship. Only work for pre-order, it means this value should be bigger than 7. * - * @param int $packageLength + * @param PreOrder $preOrder * @return $this */ - public function setPackageLength(int $packageLength) + public function setPreOrder(PreOrder $preOrder) { - $this->parameters['package_length'] = $packageLength; + $this->parameters['pre_order'] = $preOrder; return $this; } - public function getPackageWidth(): ?int + public function getWholesales(): ?Wholesales { - return $this->parameters['package_width']; + return $this->parameters['wholesales']; } /** - * The height of package for this single item, the unit is CM. + * The wholesales tier list. Please put the wholesale tier info in order by min count. * - * @param int $packageWidth + * @param Wholesales $wholesales * @return $this */ - public function setPackageWidth(int $packageWidth) + public function setWholesales(Wholesales $wholesales) { - $this->parameters['package_width'] = $packageWidth; + $this->parameters['wholesales'] = $wholesales; return $this; } - public function getPackageHeight(): ?int + public function getBrand(): ?Brand { - return $this->parameters['package_height']; + return $this->parameters['brand']; } /** - * The height of package for this single item, the unit is CM. - * @param int $packageHeight + * + * @param Brand $brand * @return $this */ - public function setPackageHeight(int $packageHeight) + public function setBrand(Brand $brand) { - $this->parameters['package_height'] = $packageHeight; + $this->parameters['brand'] = $brand; return $this; } diff --git a/src/Nodes/Item/Parameters/UpdateTierVariation.php b/src/Nodes/Item/Parameters/UpdateTierVariation.php new file mode 100644 index 0000000..fa15a5a --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateTierVariation.php @@ -0,0 +1,22 @@ +parameters['tier_variation']; + } + + public function setTierVariation(TierVariants $tier_variants) + { + $this->parameters['tier_variation'] = $tier_variants; + } + +} diff --git a/src/Nodes/Item/Parameters/UpdateVariation.php b/src/Nodes/Item/Parameters/UpdateVariation.php new file mode 100644 index 0000000..86943d0 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariation.php @@ -0,0 +1,26 @@ +parameters['model_sku']; + } + + /** + * @param string $variationSku + * @return $this + */ + public function setVariationSku(string $variationSku) + { + $this->parameters['model_sku'] = $variationSku; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationModel.php b/src/Nodes/Item/Parameters/UpdateVariationModel.php new file mode 100644 index 0000000..b329dc5 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariationModel.php @@ -0,0 +1,22 @@ +parameters['model']; + } + + public function setModel(UpdateVariations $variations) + { + $this->parameters['model'] = $variations; + } + +} diff --git a/src/Nodes/Item/Parameters/UpdateVariations.php b/src/Nodes/Item/Parameters/UpdateVariations.php new file mode 100644 index 0000000..03976ca --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariations.php @@ -0,0 +1,34 @@ +add(new UpdateVariation($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/Variation.php b/src/Nodes/Item/Parameters/Variation.php index cbfa379..7ef4d5f 100644 --- a/src/Nodes/Item/Parameters/Variation.php +++ b/src/Nodes/Item/Parameters/Variation.php @@ -6,30 +6,26 @@ class Variation extends RequestParameters { - public function getName(): string + public function getTierIndex(): array { - return $this->parameters['name']; + return $this->parameters['tier_index']; } /** - * Name of the variation that belongs to the same item.A seller can offer variations of the same item. - * For example, the seller could create a fixed-priced listing for a t-shirt design and offer the shirt in - * different colors and sizes. In this case, each color and size combination is a separate variation. - * Each variation can have a different quantity and price. * - * @param string $name + * @param array $index_list * @return $this */ - public function setName(string $name) + public function setTierIndex(array $index_list) { - $this->parameters['name'] = $name; + $this->parameters['tier_index'] = $index_list; return $this; } public function getStock(): int { - return $this->parameters['stock']; + return $this->parameters['normal_stock']; } /** @@ -40,14 +36,14 @@ public function getStock(): int */ public function setStock(int $stock) { - $this->parameters['stock'] = $stock; + $this->parameters['normal_stock'] = $stock; return $this; } public function getPrice() { - return $this->parameters['price']; + return $this->parameters['original_price']; } /** @@ -58,28 +54,23 @@ public function getPrice() */ public function setPrice(float $price) { - $this->parameters['price'] = $price; + $this->parameters['original_price'] = $price; return $this; } public function getVariationSku() { - return $this->parameters['variation_sku']; + return $this->parameters['model_sku']; } /** - * A variation SKU (stock keeping unit) is an identifier defined by a seller. - * It is only intended for the seller's use. - * Many sellers assign a SKU to an item of a specific type, size, and color, which are variations of one item in - * Shopee Listings. - * * @param string $variationSku * @return $this */ public function setVariationSku(string $variationSku) { - $this->parameters['variation_sku'] = $variationSku; + $this->parameters['model_sku'] = $variationSku; return $this; } diff --git a/src/Nodes/Item/Parameters/Variations.php b/src/Nodes/Item/Parameters/Variations.php index cd3f735..faa3741 100644 --- a/src/Nodes/Item/Parameters/Variations.php +++ b/src/Nodes/Item/Parameters/Variations.php @@ -21,6 +21,7 @@ public function add(RequestParametersInterface $parameter) /** * @param array $parameters * @return $this + * @throws \ReflectionException */ public function fromArray(array $parameters) { diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index d4dfea0..858daa8 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -58,4 +58,18 @@ public function get($uri, $type_api, $parameters) return new ResponseData($response); } + + /** + * @param string|UriInterface $uri + * @param $type_api + * @param $file_url + * @return ResponseData + */ + public function upload($uri, $type_api, $file_url) + { + + $request = $this->client->newRequest($uri, $type_api, []); + $response = $this->client->upload($request, $file_url); + return new ResponseData($response); + } } From 7df098af49a4a627cff5d3d65b9292a122d02632 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Sat, 14 Aug 2021 16:56:38 +0700 Subject: [PATCH 19/89] Update model and stock --- src/Nodes/Item/Item.php | 4 +-- src/Nodes/Item/Parameters/UpdateVariation.php | 2 +- .../Parameters/UpdateVariationModelPrice.php | 22 ++++++++++++ .../Parameters/UpdateVariationModelStock.php | 22 ++++++++++++ .../Item/Parameters/UpdateVariationPrice.php | 17 +++++++++- .../Parameters/UpdateVariationPriceList.php | 34 +++++++++++++++++++ .../Item/Parameters/UpdateVariationStock.php | 17 +++++++++- .../Parameters/UpdateVariationStockList.php | 34 +++++++++++++++++++ .../Item/Parameters/VariationIdTrait.php | 14 ++++---- 9 files changed, 153 insertions(+), 13 deletions(-) create mode 100644 src/Nodes/Item/Parameters/UpdateVariationModelPrice.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariationModelStock.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariationPriceList.php create mode 100644 src/Nodes/Item/Parameters/UpdateVariationStockList.php diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index 8352206..3509e77 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -180,7 +180,7 @@ public function updateItem($parameters = []): ResponseData /** * Use this call to update item price. * https://open.shopee.com/documents?module=89&type=1&id=651&version=2 - * @param array|Parameters\UpdatePrice $parameters + * @param array|Parameters\UpdateVariationPriceList $parameters * @return ResponseData */ public function updatePrice($parameters = []): ResponseData @@ -191,7 +191,7 @@ public function updatePrice($parameters = []): ResponseData /** * Use this call to update item stock. * https://open.shopee.com/documents?module=89&type=1&id=652&version=2 - * @param array|Parameters\UpdateStock $parameters + * @param array|Parameters\UpdateVariationStockList $parameters * @return ResponseData */ public function updateStock($parameters = []): ResponseData diff --git a/src/Nodes/Item/Parameters/UpdateVariation.php b/src/Nodes/Item/Parameters/UpdateVariation.php index 86943d0..89e00f6 100644 --- a/src/Nodes/Item/Parameters/UpdateVariation.php +++ b/src/Nodes/Item/Parameters/UpdateVariation.php @@ -6,7 +6,7 @@ class UpdateVariation extends RequestParameters { - use ItemTrait; + use VariationIdTrait; public function getVariationSku() { diff --git a/src/Nodes/Item/Parameters/UpdateVariationModelPrice.php b/src/Nodes/Item/Parameters/UpdateVariationModelPrice.php new file mode 100644 index 0000000..a533745 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariationModelPrice.php @@ -0,0 +1,22 @@ +parameters['price_list']; + } + + public function setModel(UpdateVariationPriceList $variations) + { + $this->parameters['price_list'] = $variations; + } + +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationModelStock.php b/src/Nodes/Item/Parameters/UpdateVariationModelStock.php new file mode 100644 index 0000000..7bd9d2d --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariationModelStock.php @@ -0,0 +1,22 @@ +parameters['stock_list']; + } + + public function setModel(UpdateVariationStockList $variations) + { + $this->parameters['stock_list'] = $variations; + } + +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationPrice.php b/src/Nodes/Item/Parameters/UpdateVariationPrice.php index ba5de4e..42b0e46 100644 --- a/src/Nodes/Item/Parameters/UpdateVariationPrice.php +++ b/src/Nodes/Item/Parameters/UpdateVariationPrice.php @@ -4,6 +4,21 @@ class UpdateVariationPrice extends UpdatePrice { - use ItemTrait; use VariationIdTrait; + + public function getVariationPrice() + { + return $this->parameters['original_price']; + } + + /** + * @param float $price + * @return $this + */ + public function setVariationPrice(float $price) + { + $this->parameters['original_price'] = $price; + + return $this; + } } diff --git a/src/Nodes/Item/Parameters/UpdateVariationPriceList.php b/src/Nodes/Item/Parameters/UpdateVariationPriceList.php new file mode 100644 index 0000000..47b5cd9 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariationPriceList.php @@ -0,0 +1,34 @@ +add(new UpdateVariationPrice($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationStock.php b/src/Nodes/Item/Parameters/UpdateVariationStock.php index 6ed5aa4..70d08cb 100644 --- a/src/Nodes/Item/Parameters/UpdateVariationStock.php +++ b/src/Nodes/Item/Parameters/UpdateVariationStock.php @@ -4,6 +4,21 @@ class UpdateVariationStock extends UpdateStock { - use ItemTrait; use VariationIdTrait; + + public function getVariationStock() + { + return $this->parameters['normal_stock']; + } + + /** + * @param int $stock + * @return $this + */ + public function setVariationStock(int $stock) + { + $this->parameters['normal_stock'] = $stock; + + return $this; + } } diff --git a/src/Nodes/Item/Parameters/UpdateVariationStockList.php b/src/Nodes/Item/Parameters/UpdateVariationStockList.php new file mode 100644 index 0000000..96afaf6 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateVariationStockList.php @@ -0,0 +1,34 @@ +add(new UpdateVariationStock($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/VariationIdTrait.php b/src/Nodes/Item/Parameters/VariationIdTrait.php index 0e49078..521a5d3 100644 --- a/src/Nodes/Item/Parameters/VariationIdTrait.php +++ b/src/Nodes/Item/Parameters/VariationIdTrait.php @@ -4,22 +4,20 @@ trait VariationIdTrait { - public function getVariationId(): int + public function getModelId(): int { - return $this->parameters['variation_id']; + return $this->parameters['model_id']; } /** - * Shopee's unique identifier for a variation of an item. - * Please input the variation_id of a variation to be changed. - * The variation_id and item_id pair must be matched in order to perform the update. + * Set the Shopee's unique identifier for an item * - * @param int $variationId + * @param int $itemId * @return $this */ - public function setVariationId(int $variationId) + public function setModelId(int $itemId) { - $this->parameters['variation_id'] = $variationId; + $this->parameters['model_id'] = $itemId; return $this; } From 89b806d3192ae75d805daabecb80d104583d0d55 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 17 Aug 2021 22:55:13 +0700 Subject: [PATCH 20/89] Fixed: upload image --- src/ClientV2.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 93d741c..b0693d9 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -276,11 +276,15 @@ public function upload(RequestInterface $request, $file_url): ResponseInterface { try { list($tempImageDownload, $fileName) = $this->downloadFile($file_url); - $response = $this->httpClient->send($request, [ + $response = $this->httpClient->request( + "POST", + $request->getUri(), + [ 'multipart' => [ [ 'name' => 'image', - 'contents' => fopen($tempImageDownload,'r') + 'contents' => fopen($tempImageDownload, 'r'), + 'file_name' => $fileName ], ] ]); From ca8bb6d3456ebccf390dd9d533b04698fbcbff5b Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Thu, 19 Aug 2021 22:36:27 +0700 Subject: [PATCH 21/89] logistic channel --- src/ClientV2.php | 2 ++ src/Nodes/Logistics/Logistics.php | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/Nodes/Logistics/Logistics.php diff --git a/src/ClientV2.php b/src/ClientV2.php index b0693d9..479d09a 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -36,6 +36,7 @@ * @property Nodes\Item\Attribute $attribute * @property Nodes\Item\Item $item * @property Nodes\Image\Image $image + * @property Nodes\Logistics\Logistics $logistic */ class ClientV2 { @@ -135,6 +136,7 @@ public function __construct(array $config = []) $this->nodes['attribute'] = new Nodes\Item\Attribute($this); $this->nodes['item'] = new Nodes\Item\Item($this); $this->nodes['image'] = new Nodes\Image\Image($this); + $this->nodes['logistic'] = new Nodes\Logistics\Logistics($this); } public function __get(string $name) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php old mode 100644 new mode 100755 index 66b09b8..4cbe2b4 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -2,11 +2,12 @@ namespace Shopee\Nodes\Logistics; -use Shopee\Nodes\NodeAbstract; +use Shopee\ClientV2; +use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Logistics extends NodeAbstract +class Logistics extends NodeAbstractV2 { /** * Use this call to get all required param for init logistic. @@ -60,8 +61,9 @@ public function getForderWaybill($parameters = []): ResponseData */ public function getLogistics($parameters = []): ResponseData { - return $this->post('/api/v1/logistics/channel/get', $parameters); - } + return $this->get("/api/v2/logistics/get_channel_list", ClientV2::API_TYPE_SHOP, $parameters); + + } /** * Get all the logistics info of an order to Init. From 716cc03bea9f15e5f49f0e6ec0d15553e72d8caa Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Fri, 27 Aug 2021 17:30:11 +0700 Subject: [PATCH 22/89] * Add remove variation * Update model --- src/Nodes/Item/Item.php | 22 +++++++++++++++++++ src/Nodes/Item/Parameters/AddVariations.php | 4 ++-- src/Nodes/Item/Parameters/RemoveVariation.php | 11 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/Nodes/Item/Parameters/RemoveVariation.php diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index 3509e77..f4beaf3 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -255,4 +255,26 @@ public function updateModel($parameters = []): ResponseData { return $this->post('/api/v2/product/update_model', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * For adding 2-tier variations (Forked). + * + * @param array|Parameters\AddVariations $parameters + * @return ResponseData + */ + public function addModel($parameters = []): ResponseData + { + return $this->post('/api/v2/product/add_model', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * For adding 2-tier variations (Forked). + * + * @param array|Parameters\RemoveVariation $parameters + * @return ResponseData + */ + public function removeModel($parameters = []): ResponseData + { + return $this->post('/api/v2/product/delete_model', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Item/Parameters/AddVariations.php b/src/Nodes/Item/Parameters/AddVariations.php index 8b9b42b..133a290 100644 --- a/src/Nodes/Item/Parameters/AddVariations.php +++ b/src/Nodes/Item/Parameters/AddVariations.php @@ -10,7 +10,7 @@ class AddVariations extends RequestParameters public function getVariations(): Variations { - return $this->parameters['variations']; + return $this->parameters['model_list']; } /** @@ -22,7 +22,7 @@ public function getVariations(): Variations */ public function setVariations(Variations $variations) { - $this->parameters['variations'] = $variations; + $this->parameters['model_list'] = $variations; return $this; } diff --git a/src/Nodes/Item/Parameters/RemoveVariation.php b/src/Nodes/Item/Parameters/RemoveVariation.php new file mode 100644 index 0000000..dae7c94 --- /dev/null +++ b/src/Nodes/Item/Parameters/RemoveVariation.php @@ -0,0 +1,11 @@ + Date: Sat, 4 Sep 2021 16:07:25 +0700 Subject: [PATCH 23/89] update item status --- src/Nodes/Item/Parameters/Add.php | 8 ++++---- src/Nodes/Item/Parameters/UpdateItem.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 5a4544c..f21c475 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -80,7 +80,7 @@ public function setStock(int $stock) return $this; } - public function getStatus(): int + public function getStatus(): string { return $this->parameters['item_status']; } @@ -88,12 +88,12 @@ public function getStatus(): int /** * The current stock quantity of the item. * - * @param int $stock + * @param string $status * @return $this */ - public function setStatus(int $stock) + public function setStatus(string $status) { - $this->parameters['item_status'] = $stock; + $this->parameters['item_status'] = $status; return $this; } diff --git a/src/Nodes/Item/Parameters/UpdateItem.php b/src/Nodes/Item/Parameters/UpdateItem.php index 44a6fbc..e2b766a 100644 --- a/src/Nodes/Item/Parameters/UpdateItem.php +++ b/src/Nodes/Item/Parameters/UpdateItem.php @@ -45,7 +45,7 @@ public function setDescription(string $description) return $this; } - public function getStatus(): int + public function getStatus(): string { return $this->parameters['item_status']; } @@ -53,12 +53,12 @@ public function getStatus(): int /** * The current stock quantity of the item. * - * @param int $stock + * @param string $status * @return $this */ - public function setStatus(int $stock) + public function setStatus(string $status) { - $this->parameters['item_status'] = $stock; + $this->parameters['item_status'] = $status; return $this; } From 7ee1c9c0320cf0299203b8ad2c772f74723e8054 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Sat, 2 Oct 2021 10:01:11 +0700 Subject: [PATCH 24/89] updated: add order --- src/ClientV2.php | 4 + src/Nodes/Order/Order.php | 79 +++-------- src/Nodes/Order/Parameters/AddInvoiceData.php | 41 ++++++ src/Nodes/Order/Parameters/GetOrdersList.php | 132 ++++++++++++++++++ src/Nodes/Order/Parameters/InvoiceData.php | 119 ++++++++++++++++ src/Nodes/Payment/Payment.php | 19 ++- 6 files changed, 331 insertions(+), 63 deletions(-) create mode 100644 src/Nodes/Order/Parameters/AddInvoiceData.php create mode 100644 src/Nodes/Order/Parameters/GetOrdersList.php create mode 100644 src/Nodes/Order/Parameters/InvoiceData.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 479d09a..56d0ba3 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -37,6 +37,8 @@ * @property Nodes\Item\Item $item * @property Nodes\Image\Image $image * @property Nodes\Logistics\Logistics $logistic + * @property Nodes\Order\Order $order + * @property Nodes\Payment\Payment $payment */ class ClientV2 { @@ -137,6 +139,8 @@ public function __construct(array $config = []) $this->nodes['item'] = new Nodes\Item\Item($this); $this->nodes['image'] = new Nodes\Image\Image($this); $this->nodes['logistic'] = new Nodes\Logistics\Logistics($this); + $this->nodes['order'] = new Nodes\Order\Order($this); + $this->nodes['payment'] = new Nodes\Payment\Payment($this); } public function __get(string $name) diff --git a/src/Nodes/Order/Order.php b/src/Nodes/Order/Order.php index d5232cb..7c38d18 100644 --- a/src/Nodes/Order/Order.php +++ b/src/Nodes/Order/Order.php @@ -2,45 +2,15 @@ namespace Shopee\Nodes\Order; -use Shopee\Nodes\NodeAbstract; +use Shopee\ClientV2; +use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Order extends NodeAbstract +class Order extends NodeAbstractV2 { - /** - * Use this call to retrieve detailed escrow information about one order based on OrderID. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getEscrowDetails($parameters = []): ResponseData - { - return $this->post('/api/v1/orders/my_income', $parameters); - } - /** - * Use this api to get orders' release time and escrow amount. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getEscrowReleasedOrders($parameters = []): ResponseData - { - return $this->post('/api/v1/orders/get_escrow_detail', $parameters); - } - - /** - * Use this call to retrieve detailed information of all the fulfill orders(forder) under a single regular order - * based on ordersn. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getForderInfo($parameters = []): ResponseData - { - return $this->post('/api/v1/orders/forder/get', $parameters); - } + const RESPONSE_FULL_FIELD = "buyer_user_id,buyer_username,estimated_shipping_fee,recipient_address,actual_shipping_fee ,goods_to_declare,note,note_update_time,item_list,pay_time,dropshipper,credit_card_number ,dropshipper_phone,split_up,buyer_cancel_reason,cancel_by,cancel_reason,actual_shipping_fee_confirmed,buyer_cpf_id,fulfillment_flag,pickup_done_time,package_list,shipping_carrier,payment_method,total_amount,buyer_username,invoice_data"; /** * Use this call to retrieve detailed information about one or more orders based on OrderIDs. @@ -50,19 +20,9 @@ public function getForderInfo($parameters = []): ResponseData */ public function getOrderDetails($parameters = []): ResponseData { - return $this->post('/api/v1/orders/detail', $parameters); + return $this->get('/api/v2/order/get_order_detail', ClientV2::API_TYPE_SHOP, $parameters); } - /** - * GetOrdersByStatus is the recommended call to use for order management. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getOrdersByStatus($parameters = []): ResponseData - { - return $this->post('/api/v1/orders/get', $parameters); - } /** * GetOrdersList is the recommended call to use for order management. @@ -72,7 +32,7 @@ public function getOrdersByStatus($parameters = []): ResponseData */ public function getOrdersList($parameters = []): ResponseData { - return $this->post('/api/v1/orders/basics', $parameters); + return $this->get('/api/v2/order/get_order_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -81,9 +41,9 @@ public function getOrdersList($parameters = []): ResponseData * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function acceptBuyerCancellation($parameters = []): ResponseData + public function handleBuyerCancellation($parameters = []): ResponseData { - return $this->post('/api/v1/orders/buyer_cancellation/accept', $parameters); + return $this->post('/api/v2/order/handle_buyer_cancellation', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -92,9 +52,9 @@ public function acceptBuyerCancellation($parameters = []): ResponseData * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function addOrderNote($parameters = []): ResponseData + public function setOrderNote($parameters = []): ResponseData { - return $this->post('/api/v1/orders/note/add', $parameters); + return $this->post('/api/v2/order/set_note', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -105,29 +65,30 @@ public function addOrderNote($parameters = []): ResponseData */ public function cancelOrder($parameters = []): ResponseData { - return $this->post('/api/v1/orders/cancel', $parameters); + return $this->post('/api/v2/order/cancel_order', ClientV2::API_TYPE_SHOP, $parameters); } + /** - * Use this call to reject buyer cancellation. + * Use this API to split order into fulfillment orders. * * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function rejectBuyerCancellation($parameters = []): ResponseData + public function splitOrder($parameters = []): ResponseData { - return $this->post('/api/v1/orders/buyer_cancellation/reject', $parameters); + return $this->post('/api/v2/order/split_order', ClientV2::API_TYPE_SHOP, $parameters); } /** - * Use this API to split order into fulfillment orders. + * Use this API to cancel split order from the seller side. * * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function splitOrder($parameters = []): ResponseData + public function undoSplitOrder($parameters = []): ResponseData { - return $this->post('/api/v1/orders/split', $parameters); + return $this->post('/api/v2/order/unsplit_order', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -136,8 +97,8 @@ public function splitOrder($parameters = []): ResponseData * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function undoSplitOrder($parameters = []): ResponseData + public function addInvoiceData($parameters = []): ResponseData { - return $this->post('/api/v1/orders/unsplit', $parameters); + return $this->post('/api/v2/order/add_invoice_data', ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/Order/Parameters/AddInvoiceData.php b/src/Nodes/Order/Parameters/AddInvoiceData.php new file mode 100644 index 0000000..0ab0ce0 --- /dev/null +++ b/src/Nodes/Order/Parameters/AddInvoiceData.php @@ -0,0 +1,41 @@ +parameters['order_sn']; + } + + /** + * @param string $order_sn + * @return $this + */ + public function setOrderSn(string $order_sn) + { + $this->parameters['order_sn'] = $order_sn; + + return $this; + } + + public function getInvoiceData(): InvoiceData + { + return $this->parameters['invoice_data']; + } + + /** + * @param InvoiceData $invoice_data + * @return $this + */ + public function setInvoiceData($invoice_data) + { + $this->parameters['invoice_data'] = $invoice_data; + + return $this; + } + +} diff --git a/src/Nodes/Order/Parameters/GetOrdersList.php b/src/Nodes/Order/Parameters/GetOrdersList.php new file mode 100644 index 0000000..27be72e --- /dev/null +++ b/src/Nodes/Order/Parameters/GetOrdersList.php @@ -0,0 +1,132 @@ + self::TIME_RANGE_FIELD_CREATE, + 'time_from' => 0, + 'time_to' => 0, + 'page_size' => 100, + 'cursor' => "" + ]; + + public function getTimeRangeField(): string + { + return $this->parameters['time_range_field']; + } + + /** + * @param string $time_range_field + * @return $this + */ + public function setTimeRangeField(string $time_range_field) + { + $this->parameters['time_range_field'] = $time_range_field; + + return $this; + } + + public function getCursor(): int + { + return $this->parameters['cursor']; + } + + /** + * + * @param int $cursor + * @return $this + */ + public function setCursor(int $cursor) + { + $this->parameters['cursor'] = $cursor; + + return $this; + } + + public function getOrderStatus(): string + { + return $this->parameters['order_status']; + } + + /** + * + * @param string $status + * @return $this + */ + public function setOrderStatus(string $status) + { + $this->parameters['order_status'] = $status; + + return $this; + } + + public function getPaginationEntriesPerPage(): int + { + return $this->parameters['page_size']; + } + + /** + * If many items are available to retrieve, you may need to call GetItemsList multiple times to retrieve all the + * data. Each result set is returned as a page of entries. Use the Pagination filters to control the maximum number + * of entries (<= 100) to retrieve per page (i.e., per call), the offset number to start next call. + * This integer value is usUed to specify the maximum number of entries to return in a single ""page"" of data. + * + * @param int $perPage uint32 + * @return $this + */ + public function setPaginationEntriesPerPage(int $perPage = 100) + { + $this->parameters['page_size'] = $perPage; + + return $this; + } + + public function getTimeFrom(): ?int + { + return $this->parameters['time_from']; + } + + /** + * The update_time_from and update_time_to fields specify a date range for retrieving orders (based on the item + * update time). The update_time_from field is the starting date range. The maximum date range that may be specified + * with the update_time_from and update_time_to fields is 15 days. + * + * @param int $timestamp + * @return $this + */ + public function setTimeFrom(int $timestamp) + { + $this->parameters['time_from'] = $timestamp; + + return $this; + } + + public function getTimeTo(): ?int + { + return $this->parameters['time_to']; + } + + /** + * The update_time_from and update_time_to fields specify a date range for retrieving orders (based on the item + * update time). The update_time_to field is the ending date range. The maximum date range that may be specified + * with the update_time_from and update_time_to fields is 15 days. + * + * @param int $timestamp + * @return $this + */ + public function setTimeTo(int $timestamp) + { + $this->parameters['time_to'] = $timestamp; + + return $this; + } + +} diff --git a/src/Nodes/Order/Parameters/InvoiceData.php b/src/Nodes/Order/Parameters/InvoiceData.php new file mode 100644 index 0000000..35d40f2 --- /dev/null +++ b/src/Nodes/Order/Parameters/InvoiceData.php @@ -0,0 +1,119 @@ +parameters['number']; + } + + /** + * @param string $number + * @return $this + */ + public function setNumber(string $number) + { + $this->parameters['number'] = $number; + + return $this; + } + + public function getSeriesNumber(): string + { + return $this->parameters['series_number']; + } + + /** + * @param string $series_number + * @return $this + */ + public function setSeriesNumber($series_number) + { + $this->parameters['series_number'] = $series_number; + + return $this; + } + + public function getAccessKey(): string + { + return $this->parameters['access_key']; + } + + /** + * @param string $access_key + * @return $this + */ + public function setAccessKey($access_key) + { + $this->parameters['access_key'] = $access_key; + + return $this; + } + + public function getIssueDate(): int + { + return $this->parameters['issue_date']; + } + + /** + * @param int $issue_date + * @return $this + */ + public function setIssueDate($issue_date) + { + $this->parameters['issue_date'] = $issue_date; + + return $this; + } + + public function getTotalValue(): float + { + return $this->parameters['total_value']; + } + + /** + * @param float $total_value + * @return $this + */ + public function setTotalValue($total_value) + { + $this->parameters['total_value'] = $total_value; + + return $this; + } + + public function getProductsTotalValue(): float + { + return $this->parameters['products_total_value']; + } + + /** + * @param float $total_value + * @return $this + */ + public function setProductsTotalValue($total_value) + { + $this->parameters['products_total_value'] = $total_value; + + return $this; + } + public function getTaxCode(): string + { + return $this->parameters['tax_code']; + } + + /** + * @param string $tax_code + * @return $this + */ + public function setTaxCode($tax_code) + { + $this->parameters['tax_code'] = $tax_code; + + return $this; + } +} diff --git a/src/Nodes/Payment/Payment.php b/src/Nodes/Payment/Payment.php index 6d7c379..137721d 100644 --- a/src/Nodes/Payment/Payment.php +++ b/src/Nodes/Payment/Payment.php @@ -2,19 +2,21 @@ namespace Shopee\Nodes\Payment; +use Shopee\ClientV2; use Shopee\Nodes\NodeAbstract; +use Shopee\Nodes\NodeAbstractV2; use Shopee\ResponseData; -class Payment extends NodeAbstract +class Payment extends NodeAbstractV2 { /** * Use this API to get the transaction records of wallet. * @param array $parameters * @return ResponseData */ - public function getTransactionList($parameters = []): ResponseData + public function getWalletTransactionList($parameters = []): ResponseData { - return $this->post('/api/v1/wallet/transaction/list', $parameters); + return $this->get('/api/v2/payment/get_wallet_transaction_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -24,6 +26,15 @@ public function getTransactionList($parameters = []): ResponseData */ public function getPayoutDetail($parameters = []): ResponseData { - return $this->post('/api/v1/payment/get_payout_details', $parameters); + return $this->post('/api/v2/payment/get_payout_detail', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * @param array $parameters + * @return ResponseData + */ + public function getEscrowDetail($parameters = []): ResponseData + { + return $this->get('/api/v2/payment/get_escrow_detail', ClientV2::API_TYPE_SHOP, $parameters); } } From 6cd9198d04aa5351d94028ca1989bb7c1a9513af Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Sun, 27 Feb 2022 11:39:20 +0700 Subject: [PATCH 25/89] [UPBASE-966] changed: add module upload video --- src/ClientV2.php | 69 ++++++++++++++++++++++++++++++++++-- src/Nodes/NodeAbstractV2.php | 52 +++++++++++++++++++++++++++ src/Nodes/Video/Video.php | 69 ++++++++++++++++++++++++++++++++++++ src/ResponseData.php | 4 +++ 4 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 src/Nodes/Video/Video.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 56d0ba3..634c4e2 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -2,6 +2,7 @@ namespace Shopee; +use function _PHPStan_76800bfb5\RingCentral\Psr7\stream_for; use GuzzleHttp\Client as HttpClient; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ClientException as GuzzleClientException; @@ -36,13 +37,14 @@ * @property Nodes\Item\Attribute $attribute * @property Nodes\Item\Item $item * @property Nodes\Image\Image $image + * @property Nodes\Video\Video $video * @property Nodes\Logistics\Logistics $logistic * @property Nodes\Order\Order $order * @property Nodes\Payment\Payment $payment */ class ClientV2 { - public const VERSION = '2'; + const VERSION = '2'; const API_TYPE_PUBLIC = 1; const API_TYPE_SHOP = 2; @@ -141,6 +143,7 @@ public function __construct(array $config = []) $this->nodes['logistic'] = new Nodes\Logistics\Logistics($this); $this->nodes['order'] = new Nodes\Order\Order($this); $this->nodes['payment'] = new Nodes\Payment\Payment($this); + $this->nodes['video'] = new Nodes\Video\Video($this); } public function __get(string $name) @@ -316,6 +319,68 @@ public function upload(RequestInterface $request, $file_url): ResponseInterface return $response; } + public function uploadVideoPart(RequestInterface $request, $video_upload_id, $file_name, $chunk, $part_seq): ResponseInterface + { + try { + $part_md5 = md5($chunk); + $boundary = '----iCEBrkUploaderBoundary' . uniqid(); + $response = $this->httpClient->request( + "POST", + $request->getUri(), + [ + 'headers' => [ + 'Transfer-Encoding' => 'chunked', + 'Accept-Encoding' => 'gzip, deflate, br', + 'Accept' => 'application/json, text/javascript, */*; q=0.01', + 'Content-disposition' => 'attachment; filename="' . $file_name . '"', + 'Content-length' => strlen($chunk)-1, + ], + 'multipart' => [ + [ + 'name' => 'video_upload_id', + 'contents' => $video_upload_id, + ], + [ + 'name' => 'part_seq', + 'contents' => $part_seq, + ], + [ + 'name' => 'content_md5', + 'contents' => $part_md5, + ], + [ + 'name' => 'part_content', + 'contents' => $chunk, + 'filename' => $file_name, + 'headers' => [ + 'Content-Type' => 'multipart/form-data; boundary=' . $boundary + ] + ] + ] + ]); + + } catch (GuzzleClientException $exception) { + switch ($exception->getCode()) { + case 400: + $className = BadRequestException::class; + break; + case 403: + $className = AuthException::class; + break; + default: + $className = ClientException::class; + } + + throw Factory::create($className, $exception); + } catch (GuzzleServerException $exception) { + throw Factory::create(ServerException::class, $exception); + } catch (GuzzleException $exception) { + throw Factory::create(ServerException::class, $exception); + } + + return $response; + } + public function send(RequestInterface $request): ResponseInterface { try { @@ -358,7 +423,7 @@ public function getAuthorizationUrl($redirect_url) return $uri->__toString(); } - private function downloadFile($urlDownload) + public function downloadFile($urlDownload) { $path_info = pathinfo($urlDownload); $filename = $path_info['basename']; diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index 858daa8..6439608 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -2,8 +2,10 @@ namespace Shopee\Nodes; +use Exception; use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Util\Json; use Psr\Http\Message\UriInterface; use Shopee\Client; use Shopee\ClientV2; @@ -72,4 +74,54 @@ public function upload($uri, $type_api, $file_url) $response = $this->client->upload($request, $file_url); return new ResponseData($response); } + + /** + * @param $video_upload_id + * @param $file_url + * @param $file_name + * @return ResponseData + * @throws Exception + */ + public function uploadVideoParts($video_upload_id, $file_url, $file_name){ + $fh = fopen($file_url, 'r'); + $chunkSize = 4194304; # 4MB + $response = []; + $parts = []; + $serial = 0; + while (! feof($fh)) { + $parts[] = $serial; + $chunk = fread($fh, $chunkSize); + $request = $this->client->newRequest("/api/v2/media_space/upload_video_part", ClientV2::API_TYPE_SHOP, []); + $response = $this->client->uploadVideoPart($request, $video_upload_id, $file_name, $chunk, $serial); + $this->parseResponseData(new ResponseData($response)); + $serial ++; + } + $response_data_video = new ResponseData($response); + $response_data_video->addData('part_seq_list', $parts); + return $response_data_video; + } + + public function downloadFile($urlDownload) + { + $path_info = pathinfo($urlDownload); + $filename = $path_info['basename']; + $tempImage = tempnam(sys_get_temp_dir(), $filename); + copy($urlDownload, $tempImage); + return [$tempImage, $filename]; + } + + /** + * @param $response ResponseData + * @return mixed + * @throws Exception + */ + private function parseResponseData($response){ + $response_data = $response->getData(); + if(!empty($response_data['error'])){ + $message = $response_data['error'] . ": " . $response_data['message']; + throw new Exception($message); + } + return $response_data; + } + } diff --git a/src/Nodes/Video/Video.php b/src/Nodes/Video/Video.php new file mode 100644 index 0000000..05cbeba --- /dev/null +++ b/src/Nodes/Video/Video.php @@ -0,0 +1,69 @@ +downloadFile($file_url); + $file_size = filesize($tempVideoDownload); + $file_md5 = md5_file($tempVideoDownload); + + #Init video upload + $response_init = $this->post('/api/v2/media_space/init_video_upload', + ClientV2::API_TYPE_SHOP, + [ + 'file_md5' => $file_md5, + 'file_size' => $file_size + ] + ); + $response_data = $response_init->getData(); + if (!empty($response_data['error'])) { + $message = $response_data['error'] . ": " . $response_data['message']; + throw new Exception($message); + } + + #Upload Video Part + $start = microtime(true); + $video_upload_id = $response_data['response']['video_upload_id']; + $response_video = $this->uploadVideoParts($video_upload_id, $tempVideoDownload, $fileName); + $time_elapsed_secs = intval(microtime(true) - $start); + + #Complete Video Upload + $response_complete_data = $this->post('/api/v2/media_space/complete_video_upload', ClientV2::API_TYPE_PUBLIC, [ + 'video_upload_id' => $video_upload_id, + 'part_seq_list' => $response_video->getData()['part_seq_list'], + 'report_data' => [ + 'upload_cost' => $time_elapsed_secs + ] + ]); + + $response_complete_data->addData('video_upload_id', $video_upload_id); + return $response_complete_data; + } + + /** + * Use this call to add a product item. + * + * @param array $parameters + * @return ResponseData + */ + public function getVideoUploadResult($parameters = []): ResponseData + { + return $this->get('/api/v2/media_space/get_video_upload_result', ClientV2::API_TYPE_SHOP, $parameters); + } + +} diff --git a/src/ResponseData.php b/src/ResponseData.php index 7cdd480..2548d36 100644 --- a/src/ResponseData.php +++ b/src/ResponseData.php @@ -32,4 +32,8 @@ public function getData(): array { return $this->data; } + + public function addData($key, $value){ + $this->data[$key] = $value; + } } From 98f9f413d2c4a9686e12748fcc4414b6590e093f Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Tue, 1 Mar 2022 07:08:06 +0700 Subject: [PATCH 26/89] add support chart --- src/Nodes/Item/Category.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php index 4158df6..45c3554 100755 --- a/src/Nodes/Item/Category.php +++ b/src/Nodes/Item/Category.php @@ -28,4 +28,14 @@ public function getListCategory($parameters = []): ResponseData { public function getCategoryRecommend($parameters = []): ResponseData { return $this->get("/api/v2/product/category_recommend", ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.product.support_size_chart?module=89&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function checkSupportChart($parameters = []): ResponseData { + return $this->get("/api/v2/product/support_size_chart", ClientV2::API_TYPE_SHOP, $parameters); + } } From 36771bae84d1421a01dcb1f3f84d0d625181e3b3 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 1 Mar 2022 22:44:14 +0700 Subject: [PATCH 27/89] changed: add update video_upload_id --- src/Nodes/Item/Parameters/Add.php | 18 ++++++++++++++++++ src/Nodes/Item/Parameters/UpdateItem.php | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index f21c475..04e31a5 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -258,4 +258,22 @@ public function setBrand(Brand $brand) return $this; } + + public function geVideoUploadId(): string + { + return $this->parameters['video_upload_id']; + } + + /** + * Name of the item in local language. + * + * @param string $name + * @return $this + */ + public function setVideoUploadId(string $name) + { + $this->parameters['video_upload_id'] = $name; + + return $this; + } } diff --git a/src/Nodes/Item/Parameters/UpdateItem.php b/src/Nodes/Item/Parameters/UpdateItem.php index e2b766a..b132d16 100644 --- a/src/Nodes/Item/Parameters/UpdateItem.php +++ b/src/Nodes/Item/Parameters/UpdateItem.php @@ -224,4 +224,22 @@ public function setBrand(Brand $brand) return $this; } + + public function geVideoUploadId(): string + { + return $this->parameters['video_upload_id']; + } + + /** + * Name of the item in local language. + * + * @param string $name + * @return $this + */ + public function setVideoUploadId(string $name) + { + $this->parameters['video_upload_id'] = $name; + + return $this; + } } From f27defe4a3e356bfcfdc6a3a19ae4f6fc3141ba7 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 1 Mar 2022 23:52:06 +0700 Subject: [PATCH 28/89] changed: fix set parameter video_upload_id --- src/Nodes/Item/Parameters/Add.php | 2 +- src/Nodes/Item/Parameters/UpdateItem.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 04e31a5..49dd8b3 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -272,7 +272,7 @@ public function geVideoUploadId(): string */ public function setVideoUploadId(string $name) { - $this->parameters['video_upload_id'] = $name; + $this->parameters['video_upload_id'] = [$name]; return $this; } diff --git a/src/Nodes/Item/Parameters/UpdateItem.php b/src/Nodes/Item/Parameters/UpdateItem.php index b132d16..64cb0d1 100644 --- a/src/Nodes/Item/Parameters/UpdateItem.php +++ b/src/Nodes/Item/Parameters/UpdateItem.php @@ -238,7 +238,7 @@ public function geVideoUploadId(): string */ public function setVideoUploadId(string $name) { - $this->parameters['video_upload_id'] = $name; + $this->parameters['video_upload_id'] = [$name]; return $this; } From c1b37be53b9ca6f707ba0a9f1d5e082083d81205 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Fri, 4 Mar 2022 23:21:33 +0700 Subject: [PATCH 29/89] update size chart --- src/Nodes/Item/Item.php | 11 ++++++++ src/Nodes/Item/Parameters/UpdateSizeChart.php | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/Nodes/Item/Parameters/UpdateSizeChart.php diff --git a/src/Nodes/Item/Item.php b/src/Nodes/Item/Item.php index f4beaf3..6a416c3 100644 --- a/src/Nodes/Item/Item.php +++ b/src/Nodes/Item/Item.php @@ -277,4 +277,15 @@ public function removeModel($parameters = []): ResponseData { return $this->post('/api/v2/product/delete_model', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * Update size chart image of item. + * https://open.shopee.com/documents/v2/v2.product.update_size_chart?module=89&type=1 + * @param array|Parameters\UpdateSizeChart $parameters + * @return ResponseData + */ + public function updateSizeChart($parameters = []): ResponseData + { + return $this->post('/api/v2/product/update_size_chart', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Item/Parameters/UpdateSizeChart.php b/src/Nodes/Item/Parameters/UpdateSizeChart.php new file mode 100644 index 0000000..fc9e0e2 --- /dev/null +++ b/src/Nodes/Item/Parameters/UpdateSizeChart.php @@ -0,0 +1,28 @@ +parameters['size_chart']; + } + + /** + * size chart image id + * + * @param string size_chart_id + * @return $this + */ + public function setSizeChart(string $size_chart_id) + { + $this->parameters['size_chart'] = $size_chart_id; + + return $this; + } +} From cdc165dd22080d65a9596a15058246497b850277 Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Sat, 5 Mar 2022 10:53:14 +0700 Subject: [PATCH 30/89] update size chart --- src/Nodes/Item/Parameters/UpdateSizeChart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Item/Parameters/UpdateSizeChart.php b/src/Nodes/Item/Parameters/UpdateSizeChart.php index fc9e0e2..57d54c3 100644 --- a/src/Nodes/Item/Parameters/UpdateSizeChart.php +++ b/src/Nodes/Item/Parameters/UpdateSizeChart.php @@ -8,7 +8,7 @@ class UpdateSizeChart extends RequestParameters { use ItemTrait; - public function getSizeChart(): int + public function getSizeChart(): string { return $this->parameters['size_chart']; } From c169fbf8de8f8df78c8d74c600598091210a7001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sat, 28 May 2022 09:23:48 +0700 Subject: [PATCH 31/89] add product params --- src/Nodes/Item/Parameters/Add.php | 18 ++++++++++++++++++ src/RequestParameters.php | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 49dd8b3..58315fc 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -276,4 +276,22 @@ public function setVideoUploadId(string $name) return $this; } + public function getDescriptionType(): string + { + return $this->parameters['description_type']; + } + + /** + * Name of the item in description_type + * + * @param string $description_type + * @return $this + */ + public function setDescriptionType(string $description_type) + { + $this->parameters['description_type'] = $description_type; + + return $this; + } + } diff --git a/src/RequestParameters.php b/src/RequestParameters.php index b3bf654..355df0f 100644 --- a/src/RequestParameters.php +++ b/src/RequestParameters.php @@ -80,4 +80,12 @@ public function toArray(): array return $value; }, $this->parameters); } + + public function setParameter(string $param_name, $param_value) + { + $this->parameters[$param_name] = $param_value; + + return $this; + } + } From d3c082f9c964aef36e9e8b2989a2c632aa672077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 1 Jun 2022 16:30:54 +0700 Subject: [PATCH 32/89] update load product shopee param --- src/Nodes/Item/Parameters/GetItemsList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Item/Parameters/GetItemsList.php b/src/Nodes/Item/Parameters/GetItemsList.php index 00b3302..dfb16e7 100644 --- a/src/Nodes/Item/Parameters/GetItemsList.php +++ b/src/Nodes/Item/Parameters/GetItemsList.php @@ -17,7 +17,7 @@ class GetItemsList extends RequestParameters 'item_status' => self::NORMAL ]; - public function getItemStatus(): int + public function getItemStatus(): string { return $this->parameters['item_status']; } @@ -26,7 +26,7 @@ public function getItemStatus(): int * @param int $status * @return $this */ - public function setItemStatus(int $status) + public function setItemStatus(string $status) { $this->parameters['item_status'] = $status; From 7249a8f1b09b8fc7e2c0c31183ba0061a4b17b21 Mon Sep 17 00:00:00 2001 From: Quang Le Date: Thu, 9 Jun 2022 16:04:51 +0700 Subject: [PATCH 33/89] returns v2 --- .../Parameters/GetReturnOrdersList.php | 38 ++++++++++++++++++ src/Nodes/Returns/Returns.php | 40 +++---------------- 2 files changed, 43 insertions(+), 35 deletions(-) create mode 100755 src/Nodes/Returns/Parameters/GetReturnOrdersList.php mode change 100644 => 100755 src/Nodes/Returns/Returns.php diff --git a/src/Nodes/Returns/Parameters/GetReturnOrdersList.php b/src/Nodes/Returns/Parameters/GetReturnOrdersList.php new file mode 100755 index 0000000..45f7f92 --- /dev/null +++ b/src/Nodes/Returns/Parameters/GetReturnOrdersList.php @@ -0,0 +1,38 @@ + 0, + 'page_size' => 40, + ]; + + /** + * @param int $page_no + * @return $this + */ + + public function setPageNo(int $page_no) + { + $this->parameters['page_no'] = $page_no; + return $this; + } + + /** + * @param int $page_no + * @return $this + */ + + public function setPaginationEntriesPerPage(int $perPage = 100) + { + $this->parameters['page_size'] = $perPage; + + return $this; + } + +} diff --git a/src/Nodes/Returns/Returns.php b/src/Nodes/Returns/Returns.php old mode 100644 new mode 100755 index 3c71287..c2850ac --- a/src/Nodes/Returns/Returns.php +++ b/src/Nodes/Returns/Returns.php @@ -2,33 +2,14 @@ namespace Shopee\Nodes\Returns; -use Shopee\Nodes\NodeAbstract; +use Illuminate\Support\Facades\Log; +use Shopee\ClientV2; +use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Returns extends NodeAbstract +class Returns extends NodeAbstractV2 { - /** - * Confirm return. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function confirmReturn($parameters = []): ResponseData - { - return $this->post('/api/v1/returns/confirm', $parameters); - } - - /** - * Dispute return. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function disputeReturn($parameters = []): ResponseData - { - return $this->post('/api/v1/returns/dispute', $parameters); - } /** * Get return list. @@ -38,17 +19,6 @@ public function disputeReturn($parameters = []): ResponseData */ public function getReturnList($parameters = []): ResponseData { - return $this->post('/api/v1/returns/get', $parameters); - } - - /** - * Use this api to get detail information of a returned order. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getReturnDetail($parameters = []): ResponseData - { - return $this->post('/api/v1/returns/detail', $parameters); + return $this->get('/api/v2/returns/get_return_list', ClientV2::API_TYPE_SHOP, $parameters); } } From e466d65b11a7474b11891f38055d650309e89481 Mon Sep 17 00:00:00 2001 From: Quang Le Date: Fri, 10 Jun 2022 10:35:26 +0700 Subject: [PATCH 34/89] returns v2 --- src/ClientV2.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ClientV2.php b/src/ClientV2.php index 634c4e2..d47f031 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -41,6 +41,7 @@ * @property Nodes\Logistics\Logistics $logistic * @property Nodes\Order\Order $order * @property Nodes\Payment\Payment $payment + * @property Nodes\Returns\Returns $returns */ class ClientV2 { @@ -144,6 +145,7 @@ public function __construct(array $config = []) $this->nodes['order'] = new Nodes\Order\Order($this); $this->nodes['payment'] = new Nodes\Payment\Payment($this); $this->nodes['video'] = new Nodes\Video\Video($this); + $this->nodes['returns'] = new Nodes\Returns\Returns($this); } public function __get(string $name) From b13e173cd0a08ab85f57f314ab6b4c1800a155c1 Mon Sep 17 00:00:00 2001 From: Quang Le Date: Mon, 13 Jun 2022 11:22:55 +0700 Subject: [PATCH 35/89] logistics v2 --- src/Nodes/Logistics/Logistics.php | 161 +----------------- .../Parameters/GetTrackingNumber.php | 25 +++ 2 files changed, 29 insertions(+), 157 deletions(-) create mode 100755 src/Nodes/Logistics/Parameters/GetTrackingNumber.php diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 4cbe2b4..b409683 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -2,6 +2,7 @@ namespace Shopee\Nodes\Logistics; +use Illuminate\Support\Facades\Log; use Shopee\ClientV2; use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; @@ -9,169 +10,15 @@ class Logistics extends NodeAbstractV2 { - /** - * Use this call to get all required param for init logistic. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getAddress($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/address/get', $parameters); - } - - /** - * Use this API to get airway bill for orders. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getAirwayBill($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/airway_bill/get_mass', $parameters); - } - - /** - * Use this call to get all required param for init logistic. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getBranch($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/branch/get', $parameters); - } - - /** - * Use this API to get airwaybill for fulfillment orders. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getForderWaybill($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/forder_waybill/get_mass', $parameters); - } - - /** - * Use this call to get all supported Logistic Channel. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getLogistics($parameters = []): ResponseData - { - return $this->get("/api/v2/logistics/get_channel_list", ClientV2::API_TYPE_SHOP, $parameters); - - } - - /** - * Get all the logistics info of an order to Init. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getLogisticInfo($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/init_info/get', $parameters); - } - - /** - * Use this call to get the logistics tracking information of an order. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getLogisticsMessage($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/tracking', $parameters); - } /** - * Use this call to fetch the logistics information of an order, these info can be used for waybill printing. + * Get return list. * * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function getOrderLogistics($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/order/get', $parameters); - } - - /** - * Use this call to get all required param for init logistic. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getParameterForInit($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/init_parameter/get', $parameters); - } - - /** - * Use this call to get all required param for init logistic. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getTimeSlot($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/timeslot/get', $parameters); - } - - /** - * Use this API to get tracking number of orders. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getTrackingNo($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/tracking_number/get_mass', $parameters); - } - - /** - * Use this call to arrange Pickup, Dropoff or shipment for non-integrated logistic channels. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function init($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/init', $parameters); - } - - /** - * Set Logistic Status to PICKUP_DONE, this API only works for non-integrated logistic channels. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function setLogisticStatus($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/offline/set', $parameters); - } - - /** - * Use this call to set tracking number for each order in batch. - * - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function setTrackingNo($parameters = []): ResponseData - { - return $this->post('/api/v1/logistics/tracking_number/set_mass', $parameters); - } - - /** - * Configure shop level logistics. - * - * @param array|RequestParametersInterface $parameters $parameters - * @return ResponseData - */ - public function updateShopLogistics($parameters = []): ResponseData + public function getTrackingNumber($parameters = []): ResponseData { - return $this->post('/api/v1/logistics/channels/update', $parameters); + return $this->get('/api/v2/logistics/get_tracking_number', ClientV2::API_TYPE_SHOP, $parameters); } } diff --git a/src/Nodes/Logistics/Parameters/GetTrackingNumber.php b/src/Nodes/Logistics/Parameters/GetTrackingNumber.php new file mode 100755 index 0000000..afa6b26 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/GetTrackingNumber.php @@ -0,0 +1,25 @@ + 0, + ]; + + /** + * @param string $order_sn + * @return $this + */ + + public function setOrderSn(string $order_sn) + { + $this->parameters['order_sn'] = $order_sn; + return $this; + } + +} From e089ae22577aba15e9f76f9c17a5fa50ae2e7f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 20 Sep 2022 13:57:43 +0700 Subject: [PATCH 36/89] update seller_stock --- src/Nodes/Item/Parameters/Add.php | 10 ++--- src/Nodes/Item/Parameters/SellerStock.php | 40 +++++++++++++++++++ .../Item/Parameters/UpdateVariationStock.php | 8 ++-- src/Nodes/Item/Parameters/Variation.php | 10 ++--- 4 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 src/Nodes/Item/Parameters/SellerStock.php diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 58315fc..4df1c3f 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -62,20 +62,20 @@ public function setPrice(float $price) return $this; } - public function getStock(): int + public function getStock(): SellerStock { - return $this->parameters['normal_stock']; + return $this->parameters['seller_stock']; } /** * The current stock quantity of the item. * - * @param int $stock + * @param SellerStock $stock * @return $this */ - public function setStock(int $stock) + public function setStock(SellerStock $stock) { - $this->parameters['normal_stock'] = $stock; + $this->parameters['seller_stock'] = $stock; return $this; } diff --git a/src/Nodes/Item/Parameters/SellerStock.php b/src/Nodes/Item/Parameters/SellerStock.php new file mode 100644 index 0000000..f25a7a5 --- /dev/null +++ b/src/Nodes/Item/Parameters/SellerStock.php @@ -0,0 +1,40 @@ +parameters['stock']; + } + + /** + * @param int $stock + * @return $this + */ + public function setStock(int $stock) + { + $this->parameters['stock'] = $stock; + + return $this; + } + + public function getLocationId(): string + { + return $this->parameters['location_id']; + } + + /** + * @param string $location_id + * @return $this + */ + public function setLocationId(string $location_id) + { + $this->parameters['location_id'] = $location_id; + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationStock.php b/src/Nodes/Item/Parameters/UpdateVariationStock.php index 70d08cb..ecf0be3 100644 --- a/src/Nodes/Item/Parameters/UpdateVariationStock.php +++ b/src/Nodes/Item/Parameters/UpdateVariationStock.php @@ -8,16 +8,16 @@ class UpdateVariationStock extends UpdateStock public function getVariationStock() { - return $this->parameters['normal_stock']; + return $this->parameters['seller_stock']; } /** - * @param int $stock + * @param SellerStock $stock * @return $this */ - public function setVariationStock(int $stock) + public function setVariationStock(SellerStock $stock) { - $this->parameters['normal_stock'] = $stock; + $this->parameters['seller_stock'] = $stock; return $this; } diff --git a/src/Nodes/Item/Parameters/Variation.php b/src/Nodes/Item/Parameters/Variation.php index 7ef4d5f..2524183 100644 --- a/src/Nodes/Item/Parameters/Variation.php +++ b/src/Nodes/Item/Parameters/Variation.php @@ -23,20 +23,20 @@ public function setTierIndex(array $index_list) return $this; } - public function getStock(): int + public function getStock(): SellerStock { - return $this->parameters['normal_stock']; + return $this->parameters['seller_stock']; } /** * The current stock quantity of the variation in the listing currency. * - * @param int $stock + * @param SellerStock $stock * @return $this */ - public function setStock(int $stock) + public function setStock(SellerStock $stock) { - $this->parameters['normal_stock'] = $stock; + $this->parameters['seller_stock'] = $stock; return $this; } From 644e898ae1c3211b308dc6518a1e46936f7f89a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 20 Sep 2022 14:21:52 +0700 Subject: [PATCH 37/89] get logistic --- src/Nodes/Logistics/Logistics.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index b409683..8a77579 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -11,6 +11,17 @@ class Logistics extends NodeAbstractV2 { + /** + * Use this call to get all supported Logistic Channel. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getLogistics($parameters = []): ResponseData + { + return $this->get("/api/v2/logistics/get_channel_list", ClientV2::API_TYPE_SHOP, $parameters); + + } /** * Get return list. * From e19f84d4f02b3393bccdc9fe33034c5384920cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 20 Sep 2022 14:48:44 +0700 Subject: [PATCH 38/89] build SellerStocks --- src/Nodes/Item/Parameters/Add.php | 6 ++-- src/Nodes/Item/Parameters/SellerStocks.php | 34 +++++++++++++++++++ .../Item/Parameters/UpdateVariationStock.php | 4 +-- src/Nodes/Item/Parameters/Variation.php | 6 ++-- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 src/Nodes/Item/Parameters/SellerStocks.php diff --git a/src/Nodes/Item/Parameters/Add.php b/src/Nodes/Item/Parameters/Add.php index 4df1c3f..eea8f42 100644 --- a/src/Nodes/Item/Parameters/Add.php +++ b/src/Nodes/Item/Parameters/Add.php @@ -62,7 +62,7 @@ public function setPrice(float $price) return $this; } - public function getStock(): SellerStock + public function getStock(): SellerStocks { return $this->parameters['seller_stock']; } @@ -70,10 +70,10 @@ public function getStock(): SellerStock /** * The current stock quantity of the item. * - * @param SellerStock $stock + * @param SellerStocks $stock * @return $this */ - public function setStock(SellerStock $stock) + public function setStock(SellerStocks $stock) { $this->parameters['seller_stock'] = $stock; diff --git a/src/Nodes/Item/Parameters/SellerStocks.php b/src/Nodes/Item/Parameters/SellerStocks.php new file mode 100644 index 0000000..aa74cbd --- /dev/null +++ b/src/Nodes/Item/Parameters/SellerStocks.php @@ -0,0 +1,34 @@ +add(new SellerStock($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Item/Parameters/UpdateVariationStock.php b/src/Nodes/Item/Parameters/UpdateVariationStock.php index ecf0be3..4a2b788 100644 --- a/src/Nodes/Item/Parameters/UpdateVariationStock.php +++ b/src/Nodes/Item/Parameters/UpdateVariationStock.php @@ -12,10 +12,10 @@ public function getVariationStock() } /** - * @param SellerStock $stock + * @param SellerStocks $stock * @return $this */ - public function setVariationStock(SellerStock $stock) + public function setVariationStock(SellerStocks $stock) { $this->parameters['seller_stock'] = $stock; diff --git a/src/Nodes/Item/Parameters/Variation.php b/src/Nodes/Item/Parameters/Variation.php index 2524183..4077bf4 100644 --- a/src/Nodes/Item/Parameters/Variation.php +++ b/src/Nodes/Item/Parameters/Variation.php @@ -23,7 +23,7 @@ public function setTierIndex(array $index_list) return $this; } - public function getStock(): SellerStock + public function getStock(): SellerStocks { return $this->parameters['seller_stock']; } @@ -31,10 +31,10 @@ public function getStock(): SellerStock /** * The current stock quantity of the variation in the listing currency. * - * @param SellerStock $stock + * @param SellerStocks $stock * @return $this */ - public function setStock(SellerStock $stock) + public function setStock(SellerStocks $stock) { $this->parameters['seller_stock'] = $stock; From 86309707cd460b9a8e6d6c76069c7cdf3f7991e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sat, 24 Sep 2022 15:06:29 +0700 Subject: [PATCH 39/89] add discount api --- src/Nodes/Discount/Discount.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Nodes/Discount/Discount.php b/src/Nodes/Discount/Discount.php index 643bd8f..dc7a117 100644 --- a/src/Nodes/Discount/Discount.php +++ b/src/Nodes/Discount/Discount.php @@ -2,11 +2,12 @@ namespace Shopee\Nodes\Discount; -use Shopee\Nodes\NodeAbstract; +use Shopee\ClientV2; +use Shopee\Nodes\NodeAbstractV2; use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Discount extends NodeAbstract +class Discount extends NodeAbstractV2 { /** * Use this api to add shop discount activity. @@ -16,7 +17,7 @@ class Discount extends NodeAbstract */ public function addDiscount($parameters = []): ResponseData { - return $this->post('/api/v1/discount/add', $parameters); + return $this->post('/api/v2/discount/add_discount', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -27,7 +28,7 @@ public function addDiscount($parameters = []): ResponseData */ public function addDiscountItem($parameters = []): ResponseData { - return $this->post('/api/v1/discount/items/add', $parameters); + return $this->post('/api/v2/discount/add_discount_item', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -38,7 +39,7 @@ public function addDiscountItem($parameters = []): ResponseData */ public function deleteDiscount($parameters = []): ResponseData { - return $this->post('/api/v1/discount/delete', $parameters); + return $this->post('/api/v2/discount/delete_discount', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -49,7 +50,7 @@ public function deleteDiscount($parameters = []): ResponseData */ public function deleteDiscountItem($parameters = []): ResponseData { - return $this->post('/api/v1/discount/item/delete', $parameters); + return $this->post('/api/v2/discount/delete_discount_item', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -60,7 +61,7 @@ public function deleteDiscountItem($parameters = []): ResponseData */ public function getDiscountDetail($parameters = []): ResponseData { - return $this->post('/api/v1/discount/detail', $parameters); + return $this->post('/api/v2/discount/get_discount', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -71,7 +72,7 @@ public function getDiscountDetail($parameters = []): ResponseData */ public function getDiscountsList($parameters = []): ResponseData { - return $this->post('/api/v1/discounts/get', $parameters); + return $this->post('/api/v2/discount/get_discount_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -82,7 +83,7 @@ public function getDiscountsList($parameters = []): ResponseData */ public function updateDiscount($parameters = []): ResponseData { - return $this->post('/api/v1/discount/update', $parameters); + return $this->post('/api/v2/discount/update_discount', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -93,6 +94,6 @@ public function updateDiscount($parameters = []): ResponseData */ public function updateDiscountItems($parameters = []): ResponseData { - return $this->post('/api/v1/discount/items/update', $parameters); + return $this->post('/api/v2/discount/update_discount_item', ClientV2::API_TYPE_SHOP, $parameters); } } From ddb250e00e27044e5ca446850405932d72c3e5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sat, 24 Sep 2022 15:17:40 +0700 Subject: [PATCH 40/89] add discount to clientv2 --- src/ClientV2.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ClientV2.php b/src/ClientV2.php index d47f031..2a2628c 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -42,6 +42,7 @@ * @property Nodes\Order\Order $order * @property Nodes\Payment\Payment $payment * @property Nodes\Returns\Returns $returns + * @property Nodes\Discount\Discount $discount */ class ClientV2 { @@ -146,6 +147,7 @@ public function __construct(array $config = []) $this->nodes['payment'] = new Nodes\Payment\Payment($this); $this->nodes['video'] = new Nodes\Video\Video($this); $this->nodes['returns'] = new Nodes\Returns\Returns($this); + $this->nodes['discount'] = new Nodes\Discount\Discount($this); } public function __get(string $name) From 41be99e46f13e9b15c485026f20d789d62b7ec99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sat, 24 Sep 2022 16:23:43 +0700 Subject: [PATCH 41/89] add discount param --- src/Nodes/Discount/Parameters/AddDiscount.php | 59 +++++++++++++++ .../Discount/Parameters/UpdateDiscount.php | 73 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100755 src/Nodes/Discount/Parameters/AddDiscount.php create mode 100755 src/Nodes/Discount/Parameters/UpdateDiscount.php diff --git a/src/Nodes/Discount/Parameters/AddDiscount.php b/src/Nodes/Discount/Parameters/AddDiscount.php new file mode 100755 index 0000000..1f1aa81 --- /dev/null +++ b/src/Nodes/Discount/Parameters/AddDiscount.php @@ -0,0 +1,59 @@ +parameters['discount_name']; + } + + /** + * Name of the discount. + * + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['discount_name'] = $name; + + return $this; + } + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } +} diff --git a/src/Nodes/Discount/Parameters/UpdateDiscount.php b/src/Nodes/Discount/Parameters/UpdateDiscount.php new file mode 100755 index 0000000..9586949 --- /dev/null +++ b/src/Nodes/Discount/Parameters/UpdateDiscount.php @@ -0,0 +1,73 @@ +parameters['discount_id']; + } + + /** + * @param int $discount_id + * @return $this + */ + public function setDiscountId(int $discount_id) + { + $this->parameters['discount_id'] = $discount_id; + + return $this; + } + public function getName(): string + { + return $this->parameters['discount_name']; + } + + /** + * Name of the discount. + * + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['discount_name'] = $name; + + return $this; + } + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } +} From 5ba9c8833afc076b138bb78c893ff67cc3d45745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Fri, 30 Sep 2022 15:54:20 +0700 Subject: [PATCH 42/89] add shopee discount params --- .../Discount/Parameters/AddDiscountItems.php | 28 +++++++ .../Discount/Parameters/DiscountItem.php | 75 +++++++++++++++++++ .../Discount/Parameters/DiscountItemList.php | 34 +++++++++ .../Discount/Parameters/DiscountTrait.php | 23 ++++++ src/Nodes/Discount/Parameters/ItemModel.php | 45 +++++++++++ .../Discount/Parameters/ItemModelList.php | 34 +++++++++ .../Discount/Parameters/UpdateDiscount.php | 16 +--- 7 files changed, 240 insertions(+), 15 deletions(-) create mode 100755 src/Nodes/Discount/Parameters/AddDiscountItems.php create mode 100755 src/Nodes/Discount/Parameters/DiscountItem.php create mode 100755 src/Nodes/Discount/Parameters/DiscountItemList.php create mode 100644 src/Nodes/Discount/Parameters/DiscountTrait.php create mode 100755 src/Nodes/Discount/Parameters/ItemModel.php create mode 100755 src/Nodes/Discount/Parameters/ItemModelList.php diff --git a/src/Nodes/Discount/Parameters/AddDiscountItems.php b/src/Nodes/Discount/Parameters/AddDiscountItems.php new file mode 100755 index 0000000..9bb6b8c --- /dev/null +++ b/src/Nodes/Discount/Parameters/AddDiscountItems.php @@ -0,0 +1,28 @@ +parameters['item_list']; + } + + /** + * Name of the discount. + * + * @param DiscountItemList $discountItemList + * @return $this + */ + public function setItemList(DiscountItemList $discountItemList) + { + $this->parameters['item_list'] = $discountItemList; + + return $this; + } + +} diff --git a/src/Nodes/Discount/Parameters/DiscountItem.php b/src/Nodes/Discount/Parameters/DiscountItem.php new file mode 100755 index 0000000..48020ce --- /dev/null +++ b/src/Nodes/Discount/Parameters/DiscountItem.php @@ -0,0 +1,75 @@ +parameters['item_promotion_price']; + } + + /** + * Name of the discount. + * + * @param float $item_promotion_price + * @return $this + */ + public function setPromotionPrice(float $item_promotion_price) + { + $this->parameters['item_promotion_price'] = $item_promotion_price; + + return $this; + } + + public function getPurchaseLimit(): int + { + return $this->parameters['purchase_limit']; + } + + /** + * @param int $purchase_limit + * @return $this + */ + public function setPurchaseLimit(int $purchase_limit) + { + $this->parameters['purchase_limit'] = $purchase_limit; + return $this; + } + + public function getPromotionStock(): int + { + return $this->parameters['item_promotion_stock']; + } + + /** + * @param int $item_promotion_stock + * @return $this + */ + public function setPromotionStock(int $item_promotion_stock) + { + $this->parameters['item_promotion_stock'] = $item_promotion_stock; + + return $this; + } + + public function getModelList(): ItemModelList + { + return $this->parameters['model_list']; + } + + /** + * @param ItemModelList $item_model_list + * @return $this + */ + public function setModelList(ItemModelList $item_model_list) + { + $this->parameters['model_list'] = $item_model_list; + + return $this; + } +} diff --git a/src/Nodes/Discount/Parameters/DiscountItemList.php b/src/Nodes/Discount/Parameters/DiscountItemList.php new file mode 100755 index 0000000..b92addb --- /dev/null +++ b/src/Nodes/Discount/Parameters/DiscountItemList.php @@ -0,0 +1,34 @@ +add(new DiscountItem($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Discount/Parameters/DiscountTrait.php b/src/Nodes/Discount/Parameters/DiscountTrait.php new file mode 100644 index 0000000..e5b504f --- /dev/null +++ b/src/Nodes/Discount/Parameters/DiscountTrait.php @@ -0,0 +1,23 @@ +parameters['discount_id']; + } + + /** + * @param int $discount_id + * @return $this + */ + public function setDiscountId(int $discount_id) + { + $this->parameters['discount_id'] = $discount_id; + + return $this; + } +} diff --git a/src/Nodes/Discount/Parameters/ItemModel.php b/src/Nodes/Discount/Parameters/ItemModel.php new file mode 100755 index 0000000..3ba0756 --- /dev/null +++ b/src/Nodes/Discount/Parameters/ItemModel.php @@ -0,0 +1,45 @@ +parameters['model_promotion_price']; + } + + /** + * Name of the discount. + * + * @param float $model_promotion_price + * @return $this + */ + public function setModelPromotionPrice(float $model_promotion_price) + { + $this->parameters['model_promotion_price'] = $model_promotion_price; + + return $this; + } + + public function getModelPromotionStock(): int + { + return $this->parameters['model_promotion_stock']; + } + + /** + * @param int $model_promotion_stock + * @return $this + */ + public function setModelPromotionStock(int $model_promotion_stock) + { + $this->parameters['model_promotion_stock'] = $model_promotion_stock; + + return $this; + } + +} diff --git a/src/Nodes/Discount/Parameters/ItemModelList.php b/src/Nodes/Discount/Parameters/ItemModelList.php new file mode 100755 index 0000000..110e9b1 --- /dev/null +++ b/src/Nodes/Discount/Parameters/ItemModelList.php @@ -0,0 +1,34 @@ +add(new ItemModel($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Discount/Parameters/UpdateDiscount.php b/src/Nodes/Discount/Parameters/UpdateDiscount.php index 9586949..c4568e5 100755 --- a/src/Nodes/Discount/Parameters/UpdateDiscount.php +++ b/src/Nodes/Discount/Parameters/UpdateDiscount.php @@ -6,21 +6,7 @@ class UpdateDiscount extends RequestParameters { - public function getDiscountId(): int - { - return $this->parameters['discount_id']; - } - - /** - * @param int $discount_id - * @return $this - */ - public function setDiscountId(int $discount_id) - { - $this->parameters['discount_id'] = $discount_id; - - return $this; - } + use DiscountTrait; public function getName(): string { return $this->parameters['discount_name']; From 822e6a0929ae326124c9ae8438a7a4e0ca69ec17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Fri, 30 Sep 2022 17:05:46 +0700 Subject: [PATCH 43/89] delete discount item --- .../Discount/Parameters/DeleteDiscountItems.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 src/Nodes/Discount/Parameters/DeleteDiscountItems.php diff --git a/src/Nodes/Discount/Parameters/DeleteDiscountItems.php b/src/Nodes/Discount/Parameters/DeleteDiscountItems.php new file mode 100755 index 0000000..14bf6f7 --- /dev/null +++ b/src/Nodes/Discount/Parameters/DeleteDiscountItems.php @@ -0,0 +1,15 @@ + Date: Mon, 24 Apr 2023 17:20:45 +0700 Subject: [PATCH 44/89] logistic --- src/Nodes/Logistics/Logistics.php | 43 +++++++++++++++ .../CreateShippingDocumentArrays.php | 37 +++++++++++++ .../CreateShippingDocumentInput.php | 22 ++++++++ .../CreateShippingDocumentParameter.php | 54 +++++++++++++++++++ .../DownloadShippingDocumentInput.php | 35 ++++++++++++ .../Logistics/Parameters/ShipOrderInput.php | 37 +++++++++++++ .../Parameters/ShipOrderPickupInput.php | 43 +++++++++++++++ .../Parameters/ShippingParameterInput.php | 33 ++++++++++++ 8 files changed, 304 insertions(+) create mode 100755 src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php create mode 100755 src/Nodes/Logistics/Parameters/CreateShippingDocumentInput.php create mode 100755 src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php create mode 100755 src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php create mode 100755 src/Nodes/Logistics/Parameters/ShipOrderInput.php create mode 100755 src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php create mode 100755 src/Nodes/Logistics/Parameters/ShippingParameterInput.php diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 8a77579..bc7a204 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -32,4 +32,47 @@ public function getTrackingNumber($parameters = []): ResponseData { return $this->get('/api/v2/logistics/get_tracking_number', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getShippingParameter($parameters = []): ResponseData + { + return $this->get('/api/v2/logistics/get_shipping_parameter', ClientV2::API_TYPE_SHOP, $parameters); + } + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function shipOrder($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/ship_order', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function createShipingDocument($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/create_shipping_document', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function downloadShipingDocument($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/download_shipping_document', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php b/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php new file mode 100755 index 0000000..79fd4ac --- /dev/null +++ b/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php @@ -0,0 +1,37 @@ +add(new CreateShippingDocumentParameter($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/CreateShippingDocumentInput.php b/src/Nodes/Logistics/Parameters/CreateShippingDocumentInput.php new file mode 100755 index 0000000..0128386 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/CreateShippingDocumentInput.php @@ -0,0 +1,22 @@ +parameters['order_list'] = $params; + return $this; + } + +} diff --git a/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php b/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php new file mode 100755 index 0000000..36fd19b --- /dev/null +++ b/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php @@ -0,0 +1,54 @@ + 'NORMAL_AIR_WAYBILL', + ]; + /** + * @param string $order_sn + * @return $this + */ + + public function setOrderSn(string $order_sn) + { + $this->parameters['order_sn'] = $order_sn; + return $this; + } + + /** + * @param string $shipping_document_type + * @return $this + */ + + public function setDocumentType(string $shipping_document_type) + { + $this->parameters['shipping_document_type'] = $shipping_document_type; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + /** + * @param string $tracking_number + * @return $this + */ + + public function setTrackingNumber(string $tracking_number) + { + $this->parameters['tracking_number'] = $tracking_number; + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php b/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php new file mode 100755 index 0000000..e273258 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php @@ -0,0 +1,35 @@ + 'NORMAL_AIR_WAYBILL', + ]; + + /** + * @param CreateShippingDocumentArrays $params + * @return $this + */ + + public function setOrderList(CreateShippingDocumentArrays $params) + { + $this->parameters['order_list'] = $params; + return $this; + } + + /** + * @param string $shipping_document_type + * @return $this + */ + + public function setDocumentType(string $shipping_document_type) + { + $this->parameters['shipping_document_type'] = $shipping_document_type; + return $this; + } + +} diff --git a/src/Nodes/Logistics/Parameters/ShipOrderInput.php b/src/Nodes/Logistics/Parameters/ShipOrderInput.php new file mode 100755 index 0000000..45b1780 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/ShipOrderInput.php @@ -0,0 +1,37 @@ +parameters['order_sn'] = $order_sn; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + public function setPickup(ShipOrderPickupInput $pickupInput) + { + $this->parameters['pickup'] = $pickupInput; + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php new file mode 100755 index 0000000..d16258e --- /dev/null +++ b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php @@ -0,0 +1,43 @@ +parameters['address_id'] = $address_id; + return $this; + } + /** + * @param int $pickup_time_id + * @return $this + */ + + public function setPickupTimeId(int $pickup_time_id) + { + $this->parameters['pickup_time_id'] = $pickup_time_id; + return $this; + } + /** + * @param string $tracking_number + * @return $this + */ + + public function setTrackingNumber(string $tracking_number) + { + $this->parameters['tracking_number'] = $tracking_number; + return $this; + } + +} diff --git a/src/Nodes/Logistics/Parameters/ShippingParameterInput.php b/src/Nodes/Logistics/Parameters/ShippingParameterInput.php new file mode 100755 index 0000000..9f2280a --- /dev/null +++ b/src/Nodes/Logistics/Parameters/ShippingParameterInput.php @@ -0,0 +1,33 @@ +parameters['order_sn'] = $order_sn; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + +} From 15bf3a2cc2117ca8954a9df6c23865416fe5cf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 26 Apr 2023 17:28:01 +0700 Subject: [PATCH 45/89] update param type --- .../Logistics/Parameters/CreateShippingDocumentArrays.php | 3 ++- src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php b/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php index 79fd4ac..32641cc 100755 --- a/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php +++ b/src/Nodes/Logistics/Parameters/CreateShippingDocumentArrays.php @@ -3,10 +3,11 @@ namespace Shopee\Nodes\Logistics\Parameters; use Shopee\Nodes\Item\Parameters\Logistic; +use Shopee\RequestParameterCollection; use Shopee\RequestParameters; use Shopee\RequestParametersInterface; -class CreateShippingDocumentArrays extends RequestParameters +class CreateShippingDocumentArrays extends RequestParameterCollection { diff --git a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php index d16258e..71694c2 100755 --- a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php +++ b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php @@ -24,7 +24,7 @@ public function setAddressId(int $address_id) * @return $this */ - public function setPickupTimeId(int $pickup_time_id) + public function setPickupTimeId(string $pickup_time_id) { $this->parameters['pickup_time_id'] = $pickup_time_id; return $this; From ca29f3c7c47731b7fbe651369101ae7ba4f154bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Fri, 28 Apr 2023 09:55:26 +0700 Subject: [PATCH 46/89] add api getAddressList --- src/Nodes/Logistics/Logistics.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index bc7a204..7181ad8 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -75,4 +75,15 @@ public function downloadShipingDocument($parameters = []): ResponseData { return $this->post('/api/v2/logistics/download_shipping_document', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * Get return list address + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getAddressList($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/get_address_list', ClientV2::API_TYPE_SHOP, $parameters); + } } From 83f38c6829800e4e51410fb2e7e52a3ebe101ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Fri, 28 Apr 2023 10:54:02 +0700 Subject: [PATCH 47/89] change get --- src/Nodes/Logistics/Logistics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 7181ad8..96c36a6 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -84,6 +84,6 @@ public function downloadShipingDocument($parameters = []): ResponseData */ public function getAddressList($parameters = []): ResponseData { - return $this->post('/api/v2/logistics/get_address_list', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/logistics/get_address_list', ClientV2::API_TYPE_SHOP, $parameters); } } From 215098f024a9e611d0664c6d2e156008291de54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 4 May 2023 10:08:56 +0700 Subject: [PATCH 48/89] batch ship order --- .../Parameters/BatchShipOrderInput.php | 27 +++++++++++++ .../Logistics/Parameters/ListOrderInput.php | 38 +++++++++++++++++++ .../Parameters/OrderPackageInput.php | 33 ++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100755 src/Nodes/Logistics/Parameters/BatchShipOrderInput.php create mode 100755 src/Nodes/Logistics/Parameters/ListOrderInput.php create mode 100755 src/Nodes/Logistics/Parameters/OrderPackageInput.php diff --git a/src/Nodes/Logistics/Parameters/BatchShipOrderInput.php b/src/Nodes/Logistics/Parameters/BatchShipOrderInput.php new file mode 100755 index 0000000..4542f99 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/BatchShipOrderInput.php @@ -0,0 +1,27 @@ +parameters['order_list'] = $listOrderInput; + return $this; + } + + public function setPickup(ShipOrderPickupInput $pickupInput) + { + $this->parameters['pickup'] = $pickupInput; + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/ListOrderInput.php b/src/Nodes/Logistics/Parameters/ListOrderInput.php new file mode 100755 index 0000000..864f329 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/ListOrderInput.php @@ -0,0 +1,38 @@ +add(new OrderPackageInput($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/OrderPackageInput.php b/src/Nodes/Logistics/Parameters/OrderPackageInput.php new file mode 100755 index 0000000..c67e9bd --- /dev/null +++ b/src/Nodes/Logistics/Parameters/OrderPackageInput.php @@ -0,0 +1,33 @@ +parameters['order_sn'] = $order_sn; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + +} From 1c0fca37bc01a12e4bf3a8a121d11fa12facfc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 4 May 2023 14:32:02 +0700 Subject: [PATCH 49/89] add api batch_ship_order --- src/Nodes/Logistics/Logistics.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 96c36a6..8768d5f 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -54,6 +54,18 @@ public function shipOrder($parameters = []): ResponseData return $this->post('/api/v2/logistics/ship_order', ClientV2::API_TYPE_SHOP, $parameters); } + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function batchShipOrder($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/batch_ship_order', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** * Get return list. * From a2fb17afc2e1c92bf65d1ae14e7f8a0a1f00562b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 10 May 2023 15:37:12 +0700 Subject: [PATCH 50/89] add getShipingDocumentResult --- src/Nodes/Logistics/Logistics.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 8768d5f..6df838d 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -77,6 +77,17 @@ public function createShipingDocument($parameters = []): ResponseData return $this->post('/api/v2/logistics/create_shipping_document', ClientV2::API_TYPE_SHOP, $parameters); } + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getShipingDocumentResult($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/get_shipping_document_result', ClientV2::API_TYPE_SHOP, $parameters); + } + /** * Get return list. * From d7abd53ccd8160a9675fa020a07ac18e3e4752ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Mon, 22 May 2023 16:40:06 +0700 Subject: [PATCH 51/89] update THERMAL_AIR_WAYBILL --- .../Logistics/Parameters/CreateShippingDocumentParameter.php | 2 +- .../Logistics/Parameters/DownloadShippingDocumentInput.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php b/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php index 36fd19b..0da7d1a 100755 --- a/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php +++ b/src/Nodes/Logistics/Parameters/CreateShippingDocumentParameter.php @@ -8,7 +8,7 @@ class CreateShippingDocumentParameter extends RequestParameters { protected $parameters = [ - 'shipping_document_type' => 'NORMAL_AIR_WAYBILL', + 'shipping_document_type' => 'THERMAL_AIR_WAYBILL', ]; /** * @param string $order_sn diff --git a/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php b/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php index e273258..ce5adce 100755 --- a/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php +++ b/src/Nodes/Logistics/Parameters/DownloadShippingDocumentInput.php @@ -7,7 +7,7 @@ class DownloadShippingDocumentInput extends RequestParameters { protected $parameters = [ - 'shipping_document_type' => 'NORMAL_AIR_WAYBILL', + 'shipping_document_type' => 'THERMAL_AIR_WAYBILL', ]; /** From 86071dee9273d64fe237ae3797f77e336d65f575 Mon Sep 17 00:00:00 2001 From: quanglx Date: Fri, 16 Jun 2023 17:31:45 +0700 Subject: [PATCH 52/89] add logistics info --- src/Nodes/Logistics/Logistics.php | 5 +++ .../Logistics/Parameters/GetTrackingInfo.php | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 src/Nodes/Logistics/Parameters/GetTrackingInfo.php diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 6df838d..52bfda8 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -109,4 +109,9 @@ public function getAddressList($parameters = []): ResponseData { return $this->get('/api/v2/logistics/get_address_list', ClientV2::API_TYPE_SHOP, $parameters); } + + public function getTrackingInfo($parameters = []): ResponseData + { + return $this->get('/api/v2/logistics/get_tracking_info', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Logistics/Parameters/GetTrackingInfo.php b/src/Nodes/Logistics/Parameters/GetTrackingInfo.php new file mode 100755 index 0000000..96f65bc --- /dev/null +++ b/src/Nodes/Logistics/Parameters/GetTrackingInfo.php @@ -0,0 +1,33 @@ +parameters['order_sn'] = $order_sn; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + +} From e0ed7f10998bd2addf56bfa48380efc2ce209c32 Mon Sep 17 00:00:00 2001 From: quanglx Date: Fri, 14 Jul 2023 17:18:12 +0700 Subject: [PATCH 53/89] add getReturnDetail --- src/Nodes/Returns/Returns.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Nodes/Returns/Returns.php b/src/Nodes/Returns/Returns.php index c2850ac..c4e8e27 100755 --- a/src/Nodes/Returns/Returns.php +++ b/src/Nodes/Returns/Returns.php @@ -21,4 +21,9 @@ public function getReturnList($parameters = []): ResponseData { return $this->get('/api/v2/returns/get_return_list', ClientV2::API_TYPE_SHOP, $parameters); } + + public function getReturnDetail($parameters = []): ResponseData + { + return $this->get('/api/v2/returns/get_return_detail', ClientV2::API_TYPE_SHOP, $parameters); + } } From f29ee6d032e71f04a1b9b9def61b68dab8ef8234 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 29 Aug 2023 10:40:35 +0700 Subject: [PATCH 54/89] changed: add get getEscrowList --- src/Nodes/Payment/Payment.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Nodes/Payment/Payment.php b/src/Nodes/Payment/Payment.php index 137721d..82ad86b 100644 --- a/src/Nodes/Payment/Payment.php +++ b/src/Nodes/Payment/Payment.php @@ -3,7 +3,6 @@ namespace Shopee\Nodes\Payment; use Shopee\ClientV2; -use Shopee\Nodes\NodeAbstract; use Shopee\Nodes\NodeAbstractV2; use Shopee\ResponseData; @@ -37,4 +36,13 @@ public function getEscrowDetail($parameters = []): ResponseData { return $this->get('/api/v2/payment/get_escrow_detail', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * @param array $parameters + * @return ResponseData + */ + public function getEscrowList($parameters = []): ResponseData + { + return $this->get('/api/v2/payment/get_escrow_list', ClientV2::API_TYPE_SHOP, $parameters); + } } From d99aebecaf9428ef7d654abfa2167a44799f2cce Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Mon, 23 Oct 2023 11:07:09 +0700 Subject: [PATCH 55/89] changed: add get warehouse_detail --- src/Nodes/Shop/Shop.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nodes/Shop/Shop.php b/src/Nodes/Shop/Shop.php index 2285d9d..8e86b75 100644 --- a/src/Nodes/Shop/Shop.php +++ b/src/Nodes/Shop/Shop.php @@ -42,4 +42,15 @@ public function updateShopProfile($parameters = []): ResponseData return $this->post('/api/v2/shop/update_profile', ClientV2::API_TYPE_SHOP, $parameters); } + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.shop.get_warehouse_detail?module=92&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getWarehouseDetail($parameters = []): ResponseData + { + return $this->get('/api/v2/shop/get_warehouse_detail', ClientV2::API_TYPE_SHOP, $parameters); + } + } From 792b414ed8ebb087541cbd670def04deaa8e2f79 Mon Sep 17 00:00:00 2001 From: quanglx Date: Wed, 8 Nov 2023 11:20:01 +0700 Subject: [PATCH 56/89] update param comment shopee --- src/Nodes/Item/Parameters/Comment.php | 42 ++++++++++++++++++++++ src/Nodes/Item/Parameters/CommentList.php | 33 +++++++++++++++++ src/Nodes/Item/Parameters/ReplyComment.php | 24 +++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/Nodes/Item/Parameters/Comment.php create mode 100644 src/Nodes/Item/Parameters/CommentList.php create mode 100644 src/Nodes/Item/Parameters/ReplyComment.php diff --git a/src/Nodes/Item/Parameters/Comment.php b/src/Nodes/Item/Parameters/Comment.php new file mode 100644 index 0000000..f089790 --- /dev/null +++ b/src/Nodes/Item/Parameters/Comment.php @@ -0,0 +1,42 @@ +parameters['comment_id']; + } + + /** + * @param int $commentId + * @return $this + */ + public function setCommentId(int $commentId) + { + $this->parameters['comment_id'] = $commentId; + + return $this; + } + + public function getComment(): string + { + return $this->parameters['comment']; + } + + /** + * @param string $comment + * @return $this + */ + public function setComment(string $comment) + { + $this->parameters['comment'] = $comment; + + return $this; + } + + +} diff --git a/src/Nodes/Item/Parameters/CommentList.php b/src/Nodes/Item/Parameters/CommentList.php new file mode 100644 index 0000000..e8d123b --- /dev/null +++ b/src/Nodes/Item/Parameters/CommentList.php @@ -0,0 +1,33 @@ +add(new Comment($parameter)); + } + + return $this; + } + +} diff --git a/src/Nodes/Item/Parameters/ReplyComment.php b/src/Nodes/Item/Parameters/ReplyComment.php new file mode 100644 index 0000000..e1c4b6e --- /dev/null +++ b/src/Nodes/Item/Parameters/ReplyComment.php @@ -0,0 +1,24 @@ +parameters['comment_list']; + } + + /** + * @param array $comment_list + * @return $this + */ + public function setCommentList(CommentList $comment_list) + { + $this->parameters['comment_list'] = $comment_list; + + return $this; + } +} From ded2a58845491cf09b6d5a519c9b937386fa43be Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Wed, 13 Mar 2024 18:05:09 +0700 Subject: [PATCH 57/89] changed: add getAccessTokenByMainAccount --- src/Nodes/Shop/Authorization.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Nodes/Shop/Authorization.php b/src/Nodes/Shop/Authorization.php index b648c8c..d60d10c 100644 --- a/src/Nodes/Shop/Authorization.php +++ b/src/Nodes/Shop/Authorization.php @@ -25,6 +25,22 @@ public function getAccessToken($auth_code, $partner_id, $shop_id): ResponseData 'shop_id' => $shop_id ]); } + /** + * Shop performance includes the indexes from "My Performance" of Seller Center. + * + * @param $auth_code + * @param $partner_id + * @param $shop_id + * @return ResponseData + */ + public function getAccessTokenByMainAccount($auth_code, $partner_id, $main_account_id): ResponseData + { + return $this->post('/api/v2/auth/token/get', ClientV2::API_TYPE_PUBLIC, [ + 'code' => $auth_code, + 'partner_id' => $partner_id, + 'main_account_id' => $main_account_id + ]); + } /** * Only for TW whitelisted shop.Use this API to set the installment status of shop. From d5933710414a51e5f8792bfc352d59479461c6b0 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Thu, 14 Mar 2024 09:54:58 +0700 Subject: [PATCH 58/89] changed: remove shop_id when call PUBLIC --- src/ClientV2.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 2a2628c..60b232b 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -207,13 +207,20 @@ public function setBaseUrl(string $url) return $this; } - public function getDefaultParameters(): array + public function getDefaultParameters($type_api = self::API_TYPE_SHOP): array { - return [ - 'partner_id' => $this->partnerId, - 'shopid' => $this->shopId, - 'timestamp' => time(), // Put the current UNIX timestamp when making a request - ]; + if($type_api == self::API_TYPE_PUBLIC){ + return [ + 'partner_id' => $this->partnerId, + 'timestamp' => time(), // Put the current UNIX timestamp when making a request + ]; + }else{ + return [ + 'partner_id' => $this->partnerId, + 'shopid' => $this->shopId, + 'timestamp' => time(), // Put the current UNIX timestamp when making a request + ]; + } } /** @@ -224,9 +231,9 @@ public function getDefaultParameters(): array * @param array $data * @return string */ - protected function createJsonBody(array $data): string + protected function createJsonBody(array $data, $type_api = self::API_TYPE_SHOP): string { - $data = array_merge($this->getDefaultParameters(), $data); + $data = array_merge($this->getDefaultParameters($type_api), $data); return json_encode($data); } @@ -272,7 +279,7 @@ public function newRequest($uri, $api_type, array $headers = [], $data = []): Re ->withPath($path) ->withQuery($auth_query); - $jsonBody = $this->createJsonBody($data); + $jsonBody = $this->createJsonBody($data, $api_type); $headers['User-Agent'] = $this->userAgent; $headers['Content-Type'] = 'application/json'; From df2cc9297d90adbaf42e538f98f0d6ca304765ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 19 Mar 2024 11:05:48 +0700 Subject: [PATCH 59/89] add upload with body --- src/Nodes/Image/Image.php | 4 ++-- src/Nodes/NodeAbstractV2.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Nodes/Image/Image.php b/src/Nodes/Image/Image.php index 597cf14..4bee242 100644 --- a/src/Nodes/Image/Image.php +++ b/src/Nodes/Image/Image.php @@ -16,8 +16,8 @@ class Image extends NodeAbstractV2 * @param array $parameters * @return ResponseData */ - public function uploadImage($image_url): ResponseData + public function uploadImage($image_url, $params = []): ResponseData { - return $this->upload('/api/v2/media_space/upload_image', ClientV2::API_TYPE_PUBLIC, $image_url); + return $this->uploadWithBody('/api/v2/media_space/upload_image', ClientV2::API_TYPE_PUBLIC, $image_url,$params); } } diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index 6439608..de446ca 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -74,7 +74,19 @@ public function upload($uri, $type_api, $file_url) $response = $this->client->upload($request, $file_url); return new ResponseData($response); } + /** + * @param string|UriInterface $uri + * @param $type_api + * @param $file_url + * @return ResponseData + */ + public function uploadWithBody($uri, $type_api, $file_url, $params = []) + { + $request = $this->client->newRequest($uri, $type_api, $params); + $response = $this->client->upload($request, $file_url); + return new ResponseData($response); + } /** * @param $video_upload_id * @param $file_url From 93055463df514187150b7264d0ad20942d376967 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 2 Apr 2024 20:29:35 +0700 Subject: [PATCH 60/89] changed: integrated chat api --- src/Nodes/Chat/Conversation.php | 39 ++++++++++++++++++++++++++++ src/Nodes/Chat/Messages.php | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 src/Nodes/Chat/Conversation.php create mode 100755 src/Nodes/Chat/Messages.php diff --git a/src/Nodes/Chat/Conversation.php b/src/Nodes/Chat/Conversation.php new file mode 100755 index 0000000..8137a40 --- /dev/null +++ b/src/Nodes/Chat/Conversation.php @@ -0,0 +1,39 @@ +get("/api/v2/sellerchat/get_conversation_list", ClientV2::API_TYPE_SHOP, $parameters); + } + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.sellerchat.get_one_conversation?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getOneConversation($parameters = []): ResponseData { + return $this->get("/api/v2/sellerchat/get_one_conversation", ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.sellerchat.read_conversation?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function readConversation($parameters = []): ResponseData { + return $this->post("/api/v2/sellerchat/read_conversation", ClientV2::API_TYPE_SHOP, $parameters); + } +} diff --git a/src/Nodes/Chat/Messages.php b/src/Nodes/Chat/Messages.php new file mode 100755 index 0000000..45c8a6e --- /dev/null +++ b/src/Nodes/Chat/Messages.php @@ -0,0 +1,45 @@ +get("/api/v2/sellerchat/get_message", ClientV2::API_TYPE_SHOP, $parameters); + } + /** + * https://open.shopee.com/documents/v2/v2.sellerchat.send_message?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function sendMessage($parameters = []): ResponseData { + return $this->post("/api/v2/sellerchat/send_message", ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * https://open.shopee.com/documents/v2/v2.sellerchat.send_autoreply_message?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function sendAutoReply($parameters = []): ResponseData { + return $this->post("/api/v2/sellerchat/send_autoreply_message", ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * https://open.shopee.com/documents/v2/v2.sellerchat.upload_image?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function uploadImage($image_url, $parameters = []): ResponseData { + return $this->uploadWithBody("/api/v2/sellerchat/upload_image", ClientV2::API_TYPE_SHOP, $image_url, $parameters); + } +} From 19ee0274e67828c72a8aec91d78094b052267c35 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 2 Apr 2024 21:22:46 +0700 Subject: [PATCH 61/89] changed: add chat to node --- src/ClientV2.php | 2 ++ src/Nodes/Chat/{Messages.php => Chat.php} | 30 ++++++++++++++++- src/Nodes/Chat/Conversation.php | 39 ----------------------- 3 files changed, 31 insertions(+), 40 deletions(-) rename src/Nodes/Chat/{Messages.php => Chat.php} (55%) delete mode 100755 src/Nodes/Chat/Conversation.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 60b232b..dbc1076 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -43,6 +43,7 @@ * @property Nodes\Payment\Payment $payment * @property Nodes\Returns\Returns $returns * @property Nodes\Discount\Discount $discount + * @property Nodes\Chat\Chat $chat */ class ClientV2 { @@ -148,6 +149,7 @@ public function __construct(array $config = []) $this->nodes['video'] = new Nodes\Video\Video($this); $this->nodes['returns'] = new Nodes\Returns\Returns($this); $this->nodes['discount'] = new Nodes\Discount\Discount($this); + $this->nodes['chat'] = new Nodes\Chat\Chat($this); } public function __get(string $name) diff --git a/src/Nodes/Chat/Messages.php b/src/Nodes/Chat/Chat.php similarity index 55% rename from src/Nodes/Chat/Messages.php rename to src/Nodes/Chat/Chat.php index 45c8a6e..4ef491c 100755 --- a/src/Nodes/Chat/Messages.php +++ b/src/Nodes/Chat/Chat.php @@ -7,8 +7,36 @@ use Shopee\RequestParametersInterface; use Shopee\ResponseData; -class Messages extends NodeAbstractV2 { +class Chat extends NodeAbstractV2 { /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.sellerchat.get_conversation_list?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getConversationList($parameters = []): ResponseData { + return $this->get("/api/v2/sellerchat/get_conversation_list", ClientV2::API_TYPE_SHOP, $parameters); + } + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.sellerchat.get_one_conversation?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getOneConversation($parameters = []): ResponseData { + return $this->get("/api/v2/sellerchat/get_one_conversation", ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this call to get information of shop. + * https://open.shopee.com/documents/v2/v2.sellerchat.read_conversation?module=109&type=1 + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function readConversation($parameters = []): ResponseData { + return $this->post("/api/v2/sellerchat/read_conversation", ClientV2::API_TYPE_SHOP, $parameters); + } + /** * https://open.shopee.com/documents/v2/v2.sellerchat.get_message?module=109&type=1 * @param array|RequestParametersInterface $parameters * @return ResponseData diff --git a/src/Nodes/Chat/Conversation.php b/src/Nodes/Chat/Conversation.php deleted file mode 100755 index 8137a40..0000000 --- a/src/Nodes/Chat/Conversation.php +++ /dev/null @@ -1,39 +0,0 @@ -get("/api/v2/sellerchat/get_conversation_list", ClientV2::API_TYPE_SHOP, $parameters); - } - /** - * Use this call to get information of shop. - * https://open.shopee.com/documents/v2/v2.sellerchat.get_one_conversation?module=109&type=1 - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function getOneConversation($parameters = []): ResponseData { - return $this->get("/api/v2/sellerchat/get_one_conversation", ClientV2::API_TYPE_SHOP, $parameters); - } - - /** - * Use this call to get information of shop. - * https://open.shopee.com/documents/v2/v2.sellerchat.read_conversation?module=109&type=1 - * @param array|RequestParametersInterface $parameters - * @return ResponseData - */ - public function readConversation($parameters = []): ResponseData { - return $this->post("/api/v2/sellerchat/read_conversation", ClientV2::API_TYPE_SHOP, $parameters); - } -} From bbae3c391f9c075dfd0c30bccd92ad355347df2e Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Mon, 8 Apr 2024 20:31:35 +0700 Subject: [PATCH 62/89] changed: add Message and Message payload params --- src/Nodes/Chat/Parameters/Message.php | 55 +++++++++++++++ src/Nodes/Chat/Parameters/MessageContent.php | 70 ++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 src/Nodes/Chat/Parameters/Message.php create mode 100644 src/Nodes/Chat/Parameters/MessageContent.php diff --git a/src/Nodes/Chat/Parameters/Message.php b/src/Nodes/Chat/Parameters/Message.php new file mode 100644 index 0000000..6709d6c --- /dev/null +++ b/src/Nodes/Chat/Parameters/Message.php @@ -0,0 +1,55 @@ +parameters['to_id']; + } + + /** + * @param int $to_id + * @return $this + */ + public function setToId(int $to_id) + { + $this->parameters['to_id'] = $to_id; + + return $this; + } + + public function getMessageType(): string + { + return $this->parameters['message_type']; + } + + /** + * @param string $message_type + * @return $this + */ + public function setMessageType(string $message_type) + { + $this->parameters['message_type'] = $message_type; + + return $this; + } + + public function getMessageContent(){ + return $this->parameters['content']; + } + + /** + * @param MessageContent + * @return $this + */ + public function setMessageContent($message_content) + { + $this->parameters['content'] = $message_content; + + return $this; + } +} diff --git a/src/Nodes/Chat/Parameters/MessageContent.php b/src/Nodes/Chat/Parameters/MessageContent.php new file mode 100644 index 0000000..58b1172 --- /dev/null +++ b/src/Nodes/Chat/Parameters/MessageContent.php @@ -0,0 +1,70 @@ +parameters['text']; + } + + /** + * @param int $text + * @return $this + */ + public function setText(string $text) + { + $this->parameters['text'] = $text; + + return $this; + } + + public function getImageUrl(): string + { + return $this->parameters['image_url']; + } + + /** + * @param string $image_url + * @return $this + */ + public function setImageUrl(string $image_url) + { + $this->parameters['image_url'] = $image_url; + + return $this; + } + + public function getItemId(): string + { + return $this->parameters['item_id']; + } + + /** + * @param string $item_id + * @return $this + */ + public function setItemId(string $item_id) + { + $this->parameters['item_id'] = $item_id; + return $this; + } + + public function getOrderSn(): string + { + return $this->parameters['order_sn']; + } + + /** + * @param string $order_sn + * @return $this + */ + public function setOrderSn(string $order_sn) + { + $this->parameters['order_sn'] = $order_sn; + return $this; + } +} From 6e3ec62b7e4c1b0502325eb57ce5fa1be4930d06 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Mon, 8 Apr 2024 20:34:16 +0700 Subject: [PATCH 63/89] changed: add readconversaion params --- .../Chat/Parameters/ReadConversation.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Nodes/Chat/Parameters/ReadConversation.php diff --git a/src/Nodes/Chat/Parameters/ReadConversation.php b/src/Nodes/Chat/Parameters/ReadConversation.php new file mode 100644 index 0000000..2961ea4 --- /dev/null +++ b/src/Nodes/Chat/Parameters/ReadConversation.php @@ -0,0 +1,40 @@ +parameters['conversation_id']; + } + + /** + * @param int $conversation_id + * @return $this + */ + public function setConversationId($conversation_id) + { + $this->parameters['conversation_id'] = $conversation_id; + + return $this; + } + + public function getLastReadMessageId(): string + { + return $this->parameters['last_read_message_id']; + } + + /** + * @param string $last_read_message_id + * @return $this + */ + public function setLastReadMessageId(string $last_read_message_id) + { + $this->parameters['last_read_message_id'] = $last_read_message_id; + + return $this; + } +} From b08aa5b5cddfe104bbe0326953636af7aaca9577 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 9 Apr 2024 00:51:03 +0700 Subject: [PATCH 64/89] changed: fix format item --- src/Nodes/Chat/Parameters/MessageContent.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nodes/Chat/Parameters/MessageContent.php b/src/Nodes/Chat/Parameters/MessageContent.php index 58b1172..d545d07 100644 --- a/src/Nodes/Chat/Parameters/MessageContent.php +++ b/src/Nodes/Chat/Parameters/MessageContent.php @@ -38,16 +38,16 @@ public function setImageUrl(string $image_url) return $this; } - public function getItemId(): string + public function getItemId() { return $this->parameters['item_id']; } /** - * @param string $item_id + * @param $item_id * @return $this */ - public function setItemId(string $item_id) + public function setItemId($item_id) { $this->parameters['item_id'] = $item_id; return $this; From 0a97dfd003b9549e8e7df92320a5b16ce1dbcd30 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 9 Apr 2024 02:15:08 +0700 Subject: [PATCH 65/89] changed: add request GetMessages --- src/Nodes/Chat/Parameters/GetMessages.php | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/Nodes/Chat/Parameters/GetMessages.php diff --git a/src/Nodes/Chat/Parameters/GetMessages.php b/src/Nodes/Chat/Parameters/GetMessages.php new file mode 100644 index 0000000..3a25b01 --- /dev/null +++ b/src/Nodes/Chat/Parameters/GetMessages.php @@ -0,0 +1,70 @@ +parameters['message_id_list']; + } + + /** + * @param int $message_id_list + * @return $this + */ + public function setMessageIdList(int $message_id_list) + { + $this->parameters['message_id_list'] = $message_id_list; + + return $this; + } + + public function getConversationId(): int + { + return $this->parameters['conversation_id']; + } + + /** + * @param int $conversation_id + * @return $this + */ + public function setConversationId(int $conversation_id) + { + $this->parameters['conversation_id'] = $conversation_id; + + return $this; + } + + public function getPageSize(){ + return $this->parameters['page_size']; + } + + /** + * @param MessageContent + * @return $this + */ + public function setPageSize($page_size) + { + $this->parameters['page_size'] = $page_size; + + return $this; + } + + public function getOffset(){ + return $this->parameters['offset']; + } + + /** + * @param MessageContent + * @return $this + */ + public function setOffset($offset) + { + $this->parameters['offset'] = $offset; + + return $this; + } +} From 464cb753a1e1d440ca89e60d42532c9e49496122 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 9 Apr 2024 02:40:57 +0700 Subject: [PATCH 66/89] changed: fix force type --- src/Nodes/Chat/Parameters/GetMessages.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nodes/Chat/Parameters/GetMessages.php b/src/Nodes/Chat/Parameters/GetMessages.php index 3a25b01..d75d4ff 100644 --- a/src/Nodes/Chat/Parameters/GetMessages.php +++ b/src/Nodes/Chat/Parameters/GetMessages.php @@ -6,7 +6,7 @@ class GetMessages extends RequestParameters { - public function getMessageIdList(): int + public function getMessageIdList() { return $this->parameters['message_id_list']; } @@ -15,14 +15,14 @@ public function getMessageIdList(): int * @param int $message_id_list * @return $this */ - public function setMessageIdList(int $message_id_list) + public function setMessageIdList($message_id_list) { $this->parameters['message_id_list'] = $message_id_list; return $this; } - public function getConversationId(): int + public function getConversationId() { return $this->parameters['conversation_id']; } From 59af48b27ffc4ef984ca3b3802c35bad0b0f0681 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 9 Apr 2024 03:22:41 +0700 Subject: [PATCH 67/89] changed: add sent chat image --- src/ClientV2.php | 4 ++-- src/Nodes/Chat/Chat.php | 2 +- src/Nodes/NodeAbstractV2.php | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index dbc1076..126e7b8 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -294,7 +294,7 @@ public function newRequest($uri, $api_type, array $headers = [], $data = []): Re ); } - public function upload(RequestInterface $request, $file_url): ResponseInterface + public function upload(RequestInterface $request, $file_url, $field_name = 'image'): ResponseInterface { try { list($tempImageDownload, $fileName) = $this->downloadFile($file_url); @@ -304,7 +304,7 @@ public function upload(RequestInterface $request, $file_url): ResponseInterface [ 'multipart' => [ [ - 'name' => 'image', + 'name' => $field_name, 'contents' => fopen($tempImageDownload, 'r'), 'file_name' => $fileName ], diff --git a/src/Nodes/Chat/Chat.php b/src/Nodes/Chat/Chat.php index 4ef491c..af3f8e9 100755 --- a/src/Nodes/Chat/Chat.php +++ b/src/Nodes/Chat/Chat.php @@ -68,6 +68,6 @@ public function sendAutoReply($parameters = []): ResponseData { * @return ResponseData */ public function uploadImage($image_url, $parameters = []): ResponseData { - return $this->uploadWithBody("/api/v2/sellerchat/upload_image", ClientV2::API_TYPE_SHOP, $image_url, $parameters); + return $this->chatUploadWithBody("/api/v2/sellerchat/upload_image", ClientV2::API_TYPE_SHOP, $image_url, $parameters); } } diff --git a/src/Nodes/NodeAbstractV2.php b/src/Nodes/NodeAbstractV2.php index de446ca..69333ca 100644 --- a/src/Nodes/NodeAbstractV2.php +++ b/src/Nodes/NodeAbstractV2.php @@ -87,6 +87,21 @@ public function uploadWithBody($uri, $type_api, $file_url, $params = []) $response = $this->client->upload($request, $file_url); return new ResponseData($response); } + + /** + * @param string|UriInterface $uri + * @param $type_api + * @param $file_url + * @return ResponseData + */ + public function chatUploadWithBody($uri, $type_api, $file_url, $params = []) + { + + $request = $this->client->newRequest($uri, $type_api, $params); + $response = $this->client->upload($request, $file_url, 'file'); + return new ResponseData($response); + } + /** * @param $video_upload_id * @param $file_url From 8cd0470f3a17418389014258b7c75f4265ba01b4 Mon Sep 17 00:00:00 2001 From: "qhuy.duong" Date: Tue, 9 Apr 2024 06:13:43 +0700 Subject: [PATCH 68/89] changed: fix generate temp file --- src/ClientV2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 126e7b8..ab8a12f 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -440,7 +440,7 @@ public function downloadFile($urlDownload) { $path_info = pathinfo($urlDownload); $filename = $path_info['basename']; - $tempImage = tempnam(sys_get_temp_dir(), $filename); + $tempImage = tempnam(sys_get_temp_dir(), 'shopee').$filename; copy($urlDownload, $tempImage); return [$tempImage, $filename]; } From 8bf4023b8fbb76a56eafdda86e47f498412e963e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sun, 5 May 2024 23:29:37 +0700 Subject: [PATCH 69/89] attribute --- src/Nodes/Item/Attribute.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nodes/Item/Attribute.php b/src/Nodes/Item/Attribute.php index af5fd0b..2da7caf 100755 --- a/src/Nodes/Item/Attribute.php +++ b/src/Nodes/Item/Attribute.php @@ -20,4 +20,7 @@ public function getAttributes($parameters = []): ResponseData { return $this->get("/api/v2/product/get_attributes", ClientV2::API_TYPE_SHOP, $parameters); } + public function getVariantAttributes($parameters = []): ResponseData { + return $this->get("/api/v2/product/get_variation_tree", ClientV2::API_TYPE_SHOP, $parameters); + } } From 005a094a49c8c49dd249fdf063e4a62310ea8f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sun, 12 May 2024 14:48:02 +0700 Subject: [PATCH 70/89] api discount --- src/Nodes/Discount/Discount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Discount/Discount.php b/src/Nodes/Discount/Discount.php index dc7a117..5b38c48 100644 --- a/src/Nodes/Discount/Discount.php +++ b/src/Nodes/Discount/Discount.php @@ -61,7 +61,7 @@ public function deleteDiscountItem($parameters = []): ResponseData */ public function getDiscountDetail($parameters = []): ResponseData { - return $this->post('/api/v2/discount/get_discount', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/discount/get_discount', ClientV2::API_TYPE_SHOP, $parameters); } /** From c5b26ddd7230db0110ba66cb300c2516eed8d6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Sun, 12 May 2024 14:53:09 +0700 Subject: [PATCH 71/89] discount list --- src/Nodes/Discount/Discount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Discount/Discount.php b/src/Nodes/Discount/Discount.php index 5b38c48..f029968 100644 --- a/src/Nodes/Discount/Discount.php +++ b/src/Nodes/Discount/Discount.php @@ -72,7 +72,7 @@ public function getDiscountDetail($parameters = []): ResponseData */ public function getDiscountsList($parameters = []): ResponseData { - return $this->post('/api/v2/discount/get_discount_list', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/discount/get_discount_list', ClientV2::API_TYPE_SHOP, $parameters); } /** From 7b499a385314cd52cd4e7486ae3ee6ebd61b0dbb Mon Sep 17 00:00:00 2001 From: quanglx Date: Thu, 16 May 2024 15:39:36 +0700 Subject: [PATCH 72/89] add endDiscount shoppe --- src/Nodes/Discount/Discount.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nodes/Discount/Discount.php b/src/Nodes/Discount/Discount.php index f029968..7d6dd91 100644 --- a/src/Nodes/Discount/Discount.php +++ b/src/Nodes/Discount/Discount.php @@ -96,4 +96,8 @@ public function updateDiscountItems($parameters = []): ResponseData { return $this->post('/api/v2/discount/update_discount_item', ClientV2::API_TYPE_SHOP, $parameters); } + public function endDiscount($parameters = []): ResponseData + { + return $this->post('/api/v2/discount/end_discount', ClientV2::API_TYPE_SHOP, $parameters); + } } From ccd57bbe5a2b264be4604dcc21661e61002a847d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 2 Jul 2024 09:31:51 +0700 Subject: [PATCH 73/89] voucher api --- src/ClientV2.php | 3 + src/Nodes/Voucher/Parameters/AddVoucher.php | 79 ++++++++++++++++++ .../Voucher/Parameters/UpdateVoucher.php | 81 +++++++++++++++++++ src/Nodes/Voucher/Parameters/VoucherTrait.php | 23 ++++++ src/Nodes/Voucher/Voucher.php | 75 +++++++++++++++++ 5 files changed, 261 insertions(+) create mode 100755 src/Nodes/Voucher/Parameters/AddVoucher.php create mode 100755 src/Nodes/Voucher/Parameters/UpdateVoucher.php create mode 100644 src/Nodes/Voucher/Parameters/VoucherTrait.php create mode 100644 src/Nodes/Voucher/Voucher.php diff --git a/src/ClientV2.php b/src/ClientV2.php index ab8a12f..adf2cc3 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -43,6 +43,7 @@ * @property Nodes\Payment\Payment $payment * @property Nodes\Returns\Returns $returns * @property Nodes\Discount\Discount $discount + * @property Nodes\Voucher\Voucher $voucher * @property Nodes\Chat\Chat $chat */ class ClientV2 @@ -150,6 +151,8 @@ public function __construct(array $config = []) $this->nodes['returns'] = new Nodes\Returns\Returns($this); $this->nodes['discount'] = new Nodes\Discount\Discount($this); $this->nodes['chat'] = new Nodes\Chat\Chat($this); + $this->nodes['voucher'] = new Nodes\Voucher\Voucher($this); + } public function __get(string $name) diff --git a/src/Nodes/Voucher/Parameters/AddVoucher.php b/src/Nodes/Voucher/Parameters/AddVoucher.php new file mode 100755 index 0000000..11ea982 --- /dev/null +++ b/src/Nodes/Voucher/Parameters/AddVoucher.php @@ -0,0 +1,79 @@ +parameters['voucher_name']; + } + + /** + * Name of the discount. + * + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['voucher_name'] = $name; + + return $this; + } + public function getCode(): string + { + return $this->parameters['voucher_code']; + } + + /** + * Name of the discount. + * + * @param string $code + * @return $this + */ + public function setCode(string $code) + { + $this->parameters['voucher_code'] = $code; + + return $this; + } + + + + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } +} diff --git a/src/Nodes/Voucher/Parameters/UpdateVoucher.php b/src/Nodes/Voucher/Parameters/UpdateVoucher.php new file mode 100755 index 0000000..1f388b7 --- /dev/null +++ b/src/Nodes/Voucher/Parameters/UpdateVoucher.php @@ -0,0 +1,81 @@ +parameters['voucher_name']; + } + + /** + * Name of the discount. + * + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['voucher_name'] = $name; + + return $this; + } + public function getCode(): string + { + return $this->parameters['voucher_code']; + } + + /** + * Name of the discount. + * + * @param string $code + * @return $this + */ + public function setCode(string $code) + { + $this->parameters['voucher_code'] = $code; + + return $this; + } + + + + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } +} diff --git a/src/Nodes/Voucher/Parameters/VoucherTrait.php b/src/Nodes/Voucher/Parameters/VoucherTrait.php new file mode 100644 index 0000000..2101065 --- /dev/null +++ b/src/Nodes/Voucher/Parameters/VoucherTrait.php @@ -0,0 +1,23 @@ +parameters['voucher_id']; + } + + /** + * @param int $voucher_id + * @return $this + */ + public function setVoucherId(int $voucher_id) + { + $this->parameters['voucher_id'] = $voucher_id; + + return $this; + } +} diff --git a/src/Nodes/Voucher/Voucher.php b/src/Nodes/Voucher/Voucher.php new file mode 100644 index 0000000..c818380 --- /dev/null +++ b/src/Nodes/Voucher/Voucher.php @@ -0,0 +1,75 @@ +post('/api/v2/voucher/add_voucher', ClientV2::API_TYPE_SHOP, $parameters); + } + + + + /** + * Use this api to delete one discount activity BEFORE it starts. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteVoucher($parameters = []): ResponseData + { + return $this->post('/api/v2/voucher/delete_voucher', ClientV2::API_TYPE_SHOP, $parameters); + } + + + + /** + * Use this api to get one shop discount activity detail. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getVoucherDetail($parameters = []): ResponseData + { + return $this->get('/api/v2/voucher/get_voucher', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to get shop discount activity list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getVoucherList($parameters = []): ResponseData + { + return $this->get('/api/v2/voucher/get_voucher_list', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to update one discount information + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateVoucher($parameters = []): ResponseData + { + return $this->post('/api/v2/voucher/update_voucher', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function endVoucher($parameters = []): ResponseData + { + return $this->post('/api/v2/voucher/end_voucher', ClientV2::API_TYPE_SHOP, $parameters); + } +} From 29fec9044f3082ba7df94813afd4fab5b69e8a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Tue, 6 Aug 2024 20:26:02 +0700 Subject: [PATCH 74/89] remove require time id --- src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php index 71694c2..b35683c 100755 --- a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php +++ b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php @@ -24,7 +24,7 @@ public function setAddressId(int $address_id) * @return $this */ - public function setPickupTimeId(string $pickup_time_id) + public function setPickupTimeId($pickup_time_id) { $this->parameters['pickup_time_id'] = $pickup_time_id; return $this; From 5c679d59efbfe08b5c9567e120ddba416b48715d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 7 Aug 2024 08:40:43 +0700 Subject: [PATCH 75/89] update shpoee --- src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php index b35683c..16f99f0 100755 --- a/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php +++ b/src/Nodes/Logistics/Parameters/ShipOrderPickupInput.php @@ -26,7 +26,7 @@ public function setAddressId(int $address_id) public function setPickupTimeId($pickup_time_id) { - $this->parameters['pickup_time_id'] = $pickup_time_id; + $this->parameters['pickup_time_id'] = $pickup_time_id? ((string)$pickup_time_id ): null; return $this; } /** From f718c22ef188b2d4a6a927d42202535532cea0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 7 Aug 2024 16:16:01 +0700 Subject: [PATCH 76/89] update new request method --- src/ClientV2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index adf2cc3..2b77760 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -271,7 +271,7 @@ protected function signature($uri, $api_type): string * @param array $data * @return RequestInterface */ - public function newRequest($uri, $api_type, array $headers = [], $data = []): RequestInterface + public function newRequest($uri, $api_type, array $headers = [], $data = [], $method = 'POST'): RequestInterface { $uri = Utils::uriFor($uri); $auth_query = $this->signature($uri, $api_type); @@ -290,7 +290,7 @@ public function newRequest($uri, $api_type, array $headers = [], $data = []): Re $headers['Content-Type'] = 'application/json'; return new Request( - 'POST', // All APIs should use POST method + $method, // All APIs should use POST method $uri, $headers, $jsonBody From 129202c87ac1f1c0a258f2b118c4b1e6cc0ac2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Wed, 7 Aug 2024 17:30:08 +0700 Subject: [PATCH 77/89] Revert "update new request method" This reverts commit f718c22ef188b2d4a6a927d42202535532cea0d0. --- src/ClientV2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ClientV2.php b/src/ClientV2.php index 2b77760..adf2cc3 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -271,7 +271,7 @@ protected function signature($uri, $api_type): string * @param array $data * @return RequestInterface */ - public function newRequest($uri, $api_type, array $headers = [], $data = [], $method = 'POST'): RequestInterface + public function newRequest($uri, $api_type, array $headers = [], $data = []): RequestInterface { $uri = Utils::uriFor($uri); $auth_query = $this->signature($uri, $api_type); @@ -290,7 +290,7 @@ public function newRequest($uri, $api_type, array $headers = [], $data = [], $me $headers['Content-Type'] = 'application/json'; return new Request( - $method, // All APIs should use POST method + 'POST', // All APIs should use POST method $uri, $headers, $jsonBody From 5bbb56ad39f7b8f9e1a1545ed873ebed852d9a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 15 Aug 2024 15:41:30 +0700 Subject: [PATCH 78/89] update ship order --- src/Nodes/Logistics/Logistics.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index 52bfda8..d155e39 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -114,4 +114,15 @@ public function getTrackingInfo($parameters = []): ResponseData { return $this->get('/api/v2/logistics/get_tracking_info', ClientV2::API_TYPE_SHOP, $parameters); } + + /** + * Get return list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateShipOrder($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/update_shipping_order', ClientV2::API_TYPE_SHOP, $parameters); + } } From 8497106d9f9f5fbe972c6b5e6712e10f50fcd5ee Mon Sep 17 00:00:00 2001 From: quanglx Date: Fri, 16 Aug 2024 15:45:10 +0700 Subject: [PATCH 79/89] UT01-1129 --- src/Nodes/AddOnDeal/AddOnDeal.php | 126 ++++++++++++++++++ .../AddOnDeal/Parameters/AddAddOnDeal.php | 120 +++++++++++++++++ .../Parameters/AddAddOnDealMainItem.php | 28 ++++ .../Parameters/AddAddOnDealSubItem.php | 27 ++++ .../AddOnDeal/Parameters/AddOnDealTrait.php | 22 +++ .../AddOnDeal/Parameters/DeleteAddOnDeal.php | 10 ++ .../Parameters/DeleteAddOnDealMainItem.php | 26 ++++ .../Parameters/DeleteAddOnDealSubItem.php | 26 ++++ .../AddOnDeal/Parameters/EndAddOnDeal.php | 10 ++ .../AddOnDeal/Parameters/GetAddOnDeal.php | 10 ++ .../AddOnDeal/Parameters/GetAddOnDealList.php | 56 ++++++++ .../Parameters/GetAddOnDealMainItem.php | 10 ++ .../Parameters/GetAddOnDealSubItem.php | 10 ++ src/Nodes/AddOnDeal/Parameters/MainItem.php | 41 ++++++ .../AddOnDeal/Parameters/MainItemList.php | 34 +++++ src/Nodes/AddOnDeal/Parameters/SubItem.php | 89 +++++++++++++ .../AddOnDeal/Parameters/SubItemList.php | 33 +++++ .../AddOnDeal/Parameters/UpdateAddOnDeal.php | 121 +++++++++++++++++ .../Parameters/UpdateAddOnDealMainItem.php | 28 ++++ .../Parameters/UpdateAddOnDealSubItem.php | 28 ++++ 20 files changed, 855 insertions(+) create mode 100644 src/Nodes/AddOnDeal/AddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/AddAddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/AddAddOnDealMainItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php create mode 100644 src/Nodes/AddOnDeal/Parameters/AddOnDealTrait.php create mode 100755 src/Nodes/AddOnDeal/Parameters/DeleteAddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/DeleteAddOnDealMainItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/DeleteAddOnDealSubItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/EndAddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/GetAddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/GetAddOnDealList.php create mode 100755 src/Nodes/AddOnDeal/Parameters/GetAddOnDealMainItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/GetAddOnDealSubItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/MainItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/MainItemList.php create mode 100755 src/Nodes/AddOnDeal/Parameters/SubItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/SubItemList.php create mode 100755 src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php create mode 100755 src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealMainItem.php create mode 100755 src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealSubItem.php diff --git a/src/Nodes/AddOnDeal/AddOnDeal.php b/src/Nodes/AddOnDeal/AddOnDeal.php new file mode 100644 index 0000000..0613c5d --- /dev/null +++ b/src/Nodes/AddOnDeal/AddOnDeal.php @@ -0,0 +1,126 @@ +post('/api/v2/add_on_deal/add_add_on_deal', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to add shop discount item. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function addAddOnDealMainItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/add_add_on_deal_main_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to delete one discount activity BEFORE it starts. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function addAddOnDealSubItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/add_add_on_deal_sub_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to delete items of the discount activity. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteAddOnDeal($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/delete_add_on_deal', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to get one shop discount activity detail. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteAddOnDealMainItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/delete_add_on_deal_main_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to get shop discount activity list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteAddOnDealSubItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/delete_add_on_deal_sub_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to update one discount information + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateAddOnDeal($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/update_add_on_deal', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to update items of the discount activity. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateAddOnDealMainItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/update_add_on_deal_main_item', ClientV2::API_TYPE_SHOP, $parameters); + } + public function updateAddOnDealSubItem($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/update_add_on_deal_sub_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function endAddOnDeal($parameters = []): ResponseData + { + return $this->post('/api/v2/add_on_deal/end_add_on_deal', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getAddOnDealList($parameters = []): ResponseData + { + return $this->get('/api/v2/add_on_deal/get_add_on_deal_list', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getAddOnDeal($parameters = []): ResponseData + { + return $this->get('/api/v2/add_on_deal/get_add_on_deal', ClientV2::API_TYPE_SHOP, $parameters); + } + public function getAddOnDealMainItem($parameters = []): ResponseData + { + return $this->get('/api/v2/add_on_deal/get_add_on_deal_main_item', ClientV2::API_TYPE_SHOP, $parameters); + } + public function getAddOnDealSubItem($parameters = []): ResponseData + { + return $this->get('/api/v2/add_on_deal/get_add_on_deal_sub_item', ClientV2::API_TYPE_SHOP, $parameters); + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/AddAddOnDeal.php b/src/Nodes/AddOnDeal/Parameters/AddAddOnDeal.php new file mode 100755 index 0000000..f51aa7f --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/AddAddOnDeal.php @@ -0,0 +1,120 @@ +parameters['add_on_deal_name']; + } + + /** + * @param string $add_on_deal_name + * @return $this + */ + public function setAddOnDealName(string $add_on_deal_name) + { + $this->parameters['add_on_deal_name'] = $add_on_deal_name; + return $this; + } + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } + + public function getPromotionType(): int + { + return $this->parameters['promotion_type']; + } + + /** + * @param int $promotion_type + * @return $this + */ + public function setPromotionType(int $promotion_type) + { + $this->parameters['promotion_type'] = $promotion_type; + + return $this; + } + + public function getPuschaseMinSpend(): float + { + return $this->parameters['purchase_min_spend']; + } + + /** + * @param float $purchase_min_spend + * @return $this + */ + public function setPuschaseMinSpend(float $purchase_min_spend) + { + $this->parameters['purchase_min_spend'] = $purchase_min_spend; + + return $this; + } + + public function getPerGiftNum(): int + { + return $this->parameters['per_gift_num']; + } + + /** + * @param int $per_gift_num + * @return $this + */ + public function setPerGiftNum(int $per_gift_num) + { + $this->parameters['per_gift_num'] = $per_gift_num; + + return $this; + } + + public function getPromotionPurchaseLimit(): int + { + return $this->parameters['promotion_purchase_limit']; + } + + /** + * @param int $promotion_purchase_limit + * @return $this + */ + public function setPromotionPurchaseLimit(int $promotion_purchase_limit) + { + $this->parameters['promotion_purchase_limit'] = $promotion_purchase_limit; + + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/AddAddOnDealMainItem.php b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealMainItem.php new file mode 100755 index 0000000..1d15449 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealMainItem.php @@ -0,0 +1,28 @@ +parameters['main_item_list']; + } + + /** + * + * @param MainItemList $main_item_list + * @return $this + */ + public function setMainItemList(MainItemList $main_item_list) + { + $this->parameters['main_item_list'] = $main_item_list; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php new file mode 100755 index 0000000..c277f88 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php @@ -0,0 +1,27 @@ +parameters['sub_item_list']; + } + + /** + * + * @param SubItemList $sub_item_list + * @return $this + */ + public function setSubItemList(SubItemList $sub_item_list) + { + $this->parameters['sub_item_list'] = $sub_item_list; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/AddOnDealTrait.php b/src/Nodes/AddOnDeal/Parameters/AddOnDealTrait.php new file mode 100644 index 0000000..c34c266 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/AddOnDealTrait.php @@ -0,0 +1,22 @@ +parameters['add_on_deal_id']; + } + + /** + * @param int $add_on_deal_id + * @return $this + */ + public function setAddOnDealId(int $add_on_deal_id) + { + $this->parameters['add_on_deal_id'] = $add_on_deal_id; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDeal.php b/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDeal.php new file mode 100755 index 0000000..f91a091 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDeal.php @@ -0,0 +1,10 @@ +parameters['main_item_list']; + } + + /** + * @param array $main_item_list + * @return $this + */ + public function setMainItemList(array $main_item_list) + { + $this->parameters['main_item_list'] = $main_item_list; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDealSubItem.php b/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDealSubItem.php new file mode 100755 index 0000000..0654579 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/DeleteAddOnDealSubItem.php @@ -0,0 +1,26 @@ +parameters['sub_item_list']; + } + + /** + * @param $sub_item_list + * @return $this + */ + public function setMainItemList(SubItemList $sub_item_list) + { + $this->parameters['sub_item_list'] = $sub_item_list; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/EndAddOnDeal.php b/src/Nodes/AddOnDeal/Parameters/EndAddOnDeal.php new file mode 100755 index 0000000..202e122 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/EndAddOnDeal.php @@ -0,0 +1,10 @@ +parameters['promotion_status']; + } + + /** + * @param string $promotion_status + * @return $this + */ + public function setPromotionStatus(string $promotion_status) + { + $this->parameters['promotion_status'] = $promotion_status; + + return $this; + } + + public function getPageNo(): int + { + return $this->parameters['page_no']; + } + + /** + * @param int $page_no + * @return $this + */ + public function setPageNo(int $page_no) + { + $this->parameters['page_no'] = $page_no; + + return $this; + } + + public function getPageSize(): int + { + return $this->parameters['page_size']; + } + + /** + * @param int $page_size + * @return $this + */ + public function setPageSize(int $page_size) + { + $this->parameters['page_size'] = $page_size; + + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/GetAddOnDealMainItem.php b/src/Nodes/AddOnDeal/Parameters/GetAddOnDealMainItem.php new file mode 100755 index 0000000..4bd762d --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/GetAddOnDealMainItem.php @@ -0,0 +1,10 @@ +parameters['item_id']; + } + + /** + * @param int $item_id + * @return $this + */ + public function setItemId(int $item_id) + { + $this->parameters['item_id'] = $item_id; + + return $this; + } + + public function getStatus(): int + { + return $this->parameters['status']; + } + + /** + * @param int $status + * @return $this + */ + public function setStatus(int $status) + { + $this->parameters['status'] = $status; + + return $this; + } + +} diff --git a/src/Nodes/AddOnDeal/Parameters/MainItemList.php b/src/Nodes/AddOnDeal/Parameters/MainItemList.php new file mode 100755 index 0000000..51f4db3 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/MainItemList.php @@ -0,0 +1,34 @@ +add(new MainItem($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/SubItem.php b/src/Nodes/AddOnDeal/Parameters/SubItem.php new file mode 100755 index 0000000..940b8bc --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/SubItem.php @@ -0,0 +1,89 @@ +parameters['item_id']; + } + + /** + * @param int $item_id + * @return $this + */ + public function setItemId(int $item_id) + { + $this->parameters['item_id'] = $item_id; + + return $this; + } + + public function getModelId(): int + { + return $this->parameters['model_id']; + } + + /** + * @param int $model_id + * @return $this + */ + public function setModelId(int $model_id) + { + $this->parameters['model_id'] = $model_id; + + return $this; + } + + public function getStatus(): int + { + return $this->parameters['status']; + } + + /** + * @param int $status + * @return $this + */ + public function setStatus(int $status) + { + $this->parameters['status'] = $status; + + return $this; + } + + public function getSubItemInputPrice(): float + { + return $this->parameters['sub_item_input_price']; + } + + /** + * @param float $sub_item_input_price + * @return $this + */ + public function setSubItemInputPrice(float $sub_item_input_price) + { + $this->parameters['sub_item_input_price'] = $sub_item_input_price; + + return $this; + } + + public function getSubItemLimit(): float + { + return $this->parameters['sub_item_limit']; + } + + /** + * @param float $sub_item_limit + * @return $this + */ + public function setSubItemLimit(float $sub_item_limit) + { + $this->parameters['sub_item_limit'] = $sub_item_limit; + + return $this; + } + +} diff --git a/src/Nodes/AddOnDeal/Parameters/SubItemList.php b/src/Nodes/AddOnDeal/Parameters/SubItemList.php new file mode 100755 index 0000000..c181095 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/SubItemList.php @@ -0,0 +1,33 @@ +add(new SubItem($parameter)); + } + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php new file mode 100755 index 0000000..c43afeb --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php @@ -0,0 +1,121 @@ +parameters['add_on_deal_name']; + } + + /** + * @param string $add_on_deal_name + * @return $this + */ + public function setAddOnDealName(string $add_on_deal_name) + { + $this->parameters['add_on_deal_name'] = $add_on_deal_name; + return $this; + } + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } + + public function getPuschaseMinSpend(): float + { + return $this->parameters['purchase_min_spend']; + } + + /** + * @param float $purchase_min_spend + * @return $this + */ + public function setPuschaseMinSpend(float $purchase_min_spend) + { + $this->parameters['purchase_min_spend'] = $purchase_min_spend; + + return $this; + } + + public function getPerGiftNum(): int + { + return $this->parameters['per_gift_num']; + } + + /** + * @param int $per_gift_num + * @return $this + */ + public function setPerGiftNum(int $per_gift_num) + { + $this->parameters['per_gift_num'] = $per_gift_num; + + return $this; + } + + public function getPromotionPurchaseLimit(): int + { + return $this->parameters['promotion_purchase_limit']; + } + + /** + * @param int $promotion_purchase_limit + * @return $this + */ + public function setPromotionPurchaseLimit(int $promotion_purchase_limit) + { + $this->parameters['promotion_purchase_limit'] = $promotion_purchase_limit; + + return $this; + } + + public function getSubItemPriority(): array + { + return $this->parameters['sub_item_priority']; + } + + /** + * @param array $sub_item_priority + * @return $this + */ + public function setSubItemPriority(array $sub_item_priority) + { + $this->parameters['sub_item_priority'] = $sub_item_priority; + + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealMainItem.php b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealMainItem.php new file mode 100755 index 0000000..8cf5506 --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealMainItem.php @@ -0,0 +1,28 @@ +parameters['main_item_list']; + } + + /** + * + * @param MainItemList $main_item_list + * @return $this + */ + public function setMainItemList(MainItemList $main_item_list) + { + $this->parameters['main_item_list'] = $main_item_list; + return $this; + } +} diff --git a/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealSubItem.php b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealSubItem.php new file mode 100755 index 0000000..ad39a8f --- /dev/null +++ b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDealSubItem.php @@ -0,0 +1,28 @@ +parameters['main_item_list']; + } + + /** + * + * @param SubItemList $main_item_list + * @return $this + */ + public function setSubItemList(SubItemList $main_item_list) + { + $this->parameters['main_item_list'] = $main_item_list; + return $this; + } +} From 8530aed4f90213ff0074b03913ecec8df4685a3b Mon Sep 17 00:00:00 2001 From: quanglx Date: Mon, 19 Aug 2024 14:33:10 +0700 Subject: [PATCH 80/89] 1129 --- src/Nodes/AddOnDeal/AddOnDeal.php | 18 +++++++++--------- .../AddOnDeal/Parameters/AddAddOnDeal.php | 12 ++++++------ .../Parameters/AddAddOnDealSubItem.php | 2 +- .../AddOnDeal/Parameters/UpdateAddOnDeal.php | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Nodes/AddOnDeal/AddOnDeal.php b/src/Nodes/AddOnDeal/AddOnDeal.php index 0613c5d..1586cff 100644 --- a/src/Nodes/AddOnDeal/AddOnDeal.php +++ b/src/Nodes/AddOnDeal/AddOnDeal.php @@ -1,6 +1,6 @@ parameters['purchase_min_spend'] = $purchase_min_spend; @@ -92,10 +92,10 @@ public function getPerGiftNum(): int } /** - * @param int $per_gift_num + * @param int|null $per_gift_num * @return $this */ - public function setPerGiftNum(int $per_gift_num) + public function setPerGiftNum($per_gift_num) { $this->parameters['per_gift_num'] = $per_gift_num; @@ -108,10 +108,10 @@ public function getPromotionPurchaseLimit(): int } /** - * @param int $promotion_purchase_limit + * @param int|null $promotion_purchase_limit * @return $this */ - public function setPromotionPurchaseLimit(int $promotion_purchase_limit) + public function setPromotionPurchaseLimit($promotion_purchase_limit) { $this->parameters['promotion_purchase_limit'] = $promotion_purchase_limit; diff --git a/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php index c277f88..11ce954 100755 --- a/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php +++ b/src/Nodes/AddOnDeal/Parameters/AddAddOnDealSubItem.php @@ -4,7 +4,7 @@ use Shopee\RequestParameters; -class AddAddOnDealMainItem extends RequestParameters +class AddAddOnDealSubItem extends RequestParameters { use AddOnDealTrait; diff --git a/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php index c43afeb..0eb957a 100755 --- a/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php +++ b/src/Nodes/AddOnDeal/Parameters/UpdateAddOnDeal.php @@ -96,7 +96,7 @@ public function getPromotionPurchaseLimit(): int * @param int $promotion_purchase_limit * @return $this */ - public function setPromotionPurchaseLimit(int $promotion_purchase_limit) + public function setPromotionPurchaseLimit($promotion_purchase_limit) { $this->parameters['promotion_purchase_limit'] = $promotion_purchase_limit; From c6bc16c8f62070c1242d4ae18e52f87dc56c2eeb Mon Sep 17 00:00:00 2001 From: quanglx Date: Mon, 19 Aug 2024 14:48:11 +0700 Subject: [PATCH 81/89] 1129 --- src/ClientV2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ClientV2.php b/src/ClientV2.php index adf2cc3..cdbbf53 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -152,6 +152,7 @@ public function __construct(array $config = []) $this->nodes['discount'] = new Nodes\Discount\Discount($this); $this->nodes['chat'] = new Nodes\Chat\Chat($this); $this->nodes['voucher'] = new Nodes\Voucher\Voucher($this); + $this->nodes['add_on_deal'] = new Nodes\AddOnDeal\AddOnDeal($this); } From bb37db5c8bb870e0afff52e6aed0eeecaf9d9c49 Mon Sep 17 00:00:00 2001 From: quanglx Date: Mon, 16 Sep 2024 09:41:56 +0700 Subject: [PATCH 82/89] add get_shipping_document_data_info --- src/Nodes/Logistics/Logistics.php | 4 + .../GetShippingDocumentDataInfo.php | 42 +++++++++ .../Parameters/RecipientAddressInfo.php | 34 +++++++ .../Parameters/StyleShippingDocument.php | 88 +++++++++++++++++++ 4 files changed, 168 insertions(+) create mode 100755 src/Nodes/Logistics/Parameters/GetShippingDocumentDataInfo.php create mode 100755 src/Nodes/Logistics/Parameters/RecipientAddressInfo.php create mode 100755 src/Nodes/Logistics/Parameters/StyleShippingDocument.php diff --git a/src/Nodes/Logistics/Logistics.php b/src/Nodes/Logistics/Logistics.php index d155e39..936620b 100755 --- a/src/Nodes/Logistics/Logistics.php +++ b/src/Nodes/Logistics/Logistics.php @@ -125,4 +125,8 @@ public function updateShipOrder($parameters = []): ResponseData { return $this->post('/api/v2/logistics/update_shipping_order', ClientV2::API_TYPE_SHOP, $parameters); } + public function getShippingDocumentDataInfo($parameters = []): ResponseData + { + return $this->post('/api/v2/logistics/get_shipping_document_data_info', ClientV2::API_TYPE_SHOP, $parameters); + } } diff --git a/src/Nodes/Logistics/Parameters/GetShippingDocumentDataInfo.php b/src/Nodes/Logistics/Parameters/GetShippingDocumentDataInfo.php new file mode 100755 index 0000000..2f153b7 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/GetShippingDocumentDataInfo.php @@ -0,0 +1,42 @@ +parameters['order_sn'] = $order_sn; + return $this; + } + /** + * @param string $package_number + * @return $this + */ + + public function setPackageNumber(string $package_number) + { + $this->parameters['package_number'] = $package_number; + return $this; + } + /** + * @param RecipientAddressInfo[] $recipient_address_infos + * @return $this + */ + public function setRecipientAddressInfo($recipient_address_infos) + { + foreach ($recipient_address_infos as $recipient_address_info) { + $this->parameters['recipient_address_info'][] = $recipient_address_info->toArray(); + } + return $this; + } + +} diff --git a/src/Nodes/Logistics/Parameters/RecipientAddressInfo.php b/src/Nodes/Logistics/Parameters/RecipientAddressInfo.php new file mode 100755 index 0000000..03e7115 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/RecipientAddressInfo.php @@ -0,0 +1,34 @@ +parameters['key']; + } + + /** + * @param bool $key + * @return $this + */ + public function setKey(string $key) + { + $this->parameters['key'] = $key; + + return $this; + } + // /** + // * @param StyleShippingDocument[] $recipient_address_info + // * @return $this + // */ + public function setStyleShippingDocument(StyleShippingDocument $recipient_address_info) + { + $this->parameters['style'] = $recipient_address_info->toArray(); + return $this; + } +} diff --git a/src/Nodes/Logistics/Parameters/StyleShippingDocument.php b/src/Nodes/Logistics/Parameters/StyleShippingDocument.php new file mode 100755 index 0000000..3397c39 --- /dev/null +++ b/src/Nodes/Logistics/Parameters/StyleShippingDocument.php @@ -0,0 +1,88 @@ +parameters['text_style']; + } + + /** + * @param bool $text_style + * @return $this + */ + public function setTextStyle(Array $text_style) + { + $this->parameters['text_style'] = $text_style; + + return $this; + } + + public function getFontSize(): bool + { + return $this->parameters['font_size']; + } + + /** + * @param bool $font_size + * @return $this + */ + public function setFontSize(Int $font_size) + { + $this->parameters['font_size'] = $font_size; + + return $this; + } + + public function getTextColor(): bool + { + return $this->parameters['text_color']; + } + + /** + * @param bool $text_color + * @return $this + */ + public function setTextColor(String $text_color) + { + $this->parameters['text_color'] = $text_color; + + return $this; + } + + public function getImageWidth(): bool + { + return $this->parameters['image_width']; + } + + /** + * @param bool $image_width + * @return $this + */ + public function setImageWidth(Int $image_width) + { + $this->parameters['image_width'] = $image_width; + + return $this; + } + + public function getHAlign(): bool + { + return $this->parameters['h_align']; + } + + /** + * @param bool $h_align + * @return $this + */ + public function setHAlign(String $h_align) + { + $this->parameters['h_align'] = $h_align; + + return $this; + } +} From 0ecf7deea95c1756468078d802d3e1988e9c58cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 31 Oct 2024 09:51:13 +0700 Subject: [PATCH 83/89] add shopee tree --- src/Nodes/Item/Attribute.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nodes/Item/Attribute.php b/src/Nodes/Item/Attribute.php index 2da7caf..056df4b 100755 --- a/src/Nodes/Item/Attribute.php +++ b/src/Nodes/Item/Attribute.php @@ -23,4 +23,8 @@ public function getAttributes($parameters = []): ResponseData { public function getVariantAttributes($parameters = []): ResponseData { return $this->get("/api/v2/product/get_variation_tree", ClientV2::API_TYPE_SHOP, $parameters); } + + public function getTreeAttributes($parameters = []): ResponseData { + return $this->get("/api/v2/product/get_attributes", ClientV2::API_TYPE_SHOP, $parameters); + } } From 10bf6a50201a9668751a1818b90ec8deee25cc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 31 Oct 2024 11:47:02 +0700 Subject: [PATCH 84/89] add api get attribute tree --- src/Nodes/Item/Attribute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nodes/Item/Attribute.php b/src/Nodes/Item/Attribute.php index 056df4b..bc7c835 100755 --- a/src/Nodes/Item/Attribute.php +++ b/src/Nodes/Item/Attribute.php @@ -25,6 +25,6 @@ public function getVariantAttributes($parameters = []): ResponseData { } public function getTreeAttributes($parameters = []): ResponseData { - return $this->get("/api/v2/product/get_attributes", ClientV2::API_TYPE_SHOP, $parameters); + return $this->get("/api/v2/product/get_attribute_tree", ClientV2::API_TYPE_SHOP, $parameters); } } From e7c2401d2a8f33c0a8b55465adf20c379c67ee10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linh=20Pha=CC=A3m?= Date: Thu, 21 Nov 2024 10:08:31 +0700 Subject: [PATCH 85/89] add api item limit --- src/Nodes/Item/Category.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nodes/Item/Category.php b/src/Nodes/Item/Category.php index 45c3554..60fe7ac 100755 --- a/src/Nodes/Item/Category.php +++ b/src/Nodes/Item/Category.php @@ -38,4 +38,8 @@ public function getCategoryRecommend($parameters = []): ResponseData { public function checkSupportChart($parameters = []): ResponseData { return $this->get("/api/v2/product/support_size_chart", ClientV2::API_TYPE_SHOP, $parameters); } + + public function getItemLimit($parameters = []): ResponseData { + return $this->get("/api/v2/product/get_item_limit", ClientV2::API_TYPE_SHOP, $parameters); + } } From b2572dc93fdfbea57798f9370941d996d7d8bd17 Mon Sep 17 00:00:00 2001 From: huongpv Date: Thu, 28 Nov 2024 10:08:30 +0700 Subject: [PATCH 86/89] add node connect ads --- .DS_Store | Bin 0 -> 6148 bytes src/.DS_Store | Bin 0 -> 6148 bytes src/Client.php | 1 + src/ClientV2.php | 1 + src/Nodes/.DS_Store | Bin 0 -> 6148 bytes src/Nodes/Ads/.DS_Store | Bin 0 -> 6148 bytes src/Nodes/Ads/Ads.php | 34 ++++++++++++++++++ .../Parameters/GetCqcAdsDailyPerformance.php | 27 ++++++++++++++ 8 files changed, 63 insertions(+) create mode 100644 .DS_Store create mode 100644 src/.DS_Store create mode 100644 src/Nodes/.DS_Store create mode 100644 src/Nodes/Ads/.DS_Store create mode 100644 src/Nodes/Ads/Ads.php create mode 100644 src/Nodes/Ads/Parameters/GetCqcAdsDailyPerformance.php diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9a874b5768f336915163bb88cd434575b859f936 GIT binary patch literal 6148 zcmeH~Jr2S!425ml0g0s}V-^m;4I%_5-~tF3k&vj^b9A16778<}(6eNJu~Vz<8=6`~ zboab&MFtUB!i}=AFfm2m$tVxGT*u4pe81nUlA49C} z?O@64YO)2RT{MRe%{!}2F))pG(Sih~)xkgosK7*lF7m<7{{#Hn{6A@7N(HFEpDCdI z{l&S!y&|Jxk7uop^q} zVloC`hx@Pxwg5JCSL}S4m@!`C3nK>n;x^oVuHWN$^)wc_*8@7Q@w}eP5)lvq5fA|p z5P=yHh(ny`|Hq7;Nsl4|A}|jE{(UHP*P7b8#;1crv;fo<(_x%PFF`Gypw`sZl^L34 z_h4CS(S~?F%Bdyy)zsFtm&3C8u)MQ*7eljN4l4|3Rzoz1fCx+oEPK55^Z!JD)&EaQ z6pDZd{4)Z!I-ZXQzEqyAe_qe?m(2RS(W$YW!_!Xy13!vC>0w+iKB3ms)|DBWegp!8 J1`&8Gfd{^16LJ6m literal 0 HcmV?d00001 diff --git a/src/Client.php b/src/Client.php index d9999e8..2df4104 100644 --- a/src/Client.php +++ b/src/Client.php @@ -116,6 +116,7 @@ public function __construct(array $config = []) $this->nodes['image'] = new Nodes\Image\Image($this); $this->nodes['push'] = new Nodes\Push\Push($this); $this->nodes['payment'] = new Nodes\Payment\Payment($this); + $this->nodes['ads'] = new Nodes\Ads\Ads($this); } public function __get(string $name) diff --git a/src/ClientV2.php b/src/ClientV2.php index cdbbf53..00ce9ed 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -153,6 +153,7 @@ public function __construct(array $config = []) $this->nodes['chat'] = new Nodes\Chat\Chat($this); $this->nodes['voucher'] = new Nodes\Voucher\Voucher($this); $this->nodes['add_on_deal'] = new Nodes\AddOnDeal\AddOnDeal($this); + $this->nodes['ads'] = new Nodes\Ads\Ads($this); } diff --git a/src/Nodes/.DS_Store b/src/Nodes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9ef028a2536418bf8d379afdc1b379cb4e1bc953 GIT binary patch literal 6148 zcmeH~Jr2S!425mzfW*>~F$)La1_8kdxB!BVl^76vj?VMXLSaS~dY0@jc51bKLsN^0 z9-hNaq!*DD+$dWM6I0|%*~=i0;c*+U_xoriw?)zl@LneSxlK?3DnJFO02QDDGg2TA z^3{4q&%{Te0#slg3fT9dz>PK8g8u11@DTv)PHbbJCO%b0V?n)3fT9dzzu8S6zHE04Bi3&mk7II z?!5%CSO8cPr$9tt8dP9VHCqe~I^resYT^_abkS@+G;h}IP}Fb7`Nh*kYamA|Km{%p zc#7r5>i;YJM*n|F;))7TfrnB+m)%>};z?OsXOFX5Tj1|-%Q?Z#Fn0c7 ee)gouD>lb|O`HOqj=0l-{24G^XjI_86*vQ-n-z}$ literal 0 HcmV?d00001 diff --git a/src/Nodes/Ads/Ads.php b/src/Nodes/Ads/Ads.php new file mode 100644 index 0000000..e74eb24 --- /dev/null +++ b/src/Nodes/Ads/Ads.php @@ -0,0 +1,34 @@ +get("/api/v2/ads/get_all_cpc_ads_daily_performance", ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getCPCAdsHourlyPerformance($parameters = []): ResponseData + { + return $this->get("/api/v2/ads/get_all_cpc_ads_hourly_performance", ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getProductCampainDailyPerformance($parameters = []): ResponseData + { + return $this->get("/api/v2/ads/get_product_campaign_daily_performance", ClientV2::API_TYPE_SHOP, $parameters); + } + +} diff --git a/src/Nodes/Ads/Parameters/GetCqcAdsDailyPerformance.php b/src/Nodes/Ads/Parameters/GetCqcAdsDailyPerformance.php new file mode 100644 index 0000000..9e1b928 --- /dev/null +++ b/src/Nodes/Ads/Parameters/GetCqcAdsDailyPerformance.php @@ -0,0 +1,27 @@ +parameters['start_date'] = $start_date; + } + public function setStartDate($start_date) + { + $this->parameters['start_date'] = $start_date; + return $this; + } + public function getEndDate($start_date) + { + return $this->parameters['end_date'] = $start_date; + } + public function setEndDate($start_date) + { + $this->parameters['end_date'] = $start_date; + return $this; + } +} \ No newline at end of file From f1eedd3519d95f0a81085787123e464042e6caed Mon Sep 17 00:00:00 2001 From: quanglx Date: Tue, 10 Dec 2024 16:59:18 +0700 Subject: [PATCH 87/89] flash sale shopee --- src/ClientV2.php | 2 +- src/Nodes/FlashSale/FlashSale.php | 108 ++++++++++++++++++ .../Parameters/AddFlashSaleItems.php | 28 +++++ .../Parameters/DeleteFlashSaleItems.php | 15 +++ .../FlashSale/Parameters/FlashSaleItem.php | 57 +++++++++ .../Parameters/FlashSaleItemList.php | 34 ++++++ .../FlashSale/Parameters/FlashSaleTrait.php | 23 ++++ src/Nodes/FlashSale/Parameters/ItemModel.php | 61 ++++++++++ .../FlashSale/Parameters/ItemModelList.php | 35 ++++++ .../FlashSale/Parameters/UpdateFlashSale.php | 59 ++++++++++ 10 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 src/Nodes/FlashSale/FlashSale.php create mode 100755 src/Nodes/FlashSale/Parameters/AddFlashSaleItems.php create mode 100755 src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php create mode 100755 src/Nodes/FlashSale/Parameters/FlashSaleItem.php create mode 100755 src/Nodes/FlashSale/Parameters/FlashSaleItemList.php create mode 100644 src/Nodes/FlashSale/Parameters/FlashSaleTrait.php create mode 100755 src/Nodes/FlashSale/Parameters/ItemModel.php create mode 100755 src/Nodes/FlashSale/Parameters/ItemModelList.php create mode 100755 src/Nodes/FlashSale/Parameters/UpdateFlashSale.php diff --git a/src/ClientV2.php b/src/ClientV2.php index 00ce9ed..27360d4 100644 --- a/src/ClientV2.php +++ b/src/ClientV2.php @@ -154,7 +154,7 @@ public function __construct(array $config = []) $this->nodes['voucher'] = new Nodes\Voucher\Voucher($this); $this->nodes['add_on_deal'] = new Nodes\AddOnDeal\AddOnDeal($this); $this->nodes['ads'] = new Nodes\Ads\Ads($this); - + $this->nodes['flash_sale'] = new Nodes\FlashSale\FlashSale($this); } public function __get(string $name) diff --git a/src/Nodes/FlashSale/FlashSale.php b/src/Nodes/FlashSale/FlashSale.php new file mode 100644 index 0000000..cfbdd70 --- /dev/null +++ b/src/Nodes/FlashSale/FlashSale.php @@ -0,0 +1,108 @@ +post('/api/v2/shop_flash_sale/create_shop_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to add shop flash_sale item. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function addFlashSaleItem($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/add_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to delete one flash_sale activity BEFORE it starts. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteFlashSale($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/delete_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to delete items of the flash_sale activity. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function deleteFlashSaleItem($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/delete_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to get one shop flash_sale activity detail. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getFlashSaleDetail($parameters = []): ResponseData + { + return $this->get('/api/v2/flash_sale/get_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to get shop flash_sale activity list. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function getFlashSalesList($parameters = []): ResponseData + { + return $this->get('/api/v2/flash_sale/get_flash_sale_list', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to update one flash_sale information + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateFlashSale($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/update_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + /** + * Use this api to update items of the flash_sale activity. + * + * @param array|RequestParametersInterface $parameters + * @return ResponseData + */ + public function updateFlashSaleItems($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/update_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); + } + public function endFlashSale($parameters = []): ResponseData + { + return $this->post('/api/v2/flash_sale/end_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getTimeSlotId($parameters = []): ResponseData + { + return $this->get('/api/v2/shop_flash_sale/get_time_slot_id', ClientV2::API_TYPE_SHOP, $parameters); + } +} diff --git a/src/Nodes/FlashSale/Parameters/AddFlashSaleItems.php b/src/Nodes/FlashSale/Parameters/AddFlashSaleItems.php new file mode 100755 index 0000000..377dbcb --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/AddFlashSaleItems.php @@ -0,0 +1,28 @@ +parameters['items']; + } + + /** + * Name of the FlashSale. + * + * @param FlashSaleItemList $FlashSaleItemList + * @return $this + */ + public function setItemList(FlashSaleItemList $FlashSaleItemList) + { + $this->parameters['items'] = $FlashSaleItemList; + + return $this; + } + +} diff --git a/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php b/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php new file mode 100755 index 0000000..9212ca6 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php @@ -0,0 +1,15 @@ +parameters['purchase_limit']; + } + + /** + * @param int $purchase_limit + * @return $this + */ + public function setPurchaseLimit(int $purchase_limit) + { + $this->parameters['purchase_limit'] = $purchase_limit; + return $this; + } + + public function getItemId(): int + { + return $this->parameters['item_id']; + } + + /** + * @param int $item_id + * @return $this + */ + public function setItemId(int $item_id) + { + $this->parameters['item_id'] = $item_id; + return $this; + } + + public function getModelList(): ItemModelList + { + return $this->parameters['model_list']; + } + + /** + * @param ItemModelList $item_model_list + * @return $this + */ + public function setModelList(ItemModelList $item_model_list) + { + $this->parameters['model_list'] = $item_model_list; + + return $this; + } +} diff --git a/src/Nodes/FlashSale/Parameters/FlashSaleItemList.php b/src/Nodes/FlashSale/Parameters/FlashSaleItemList.php new file mode 100755 index 0000000..4275a13 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/FlashSaleItemList.php @@ -0,0 +1,34 @@ +add(new FlashSaleItem($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php b/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php new file mode 100644 index 0000000..356ab37 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php @@ -0,0 +1,23 @@ +parameters['flase_sale_id']; + } + + /** + * @param int $flase_sale_id + * @return $this + */ + public function setFlashSaleId(int $flase_sale_id) + { + $this->parameters['flase_sale_id'] = $flase_sale_id; + + return $this; + } +} diff --git a/src/Nodes/FlashSale/Parameters/ItemModel.php b/src/Nodes/FlashSale/Parameters/ItemModel.php new file mode 100755 index 0000000..24d0633 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/ItemModel.php @@ -0,0 +1,61 @@ +parameters['input_promo_price']; + } + + /** + * Name of the discount. + * + * @param float $input_promo_price + * @return $this + */ + public function setInputPromoPrice(float $input_promo_price) + { + $this->parameters['input_promo_price'] = $input_promo_price; + + return $this; + } + + public function getStock(): int + { + return $this->parameters['stock']; + } + + /** + * @param int $stock + * @return $this + */ + public function setStock(int $stock) + { + $this->parameters['stock'] = $stock; + + return $this; + } + + public function getModelId(): int + { + return $this->parameters['model_id']; + } + + /** + * @param int $model_id + * @return $this + */ + public function setModelId(int $model_id) + { + $this->parameters['model_id'] = $model_id; + + return $this; + } + +} diff --git a/src/Nodes/FlashSale/Parameters/ItemModelList.php b/src/Nodes/FlashSale/Parameters/ItemModelList.php new file mode 100755 index 0000000..93e4760 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/ItemModelList.php @@ -0,0 +1,35 @@ +add(new ItemModel($parameter)); + } + + return $this; + } +} diff --git a/src/Nodes/FlashSale/Parameters/UpdateFlashSale.php b/src/Nodes/FlashSale/Parameters/UpdateFlashSale.php new file mode 100755 index 0000000..2484870 --- /dev/null +++ b/src/Nodes/FlashSale/Parameters/UpdateFlashSale.php @@ -0,0 +1,59 @@ +parameters['discount_name']; + } + + /** + * Name of the discount. + * + * @param string $name + * @return $this + */ + public function setName(string $name) + { + $this->parameters['discount_name'] = $name; + + return $this; + } + + public function getStartTime(): int + { + return $this->parameters['start_time']; + } + + /** + * @param int $start_time + * @return $this + */ + public function setStartTime(int $start_time) + { + $this->parameters['start_time'] = $start_time; + + return $this; + } + + public function getEndTime(): int + { + return $this->parameters['end_time']; + } + + /** + * @param int $end_time + * @return $this + */ + public function setEndTime(int $end_time) + { + $this->parameters['end_time'] = $end_time; + + return $this; + } +} From 42ba6b866a14d24336a1ba964557433ffb117d48 Mon Sep 17 00:00:00 2001 From: quanglx Date: Thu, 12 Dec 2024 14:04:40 +0700 Subject: [PATCH 88/89] flash_sale --- src/Nodes/FlashSale/FlashSale.php | 26 +++++++++-------- .../FlashSale/Parameters/FlashSaleItem.php | 4 +-- .../FlashSale/Parameters/FlashSaleTrait.php | 4 +-- src/Nodes/FlashSale/Parameters/ItemModel.php | 28 +++++++++++++++---- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/Nodes/FlashSale/FlashSale.php b/src/Nodes/FlashSale/FlashSale.php index cfbdd70..32ef5a2 100644 --- a/src/Nodes/FlashSale/FlashSale.php +++ b/src/Nodes/FlashSale/FlashSale.php @@ -28,7 +28,7 @@ public function createFlashSale($parameters = []): ResponseData */ public function addFlashSaleItem($parameters = []): ResponseData { - return $this->post('/api/v2/flash_sale/add_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop_flash_sale/add_shop_flash_sale_items', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -39,7 +39,7 @@ public function addFlashSaleItem($parameters = []): ResponseData */ public function deleteFlashSale($parameters = []): ResponseData { - return $this->post('/api/v2/flash_sale/delete_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop_flash_sale/delete_shop_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -50,7 +50,7 @@ public function deleteFlashSale($parameters = []): ResponseData */ public function deleteFlashSaleItem($parameters = []): ResponseData { - return $this->post('/api/v2/flash_sale/delete_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop_flash_sale/delete_shop_flash_sale_items', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -59,9 +59,14 @@ public function deleteFlashSaleItem($parameters = []): ResponseData * @param array|RequestParametersInterface $parameters * @return ResponseData */ - public function getFlashSaleDetail($parameters = []): ResponseData + public function getFlashSale($parameters = []): ResponseData { - return $this->get('/api/v2/flash_sale/get_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/shop_flash_sale/get_shop_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + } + + public function getFlashSaleItems($parameters = []): ResponseData + { + return $this->get('/api/v2/shop_flash_sale/get_shop_flash_sale_items', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -72,7 +77,7 @@ public function getFlashSaleDetail($parameters = []): ResponseData */ public function getFlashSalesList($parameters = []): ResponseData { - return $this->get('/api/v2/flash_sale/get_flash_sale_list', ClientV2::API_TYPE_SHOP, $parameters); + return $this->get('/api/v2/shop_flash_sale/get_shop_flash_sale_list', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -83,7 +88,7 @@ public function getFlashSalesList($parameters = []): ResponseData */ public function updateFlashSale($parameters = []): ResponseData { - return $this->post('/api/v2/flash_sale/update_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop_flash_sale/update_shop_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); } /** @@ -94,13 +99,10 @@ public function updateFlashSale($parameters = []): ResponseData */ public function updateFlashSaleItems($parameters = []): ResponseData { - return $this->post('/api/v2/flash_sale/update_flash_sale_item', ClientV2::API_TYPE_SHOP, $parameters); - } - public function endFlashSale($parameters = []): ResponseData - { - return $this->post('/api/v2/flash_sale/end_flash_sale', ClientV2::API_TYPE_SHOP, $parameters); + return $this->post('/api/v2/shop_flash_sale/update_shop_flash_sale_items', ClientV2::API_TYPE_SHOP, $parameters); } + public function getTimeSlotId($parameters = []): ResponseData { return $this->get('/api/v2/shop_flash_sale/get_time_slot_id', ClientV2::API_TYPE_SHOP, $parameters); diff --git a/src/Nodes/FlashSale/Parameters/FlashSaleItem.php b/src/Nodes/FlashSale/Parameters/FlashSaleItem.php index 0e31c81..269e890 100755 --- a/src/Nodes/FlashSale/Parameters/FlashSaleItem.php +++ b/src/Nodes/FlashSale/Parameters/FlashSaleItem.php @@ -41,7 +41,7 @@ public function setItemId(int $item_id) public function getModelList(): ItemModelList { - return $this->parameters['model_list']; + return $this->parameters['models']; } /** @@ -50,7 +50,7 @@ public function getModelList(): ItemModelList */ public function setModelList(ItemModelList $item_model_list) { - $this->parameters['model_list'] = $item_model_list; + $this->parameters['models'] = $item_model_list; return $this; } diff --git a/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php b/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php index 356ab37..8fcbe27 100644 --- a/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php +++ b/src/Nodes/FlashSale/Parameters/FlashSaleTrait.php @@ -7,7 +7,7 @@ trait FlashSaleTrait { public function getFlashSaleId(): int { - return $this->parameters['flase_sale_id']; + return $this->parameters['flash_sale_id']; } /** @@ -16,7 +16,7 @@ public function getFlashSaleId(): int */ public function setFlashSaleId(int $flase_sale_id) { - $this->parameters['flase_sale_id'] = $flase_sale_id; + $this->parameters['flash_sale_id'] = $flase_sale_id; return $this; } diff --git a/src/Nodes/FlashSale/Parameters/ItemModel.php b/src/Nodes/FlashSale/Parameters/ItemModel.php index 24d0633..a5bbee9 100755 --- a/src/Nodes/FlashSale/Parameters/ItemModel.php +++ b/src/Nodes/FlashSale/Parameters/ItemModel.php @@ -26,18 +26,18 @@ public function setInputPromoPrice(float $input_promo_price) return $this; } - public function getStock(): int + public function getStatus(): int { - return $this->parameters['stock']; + return $this->parameters['status']; } /** - * @param int $stock + * @param int $status * @return $this */ - public function setStock(int $stock) + public function setStatus(int $status) { - $this->parameters['stock'] = $stock; + $this->parameters['status'] = $status; return $this; } @@ -58,4 +58,22 @@ public function setModelId(int $model_id) return $this; } + public function getStock(): int + { + return $this->parameters['stock']; + } + + /** + * @param int $stock + * @return $this + */ + public function setStock(int $stock) + { + $this->parameters['stock'] = $stock; + + return $this; + } + + + } From 8f352ec46e7e110fd97c5ff014661f4723f6c0e7 Mon Sep 17 00:00:00 2001 From: quanglx Date: Mon, 16 Dec 2024 11:11:59 +0700 Subject: [PATCH 89/89] flash sale shopee --- .../FlashSale/Parameters/DeleteFlashSaleItems.php | 13 +++++++++++++ src/Nodes/FlashSale/Parameters/ItemModel.php | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php b/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php index 9212ca6..8dadeda 100755 --- a/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php +++ b/src/Nodes/FlashSale/Parameters/DeleteFlashSaleItems.php @@ -11,5 +11,18 @@ class DeleteFlashSaleItems extends RequestParameters use FlashSaleTrait; use ItemTrait; use VariationIdTrait; + /** + * @param int $item_ids + * @return $this + */ + public function setItemIds($item_ids) + { + $this->parameters['item_ids'] = $item_ids; + return $this; + } + public function getItemIds(): int + { + return $this->parameters['item_ids']; + } } diff --git a/src/Nodes/FlashSale/Parameters/ItemModel.php b/src/Nodes/FlashSale/Parameters/ItemModel.php index a5bbee9..e579abe 100755 --- a/src/Nodes/FlashSale/Parameters/ItemModel.php +++ b/src/Nodes/FlashSale/Parameters/ItemModel.php @@ -42,16 +42,16 @@ public function setStatus(int $status) return $this; } - public function getModelId(): int + public function getModelId() { return $this->parameters['model_id']; } /** - * @param int $model_id + * @param $model_id * @return $this */ - public function setModelId(int $model_id) + public function setModelId($model_id) { $this->parameters['model_id'] = $model_id;