storeId = $storeId; $this->headers = [ 'authorization' => 'Bearer '.$accessToken, 'accept' => 'application/json', 'content-type' => 'application/json', ]; $this->curl = new curl\Curl(); $this->curl->setHeader('Authorization', 'Bearer '.$accessToken); $this->curl->setHeader('accept', 'application/json'); } public function getUrlAuthorizeCode(string $clientId, string $redirectUri): string { return "https://oauth.api.tiller.systems/oauth2/authorize?client_id=$clientId&response_type=code&scope=&redirect_uri=$redirectUri"; } public function isAuthenticated(): bool { /*$resultOrders = $this->getOrders('2024-02-01'); print_r($resultOrders); die();*/ return false; } public function getOrders($date) { $client = new \GuzzleHttp\Client(); $response = $client->request('POST', 'https://api.tiller.systems/orders/v3/orders/search', [ 'body' => json_encode([ 'storeIds' => [$this->storeId], 'openDate' => [ 'from' => date('Y-m-d H-i-s', strtotime($date)), 'to' => date('Y-m-d H-i-s', strtotime($date) + 24 * 60 * 60 - 1) ] ]), 'headers' => $this->headers ]); return $response->getBody()->getContents(); /*$orders = $this->curl ->setRequestBody(json_encode([ 'storeIds' => [$this->storeId], 'openDate' => [ 'from' => date('Y-m-d H-i-s', strtotime($date)), 'to' => date('Y-m-d H-i-s', strtotime($date) + 24 * 60 * 60 - 1), ] ])) ->setPostParams([ // 'statuses' => ['IN_PROGRESS'], ])->post($this->urlApi . 'orders/search?count=20'); return json_decode($orders);*/ } public function postOrder($params) { return $this->curl ->setPostParams($params) ->post($this->urlApi . 'orders'); } }