Completed
Push — master ( 08a67d...83c463 )
by Christian
13s queued 10s
created

getEligibleShippingServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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