|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Uon\Endpoints; |
|
4
|
|
|
|
|
5
|
|
|
use Uon\Client; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Collection of methods for work with bonus cards |
|
9
|
|
|
* |
|
10
|
|
|
* @package Uon\Endpoint |
|
11
|
|
|
*/ |
|
12
|
|
|
class Bcard extends Client |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $namespace = __CLASS__; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Bonus card activation |
|
21
|
|
|
* |
|
22
|
|
|
* @link https://api.u-on.ru/{key}/bcard-activate/create.{_format} |
|
23
|
|
|
* |
|
24
|
|
|
* @param array $parameters List of parameters [bc_number, user_id] |
|
25
|
|
|
* |
|
26
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
public function activate(array $parameters) |
|
29
|
|
|
{ |
|
30
|
|
|
// Set HTTP params |
|
31
|
|
|
$this->type = 'post'; |
|
32
|
|
|
$this->endpoint = 'bcard-activate/create'; |
|
33
|
|
|
$this->params = $parameters; |
|
34
|
|
|
|
|
35
|
|
|
return $this->done(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Bonus card create |
|
40
|
|
|
* |
|
41
|
|
|
* @link https://api.u-on.ru/{key}/bcard/create.{_format} |
|
42
|
|
|
* |
|
43
|
|
|
* @param array $parameters List of parameters [number, bonuses etc.] |
|
44
|
|
|
* |
|
45
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
public function create(array $parameters) |
|
48
|
|
|
{ |
|
49
|
|
|
// Set HTTP params |
|
50
|
|
|
$this->type = 'post'; |
|
51
|
|
|
$this->endpoint = 'bcard/create'; |
|
52
|
|
|
$this->params = $parameters; |
|
53
|
|
|
|
|
54
|
|
|
return $this->done(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Bonuses add/delete by bonus card |
|
59
|
|
|
* |
|
60
|
|
|
* @link https://api.u-on.ru/{key}/bcard-bonus/create.{_format} |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $parameters List of parameters [bc_number, user_id etc.] |
|
63
|
|
|
* |
|
64
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
|
65
|
|
|
*/ |
|
66
|
|
|
public function createBonus(array $parameters) |
|
67
|
|
|
{ |
|
68
|
|
|
// Set HTTP params |
|
69
|
|
|
$this->type = 'post'; |
|
70
|
|
|
$this->endpoint = 'bcard-bonus/create'; |
|
71
|
|
|
$this->params = $parameters; |
|
72
|
|
|
|
|
73
|
|
|
return $this->done(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Get bonus transactions by bonus card |
|
78
|
|
|
* |
|
79
|
|
|
* @link https://api.u-on.ru/{key}/bcard-bonus-by-card/{id}.{_format} |
|
80
|
|
|
* |
|
81
|
|
|
* @param int $id Unique card ID |
|
82
|
|
|
* |
|
83
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getByCard(int $id) |
|
86
|
|
|
{ |
|
87
|
|
|
// Set HTTP params |
|
88
|
|
|
$this->type = 'get'; |
|
89
|
|
|
$this->endpoint = 'bcard-bonus-by-card/' . $id; |
|
90
|
|
|
|
|
91
|
|
|
return $this->done(); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Get bonus transactions by user ID |
|
96
|
|
|
* |
|
97
|
|
|
* @link https://api.u-on.ru/{key}/bcard-bonus-by-user/{id}.{_format} |
|
98
|
|
|
* |
|
99
|
|
|
* @param int $id Unique user ID |
|
100
|
|
|
* |
|
101
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getByUser(int $id) |
|
104
|
|
|
{ |
|
105
|
|
|
// Set HTTP params |
|
106
|
|
|
$this->type = 'get'; |
|
107
|
|
|
$this->endpoint = 'bcard-bonus-by-user/' . $id; |
|
108
|
|
|
|
|
109
|
|
|
return $this->done(); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|