Skip to content

Commit

Permalink
item change
Browse files Browse the repository at this point in the history
  • Loading branch information
AdolphYu committed Dec 17, 2020
1 parent d942a3d commit 11e9b86
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
10 changes: 5 additions & 5 deletions src/Request/ItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ItemRequest extends Request
*/
public function taxonomy($param){
return $this->getAuthRequest()
->get('/v3'.$this->getCountry().'/items/taxonomy',$param);
->get('/v3'.$this->getCountry().'/items/taxonomy',$param)->json();

}

Expand All @@ -30,7 +30,7 @@ public function taxonomy($param){
*/
public function count($param){
return $this->getAuthRequest()
->get('/v3'.$this->getCountry().'/items/count',$param);
->get('/v3'.$this->getCountry().'/items/count',$param)->json();

}

Expand All @@ -39,9 +39,9 @@ public function count($param){
* @param $param
* @return \Illuminate\Http\Client\Response
*/
public function info($id,$param){
public function info($id,$param=[]){
return $this->getAuthRequest()
->get('/v3'.$this->getCountry().'/items/'.$id,$param);
->get('/v3'.$this->getCountry().'/items/'.$id,$param)->json();

}

Expand All @@ -52,7 +52,7 @@ public function info($id,$param){
*/
public function search($param){
return $this->getAuthRequest()
->get('/v3'.$this->getCountry().'/items/walmart/search',$param);
->get('/v3'.$this->getCountry().'/items/walmart/search',$param)->json();

}

Expand Down
44 changes: 20 additions & 24 deletions tests/Feature/ItemRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class ItemRequestTest extends TestCase
*/
public function testTaxonomy()
{
$request = new ItemRequest();
$request->isFetchAll = true;
$request->setConfig([
$request = new ItemRequest([
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
]);
// dd($request->taxonomy([])->json());
// $request->isFetchAll = true;
// $request->setConfig();
// dd($request->taxonomy([]));
}

/**
Expand All @@ -41,14 +43,15 @@ public function testTaxonomy()
public function testCount()
{
try {
$request = new ItemRequest();
$request->isFetchAll = true;
$request->setConfig([
$request = new ItemRequest([
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
]);
// dd($request->count(['status'=>'PUBLISHED'])->json());;
// $request->isFetchAll = true;
// dd($request->count(['status'=>'PUBLISHED']));;
} catch (\Illuminate\Http\Client\RequestException $e) {
dd($e->response->json());
}
Expand All @@ -61,14 +64,15 @@ public function testCount()
public function testInfo()
{
try {
$request = new ItemRequest();
$request->isFetchAll = true;
$request->setConfig([
$request = new ItemRequest([
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
]);
// dd($request->info('432541287',['productIdType'=>'ITEM_ID'])->json());;
// $request->isFetchAll = true;
// dd($request->info('42V1547UAAJR0'));
} catch (\Illuminate\Http\Client\RequestException $e) {
dd($e->response->json());
}
Expand All @@ -81,13 +85,9 @@ public function testInfo()
public function testSearch()
{
try {
$request = new ItemRequest([
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
]);
$request = new ItemRequest($this->config);
$request->isFetchAll = true;
// dd($request->search(['upc'=>'','query'=>'ipad','gtin'=>''])->json());;
// dd($request->search(['upc'=>'','query'=>'ipad','gtin'=>'']));;
} catch (\Illuminate\Http\Client\RequestException $e) {
dd($e->response->json());
}
Expand All @@ -100,13 +100,9 @@ public function testSearch()
public function testList()
{
try {
$request = new ItemRequest([
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
]);
$request = new ItemRequest($this->config);
// $request->isFetchAll = true;
dd($request->list(['limit'=>1])->first());;
dd($request->list(['limit'=>1]));;
} catch (\Illuminate\Http\Client\RequestException $e) {
dd($e->response->json());
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Feature/OrderRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public function testList()
'mode'=>'prod',
]);

// dd($request->list(['limit'=>1]));

}

public function testOrder(){
$request = new OrderRequest([
'channel_type'=>Env::get('WM_CHANNEL_TYPE', ''),
'client_id'=>Env::get('WM_CLIENT_ID', ''),
'client_secret'=>Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
]);
// dd($request->order('4803445924832',[]));

Expand All @@ -49,7 +53,10 @@ public function testListReleased (){
'channel_type'=>Env::get('WM_CHANNEL_TYPE', ''),
'client_id'=>Env::get('WM_CLIENT_ID', ''),
'client_secret'=>Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
]);
dd($request->listReleased(['limit'=>'1']));
// dd($request->listReleased(['limit'=>'100','createdStartDate'=>Carbon::now()->subMinutes(60)->toIso8601String()]));

}
Expand Down
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use AdolphYu\WalmartMarketplace\PackageServiceProvider;
use AdolphYu\WalmartMarketplace\Providers\WalmartMarketplaceServiceProvider;
use Illuminate\Support\Env;


class TestCase extends \Orchestra\Testbench\TestCase
{
public $config;

public function setUp(): void
{
parent::setUp();
Expand All @@ -16,6 +19,13 @@ public function setUp(): void
//// dd(realpath(__DIR__.'/../'));
// $this->app->useEnvironmentPath(realpath(__DIR__.'/../'));
// additional setup
$this->config = [
'channel_type' => Env::get('WM_CHANNEL_TYPE', ''),
'client_id' => Env::get('WM_CLIENT_ID', ''),
'client_secret' => Env::get('WM_CLIENT_SECRET', ''),
'country'=>'us',
'mode'=>'prod',
];
}

protected function getPackageProviders($app)
Expand Down

0 comments on commit 11e9b86

Please sign in to comment.