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