Skip to content

Commit

Permalink
Add next workflow to SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed May 23, 2024
1 parent 438dfc0 commit f834165
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Verify2/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Vonage\Client\APIClient;
use Vonage\Client\APIResource;
use Vonage\Client\Exception\Exception;
use Vonage\Client\Exception\Request;
use Vonage\Verify2\Request\BaseVerifyRequest;

class Client implements APIClient
Expand All @@ -30,7 +31,7 @@ public function check(string $requestId, $code): bool
} catch (Exception $e) {
// For horrible reasons in the API Error Handler, throw the error unless it's a 409.
if ($e->getCode() === 409) {
throw new \Vonage\Client\Exception\Request('Conflict: The current Verify workflow step does not support a code.');
throw new Request('Conflict: The current Verify workflow step does not support a code.');
}

throw $e;
Expand All @@ -45,4 +46,11 @@ public function cancelRequest(string $requestId): bool

return true;
}
}

public function nextWorkflow(string $requestId): bool
{
$this->api->create([], '/' . $requestId . '/next_workflow');

return true;
}
}
22 changes: 22 additions & 0 deletions test/Verify2/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,28 @@ public function testWillCancelVerification(): void
$this->assertTrue($result);
}

public function testWillHandleNextWorkflow(): void
{
$requestId = 'c11236f4-00bf-4b89-84ba-88b25df97315';

$this->vonageClient->send(Argument::that(function (Request $request) {
$uri = $request->getUri();
$uriString = $uri->__toString();
$this->assertEquals(
'https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/next_workflow',
$uriString
);

$this->assertEquals('POST', $request->getMethod());

return true;
}))->willReturn($this->getResponse('verify-next-workflow-success'));

$result = $this->verify2Client->nextWorkflow($requestId);

$this->assertTrue($result);
}

/**
* This method gets the fixtures and wraps them in a Response object to mock the API
*/
Expand Down
Empty file.

0 comments on commit f834165

Please sign in to comment.