Skip to content

Commit 4b9ba2a

Browse files
committed
Add probe endpoint response
1 parent c76111e commit 4b9ba2a

2 files changed

Lines changed: 450 additions & 8 deletions

File tree

src/Api/EditApi.php

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,12 @@ public function postRenderRequest($edit)
702702
*
703703
* @throws \Shotstack\Client\ApiException on non-2xx response
704704
* @throws \InvalidArgumentException
705-
* @return void
705+
* @return \Shotstack\Client\Model\ProbeResponse
706706
*/
707707
public function probe($url)
708708
{
709-
$this->probeWithHttpInfo($url);
709+
list($response) = $this->probeWithHttpInfo($url);
710+
return $response;
710711
}
711712

712713
/**
@@ -718,7 +719,7 @@ public function probe($url)
718719
*
719720
* @throws \Shotstack\Client\ApiException on non-2xx response
720721
* @throws \InvalidArgumentException
721-
* @return array of null, HTTP status code, HTTP response headers (array of strings)
722+
* @return array of \Shotstack\Client\Model\ProbeResponse, HTTP status code, HTTP response headers (array of strings)
722723
*/
723724
public function probeWithHttpInfo($url)
724725
{
@@ -752,10 +753,46 @@ public function probeWithHttpInfo($url)
752753
);
753754
}
754755

755-
return [null, $statusCode, $response->getHeaders()];
756+
$responseBody = $response->getBody();
757+
switch($statusCode) {
758+
case 200:
759+
if ('\Shotstack\Client\Model\ProbeResponse' === '\SplFileObject') {
760+
$content = $responseBody; //stream goes to serializer
761+
} else {
762+
$content = (string) $responseBody;
763+
}
764+
765+
return [
766+
ObjectSerializer::deserialize($content, '\Shotstack\Client\Model\ProbeResponse', []),
767+
$response->getStatusCode(),
768+
$response->getHeaders()
769+
];
770+
}
771+
772+
$returnType = '\Shotstack\Client\Model\ProbeResponse';
773+
$responseBody = $response->getBody();
774+
if ($returnType === '\SplFileObject') {
775+
$content = $responseBody; //stream goes to serializer
776+
} else {
777+
$content = (string) $responseBody;
778+
}
779+
780+
return [
781+
ObjectSerializer::deserialize($content, $returnType, []),
782+
$response->getStatusCode(),
783+
$response->getHeaders()
784+
];
756785

757786
} catch (ApiException $e) {
758787
switch ($e->getCode()) {
788+
case 200:
789+
$data = ObjectSerializer::deserialize(
790+
$e->getResponseBody(),
791+
'\Shotstack\Client\Model\ProbeResponse',
792+
$e->getResponseHeaders()
793+
);
794+
$e->setResponseObject($data);
795+
break;
759796
}
760797
throw $e;
761798
}
@@ -793,14 +830,25 @@ function ($response) {
793830
*/
794831
public function probeAsyncWithHttpInfo($url)
795832
{
796-
$returnType = '';
833+
$returnType = '\Shotstack\Client\Model\ProbeResponse';
797834
$request = $this->probeRequest($url);
798835

799836
return $this->client
800837
->sendAsync($request, $this->createHttpClientOption())
801838
->then(
802839
function ($response) use ($returnType) {
803-
return [null, $response->getStatusCode(), $response->getHeaders()];
840+
$responseBody = $response->getBody();
841+
if ($returnType === '\SplFileObject') {
842+
$content = $responseBody; //stream goes to serializer
843+
} else {
844+
$content = (string) $responseBody;
845+
}
846+
847+
return [
848+
ObjectSerializer::deserialize($content, $returnType, []),
849+
$response->getStatusCode(),
850+
$response->getHeaders()
851+
];
804852
},
805853
function ($exception) {
806854
$response = $exception->getResponse();
@@ -857,11 +905,11 @@ public function probeRequest($url)
857905

858906
if ($multipart) {
859907
$headers = $this->headerSelector->selectHeadersForMultipart(
860-
[]
908+
['application/json']
861909
);
862910
} else {
863911
$headers = $this->headerSelector->selectHeaders(
864-
[],
912+
['application/json'],
865913
[]
866914
);
867915
}

0 commit comments

Comments
 (0)