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