@@ 170-191 (lines=22) @@ | ||
167 | * @param string $contentType |
|
168 | * @return array |
|
169 | */ |
|
170 | public function post($ressourceName, $ressourcePath =null, $ressourceId = null, |
|
171 | $bodyData = array(), $query = array(), $assoc = false, |
|
172 | $contentType = 'json') |
|
173 | { |
|
174 | if ($contentType !== 'json') { |
|
175 | throw new \Exception('Use only json to update or create'); |
|
176 | } |
|
177 | try { |
|
178 | $urlRessource = $this->builPathToCall($ressourceName, $ressourcePath, $ressourceId); |
|
179 | $response = $this->getClient()->post($urlRessource, |
|
180 | array( |
|
181 | 'auth' => [$this->username, $this->password], |
|
182 | 'headers' => ['Accept' => "application/$contentType"], |
|
183 | 'json' => $bodyData, |
|
184 | 'query' => $query, |
|
185 | 'verify' => false |
|
186 | )); |
|
187 | } catch (ClientException $ex) { |
|
188 | $response = $ex->getResponse(); |
|
189 | } |
|
190 | return $this->makeCertainApiResponse($response, $contentType, $assoc); |
|
191 | } |
|
192 | ||
193 | /** |
|
194 | * Make "PUT" request with the client. |
|
@@ 204-225 (lines=22) @@ | ||
201 | * @param string $contentType |
|
202 | * @return array |
|
203 | */ |
|
204 | public function put($ressourceName, $ressourcePath =null, $ressourceId = null, |
|
205 | $bodyData = array(), $query = array(), $assoc = false, |
|
206 | $contentType = 'json') |
|
207 | { |
|
208 | if ($contentType !== 'json') { |
|
209 | throw new \Exception('Use only json to update or create'); |
|
210 | } |
|
211 | try { |
|
212 | $urlRessource = $this->builPathToCall($ressourceName, $ressourcePath, $ressourceId); |
|
213 | $response = $this->getClient()->put($urlRessource, |
|
214 | array( |
|
215 | 'auth' => [$this->username, $this->password], |
|
216 | 'headers' => ['Accept' => "application/$contentType"], |
|
217 | 'json' => $bodyData, |
|
218 | 'query' => $query, |
|
219 | 'verify' => false |
|
220 | )); |
|
221 | } catch (ClientException $ex) { |
|
222 | $response = $ex->getResponse(); |
|
223 | } |
|
224 | return $this->makeCertainApiResponse($response, $contentType, $assoc); |
|
225 | } |
|
226 | ||
227 | /** |
|
228 | * Make "DELETE" request with the client. |