-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmango.php
188 lines (124 loc) · 4.94 KB
/
mango.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
namespace Mango;
require_once "client.php";
class Mango {
public $api_key;
// Constructor
public function __construct($options) {
$this->api_key = $options["api_key"];
if (!$this->api_key) {
throw new InvalidApiKey();
}
$this->Charges = new Charges($this);
$this->Refunds = new Refunds($this);
$this->Customers = new Customers($this);
$this->Cards = new Cards($this);
$this->Queue = new Queue($this);
$this->Installments = new Installments($this);
$this->Promotions = new Promotions($this);
$this->Coupons = new Coupons($this);
}
}
class Resource extends Client {
public function __construct($mango) {
$this->mango = $mango;
}
}
class Charges extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/charges/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/charges/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function create($options = NULL) {
return $this->request("POST", "/charges/", $api_key = $this->mango->api_key, $options);
}
}
class Refunds extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/refunds/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/refunds/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function create($options = NULL) {
return $this->request("POST", "/refunds/", $api_key = $this->mango->api_key, $options);
}
}
class Customers extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/customers/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/customers/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function create($options = NULL) {
return $this->request("POST", "/customers/", $api_key = $this->mango->api_key, $options);
}
public function update($uid, $options = NULL) {
return $this->request("PATCH", "/customers/" . $uid . "/", $api_key = $this->mango->api_key, $options);
}
public function delete($uid) {
return $this->request("DELETE", "/customers/" . $uid . "/", $api_key = $this->mango->api_key);
}
}
class Cards extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/cards/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/cards/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function create($options = NULL) {
return $this->request("POST", "/cards/", $api_key = $this->mango->api_key, $options);
}
public function update($uid, $options = NULL) {
return $this->request("PATCH", "/cards/" . $uid . "/", $api_key = $this->mango->api_key, $options);
}
public function delete($uid) {
return $this->request("DELETE", "/cards/" . $uid . "/", $api_key = $this->mango->api_key);
}
}
class Queue extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/queue/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/queue/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function delete($uid) {
return $this->request("DELETE", "/queue/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function delete_all() {
return $this->request("DELETE", "/queue/", $api_key = $this->mango->api_key);
}
}
class Installments extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/installments/", $api_key = $this->mango->api_key, $options);
}
}
class Promotions extends Resource {
public function get_list($options) {
return $this->request("GET", "/promotions/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/promotions/" . $uid . "/", $api_key = $this->mango->api_key);
}
}
class Coupons extends Resource {
public function get_list($options = NULL) {
return $this->request("GET", "/coupons/", $api_key = $this->mango->api_key, $options);
}
public function get($uid) {
return $this->request("GET", "/coupons/" . $uid . "/", $api_key = $this->mango->api_key);
}
public function create($options = NULL) {
return $this->request("POST", "/coupons/", $api_key = $this->mango->api_key, $options);
}
public function update($uid, $options = NULL) {
return $this->request("PATCH", "/coupons/" . $uid . "/", $api_key = $this->mango->api_key, $options);
}
}
?>