From 19ee527a921ac337166b6062be5135b738b0d398 Mon Sep 17 00:00:00 2001 From: nVuln Date: Thu, 6 Jun 2024 13:21:18 +0700 Subject: [PATCH] add: affiliate seller api --- src/Client.php | 3 +++ src/Resources/AffiliateSeller.php | 27 +++++++++++++++++++++ tests/ClientTest.php | 9 ++++++- tests/Resources/AffiliateSellerTest.php | 32 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/Resources/AffiliateSeller.php create mode 100644 tests/Resources/AffiliateSellerTest.php diff --git a/src/Client.php b/src/Client.php index 7839fc9..f072a59 100644 --- a/src/Client.php +++ b/src/Client.php @@ -10,6 +10,7 @@ namespace EcomPHP\TiktokShop; +use EcomPHP\TiktokShop\Resources\AffiliateSeller; use EcomPHP\TiktokShop\Resources\CustomerService; use GuzzleHttp\HandlerStack; use GuzzleHttp\Client as GuzzleHttpClient; @@ -44,6 +45,7 @@ * @property-read Event $Event * @property-read ReturnRefund $ReturnRefund * @property-read CustomerService $CustomerService + * @property-read AffiliateSeller $AffiliateSeller */ class Client { @@ -80,6 +82,7 @@ class Client Event::class, ReturnRefund::class, CustomerService::class, + AffiliateSeller::class, ]; public function __construct($app_key, $app_secret, $options = []) diff --git a/src/Resources/AffiliateSeller.php b/src/Resources/AffiliateSeller.php new file mode 100644 index 0000000..ceea873 --- /dev/null +++ b/src/Resources/AffiliateSeller.php @@ -0,0 +1,27 @@ + All rights reserved. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace EcomPHP\TiktokShop\Resources; + +use EcomPHP\TiktokShop\Resource; +use GuzzleHttp\RequestOptions; + +class AffiliateSeller extends Resource +{ + protected $category = 'affiliate_seller'; + protected $minimum_version = 202405; + + public function editOpenCollaborationSettings($body) + { + return $this->call('POST', 'open_collaboration_settings', [ + RequestOptions::JSON => $body, + ]); + } +} diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 6392212..07dcb2c 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -10,6 +10,8 @@ namespace EcomPHP\TiktokShop\Tests; +use EcomPHP\TiktokShop\Resources\Authorization; +use EcomPHP\TiktokShop\Resources\Seller; use GuzzleHttp\Psr7\Request; use EcomPHP\TiktokShop\Auth; use EcomPHP\TiktokShop\Client; @@ -51,7 +53,12 @@ public function testAuth() public function test__get() { - $resources = Client::resources; + // test get some resource + $resources = [ + Authorization::class, + Seller::class, + ]; + foreach ($resources as $resource) { $reflect = new ReflectionClass($resource); $className = $reflect->getShortName(); diff --git a/tests/Resources/AffiliateSellerTest.php b/tests/Resources/AffiliateSellerTest.php new file mode 100644 index 0000000..0e5c1c4 --- /dev/null +++ b/tests/Resources/AffiliateSellerTest.php @@ -0,0 +1,32 @@ + All rights reserved. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace EcomPHP\TiktokShop\Tests\Resources; + +use EcomPHP\TiktokShop\Tests\TestResource; + +class AffiliateSellerTest extends TestResource +{ + public const TEST_API_VERSION = 202405; + + protected function tiktokShopClientForTest() + { + $client = parent::tiktokShopClientForTest(); + $client->useVersion(self::TEST_API_VERSION); + + return $client; + } + + public function testEditOpenCollaborationSettings() + { + $this->caller->editOpenCollaborationSettings([]); + $this->assertPreviousRequest('POST', 'affiliate_seller/'.self::TEST_API_VERSION.'/open_collaboration_settings'); + } +}