1
|
|
|
<?php |
2
|
|
|
// phpcs:disable Generic.Files.LineLength |
3
|
|
|
namespace Commercetools\Core\Builder\Request; |
4
|
|
|
|
5
|
|
|
use Commercetools\Core\Request\States\StateByIdGetRequest; |
6
|
|
|
use Commercetools\Core\Request\States\StateCreateRequest; |
7
|
|
|
use Commercetools\Core\Model\State\StateDraft; |
8
|
|
|
use Commercetools\Core\Request\States\StateDeleteRequest; |
9
|
|
|
use Commercetools\Core\Model\State\State; |
10
|
|
|
use Commercetools\Core\Request\States\StateQueryRequest; |
11
|
|
|
use Commercetools\Core\Request\States\StateUpdateRequest; |
12
|
|
|
|
13
|
|
|
class StateRequestBuilder |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @link https://docs.commercetools.com/http-api-projects-states.html#get-state-by-id |
18
|
|
|
* @param string $id |
19
|
|
|
* @return StateByIdGetRequest |
20
|
|
|
*/ |
21
|
1 |
|
public function getById($id) |
22
|
|
|
{ |
23
|
1 |
|
$request = StateByIdGetRequest::ofId($id); |
24
|
1 |
|
return $request; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @link https://docs.commercetools.com/http-api-projects-states.html#create-state |
29
|
|
|
* @param StateDraft $state |
30
|
|
|
* @return StateCreateRequest |
31
|
|
|
*/ |
32
|
1 |
|
public function create(StateDraft $state) |
33
|
|
|
{ |
34
|
1 |
|
$request = StateCreateRequest::ofDraft($state); |
35
|
1 |
|
return $request; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @link https://docs.commercetools.com/http-api-projects-states.html#delete-state |
40
|
|
|
* @param State $state |
41
|
|
|
* @return StateDeleteRequest |
42
|
|
|
*/ |
43
|
1 |
|
public function delete(State $state) |
44
|
|
|
{ |
45
|
1 |
|
$request = StateDeleteRequest::ofIdAndVersion($state->getId(), $state->getVersion()); |
46
|
1 |
|
return $request; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @link https://docs.commercetools.com/http-api-projects-states.html#query-states |
51
|
|
|
* |
52
|
|
|
* @return StateQueryRequest |
53
|
|
|
*/ |
54
|
1 |
|
public function query() |
55
|
|
|
{ |
56
|
1 |
|
$request = StateQueryRequest::of(); |
57
|
1 |
|
return $request; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @link https://docs.commercetools.com/http-api-projects-states.html#update-state |
62
|
|
|
* @param State $state |
63
|
|
|
* @return StateUpdateRequest |
64
|
|
|
*/ |
65
|
1 |
|
public function update(State $state) |
66
|
|
|
{ |
67
|
1 |
|
$request = StateUpdateRequest::ofIdAndVersion($state->getId(), $state->getVersion()); |
68
|
1 |
|
return $request; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return StateRequestBuilder |
73
|
|
|
*/ |
74
|
|
|
public function of() |
75
|
|
|
{ |
76
|
|
|
return new self(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|