1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Looxis\LaravelAmazonMWS; |
4
|
|
|
|
5
|
|
|
class MWSMerchantFulfillment |
6
|
|
|
{ |
7
|
|
|
const VERSION = '2015-06-01'; |
8
|
|
|
|
9
|
|
|
protected $client; |
10
|
|
|
|
11
|
|
|
public function __construct(MWSClient $client) |
12
|
|
|
{ |
13
|
|
|
$this->client = $client; |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function getEligibleShippingServices($params = []) |
17
|
|
|
{ |
18
|
|
|
$action = 'GetEligibleShippingServices'; |
19
|
|
|
|
20
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION, $params); |
21
|
|
|
|
22
|
|
|
return $this->parseResponse($response, $action.'Result'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function parseResponse($response, $resultTypeName) |
26
|
|
|
{ |
27
|
|
|
$requestId = data_get($response, 'ResponseMetadata.RequestId'); |
28
|
|
|
$data = data_get($response, $resultTypeName); |
29
|
|
|
|
30
|
|
|
$data = [ |
31
|
|
|
'request_id' => $requestId, |
32
|
|
|
'data' => $data, |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
return $data; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function createShipment($params = []) |
39
|
|
|
{ |
40
|
|
|
$action = 'CreateShipment'; |
41
|
|
|
|
42
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION, $params); |
43
|
|
|
|
44
|
|
|
return $this->parseResponse($response, $action.'Result'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
public function cancelShipment($shipmentId) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$action = 'CancelShipment'; |
50
|
|
|
|
51
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION, [ |
52
|
|
|
'ShipmentId' => $shipmentId, |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
return $this->parseResponse($response, $action.'Result'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
public function getShipment($shipmentId) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$action = 'GetShipment'; |
61
|
|
|
|
62
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION, [ |
63
|
|
|
'ShipmentId' => $shipmentId, |
64
|
|
|
]); |
65
|
|
|
|
66
|
|
|
return $this->parseResponse($response, $action.'Result'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
View Code Duplication |
public function getServiceStatus() |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
$action = 'GetServiceStatus'; |
72
|
|
|
|
73
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION); |
74
|
|
|
|
75
|
|
|
return $this->parseResponse($response, $action.'Result'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getAdditionalSellerInputs($params) |
79
|
|
|
{ |
80
|
|
|
$action = 'GetAdditionalSellerInputs'; |
81
|
|
|
|
82
|
|
|
$response = $this->client->post($action, '/MerchantFulfillment/'.self::VERSION, self::VERSION, $params); |
83
|
|
|
|
84
|
|
|
return $this->parseResponse($response, $action.'Result'); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.