-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nVuln
committed
Jul 16, 2024
1 parent
1f971fb
commit 85c2c38
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/* | ||
* This file is part of tiktokshop-php. | ||
* | ||
* 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 AffiliateCreator extends Resource | ||
{ | ||
protected $category = 'affiliate_creator'; | ||
protected $minimum_version = 202405; | ||
|
||
public function addShowcaseProducts($add_type, $product_ids = [], $product_link = '') | ||
{ | ||
return $this->call('POST', 'showcases/products/add', [ | ||
'add_type' => $add_type, | ||
'product_ids' => $product_ids, | ||
'product_link' => $product_link, | ||
]); | ||
} | ||
|
||
public function getShowcaseProducts($query = []) | ||
{ | ||
$query = array_merge([ | ||
'page_size' => 10, | ||
'origin' => 'LIVE', | ||
], $query); | ||
|
||
return $this->call('GET', 'showcases/products', [ | ||
RequestOptions::QUERY => $query, | ||
]); | ||
} | ||
|
||
public function getCreatorProfile() | ||
{ | ||
return $this->call('GET', 'profiles'); | ||
} | ||
|
||
public function searchOpenCollaborationProduct($query = [], $body = []) | ||
{ | ||
$query = array_merge([ | ||
'page_size' => 10, | ||
], $query); | ||
|
||
return $this->call('POST', 'open_collaborations/products/search', [ | ||
RequestOptions::QUERY => $query, | ||
RequestOptions::JSON => $body, | ||
]); | ||
} | ||
|
||
public function searchTargetCollaborations($query, $body = []) | ||
{ | ||
$query = array_merge([ | ||
'page_size' => 10, | ||
], $query); | ||
|
||
return $this->call('POST', 'target_collaborations/search', [ | ||
RequestOptions::QUERY => $query, | ||
RequestOptions::JSON => $body, | ||
]); | ||
} | ||
|
||
public function searchAffiliateOrders($query = []) | ||
{ | ||
$query = array_merge([ | ||
'page_size' => 10, | ||
], $query); | ||
|
||
return $this->call('POST', 'orders/search', [ | ||
RequestOptions::QUERY => $query, | ||
RequestOptions::JSON => [], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/* | ||
* This file is part of tiktokshop-php. | ||
* | ||
* 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; | ||
|
||
/** | ||
* @property-read \EcomPHP\TiktokShop\Resources\AffiliateCreator $caller | ||
*/ | ||
class AffiliateCreatorTest extends TestResource | ||
{ | ||
public const TEST_API_VERSION = 202405; | ||
|
||
protected function tiktokShopClientForTest() | ||
{ | ||
$client = parent::tiktokShopClientForTest(); | ||
$client->useVersion(self::TEST_API_VERSION); | ||
|
||
return $client; | ||
} | ||
|
||
public function testAddShowcaseProducts() | ||
{ | ||
$this->caller->addShowcaseProducts('add_type', [1, 2, 3], 'product_link'); | ||
$this->assertPreviousRequest('POST', 'affiliate_creator/'.self::TEST_API_VERSION.'/showcases/products/add'); | ||
} | ||
|
||
public function testGetShowcaseProducts() | ||
{ | ||
$this->caller->getShowcaseProducts(); | ||
$this->assertPreviousRequest('GET', 'affiliate_creator/'.self::TEST_API_VERSION.'/showcases/products'); | ||
} | ||
|
||
public function testGetCreatorProfile() | ||
{ | ||
$this->caller->getCreatorProfile(); | ||
$this->assertPreviousRequest('GET', 'affiliate_creator/'.self::TEST_API_VERSION.'/profiles'); | ||
} | ||
|
||
public function testSearchOpenCollaborationProduct() | ||
{ | ||
$this->caller->searchOpenCollaborationProduct(); | ||
$this->assertPreviousRequest('POST', 'affiliate_creator/'.self::TEST_API_VERSION.'/open_collaborations/products/search'); | ||
} | ||
|
||
public function testSearchTargetCollaborations() | ||
{ | ||
$this->caller->searchTargetCollaborations([]); | ||
$this->assertPreviousRequest('POST', 'affiliate_creator/'.self::TEST_API_VERSION.'/target_collaborations/search'); | ||
} | ||
|
||
public function testSearchAffiliateOrders() | ||
{ | ||
$this->caller->searchAffiliateOrders(); | ||
$this->assertPreviousRequest('POST', 'affiliate_creator/'.self::TEST_API_VERSION.'/orders/search'); | ||
} | ||
} |