@@ -45,48 +45,44 @@ public function __construct()
4545
4646 public function get ($ endpoint , $ query = [])
4747 {
48- $ request = new Request ('GET ' ,$ this ->buildUri ($ endpoint ), $ this ->buildHeaders ());
49-
50- $ response = $ this ->guzzle ->send ($ request );
48+ $ response = $ this ->guzzle ->request ('GET ' ,$ endpoint );
5149
5250 return $ this ->handle ($ response );
5351 }
5452
5553 public function post ($ endpoint , $ data , $ query = [])
5654 {
55+ $ response = $ this ->guzzle ->request ('POST ' ,$ endpoint );
5756
57+ return $ this ->handle ($ response );
5858 }
5959
6060 public function put ($ endpoint , $ data , $ query = [])
6161 {
62+ $ response = $ this ->guzzle ->request ('PUT ' ,$ endpoint );
6263
64+ return $ this ->handle ($ response );
6365 }
6466
6567 public function patch ($ endpoint , $ data , $ query = [])
6668 {
69+ $ response = $ this ->guzzle ->request ('PATCH ' ,$ endpoint );
6770
71+ return $ this ->handle ($ response );
6872 }
6973
7074 public function delete ($ endpoint , $ query = [])
7175 {
76+ $ response = $ this ->guzzle ->request ('DELETE ' ,$ endpoint );
7277
78+ return $ this ->handle ($ response );
7379 }
7480
7581 protected function buildUri ($ endpoint , $ options = [], $ query = [])
7682 {
7783 return 'http://example.com/ ' . ltrim ($ endpoint , '/ ' ) . '.json? ' . http_build_query ($ options , '' , '& ' );
7884 }
7985
80- protected function buildHeaders ($ extraHeaders = [])
81- {
82- $ headers = [
83- 'Accept ' => 'application/json ' ,
84- 'Content-Type: application/json ' ,
85- ];
86-
87- return array_merge ($ headers , $ extraHeaders );
88- }
89-
9086 private function handle (Response $ response , $ default = null )
9187 {
9288 $ stream = stream_for ($ response ->getBody ());
0 commit comments