Skip to content

Commit 0f87a50

Browse files
committed
Add mws auth token
1 parent 3ac0c6e commit 0f87a50

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ return [
7272
'access_key_id' => env('MWS_ACCESS_KEY_ID'),
7373
'secret_key' => env('MWS_SECRET_KEY'),
7474
'seller_id' => env('MWS_SELLER_ID'),
75+
'mws_auth_token' => env('MWS_AUTH_TOKEN'),
7576
'default_market_place' => env('MWS_DEFAULT_MARKET_PLACE', 'DE'),
7677
];
7778
```

config/amazon-mws.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
'access_key_id' => env('MWS_ACCESS_KEY_ID'),
55
'secret_key' => env('MWS_SECRET_KEY'),
66
'seller_id' => env('MWS_SELLER_ID'),
7+
'mws_auth_token' => env('MWS_AUTH_TOKEN'),
78
'default_market_place' => env('MWS_DEFAULT_MARKET_PLACE', 'DE'),
89
];

src/MWSClient.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class MWSClient
1919
protected $sellerId;
2020
protected $client;
2121
protected $marketPlaces;
22+
protected $mwsAuthToken;
2223

2324
protected $marketplaceIds = [
2425
'A2Q3Y263D00KWC' => 'mws.amazonservices.com',
@@ -38,7 +39,7 @@ class MWSClient
3839
'A19VAU5U5O7RUS' => 'mws-fe.amazonservices.com',
3940
'A39IBJ37TRP1C6' => 'mws.amazonservices.com.au',
4041
'A1VC38T7YXB528' => 'mws.amazonservices.jp',
41-
'A1805IZSGTT6HS' => 'mws-eu.amazonservices.com'
42+
'A1805IZSGTT6HS' => 'mws-eu.amazonservices.com',
4243
];
4344

4445
protected $countries = [
@@ -67,6 +68,7 @@ public function __construct(Client $client = null)
6768
$this->accessKeyId = config('amazon-mws.access_key_id');
6869
$this->secretKey = config('amazon-mws.secret_key');
6970
$this->sellerId = config('amazon-mws.seller_id');
71+
$this->mwsAuthToken = config('amazon-mws.mws_auth_token');
7072
$this->marketPlaces = ['DE'];
7173
$this->client = $client ?: new Client(['timeout' => 60]);
7274
}
@@ -111,6 +113,11 @@ public function setSellerId($id)
111113
return $this;
112114
}
113115

116+
public function getMWSAuthToken()
117+
{
118+
return $this->mwsAuthToken;
119+
}
120+
114121
public function getSignatureMethod()
115122
{
116123
return self::SIGNATURE_METHOD;
@@ -175,7 +182,6 @@ public function post($action, $path, $version, $params = [], $body = null)
175182
$response = $this->client->post($uri, $requestOptions);
176183
$xmlResponse = simplexml_load_string($response->getBody()->getContents());
177184
$json = json_encode($xmlResponse);
178-
179185
return json_decode($json, true);
180186
}
181187

@@ -186,6 +192,7 @@ public function getDefaultQueryParams($action, $version, $params = [])
186192
'Timestamp' => $this->getTimeStamp(),
187193
'AWSAccessKeyId' => $this->getAccessKeyId(),
188194
'SellerId' => $this->getSellerId(),
195+
'MWSAuthToken' => $this->getMWSAuthToken(),
189196
'SignatureMethod' => $this->getSignatureMethod(),
190197
'SignatureVersion' => $this->getSignatureVersion(),
191198
'Version' => $version,

src/MWSOrders.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function list($params = [])
2323
}
2424

2525
$response = $this->client->post($action, '/Orders/'.self::VERSION, self::VERSION, $params);
26-
2726
return $this->parseResponse($response, $action.'Result', 'Orders.Order');
2827
}
2928

@@ -48,11 +47,10 @@ public function getItems($id)
4847
'AmazonOrderId' => $id,
4948
];
5049
$response = $this->client->post('ListOrderItems', '/Orders/'.self::VERSION, self::VERSION, $params);
51-
5250
return $this->parseResponse($response, 'ListOrderItemsResult', 'OrderItems.OrderItem');
5351
}
5452

55-
protected function parseResponse($response, $resultTypeName, $dataName)
53+
public function parseResponse($response, $resultTypeName, $dataName)
5654
{
5755
$requestId = data_get($response, 'ResponseMetadata.RequestId');
5856
$data = data_get($response, $resultTypeName.'.'.$dataName);

0 commit comments

Comments
 (0)