1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ShopifyClient\Resource; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* https://help.shopify.com/api/reference/province |
7
|
|
|
*/ |
8
|
|
|
class Province extends AbstractResource |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @param float $countryId |
12
|
|
|
* @param float $id |
13
|
|
|
* @param array $fields |
14
|
|
|
* @return array |
15
|
|
|
*/ |
16
|
1 |
|
public function get(float $countryId, float $id, array $fields = []) |
17
|
|
|
{ |
18
|
1 |
|
$response = $this->request('GET', sprintf('/admin/countries/%s/provinces/%s.json', $countryId, $id), [ |
19
|
|
|
'query' => [ |
20
|
1 |
|
'fields' => $fields, |
21
|
|
|
], |
22
|
|
|
]); |
23
|
|
|
|
24
|
1 |
|
return $response['province']; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param float $id country 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/countries/%s/provinces.json', $id), [ |
35
|
1 |
|
'query' => $query, |
36
|
|
|
]); |
37
|
|
|
|
38
|
1 |
|
return $response['provinces']; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param float $id country id |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
1 |
|
public function count(float $id) |
46
|
|
|
{ |
47
|
1 |
|
$response = $this->request('GET', sprintf('/admin/countries/%s/provinces/count.json', $id)); |
48
|
|
|
|
49
|
1 |
|
return $response['count']; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param float $countryId |
54
|
|
|
* @param float $id |
55
|
|
|
* @param array $params |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
1 |
|
public function update(float $countryId, float $id, array $params = []) |
59
|
|
|
{ |
60
|
1 |
|
$response = $this->request('PUT', sprintf('/admin/countries/%s/provinces/%s.json', $countryId, $id), [ |
61
|
1 |
|
'body' => json_encode([ |
62
|
1 |
|
'province' => $params, |
63
|
|
|
]), |
64
|
|
|
]); |
65
|
|
|
|
66
|
1 |
|
return $response['province']; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|