Skip to content

Commit

Permalink
added exception for get response
Browse files Browse the repository at this point in the history
  • Loading branch information
rajneeshkatkam-plivo committed Aug 1, 2023
1 parent 193ba71 commit b8c26ad
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Plivo/Resources/Verify/VerifySessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(BaseClient $plivoClient, $authId)
/**
* @param string $sessionUuid
* @return VerifySession
* @throws PlivoValidationException
* @throws PlivoValidationException,PlivoResponseException
*/
public function get($sessionUuid)
{
Expand All @@ -54,14 +54,28 @@ public function get($sessionUuid)
$this->uri . 'Verify/Session/'. $sessionUuid .'/',
[]
);

// return the object for chain method
if ($response->getStatusCode() == 200){
return new VerifySession(
$this->client, $response->getContent(),
$this->pathParams['authId'], $this->uri);
}
return json_encode($response->getContent(), JSON_FORCE_OBJECT);

$responseContents = $response->getContent();
if(array_key_exists("error",$responseContents)){
throw new PlivoResponseException(
$responseContents['error'],
0,
null,
$response->getContent(),
$response->getStatusCode()

);
} else {
return json_encode($response->getContent(), JSON_FORCE_OBJECT);
}

}


Expand Down

0 comments on commit b8c26ad

Please sign in to comment.