@@ 417-431 (lines=15) @@ | ||
414 | * |
|
415 | * @return string The response body |
|
416 | */ |
|
417 | public function put($url, $data, $contentType = 'application/json') |
|
418 | { |
|
419 | $uri = $this->buildUrl($url); |
|
420 | ||
421 | $request = $this->requestFactory->createRequest('PUT', $uri); |
|
422 | if (!is_null($contentType)) { |
|
423 | $request = $request->withHeader('Content-Type', $contentType); |
|
424 | $request = $request->withHeader('Accept', $contentType); |
|
425 | } |
|
426 | $request = $request->withBody(stream_for($data)); |
|
427 | ||
428 | $response = $this->request($request); |
|
429 | ||
430 | return strval($response->getBody()); |
|
431 | } |
|
432 | ||
433 | /** |
|
434 | * Make a PUT request, sending JSON data. |
|
@@ 472-486 (lines=15) @@ | ||
469 | * |
|
470 | * @return string The response body |
|
471 | */ |
|
472 | public function post($url, $data, $contentType = 'application/json') |
|
473 | { |
|
474 | $uri = $this->buildUrl($url); |
|
475 | ||
476 | $request = $this->requestFactory->createRequest('POST', $uri); |
|
477 | if (!is_null($contentType)) { |
|
478 | $request = $request->withHeader('Content-Type', $contentType); |
|
479 | $request = $request->withHeader('Accept', $contentType); |
|
480 | } |
|
481 | $request = $request->withBody(stream_for($data)); |
|
482 | ||
483 | $response = $this->request($request); |
|
484 | ||
485 | return strval($response->getBody()); |
|
486 | } |
|
487 | ||
488 | /** |
|
489 | * Make a POST request, sending JSON data. |