Test Failed
Push — develop ( 9e3f9b...05a047 )
by Edwin
02:28
created

CustomerAddress::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ShopifyClient\Resource;
4
5
/**
6
 * https://help.shopify.com/api/reference/customeraddress
7
 */
8
class CustomerAddress extends AbstractResource
9
{
10
    /**
11
     * @param float $customerId
12
     * @param float $id
13
     * @param array $fields
14
     * @return array
15
     */
16 1
    public function get(float $customerId, float $id, array $fields = [])
17
    {
18 1
        $response = $this->request('GET', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id), [
19
            'query' => [
20 1
                'fields' => $fields,
21
            ],
22
        ]);
23
24 1
        return $response['customer_address'];
25
    }
26
27
    /**
28
     * @param float $id customer id
29
     * @param array $query
30
     * @return array
31
     */
32 1
    public function all(float $id, array $query = [])
33
    {
34 1
        $response = $this->request('GET', sprintf('/admin/customers/%s/addresses.json', $id), [
35 1
            'query' => $query,
36
        ]);
37
38 1
        return $response['addresses'];
39
    }
40
41
    /**
42
     * @param float $id
43
     * @param array $params
44
     * @return array
45
     */
46 1
    public function create(float $id, array $params = [])
47
    {
48 1
        $response = $this->request('POST', sprintf('/admin/customers/%s/addresses.json', $id), [
49 1
            'body' => json_encode(['address' => $params]),
50
        ]);
51
52 1
        return $response['customer_address'];
53
    }
54
55
    /**
56
     * @param float $customerId
57
     * @param float $id
58
     * @param array $params
59
     * @return array
60
     */
61 1
    public function update(float $customerId, float $id, array $params = [])
62
    {
63 1
        $response = $this->request('PUT', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id), [
64 1
            'body' => json_encode(['address' => $params]),
65
        ]);
66
67 1
        return $response['customer_address'];
68
    }
69
70
    /**
71
     * @param float $customerId
72
     * @param float $id
73
     */
74 1
    public function delete(float $customerId, float $id)
75
    {
76 1
        $this->request('DELETE', sprintf('/admin/customers/%s/addresses/%s.json', $customerId, $id));
77 1
    }
78
}
79