@@ -98,13 +98,14 @@ public function get($url, $params = []): array
9898 * Perform a POST request
9999 * @param string $url
100100 * @param mixed $body
101+ * @param array $query
101102 * @return array
102103 * @throws SendCloudApiException
103104 */
104- public function post ($ url , $ body ): array
105+ public function post ($ url , $ body, $ query = [] ): array
105106 {
106107 try {
107- $ result = $ this ->client ()->post ($ url , ['body ' => $ body ]);
108+ $ result = $ this ->client ()->post ($ url , ['body ' => $ body, ' query ' => $ query ]);
108109 return $ this ->parseResponse ($ result );
109110 } catch (RequestException $ e ) {
110111 if ($ e ->hasResponse ()) {
@@ -119,13 +120,14 @@ public function post($url, $body): array
119120 * Perform PUT request
120121 * @param string $url
121122 * @param mixed $body
123+ * @param array $query
122124 * @return array
123125 * @throws SendCloudApiException
124126 */
125- public function put ($ url , $ body ): array
127+ public function put ($ url , $ body, $ query = [] ): array
126128 {
127129 try {
128- $ result = $ this ->client ()->put ($ url , ['body ' => $ body ]);
130+ $ result = $ this ->client ()->put ($ url , ['body ' => $ body, ' query ' => $ query ]);
129131 return $ this ->parseResponse ($ result );
130132 } catch (RequestException $ e ) {
131133 if ($ e ->hasResponse ()) {
@@ -139,13 +141,14 @@ public function put($url, $body): array
139141 /**
140142 * Perform DELETE request
141143 * @param string $url
144+ * @param array $query
142145 * @return array
143146 * @throws SendCloudApiException
144147 */
145- public function delete ($ url )
148+ public function delete ($ url, $ query = [] )
146149 {
147150 try {
148- $ result = $ this ->client ()->delete ($ url );
151+ $ result = $ this ->client ()->delete ($ url, [ ' query ' => $ query ] );
149152 return $ this ->parseResponse ($ result );
150153 } catch (RequestException $ e ) {
151154 if ($ e ->hasResponse ()) {
@@ -171,10 +174,15 @@ public function parseResponse(ResponseInterface $response)
171174 $ resultArray = json_decode ($ responseBody , true );
172175
173176 if (! is_array ($ resultArray )) {
174- throw new SendCloudApiException (sprintf ('SendCloud error %s: %s ' , $ response ->getStatusCode (), $ responseBody ), $ response ->getStatusCode ());
177+ throw new SendCloudApiException (sprintf (
178+ 'SendCloud error %s: %s ' ,
179+ $ response ->getStatusCode (),
180+ $ responseBody
181+ ), $ response ->getStatusCode ());
175182 }
176183
177- if (array_key_exists ('error ' , $ resultArray )
184+ if (
185+ array_key_exists ('error ' , $ resultArray )
178186 && is_array ($ resultArray ['error ' ])
179187 && array_key_exists ('message ' , $ resultArray ['error ' ])
180188 ) {
@@ -231,4 +239,3 @@ public function download($url, array $headers = ['Accept' => 'application/pdf'])
231239 return $ result ->getBody ()->getContents ();
232240 }
233241}
234-
0 commit comments