Completed
Push — master ( fb5f04...e69765 )
by Christian
06:22
created

MWSFeeds::submit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 3
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
        return $this;
27
    }
28
29
    public function getType()
30
    {
31
        return $this->type;
32
    }
33
34
    public function setType($type)
35
    {
36
        $this->type = $type;
37
        return $this;
38
    }
39
40
    public function submit($purgeAndReplace = false, $amazonOrderId = null, $documentType = null)
0 ignored issues
show
Unused Code introduced by
The parameter $amazonOrderId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $documentType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
43
        $contentmd5Hash = base64_encode(md5($this->getContent(), true));
44
        $params = [
45
            'FeedType' => $this->type,
46
            'PurgeAndReplace' => $purgeAndReplace,
47
            'ContentMD5Value' => $contentmd5Hash
48
        ];
49
50
        $response = $this->client->post('SubmitFeed', '/', self::VERSION, $params, $this->getContent());
51
52
        return $this->parseResponse($response);
53
    }
54
55
    protected function parseResponse($response)
56
    {
57
        $requestId = data_get($response, 'ResponseMetadata.RequestId');
58
        $feed = data_get($response, 'SubmitFeedResult.FeedSubmissionInfo');
59
60
        return [
61
            'request_id' => $requestId,
62
            'data' => $feed,
63
        ];
64
    }
65
}
66