1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rezdy\Endpoints; |
4
|
|
|
|
5
|
|
|
use Rezdy\Client; |
6
|
|
|
use Rezdy\Interfaces\ProductInterface; |
7
|
|
|
use Rezdy\Interfaces\ProductsInterface; |
8
|
|
|
use Rezdy\Interfaces\QueryInterface; |
9
|
|
|
|
10
|
|
|
class Products extends Client implements ProductInterface, ProductsInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Get product |
14
|
|
|
* |
15
|
|
|
* @param int $productCode |
16
|
|
|
* |
17
|
|
|
* @return QueryInterface |
18
|
|
|
*/ |
19
|
|
|
public function __invoke(string $productCode): ProductInterface |
20
|
|
|
{ |
21
|
|
|
$this->productCode = $productCode; |
|
|
|
|
22
|
|
|
|
23
|
|
|
// Set HTTP params |
24
|
|
|
$this->type = 'get'; |
25
|
|
|
$this->endpoint = '/products/' . $productCode; |
26
|
|
|
|
27
|
|
|
return $this; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Create product |
32
|
|
|
* |
33
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
34
|
|
|
*/ |
35
|
|
|
public function create(): QueryInterface |
36
|
|
|
{ |
37
|
|
|
// Set HTTP params |
38
|
|
|
$this->type = 'post'; |
39
|
|
|
$this->endpoint = '/products'; |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Update product |
46
|
|
|
* |
47
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
48
|
|
|
*/ |
49
|
|
|
public function update(): QueryInterface |
50
|
|
|
{ |
51
|
|
|
// Set HTTP params |
52
|
|
|
$this->type = 'put'; |
53
|
|
|
$this->endpoint = '/products/' . $this->productCode; |
|
|
|
|
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Delete product |
60
|
|
|
* |
61
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
62
|
|
|
*/ |
63
|
|
|
public function delete(): QueryInterface |
64
|
|
|
{ |
65
|
|
|
// Set HTTP params |
66
|
|
|
$this->type = 'delete'; |
67
|
|
|
$this->endpoint = '/products/' . $this->productCode; |
|
|
|
|
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Search products |
74
|
|
|
* |
75
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
76
|
|
|
*/ |
77
|
|
|
public function search(): QueryInterface |
78
|
|
|
{ |
79
|
|
|
// Set HTTP params |
80
|
|
|
$this->type = 'get'; |
81
|
|
|
$this->endpoint = '/products'; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Search marketplace products |
88
|
|
|
* |
89
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
90
|
|
|
*/ |
91
|
|
|
public function searchMarketplace(): QueryInterface |
92
|
|
|
{ |
93
|
|
|
// Set HTTP params |
94
|
|
|
$this->type = 'get'; |
95
|
|
|
$this->endpoint = '/products/marketplace'; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get product pickups |
102
|
|
|
* |
103
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
104
|
|
|
*/ |
105
|
|
|
public function getPickups(): QueryInterface |
106
|
|
|
{ |
107
|
|
|
// Set HTTP params |
108
|
|
|
$this->type = 'get'; |
109
|
|
|
$this->endpoint = '/products/' . $this->productCode . '/pickups'; |
|
|
|
|
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Add product image |
116
|
|
|
* |
117
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
118
|
|
|
*/ |
119
|
|
|
public function createImage(): QueryInterface |
120
|
|
|
{ |
121
|
|
|
// Set HTTP params |
122
|
|
|
$this->type = 'post'; |
123
|
|
|
$this->endpoint = '/products/' . $this->productCode . '/images'; |
|
|
|
|
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Remove product Image |
130
|
|
|
* |
131
|
|
|
* @param string $mediaId |
132
|
|
|
* |
133
|
|
|
* @return \Rezdy\Interfaces\QueryInterface |
134
|
|
|
*/ |
135
|
|
|
public function getImage(string $mediaId): QueryInterface |
136
|
|
|
{ |
137
|
|
|
// Set HTTP params |
138
|
|
|
$this->type = 'delete'; |
139
|
|
|
$this->endpoint = '/products/' . $this->productCode . '/images/' . $mediaId; |
|
|
|
|
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.