1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Uon\Endpoints; |
4
|
|
|
|
5
|
|
|
use Uon\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Suppliers |
9
|
|
|
* |
10
|
|
|
* @package Uon\Endpoint |
11
|
|
|
*/ |
12
|
|
|
class Suppliers extends Client |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Add new partner |
16
|
|
|
* |
17
|
|
|
* @link https://api.u-on.ru/{key}/supplier/create.{_format} |
18
|
|
|
* |
19
|
|
|
* @param array $parameters List of parameters |
20
|
|
|
* |
21
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
22
|
|
|
*/ |
23
|
|
|
public function create(array $parameters) |
24
|
|
|
{ |
25
|
|
|
// Set HTTP params |
26
|
|
|
$this->type = 'post'; |
27
|
|
|
$this->endpoint = 'supplier/create'; |
28
|
|
|
$this->params = $parameters; |
29
|
|
|
|
30
|
|
|
return $this->done(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Create new type for partners |
35
|
|
|
* |
36
|
|
|
* @link https://api.u-on.ru/{key}/supplier_type/create.{_format} |
37
|
|
|
* |
38
|
|
|
* @param array $parameters List of parameters |
39
|
|
|
* |
40
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
41
|
|
|
*/ |
42
|
|
|
public function createType(array $parameters) |
43
|
|
|
{ |
44
|
|
|
// Set HTTP params |
45
|
|
|
$this->type = 'post'; |
46
|
|
|
$this->endpoint = 'supplier_type/create'; |
47
|
|
|
$this->params = $parameters; |
48
|
|
|
|
49
|
|
|
return $this->done(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get a list of partners |
54
|
|
|
* |
55
|
|
|
* @link https://api.u-on.ru/{key}/supplier/{id}.{_format} |
56
|
|
|
* |
57
|
|
|
* @param array $parameters List of parameters |
58
|
|
|
* @param int $page Number of page, 1 by default |
59
|
|
|
* |
60
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
61
|
|
|
*/ |
62
|
|
|
public function all(array $parameters = [], int $page = 1) |
63
|
|
|
{ |
64
|
|
|
// Set HTTP params |
65
|
|
|
$this->type = 'get'; |
66
|
|
|
$this->endpoint = 'suppliers/' . $page; |
67
|
|
|
$this->params = $parameters; |
68
|
|
|
|
69
|
|
|
return $this->done(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get partner by ID |
74
|
|
|
* |
75
|
|
|
* @link https://api.u-on.ru/{key}/supplier.{_format} |
76
|
|
|
* |
77
|
|
|
* @param int $id ID of partner |
78
|
|
|
* @param array $parameters List of parameters |
79
|
|
|
* |
80
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
81
|
|
|
*/ |
82
|
|
|
public function get(int $id, array $parameters = []) |
83
|
|
|
{ |
84
|
|
|
// Set HTTP params |
85
|
|
|
$this->type = 'get'; |
86
|
|
|
$this->endpoint = 'suppliers/' . $id; |
87
|
|
|
$this->params = $parameters; |
88
|
|
|
|
89
|
|
|
return $this->done(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get a list of partners types |
94
|
|
|
* |
95
|
|
|
* @link https://api.u-on.ru/{key}/supplier_type.{_format} |
96
|
|
|
* |
97
|
|
|
* @param array $parameters List of parameters |
98
|
|
|
* |
99
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
100
|
|
|
*/ |
101
|
|
|
public function getTypes(array $parameters = []) |
102
|
|
|
{ |
103
|
|
|
// Set HTTP params |
104
|
|
|
$this->type = 'get'; |
105
|
|
|
$this->endpoint = 'supplier_type'; |
106
|
|
|
$this->params = $parameters; |
107
|
|
|
|
108
|
|
|
return $this->done(); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Update partner by ID |
113
|
|
|
* |
114
|
|
|
* @link https://api.u-on.ru/{key}/supplier/update/{id}.{_format} |
115
|
|
|
* |
116
|
|
|
* @param int $id Unique ID of service |
117
|
|
|
* @param array $parameters List of parameters |
118
|
|
|
* |
119
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
120
|
|
|
*/ |
121
|
|
|
public function update(int $id, array $parameters) |
122
|
|
|
{ |
123
|
|
|
// Set HTTP params |
124
|
|
|
$this->type = 'post'; |
125
|
|
|
$this->endpoint = 'supplier/update/' . $id; |
126
|
|
|
$this->params = $parameters; |
127
|
|
|
|
128
|
|
|
return $this->done(); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|