From 87483cce4e857402550a0854aafa074b205b556a Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 14 Jun 2023 17:46:04 +0300 Subject: [PATCH] Added ApiFetcher to fetch data from DotsAPI. --- app/DotsAPI/Fetcher/v2/ApiFetcher.php | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/DotsAPI/Fetcher/v2/ApiFetcher.php diff --git a/app/DotsAPI/Fetcher/v2/ApiFetcher.php b/app/DotsAPI/Fetcher/v2/ApiFetcher.php new file mode 100644 index 0000000..c025725 --- /dev/null +++ b/app/DotsAPI/Fetcher/v2/ApiFetcher.php @@ -0,0 +1,38 @@ +get( + $apiUrl, + [ + 'headers' => [ + 'Api-Token' => $apiToken, + 'Api-Account-Token' => $apiAccountToken, + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ], + 'query' => [ + 'v'=> '2.0.0', + ], + ] + ); + + $data = json_decode($response->getBody()->getContents(), true); + $items = $data['items']; + + return $items; + } +}