-
-
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
Showing
3 changed files
with
162 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,83 @@ | ||
<?php | ||
/* | ||
* This file is part of tiktokshop-php. | ||
* | ||
* Copyright (c) 2024 Jin <j@sax.vn> 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 Analytics extends Resource | ||
{ | ||
protected $category = 'analytics'; | ||
protected $minimum_version = 202405; | ||
|
||
public function getShopPerformance($params = []) | ||
{ | ||
return $this->call('GET', 'shop/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopProductPerformance($product_id, $params = []) | ||
{ | ||
return $this->call('GET', 'shop_products/'. $product_id .'/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopProductPerformanceList($params = []) | ||
{ | ||
return $this->call('GET', 'shop_products/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopSkuPerformance($sku_id, $params = []) | ||
{ | ||
return $this->call('GET', 'shop_skus/'. $sku_id .'/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopSkuPerformanceList($params = []) | ||
{ | ||
return $this->call('GET', 'shop_skus/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopVideoPerformanceList($params = []) | ||
{ | ||
return $this->call('GET', 'shop_videos/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopVideoPerformanceOverview($params = []) | ||
{ | ||
return $this->call('GET', 'shop_videos/overview_performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopVideoPerformance($video_id, $params = []) | ||
{ | ||
return $this->call('GET', 'shop_videos/'. $video_id .'/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
|
||
public function getShopVideoProductPerformanceList($video_id, $params = []) | ||
{ | ||
return $this->call('GET', 'shop_videos/'. $video_id .'/products/performance', [ | ||
RequestOptions::QUERY => $params, | ||
]); | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
/* | ||
* This file is part of tiktokshop-php. | ||
* | ||
* Copyright (c) 2024 Jin <j@sax.vn> 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\Resources\Analytics; | ||
use EcomPHP\TiktokShop\Tests\TestResource; | ||
|
||
/** | ||
* @property-read \EcomPHP\TiktokShop\Resources\Analytics $caller | ||
*/ | ||
class AnalyticsTest extends TestResource | ||
{ | ||
public const TEST_API_VERSION = 202405; | ||
|
||
public function testGetShopPerformance() | ||
{ | ||
$this->caller->getShopPerformance(); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop/performance'); | ||
} | ||
|
||
public function testGetShopProductPerformance() | ||
{ | ||
$this->caller->getShopProductPerformance(123); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_products/123/performance'); | ||
} | ||
|
||
public function testGetShopProductPerformanceList() | ||
{ | ||
$this->caller->getShopProductPerformanceList(); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_products/performance'); | ||
} | ||
|
||
public function testGetShopSkuPerformance() | ||
{ | ||
$this->caller->getShopSkuPerformance(123); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_skus/123/performance'); | ||
} | ||
|
||
public function testGetShopSkuPerformanceList() | ||
{ | ||
$this->caller->getShopSkuPerformanceList(); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_skus/performance'); | ||
} | ||
|
||
public function testGetShopVideoPerformance() | ||
{ | ||
$this->caller->getShopVideoPerformance(123); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_videos/123/performance'); | ||
|
||
} | ||
|
||
public function testGetShopVideoPerformanceList() | ||
{ | ||
$this->caller->getShopVideoPerformanceList(); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_videos/performance'); | ||
} | ||
|
||
public function testGetShopVideoPerformanceOverview() | ||
{ | ||
$this->caller->getShopVideoPerformanceOverview(); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_videos/overview_performance'); | ||
} | ||
|
||
public function testGetShopVideoProductPerformanceList() | ||
{ | ||
$this->caller->getShopVideoProductPerformanceList(123); | ||
$this->assertPreviousRequest('GET', 'analytics/'.self::TEST_API_VERSION.'/shop_videos/123/products/performance'); | ||
} | ||
} |