22
33namespace Tapp \Airtable \Api ;
44
5- use GuzzleHttp \ Client ;
5+ use Illuminate \ Support \ Facades \ Http ;
66use Illuminate \Support \Str ;
77
88class AirtableApiClient implements ApiClient
@@ -21,36 +21,24 @@ class AirtableApiClient implements ApiClient
2121 private $ pageSize = 100 ;
2222 private $ maxRecords = 100 ;
2323
24- public function __construct ($ base , $ table , $ access_token , $ httpLogFormat = null , Client $ client = null , $ typecast = false , $ delayBetweenRequests = 200000 )
24+ public function __construct ($ base , $ table , $ access_token , $ httpLogFormat = null , Http $ client = null , $ typecast = false , $ delayBetweenRequests = 200000 )
2525 {
2626 $ this ->base = $ base ;
2727 $ this ->table = $ table ;
2828 $ this ->typecast = $ typecast ;
2929 $ this ->delay = $ delayBetweenRequests ;
3030
31- $ stack = \GuzzleHttp \HandlerStack::create ();
32-
33- if ($ httpLogFormat ) {
34- $ stack ->push (
35- \GuzzleHttp \Middleware::log (
36- new \Monolog \Logger ('Logger ' ),
37- new \GuzzleHttp \MessageFormatter ($ httpLogFormat )
38- )
39- );
40- }
41-
42- $ this ->client = $ client ?? $ this ->buildClient ($ access_token , $ stack );
31+ $ this ->client = $ client ?? $ this ->buildClient ($ access_token );
4332 }
4433
45- private function buildClient ($ access_token, $ stack )
34+ private function buildClient ($ access_token )
4635 {
47- return new Client ([
36+ return Http:: withOptions ([
4837 'base_uri ' => 'https://api.airtable.com ' ,
4938 'headers ' => [
5039 'Authorization ' => "Bearer {$ access_token }" ,
5140 'content-type ' => 'application/json ' ,
5241 ],
53- 'handler ' => $ stack ,
5442 ]);
5543 }
5644
@@ -191,7 +179,7 @@ public function decodeResponse($response)
191179 return [];
192180 }
193181
194- return json_decode ($ body , true );
182+ return collect ( json_decode ($ body , true ) );
195183 }
196184
197185 public function setFields (?array $ fields )
0 commit comments