Skip to content

Commit

Permalink
add: affiliate seller api
Browse files Browse the repository at this point in the history
  • Loading branch information
nVuln committed Jun 6, 2024
1 parent 9585fe5 commit 19ee527
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +45,7 @@
* @property-read Event $Event
* @property-read ReturnRefund $ReturnRefund
* @property-read CustomerService $CustomerService
* @property-read AffiliateSeller $AffiliateSeller
*/
class Client
{
Expand Down Expand Up @@ -80,6 +82,7 @@ class Client
Event::class,
ReturnRefund::class,
CustomerService::class,
AffiliateSeller::class,
];

public function __construct($app_key, $app_secret, $options = [])
Expand Down
27 changes: 27 additions & 0 deletions src/Resources/AffiliateSeller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/*
* This file is part of tiktokshop-client.
*
* Copyright (c) 2024 Jin <[email protected]> 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,
]);
}
}
9 changes: 8 additions & 1 deletion tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
32 changes: 32 additions & 0 deletions tests/Resources/AffiliateSellerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/*
* This file is part of tiktokshop-client.
*
* Copyright (c) 2024 Jin <[email protected]> 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');
}
}

0 comments on commit 19ee527

Please sign in to comment.