|
- <?php
-
-
-
- namespace common\components;
-
- use linslin\yii2\curl;
-
- class TillerClient
- {
- var $curl;
- var $providerToken;
- var $restaurantToken;
- var $urlApi = 'https://app.tillersystems.com/api/';
-
- public function __construct(string $providerToken = null, string $restaurantToken = null)
- {
- $this->curl = new curl\Curl();
- $this->providerToken = $providerToken;
- $this->restaurantToken = $restaurantToken;
- }
-
- public function getOrders($date)
- {
- $orders = $this->curl->setGetParams([
- 'provider_token' => $this->providerToken,
- 'restaurant_token' => $this->restaurantToken,
- 'dateFrom' => date('Y-m-d H-i-s', strtotime($date)),
- 'dateTo' => date(
- 'Y-m-d H-i-s',
- strtotime($date) + 24 * 60 * 60 - 1
- ),
- 'status' => 'IN_PROGRESS',
- ])->get($this->urlApi . 'orders');
-
- return json_decode($orders);
- }
-
- public function postOrder($params)
- {
- return $this->curl->setPostParams(
- array_merge([
- 'provider_token' => $this->providerToken,
- 'restaurant_token' => $this->restaurantToken,
- ], $params)
- )
- ->post($this->urlApi . 'orders');
- }
- }
|