1
|
|
|
<?php |
2
|
|
|
// phpcs:disable Generic.Files.LineLength |
3
|
|
|
namespace Commercetools\Core\Builder\Request; |
4
|
|
|
|
5
|
|
|
use Commercetools\Core\Request\Zones\ZoneByIdGetRequest; |
6
|
|
|
use Commercetools\Core\Request\Zones\ZoneByKeyGetRequest; |
7
|
|
|
use Commercetools\Core\Request\Zones\ZoneCreateRequest; |
8
|
|
|
use Commercetools\Core\Model\Zone\ZoneDraft; |
9
|
|
|
use Commercetools\Core\Request\Zones\ZoneDeleteByKeyRequest; |
10
|
|
|
use Commercetools\Core\Model\Zone\Zone; |
11
|
|
|
use Commercetools\Core\Request\Zones\ZoneDeleteRequest; |
12
|
|
|
use Commercetools\Core\Request\Zones\ZoneQueryRequest; |
13
|
|
|
use Commercetools\Core\Request\Zones\ZoneUpdateByKeyRequest; |
14
|
|
|
use Commercetools\Core\Request\Zones\ZoneUpdateRequest; |
15
|
|
|
|
16
|
|
|
class ZoneRequestBuilder |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#get-zone-by-id |
21
|
|
|
* @param string $id |
22
|
|
|
* @return ZoneByIdGetRequest |
23
|
|
|
*/ |
24
|
1 |
|
public function getById($id) |
25
|
|
|
{ |
26
|
1 |
|
$request = ZoneByIdGetRequest::ofId($id); |
27
|
1 |
|
return $request; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#get-zone-by-key |
32
|
|
|
* @param string $key |
33
|
|
|
* @return ZoneByKeyGetRequest |
34
|
|
|
*/ |
35
|
|
|
public function getByKey($key) |
36
|
|
|
{ |
37
|
|
|
$request = ZoneByKeyGetRequest::ofKey($key); |
38
|
|
|
return $request; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#create-zone |
43
|
|
|
* @param ZoneDraft $zone |
44
|
|
|
* @return ZoneCreateRequest |
45
|
|
|
*/ |
46
|
1 |
|
public function create(ZoneDraft $zone) |
47
|
|
|
{ |
48
|
1 |
|
$request = ZoneCreateRequest::ofDraft($zone); |
49
|
1 |
|
return $request; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#delete-zone-by-key |
54
|
|
|
* @param Zone $zone |
55
|
|
|
* @return ZoneDeleteByKeyRequest |
56
|
|
|
*/ |
57
|
|
|
public function deleteByKey(Zone $zone) |
58
|
|
|
{ |
59
|
|
|
$request = ZoneDeleteByKeyRequest::ofKeyAndVersion($zone->getKey(), $zone->getVersion()); |
60
|
|
|
return $request; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#delete-zone |
65
|
|
|
* @param Zone $zone |
66
|
|
|
* @return ZoneDeleteRequest |
67
|
|
|
*/ |
68
|
1 |
|
public function delete(Zone $zone) |
69
|
|
|
{ |
70
|
1 |
|
$request = ZoneDeleteRequest::ofIdAndVersion($zone->getId(), $zone->getVersion()); |
71
|
1 |
|
return $request; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#query-zones |
76
|
|
|
* |
77
|
|
|
* @return ZoneQueryRequest |
78
|
|
|
*/ |
79
|
1 |
|
public function query() |
80
|
|
|
{ |
81
|
1 |
|
$request = ZoneQueryRequest::of(); |
82
|
1 |
|
return $request; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#update-zone-by-key |
87
|
|
|
* @param Zone $zone |
88
|
|
|
* @return ZoneUpdateByKeyRequest |
89
|
|
|
*/ |
90
|
|
|
public function updateByKey(Zone $zone) |
91
|
|
|
{ |
92
|
|
|
$request = ZoneUpdateByKeyRequest::ofKeyAndVersion($zone->getKey(), $zone->getVersion()); |
93
|
|
|
return $request; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @link https://docs.commercetools.com/http-api-projects-zones.html#update-zone |
98
|
|
|
* @param Zone $zone |
99
|
|
|
* @return ZoneUpdateRequest |
100
|
|
|
*/ |
101
|
1 |
|
public function update(Zone $zone) |
102
|
|
|
{ |
103
|
1 |
|
$request = ZoneUpdateRequest::ofIdAndVersion($zone->getId(), $zone->getVersion()); |
104
|
1 |
|
return $request; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return ZoneRequestBuilder |
109
|
|
|
*/ |
110
|
|
|
public function of() |
111
|
|
|
{ |
112
|
|
|
return new self(); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|