Skip to content

Commit f1bc731

Browse files
authored
Add next workflow to SDK (#476)
1 parent 438dfc0 commit f1bc731

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/Verify2/Client.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Vonage\Client\APIClient;
66
use Vonage\Client\APIResource;
77
use Vonage\Client\Exception\Exception;
8+
use Vonage\Client\Exception\Request;
89
use Vonage\Verify2\Request\BaseVerifyRequest;
910

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

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

4647
return true;
4748
}
48-
}
49+
50+
public function nextWorkflow(string $requestId): bool
51+
{
52+
$this->api->create([], '/' . $requestId . '/next_workflow');
53+
54+
return true;
55+
}
56+
}

test/Verify2/ClientTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,28 @@ public function testWillCancelVerification(): void
673673
$this->assertTrue($result);
674674
}
675675

676+
public function testWillHandleNextWorkflow(): void
677+
{
678+
$requestId = 'c11236f4-00bf-4b89-84ba-88b25df97315';
679+
680+
$this->vonageClient->send(Argument::that(function (Request $request) {
681+
$uri = $request->getUri();
682+
$uriString = $uri->__toString();
683+
$this->assertEquals(
684+
'https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/next_workflow',
685+
$uriString
686+
);
687+
688+
$this->assertEquals('POST', $request->getMethod());
689+
690+
return true;
691+
}))->willReturn($this->getResponse('verify-next-workflow-success'));
692+
693+
$result = $this->verify2Client->nextWorkflow($requestId);
694+
695+
$this->assertTrue($result);
696+
}
697+
676698
/**
677699
* This method gets the fixtures and wraps them in a Response object to mock the API
678700
*/

test/Verify2/Fixtures/Responses/verify-next-workflow-success.json

Whitespace-only changes.

0 commit comments

Comments
 (0)