shop.php
12.1 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?php
class Flora_Api_Service_Shop extends Flora_Api_Service
{
const API_PRODUCT_BYID = "shop/product";
const API_PRODUCT_PARENT_BYID = "shop/products/parent";
const API_PRODUCTS_LIST = "shop/products";
const API_PRODUCTS_FEATURED = "shop/products/featured";
const API_PRODUCTS_DAY = "shop/products/day";
const API_PRODUCTS_SEARCH = "shop/products/search";
const API_CATEGORIES = "shop/categories";
const API_CATEGORY_BYID = "shop/category";
const API_CURRENCIES_LIST = "shop/currencies";
const API_CURRENCY_BYID = "shop/currency";
const API_ORDER_REASONS_LIST = "shop/order/reasons";
const API_ORDER_REASON_BYID = "shop/order/reason";
const API_ORDER_REASON_TEXTS_LIST = "shop/order/reason/texts";
const API_ORDER_REASON_TEXT_BYID = "shop/order/reason/text";
const API_ORDER_SUBMIT = "shop/order/submit";
const API_ORDER_SUBMIT_PHONE = "shop/order/submit/phone";
const API_ORDER_SUBMIT_REQUEST = "shop/order/submit/request";
const API_ORDER_BYID = "shop/order/get";
const API_ORDER_USER_LIST = "shop/order/my";
const API_ORDER_CALCULATE = "shop/order/calculate";
const API_ORDER_STATUS = "shop/order/status";
const API_ORDER_TICKETS = "shop/order/tickets";
const API_ORDER_TICKET_SUBMIT = "shop/order/tickets/submit";
const API_ORDER_LAST_DELIVERED = "shop/order/lastdelivered";
const API_PAYMENTSYSTEMS_LIST = "shop/paysystems";
const API_PAYMENTSYSTEM_BYID = "shop/paysystem";
const API_PROMO_CHECK = "shop/promo/check";
const API_GALLERY = "shop/gallery";
const API_REVIEWS_SUBMIT = "shop/reviews/submit";
const API_REVIEWS = "shop/reviews";
const API_REVIEW = "shop/review";
const API_SALONS = "shop/salons";
const API_SALONS_COUNTRIES = "shop/salons/countries";
const API_SALONS_CITIES = "shop/salons/cities";
/**
* @param $id
* @return Flora_Model_Shop_Product
*/
public function getProductById($id)
{
return $this->call(self::API_PRODUCT_BYID, array("id" => $id));
}
/**
* @param $id
* @return Flora_Model_Shop_Product
*/
public function getParentProductById($id)
{
return $this->call(self::API_PRODUCT_PARENT_BYID, array("id" => $id));
}
/**
* @param int $parent_id
* @return Flora_Collection|Flora_Model_Shop_Product_Category[]
*/
public function getCategoriesList($parent_id = 0)
{
return $this->call(self::API_CATEGORIES, array("parent_id" => $parent_id));
}
/**
* @param bool|array|int $category
* @param mixed $products
* @param mixed $ingredient
* @param int $random
* @return Flora_Model_Shop_Product[]|Flora_Collection|mixed
*/
public function getProductsList($category = array(), $products = array(), $ingredient = '', $random = 0)
{
return $this->call(self::API_PRODUCTS_LIST, array(
"category" => join(',', array_filter(array_map('intval', (array)$category))),
"products" => join(',', array_filter(array_map('intval', (array)$products))),
"ingredient" => $ingredient,
"random" => $random,
));
}
/**
* @param $id
* @return Flora_Model_Shop_Product_Category
*/
public function getCategoryById($id)
{
return $this->call(self::API_CATEGORY_BYID, array("id" => $id));
}
/**
* @param int $city_id
* @param int $country_id
* @param int $get_products_of_day deprecated, use getProductsOfDay instead
* @return Flora_Collection|Flora_Model_Shop_Product[]
*/
public function getFeaturedProducts($city_id = 0, $country_id = 0, $get_products_of_day = 0)
{
return $this->call(self::API_PRODUCTS_FEATURED, array('country_id' => $country_id, 'city_id' => $city_id, 'product_of_day' => $get_products_of_day));
}
/**
* @return Flora_Collection|Flora_Model_Shop_Product[]
*/
public function getProductsOfDay()
{
return $this->call(self::API_PRODUCTS_DAY, array());
}
/**
* @param $query string
* @return Flora_Collection|Flora_Model_Shop_Product[]
*/
public function searchProducts($query)
{
return $this->call(self::API_PRODUCTS_SEARCH, array('query' => $query));
}
/**
* @param int $order_id
* @return Flora_Model_Shop_Currency[]|Flora_Collection
*/
public function getCurrenciesList($order_id = 0)
{
return $this->call(self::API_CURRENCIES_LIST, array('order_id' => $order_id));
}
/**
* @param int $id
* @param int $order_id
* @return Flora_Model_Shop_Currency
*/
public function getCurrencyById($id, $order_id = 0)
{
return $this->call(self::API_CURRENCY_BYID, array('id' => $id, 'order_id' => $order_id));
}
/**
* @return Flora_Collection|Flora_Model_Shop_Order_Reason[]
*/
public function getOrderReasons()
{
return $this->call(self::API_ORDER_REASONS_LIST);
}
/**
* @param $id
* @return Flora_Model_Shop_Order_Reason
*/
public function getOrderReasonById($id)
{
return $this->call(self::API_ORDER_REASON_BYID, array("id" => $id));
}
/**
* @param int $parent_id
* @return Flora_Collection|Flora_Model_Shop_Order_Reasons_Text[]
*/
public function getOrderReasonsTexts($parent_id = 0)
{
return $this->call(self::API_ORDER_REASON_TEXTS_LIST, array("parent_id" => $parent_id));
}
/**
* @param $id
* @return Flora_Model_Shop_Order_Reasons_Text
*/
public function getOrderReasonsTextById($id)
{
return $this->call(self::API_ORDER_REASON_TEXT_BYID, array("id" => $id));
}
/**
* @return Flora_Model_Shop_PaySystem[]|Flora_Collection
*/
public function getPaymentSystemsList()
{
return $this->call(self::API_PAYMENTSYSTEMS_LIST);
}
/**
* @param $id int|string
* @return Flora_Model_Shop_PaySystem
*/
public function getPaymentSystemById($id)
{
return $this->call(self::API_PAYMENTSYSTEM_BYID, array("id" => $id));
}
/**
* @param Flora_Validation_Order $order
* @return Flora_Api_Result_Order_Submit
*/
public function submitOrder(Flora_Validation_Order $order)
{
return $this->call(self::API_ORDER_SUBMIT, false, $order);
}
/**
* @param Flora_Validation_Order_Phone $order
* @return Flora_Api_Result_Order_Submit
*/
public function submitOrderPhone(Flora_Validation_Order_Phone $order)
{
return $this->call(self::API_ORDER_SUBMIT_PHONE, false, $order);
}
/**
* @param $name
* @param $phone
* @param $about
* @param string $email
* @param string $type
* @return int
*/
public function submitOrderRequest($name, $phone, $about, $email = '', $type = '')
{
return $this->call(self::API_ORDER_SUBMIT_REQUEST, false, array(
'name' => $name,
'phone' => $phone,
'email' => $email,
'type' => $type,
'about' => $about,
));
}
/**
* @param $code
* @return Flora_Model_Shop_Promo_Code
*/
public function checkPromoCode($code)
{
return $this->call(self::API_PROMO_CHECK, array("code" => $code));
}
/**
* @param Flora_Validation_Order $order
* @return Flora_Model_Shop_Order
*/
public function calculateOrder(Flora_Validation_Order $order)
{
return $this->call(self::API_ORDER_CALCULATE, false, $order);
}
/**
* @param $id
* @return Flora_Model_Shop_Order
*/
public function getOrderById($id)
{
return $this->call(self::API_ORDER_BYID, array("id" => $id));
}
/**
* @param bool $is_draft
* @return Flora_Collection|Flora_Model_Shop_Order[]
*/
public function getUserOrders($is_draft = false)
{
return $this->call(self::API_ORDER_USER_LIST, array('is_draft' => (int)(bool)$is_draft));
}
/**
* @param $orderID
* @return stdClass
*/
public function getOrderStatus($orderID)
{
return $this->call(self::API_ORDER_STATUS, array("id" => (int)$orderID));
}
/**
* @param $orderID
* @param $key string
* @return array|stdClass[]
*/
public function getOrderTickets($orderID, $key)
{
return $this->call(self::API_ORDER_TICKETS, array("id" => (int)$orderID, 'key' => $key));
}
/**
* @param $orderID
* @param $key string
* @param $message string
* @return bool
*/
public function submitOrderTicket($orderID, $key, $message)
{
return $this->call(self::API_ORDER_TICKET_SUBMIT, array("id" => (int)$orderID, 'key' => $key, 'message' => $message));
}
/**
* @return Flora_Collection|stdClass[]
*/
public function getGallery()
{
return $this->call(self::API_GALLERY);
}
/**
* @param $fio
* @param $email
* @param $orderid
* @param $comment
* @param string $phone
* @param string $comment_operator
* @param string $comment_florist
* @param string $comment_manager
* @param string $comment_courier
* @param string $comment_flowers_quality
* @param string $comment_flowers_rating
* @param int $rating_operator
* @param int $rating_manager
* @param int $rating_florist
* @param int $rating_courier
* @param int $rating_flowers
* @return int
*/
public function submitReview(
$fio, $email, $orderid, $comment, $phone = '', $comment_operator = '', $comment_florist = '',
$comment_manager = '', $comment_courier = '', $comment_flowers_quality = '', $comment_flowers_rating = '',
$rating_operator = 0, $rating_manager = 0, $rating_florist = 0, $rating_courier = 0, $rating_flowers = 0
)
{
return $this->call(self::API_REVIEWS_SUBMIT, array(), array(
'fio' => $fio,
'email' => $email,
'orderid' => $orderid,
'comment' => $comment,
'phone' => $phone,
'comment_operator' => $comment_operator,
'comment_florist' => $comment_florist,
'comment_manager' => $comment_manager,
'comment_courier' => $comment_courier,
'comment_flowers_quality' => $comment_flowers_quality,
'comment_flowers_rating' => $comment_flowers_rating,
'rating_operator' => $rating_operator,
'rating_manager' => $rating_manager,
'rating_florist' => $rating_florist,
'rating_courier' => $rating_courier,
'rating_flowers' => $rating_flowers,
));
}
/**
* @param int $limit
* @param int $offset
* @param int $product_id
* @param int $after_id
* @param int $city_id
* @return Flora_Collection|stdClass[]
*/
public function getReviews($limit = 0, $offset = 0, $product_id = 0, $after_id = 0, $city_id = 0)
{
return $this->call(self::API_REVIEWS, array("limit" => (int)$limit, "offset" => (int)$offset,
"product_id" => (int)$product_id, "after_id" => (int)$after_id,
"city_id" => (int)$city_id));
}
/**
* @param $id
* @return stdClass
*/
public function getReview($id)
{
return $this->call(self::API_REVIEW, array("id" => (int)$id));
}
/**
* @return array|stdClass[]
*/
public function getLastDelivered()
{
return $this->call(self::API_ORDER_LAST_DELIVERED);
}
/**
* @return Flora_Model_Geo_Country[]|Flora_Collection
*/
public function getCashSalonsCountries()
{
return $this->call(self::API_SALONS_COUNTRIES);
}
/**
* @param $country_id
* @return Flora_Model_Geo_City[]|Flora_Collection
*/
public function getCashSalonsCities($country_id)
{
return $this->call(self::API_SALONS_CITIES, array("country_id" => $country_id));
}
/**
* @param $city_id
* @return Flora_Model_Shop_Salon[]|Flora_Collection
*/
public function getCashSalonsByCity($city_id)
{
return $this->call(self::API_SALONS, array('city_id' => (int)$city_id));
}
}