|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Looxis\LaravelAmazonMWS; |
|
4
|
|
|
|
|
5
|
|
|
class MWSFeeds |
|
6
|
|
|
{ |
|
7
|
|
|
const VERSION = '2009-01-01'; |
|
8
|
|
|
|
|
9
|
|
|
protected $client; |
|
10
|
|
|
protected $content; |
|
11
|
|
|
protected $type; |
|
12
|
|
|
|
|
13
|
|
|
public function __construct(MWSClient $client) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->client = $client; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function getContent() |
|
19
|
|
|
{ |
|
20
|
|
|
return $this->content; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function setContent($content) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->content = $content; |
|
26
|
|
|
|
|
27
|
|
|
return $this; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getType() |
|
31
|
|
|
{ |
|
32
|
|
|
return $this->type; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function setType($type) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->type = $type; |
|
38
|
|
|
|
|
39
|
|
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function submit($purgeAndReplace = false, $amazonOrderId = null, $documentType = null) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$contentmd5Hash = base64_encode(md5($this->getContent(), true)); |
|
45
|
|
|
$params = [ |
|
46
|
|
|
'FeedType' => $this->type, |
|
47
|
|
|
'PurgeAndReplace' => $purgeAndReplace, |
|
48
|
|
|
'ContentMD5Value' => $contentmd5Hash, |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$response = $this->client->post('SubmitFeed', '/', self::VERSION, $params, $this->getContent()); |
|
52
|
|
|
|
|
53
|
|
|
return $this->parseSubmitFeedResponse($response); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function parseSubmitFeedResponse($response) |
|
57
|
|
|
{ |
|
58
|
|
|
$requestId = data_get($response, 'ResponseMetadata.RequestId'); |
|
59
|
|
|
$feed = data_get($response, 'SubmitFeedResult.FeedSubmissionInfo'); |
|
60
|
|
|
|
|
61
|
|
|
return [ |
|
62
|
|
|
'request_id' => $requestId, |
|
63
|
|
|
'data' => $feed, |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getFeedSubmissionResult($amazonFeedSubmissionId) |
|
68
|
|
|
{ |
|
69
|
|
|
$params = [ |
|
70
|
|
|
'FeedSubmissionId' => $amazonFeedSubmissionId |
|
71
|
|
|
]; |
|
72
|
|
|
|
|
73
|
|
|
$response = $this->client->post('GetFeedSubmissionResult', '/', self::VERSION, $params); |
|
74
|
|
|
|
|
75
|
|
|
return $this->parseSubmissionResultResponse($response); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function parseSubmissionResultResponse($response) |
|
79
|
|
|
{ |
|
80
|
|
|
return [ |
|
81
|
|
|
'status_code' => data_get($response, 'Message.ProcessingReport.StatusCode'), |
|
82
|
|
|
'processing_summary' => data_get($response, 'Message.ProcessingReport.ProcessingSummary'), |
|
83
|
|
|
'result' => data_get($response, 'Message.ProcessingReport.Result') |
|
84
|
|
|
]; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.