@@ 396-410 (lines=15) @@ | ||
393 | * |
|
394 | * @return string The response body |
|
395 | */ |
|
396 | public function put($url, $data, $contentType = 'application/json') |
|
397 | { |
|
398 | $uri = $this->buildUrl($url); |
|
399 | ||
400 | $request = $this->requestFactory->createRequest('PUT', $uri); |
|
401 | if (!is_null($contentType)) { |
|
402 | $request = $request->withHeader('Content-Type', $contentType); |
|
403 | $request = $request->withHeader('Accept', $contentType); |
|
404 | } |
|
405 | $request = $request->withBody(stream_for($data)); |
|
406 | ||
407 | $response = $this->request($request); |
|
408 | ||
409 | return strval($response->getBody()); |
|
410 | } |
|
411 | ||
412 | /** |
|
413 | * Make a PUT request, sending JSON data. |
|
@@ 451-465 (lines=15) @@ | ||
448 | * |
|
449 | * @return string The response body |
|
450 | */ |
|
451 | public function post($url, $data, $contentType = 'application/json') |
|
452 | { |
|
453 | $uri = $this->buildUrl($url); |
|
454 | ||
455 | $request = $this->requestFactory->createRequest('POST', $uri); |
|
456 | if (!is_null($contentType)) { |
|
457 | $request = $request->withHeader('Content-Type', $contentType); |
|
458 | $request = $request->withHeader('Accept', $contentType); |
|
459 | } |
|
460 | $request = $request->withBody(stream_for($data)); |
|
461 | ||
462 | $response = $this->request($request); |
|
463 | ||
464 | return strval($response->getBody()); |
|
465 | } |
|
466 | ||
467 | /** |
|
468 | * Make a POST request, sending JSON data. |