Skip to content

Commit

Permalink
Added null checks for api-id
Browse files Browse the repository at this point in the history
  • Loading branch information
rajneeshkatkam-plivo committed Aug 1, 2023
1 parent 9d6fd5a commit 60c5b1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Plivo/Resources/Verify/VerifySession.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function __construct(
parent::__construct($client);

$this->properties = [
'apiId' => $response['api_id'],
'sessionUuid' => $response['session_uuid'],
'appUuid' => $response['app_uuid'],
'alias' => $response['alias'],
Expand All @@ -52,6 +51,10 @@ public function __construct(
];

// handled empty string and null case
if (!empty($response['api_id'])) {
$this->properties['apiId'] = $response['api_id'];
}

if (!empty($response['requestor_ip'])) {
$this->properties['requesterIP'] = $response['requestor_ip'];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Plivo/Resources/Verify/VerifySessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Plivo\Resources\ResourceInterface;
use Plivo\Exceptions\PlivoNotFoundException;
use Plivo\Resources\ResourceList;
use Plivo\Resources\ResponseUpdate;

/**
* Class VerifySessionInterface
Expand Down Expand Up @@ -175,7 +176,7 @@ public function create($recipient, array $optionalArgs = [])
*
* @param string $sessionUuid
* @param string $otp
* @return VerifySessionCreateResponse
* @return ResponseUpdate
*/
public function validate($sessionUuid, $otp)
{
Expand Down Expand Up @@ -212,10 +213,9 @@ public function validate($sessionUuid, $otp)

);
} else {
return new VerifySessionCreateResponse(
$responseContents['message'],
"",
return new ResponseUpdate(
$responseContents['api_id'],
$responseContents['message'],
$response->getStatusCode()
);
}
Expand Down

0 comments on commit 60c5b1f

Please sign in to comment.