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