@@ 320-333 (lines=14) @@ | ||
317 | * |
|
318 | * @return bool |
|
319 | */ |
|
320 | public function put($url, $data, $contentType = 'application/json') |
|
321 | { |
|
322 | $uri = $this->buildUrl($url); |
|
323 | $headers = []; |
|
324 | if (!is_null($contentType)) { |
|
325 | $headers['Content-Type'] = $contentType; |
|
326 | $headers['Accept'] = $contentType; |
|
327 | } |
|
328 | $request = $this->messageFactory->createRequest('PUT', $uri, $headers, $data); |
|
329 | $response = $this->request($request); |
|
330 | ||
331 | // Consider it a success if status code is 2XX |
|
332 | return substr($response->getStatusCode(), 0, 1) == '2'; |
|
333 | } |
|
334 | ||
335 | /** |
|
336 | * Make a PUT request, sending JSON data. |
|
@@ 372-385 (lines=14) @@ | ||
369 | * |
|
370 | * @return bool |
|
371 | */ |
|
372 | public function post($url, $data, $contentType = 'application/json') |
|
373 | { |
|
374 | $uri = $this->buildUrl($url); |
|
375 | $headers = []; |
|
376 | if (!is_null($contentType)) { |
|
377 | $headers['Content-Type'] = $contentType; |
|
378 | $headers['Accept'] = $contentType; |
|
379 | } |
|
380 | $request = $this->messageFactory->createRequest('POST', $uri, $headers, $data); |
|
381 | $response = $this->request($request); |
|
382 | ||
383 | // Consider it a success if status code is 2XX |
|
384 | return substr($response->getStatusCode(), 0, 1) == '2'; |
|
385 | } |
|
386 | ||
387 | /** |
|
388 | * Make a POST request, sending JSON data. |