@@ 153-172 (lines=20) @@ | ||
150 | * @param string $contentType |
|
151 | * @return array |
|
152 | */ |
|
153 | public function post($ressourceName, $ressourcePath =null, $ressourceId = null, |
|
154 | $bodyData = array(), $query = array(), $assoc = false, |
|
155 | $contentType = 'json') |
|
156 | { |
|
157 | if ($contentType !== 'json') { |
|
158 | throw new \Exception('Use only json to update or create'); |
|
159 | } |
|
160 | try { |
|
161 | $urlRessource = $this->builPathToCall($ressourceName, $ressourcePath, $ressourceId); |
|
162 | $response = $this->getClient()->post($urlRessource, |
|
163 | array( |
|
164 | 'headers' => ['Accept' => "application/$contentType"], |
|
165 | 'json' => $bodyData, |
|
166 | 'query' => $query |
|
167 | )); |
|
168 | } catch (ClientException $ex) { |
|
169 | $response = $ex->getResponse(); |
|
170 | } |
|
171 | return $this->makeCertainApiResponse($response, $contentType, $assoc); |
|
172 | } |
|
173 | ||
174 | /** |
|
175 | * Make "PUT" request with the client. |
|
@@ 185-204 (lines=20) @@ | ||
182 | * @param string $contentType |
|
183 | * @return array |
|
184 | */ |
|
185 | public function put($ressourceName, $ressourcePath =null, $ressourceId = null, |
|
186 | $bodyData = array(), $query = array(), $assoc = false, |
|
187 | $contentType = 'json') |
|
188 | { |
|
189 | if ($contentType !== 'json') { |
|
190 | throw new \Exception('Use only json to update or create'); |
|
191 | } |
|
192 | try { |
|
193 | $urlRessource = $this->builPathToCall($ressourceName, $ressourcePath, $ressourceId); |
|
194 | $response = $this->getClient()->put($urlRessource, |
|
195 | array( |
|
196 | 'headers' => ['Accept' => "application/$contentType"], |
|
197 | 'json' => $bodyData, |
|
198 | 'query' => $query |
|
199 | )); |
|
200 | } catch (ClientException $ex) { |
|
201 | $response = $ex->getResponse(); |
|
202 | } |
|
203 | return $this->makeCertainApiResponse($response, $contentType, $assoc); |
|
204 | } |
|
205 | ||
206 | /** |
|
207 | * Make "DELETE" request with the client. |