One Hat Cyber Team
Your IP:
216.73.216.30
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
proc
/
self
/
root
/
proc
/
thread-self
/
cwd
/
Edit File:
Verify.tar
ClientFactory.php 0000644 00000001715 15111144716 0010030 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use Psr\Container\ContainerInterface; use Vonage\Client\APIResource; use Vonage\Client\Credentials\Handler\BasicHandler; use Vonage\Client\Credentials\Handler\KeypairHandler; use Vonage\Client\Credentials\Handler\TokenBodyHandler; class ClientFactory { public function __invoke(ContainerInterface $container): Client { /** @var APIResource $api */ $api = $container->make(APIResource::class); $api ->setIsHAL(false) ->setBaseUri('/verify') ->setErrorsOn200(true) ->setAuthHandler(new TokenBodyHandler()) ->setExceptionErrorHandler(new ExceptionErrorHandler()); return new Client($api); } } Client.php 0000644 00000031320 15111144716 0006473 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use InvalidArgumentException; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use RuntimeException; use Vonage\Client\APIClient; use Vonage\Client\APIResource; use Vonage\Client\ClientAwareInterface; use Vonage\Client\ClientAwareTrait; use Vonage\Client\Exception as ClientException; use function get_class; use function is_array; use function is_null; use function is_string; use function serialize; use function trigger_error; use function unserialize; class Client implements ClientAwareInterface, APIClient { use ClientAwareTrait; public function __construct(protected ?APIResource $api = null) { } /** * Shim to handle older instantiations of this class * Will change in v3 to just return the required API object */ public function getApiResource(): APIResource { if (is_null($this->api)) { $api = new APIResource(); $api->setClient($this->getClient()) ->setIsHAL(false) ->setBaseUri('/verify'); $this->api = $api; } return $this->api; } /** * @param string|array|Verification|Request $verification * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ public function start($verification): Verification { if (is_array($verification)) { trigger_error( 'Passing an array to Vonage\Verification\Client::start() is deprecated, ' . 'please pass a Vonage\Verify\Request object instead', E_USER_DEPRECATED ); } elseif (is_string($verification)) { trigger_error( 'Passing a string to Vonage\Verification\Client::start() is deprecated, ' . 'please pass a Vonage\Verify\Request object instead', E_USER_DEPRECATED ); } if ($verification instanceof Request) { // Reformat to an array to work with v2.x code, but prep for v3.0.0 $verification = $verification->toArray(); } $api = $this->getApiResource(); $verification = $this->createVerification($verification); $response = $api->create($verification->toArray(), '/json'); $this->processReqRes($verification, $api->getLastRequest(), $api->getLastResponse(), true); return $this->checkError($verification, $response); } /** * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server * * @return array{request_id: string, status: string} */ public function requestPSD2(RequestPSD2 $request): array { $api = $this->getApiResource(); $response = $api->create($request->toArray(), '/psd2/json'); $this->checkError($request, $response); return $response; } /** * @param string|Verification $verification * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ public function search($verification) { if ($verification instanceof Verification) { trigger_error( 'Passing a Verification object to Vonage\Verification\Client::search() is deprecated, ' . 'please pass a string ID instead', E_USER_DEPRECATED ); } $api = $this->getApiResource(); $verification = $this->createVerification($verification); $params = [ 'request_id' => $verification->getRequestId() ]; $data = $api->create($params, '/search/json'); $this->processReqRes($verification, $api->getLastRequest(), $api->getLastResponse(), true); return $this->checkError($verification, $data); } /** * @param $verification * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ public function cancel($verification): Verification { if ($verification instanceof Verification) { trigger_error( 'Passing a Verification object to Vonage\Verification\Client::cancel() is deprecated, ' . 'please pass a string ID instead', E_USER_DEPRECATED ); } return $this->control($verification, 'cancel'); } /** * @param $verification * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ public function trigger($verification): Verification { if ($verification instanceof Verification) { trigger_error( 'Passing a Verification object to Vonage\Verification\Client::trigger() is deprecated, ' . 'please pass a string ID instead', E_USER_DEPRECATED ); } return $this->control($verification, 'trigger_next_event'); } /** * @param string|array|Verification $verification * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ public function check($verification, string $code, string $ip = null): Verification { if (is_array($verification)) { trigger_error( 'Passing an array for parameter 1 to Vonage\Verification\Client::check() is deprecated, ' . 'please pass a string ID instead', E_USER_DEPRECATED ); } elseif ($verification instanceof Verification) { trigger_error( 'Passing a Verification object for parameter 1 to Vonage\Verification\Client::check() is deprecated, ' . 'please pass a string ID instead', E_USER_DEPRECATED ); } $api = $this->getApiResource(); $verification = $this->createVerification($verification); $params = [ 'request_id' => $verification->getRequestId(), 'code' => $code ]; if (!is_null($ip)) { $params['ip'] = $ip; } $data = $api->create($params, '/check/json'); $this->processReqRes($verification, $api->getLastRequest(), $api->getLastResponse(), false); return $this->checkError($verification, $data); } /** * @deprecated Serialize the Verification object directly instead */ public function serialize(Verification $verification): string { trigger_error( $this::class . '::serialize() is deprecated, serialize the Verification object directly', E_USER_DEPRECATED ); return serialize($verification); } /** * @param $verification */ public function unserialize($verification): Verification { trigger_error( $this::class . '::unserialize() is deprecated, unserialize the Verification object directly', E_USER_DEPRECATED ); if (is_string($verification)) { $verification = unserialize($verification, [Verification::class]); } if (!($verification instanceof Verification)) { throw new InvalidArgumentException('expected verification object or serialize verification object'); } @$verification->setClient($this); return $verification; } /** * @param string|array|Verification $verification * @param string $cmd Next command to execute, must be `cancel` or `trigger_next_event` * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Request * @throws ClientException\Server */ protected function control($verification, string $cmd): Verification { if (is_array($verification)) { trigger_error( 'Passing an array for parameter 1 to Vonage\Verification\Client::control() is deprecated,' . 'please pass a string ID instead', E_USER_DEPRECATED ); } elseif ($verification instanceof Verification) { trigger_error( 'Passing a Verification object for parameter 1 to Vonage\Verification\Client::control() ' . 'is deprecated, please pass a string ID instead', E_USER_DEPRECATED ); } $api = $this->getApiResource(); $verification = $this->createVerification($verification); $params = [ 'request_id' => $verification->getRequestId(), 'cmd' => $cmd ]; $data = $api->create($params, '/control/json'); $this->processReqRes($verification, $api->getLastRequest(), $api->getLastResponse(), false); return $this->checkError($verification, $data); } /** * @param $verification * @param $data * * @throws ClientException\Request * @throws ClientException\Server */ protected function checkError($verification, $data) { if (!isset($data['status'])) { $e = new ClientException\Request('unexpected response from API'); $e->setEntity($data); throw $e; } //normalize errors (client vrs server) switch ($data['status']) { // These exist because `status` is valid in both the error // response and a success response, but serve different purposes // in each case case 'IN PROGRESS': case 'SUCCESS': case 'FAILED': case 'EXPIRED': case 'CANCELLED': case '0': return $verification; case '5': $e = new ClientException\Server($data['error_text'], (int)$data['status']); $e->setEntity($data); break; default: $e = new ClientException\Request($data['error_text'], (int)$data['status']); $e->setEntity($data); if (array_key_exists('request_id', $data)) { $e->setRequestId($data['request_id']); } if (array_key_exists('network', $data)) { $e->setNetworkId($data['network']); } break; } $e->setEntity($verification); throw $e; } /** * @param bool $replace */ protected function processReqRes( Verification $verification, RequestInterface $req, ResponseInterface $res, $replace = true ): void { @$verification->setClient($this); if ($replace || !@$verification->getRequest()) { @$verification->setRequest($req); } if ($replace || !@$verification->getResponse()) { @$verification->setResponse($res); } if ($res->getBody()->isSeekable()) { $res->getBody()->rewind(); } } /** * Creates a verification object from a variety of sources * * @param $verification */ protected function createVerification($verification): Verification { if ($verification instanceof Verification) { return $verification; } if (is_array($verification)) { return $this->createVerificationFromArray($verification); } if (is_string($verification)) { return new Verification($verification); } throw new RuntimeException('Unable to create Verification object from source data'); } /** * @param $array */ protected function createVerificationFromArray($array): Verification { if (!is_array($array)) { throw new RuntimeException('verification must implement `' . VerificationInterface::class . '` or be an array`'); } foreach (['number', 'brand'] as $param) { if (!isset($array[$param])) { throw new InvalidArgumentException('missing expected key `' . $param . '`'); } } $number = $array['number']; $brand = $array['brand']; unset($array['number'], $array['brand']); return @new Verification($number, $brand, $array); } } RequestPSD2.php 0000644 00000012775 15111144716 0007353 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use InvalidArgumentException; use Vonage\Entity\Hydrator\ArrayHydrateInterface; use function array_key_exists; use function strlen; class RequestPSD2 implements ArrayHydrateInterface { public const PIN_LENGTH_4 = 4; public const PIN_LENGTH_6 = 6; public const WORKFLOW_SMS_TTS_TSS = 1; public const WORKFLOW_SMS_SMS_TSS = 2; public const WORKFLOW_TTS_TSS = 3; public const WORKFLOW_SMS_SMS = 4; public const WORKFLOW_SMS_TTS = 5; public const WORKFLOW_SMS = 6; public const WORKFLOW_TTS = 7; /** * @var string */ protected $country; /** * @var int */ protected $codeLength; /** * @var string */ protected $locale; /** * @var int */ protected $pinExpiry; /** * @var int */ protected $nextEventWait; /** * @var int */ protected $workflowId; public function __construct(protected string $number, protected string $payee, protected string $amount, int $workflowId = null) { if ($workflowId) { $this->setWorkflowId($workflowId); } } public function getCountry(): ?string { return $this->country; } /** * @return $this */ public function setCountry(string $country): self { if (strlen($country) !== 2) { throw new InvalidArgumentException('Country must be in two character format'); } $this->country = $country; return $this; } public function getCodeLength(): ?int { return $this->codeLength; } /** * @return $this */ public function setCodeLength(int $codeLength): self { if ($codeLength !== 4 || $codeLength !== 6) { throw new InvalidArgumentException('Pin length must be either 4 or 6 digits'); } $this->codeLength = $codeLength; return $this; } public function getLocale(): ?string { return $this->locale; } /** * @return $this */ public function setLocale(string $locale): self { $this->locale = $locale; return $this; } public function getPinExpiry(): ?int { return $this->pinExpiry; } /** * @return $this */ public function setPinExpiry(int $pinExpiry): self { if ($pinExpiry < 60 || $pinExpiry > 3600) { throw new InvalidArgumentException('Pin expiration must be between 60 and 3600 seconds'); } $this->pinExpiry = $pinExpiry; return $this; } public function getNextEventWait(): ?int { return $this->nextEventWait; } /** * @return $this */ public function setNextEventWait(int $nextEventWait): self { if ($nextEventWait < 60 || $nextEventWait > 3600) { throw new InvalidArgumentException('Next Event time must be between 60 and 900 seconds'); } $this->nextEventWait = $nextEventWait; return $this; } public function getWorkflowId(): ?int { return $this->workflowId; } /** * @return $this */ public function setWorkflowId(int $workflowId): self { if ($workflowId < 1 || $workflowId > 7) { throw new InvalidArgumentException('Workflow ID must be from 1 to 7'); } $this->workflowId = $workflowId; return $this; } public function getNumber(): string { return $this->number; } public function getPayee(): string { return $this->payee; } public function getAmount(): string { return $this->amount; } public function fromArray(array $data): void { if (array_key_exists('code_length', $data)) { $this->setCodeLength($data['code_length']); } if (array_key_exists('pin_expiry', $data)) { $this->setPinExpiry($data['pin_expiry']); } if (array_key_exists('next_event_wait', $data)) { $this->setNextEventWait($data['next_event_wait']); } if (array_key_exists('workflow_id', $data)) { $this->setWorkflowId($data['workflow_id']); } if (array_key_exists('country', $data)) { $this->setCountry($data['country']); } if (array_key_exists('lg', $data)) { $this->setLocale($data['lg']); } } /** * @return string[] */ public function toArray(): array { $data = [ 'number' => $this->getNumber(), 'amount' => $this->getAmount(), 'payee' => $this->getPayee(), ]; if ($this->getCodeLength()) { $data['code_length'] = $this->getCodeLength(); } if ($this->getPinExpiry()) { $data['pin_expiry'] = $this->getPinExpiry(); } if ($this->getNextEventWait()) { $data['next_event_wait'] = $this->getNextEventWait(); } if ($this->getWorkflowId()) { $data['workflow_id'] = $this->getWorkflowId(); } if ($this->getCountry()) { $data['country'] = $this->getCountry(); } if ($this->getLocale()) { $data['lg'] = $this->getLocale(); } return $data; } } ExceptionErrorHandler.php 0000644 00000003300 15111144716 0011520 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Vonage\Client\Exception\Request; use Vonage\Client\Exception\Server; use function json_decode; /** * Error handler for API requests returned by the Verify API */ class ExceptionErrorHandler { /** * @todo This should throw a Server exception instead of Request, fix next major release * @throws Request */ public function __invoke(ResponseInterface $response, RequestInterface $request) { $data = json_decode($response->getBody()->getContents(), true); $response->getBody()->rewind(); $e = null; if (!isset($data['status'])) { $e = new Request('unexpected response from API'); $e->setEntity($data); throw $e; } //normalize errors (client vrs server) switch ($data['status']) { // These exist because `status` is valid in both the error // response and a success response, but serve different purposes // in each case case 'IN PROGRESS': case 'SUCCESS': case 'FAILED': case 'EXPIRED': case 'CANCELLED': case '0': break; case '5': default: $e = new Request($data['error_text'], (int)$data['status']); $e->setEntity($data); throw $e; } } } Check.php 0000644 00000001636 15111144716 0006301 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use DateTime; use Exception; class Check { /** * Possible status of checking a code. */ public const VALID = 'VALID'; public const INVALID = 'INVALID'; public function __construct(protected array $data) { } public function getCode() { return $this->data['code']; } /** * @throws Exception */ public function getDate(): DateTime { return new DateTime($this->data['date_received']); } public function getStatus() { return $this->data['status']; } public function getIpAddress() { return $this->data['ip_address']; } } Request.php 0000644 00000013231 15111144717 0006707 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use InvalidArgumentException; use Vonage\Entity\Hydrator\ArrayHydrateInterface; use function array_key_exists; use function strlen; class Request implements ArrayHydrateInterface { public const PIN_LENGTH_4 = 4; public const PIN_LENGTH_6 = 6; public const WORKFLOW_SMS_TTS_TSS = 1; public const WORKFLOW_SMS_SMS_TSS = 2; public const WORKFLOW_TTS_TSS = 3; public const WORKFLOW_SMS_SMS = 4; public const WORKFLOW_SMS_TTS = 5; public const WORKFLOW_SMS = 6; public const WORKFLOW_TTS = 7; /** * @var string */ protected $country; /** * @var string */ protected $senderId = 'VERIFY'; /** * @var int */ protected $codeLength = 4; /** * @var string */ protected $locale; /** * @var int */ protected $pinExpiry = 300; /** * @var int */ protected $nextEventWait = 300; /** * @var int */ protected $workflowId = 1; public function __construct(protected string $number, protected string $brand, int $workflowId = 1) { $this->setWorkflowId($workflowId); } public function getCountry(): ?string { return $this->country; } /** * @return $this */ public function setCountry(string $country): self { if (strlen($country) !== 2) { throw new InvalidArgumentException('Country must be in two character format'); } $this->country = $country; return $this; } public function getSenderId(): string { return $this->senderId; } /** * @return $this */ public function setSenderId(string $senderId): self { $this->senderId = $senderId; return $this; } public function getCodeLength(): int { return $this->codeLength; } /** * @return $this */ public function setCodeLength(int $codeLength): self { if ($codeLength !== self::PIN_LENGTH_4 && $codeLength !== self::PIN_LENGTH_6) { throw new InvalidArgumentException( sprintf('Pin length must be either %d or %d digits', self::PIN_LENGTH_4, self::PIN_LENGTH_6) ); } $this->codeLength = $codeLength; return $this; } public function getLocale(): ?string { return $this->locale; } /** * @return $this */ public function setLocale(string $locale): self { $this->locale = $locale; return $this; } public function getPinExpiry(): int { return $this->pinExpiry; } /** * @return $this */ public function setPinExpiry(int $pinExpiry): self { if ($pinExpiry < 60 || $pinExpiry > 3600) { throw new InvalidArgumentException('Pin expiration must be between 60 and 3600 seconds'); } $this->pinExpiry = $pinExpiry; return $this; } public function getNextEventWait(): int { return $this->nextEventWait; } /** * @return $this */ public function setNextEventWait(int $nextEventWait): self { if ($nextEventWait < 60 || $nextEventWait > 3600) { throw new InvalidArgumentException('Next Event time must be between 60 and 900 seconds'); } $this->nextEventWait = $nextEventWait; return $this; } public function getWorkflowId(): int { return $this->workflowId; } /** * @return $this */ public function setWorkflowId(int $workflowId): self { if ($workflowId < 1 || $workflowId > 7) { throw new InvalidArgumentException('Workflow ID must be from 1 to 7'); } $this->workflowId = $workflowId; return $this; } public function getNumber(): string { return $this->number; } public function getBrand(): string { return $this->brand; } public function fromArray(array $data): void { if (array_key_exists('sender_id', $data)) { $this->setSenderId($data['sender_id']); } if (array_key_exists('code_length', $data)) { $this->setCodeLength($data['code_length']); } if (array_key_exists('pin_expiry', $data)) { $this->setPinExpiry($data['pin_expiry']); } if (array_key_exists('next_event_wait', $data)) { $this->setNextEventWait($data['next_event_wait']); } if (array_key_exists('workflow_id', $data)) { $this->setWorkflowId($data['workflow_id']); } if (array_key_exists('country', $data)) { $this->setCountry($data['country']); } if (array_key_exists('lg', $data)) { $this->setLocale($data['lg']); } } public function toArray(): array { $data = [ 'number' => $this->getNumber(), 'brand' => $this->getBrand(), 'sender_id' => $this->getSenderId(), 'code_length' => $this->getCodeLength(), 'pin_expiry' => $this->getPinExpiry(), 'next_event_wait' => $this->getNextEventWait(), 'workflow_id' => $this->getWorkflowId() ]; if ($this->getCountry()) { $data['country'] = $this->getCountry(); } if ($this->getLocale()) { $data['lg'] = $this->getLocale(); } return $data; } } Verification.php 0000644 00000043443 15111144717 0007711 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use DateTime; use Exception; use Laminas\Diactoros\Request\Serializer as RequestSerializer; use Laminas\Diactoros\Response\Serializer as ResponseSerializer; use Psr\Http\Client\ClientExceptionInterface; use RuntimeException; use Serializable; use Vonage\Client\Exception\Exception as ClientException; use Vonage\Client\Exception\Request as RequestException; use Vonage\Client\Exception\Server as ServerException; use Vonage\Entity\Hydrator\ArrayHydrateInterface; use Vonage\Entity\JsonResponseTrait; use Vonage\Entity\Psr7Trait; use Vonage\Entity\RequestArrayTrait; use function array_merge; use function get_class; use function is_null; use function serialize; use function sprintf; use function trigger_error; use function unserialize; /** * Serializable interface is deprecated and will be removed in the future */ class Verification implements VerificationInterface, Serializable, ArrayHydrateInterface { use Psr7Trait; /** * @deprecated */ use RequestArrayTrait; use JsonResponseTrait; /** * Possible verification statuses. */ public const FAILED = 'FAILED'; public const SUCCESSFUL = 'SUCCESSFUL'; public const EXPIRED = 'EXPIRED'; public const IN_PROGRESS = 'IN PROGRESS'; protected $dirty = true; /** * @deprecated Use the Vonage\Verify\Client instead to interact with the API * * @var Client; */ protected $client; /** * Verification constructor. * * Create a verification with a number and brand, or the `request_id` of an existing verification. * Note that in the future, this constructor will accept only the ID as the first parameter. * * @param $idOrNumber * @param $brand * @param array $additional */ public function __construct($idOrNumber, $brand = null, array $additional = []) { if (is_null($brand)) { $this->dirty = false; $this->requestData['request_id'] = $idOrNumber; } else { trigger_error( 'Using ' . $this::class . ' for starting a verification is deprecated, ' . 'please use Vonage\Verify\Request instead', E_USER_DEPRECATED ); $this->dirty = true; $this->requestData['number'] = $idOrNumber; $this->requestData['brand'] = $brand; $this->requestData = array_merge($this->requestData, $additional); } } /** * Allow Verification to have actions. * * @param Client $client Verify Client * * @return $this * * @deprecated Use the Vonage\Verification\Client service object directly */ public function setClient(Client $client): self { trigger_error( 'Setting a client directly on a Verification object is deprecated, ' . 'please use the Vonage\Verification\Client service object directly', E_USER_DEPRECATED ); $this->client = $client; return $this; } /** * @deprecated Use the Vonage\Verification\Client service object directly */ protected function useClient(): ?Client { if (isset($this->client)) { return $this->client; } throw new RuntimeException('can not act on the verification directly unless a verify client has been set'); } /** * Check if the code is correct. Unlike the method it proxies, an invalid code does not throw an exception. * * @param $code * @param $ip * * @throws ClientException * @throws RequestException * @throws ServerException * @throws ClientExceptionInterface */ public function check($code, $ip = null): ?bool { trigger_error( 'Vonage\Verify\Verification::check() is deprecated, use Vonage\Verification\Client::check()', E_USER_DEPRECATED ); try { if (null !== $this->useClient()) { $this->useClient()->check($this, $code, $ip); return true; } return false; } catch (RequestException $e) { $code = $e->getCode(); if ($code === 16 || $code === 17) { return false; } throw $e; } } /** * Cancel the verification. * * @throws ClientExceptionInterface * @throws ClientException * @throws RequestException * @throws ServerException * * @deprecated Use Vonage\Verification\Client::cancel() */ public function cancel(): void { trigger_error( 'Vonage\Verify\Verification::cancel() is deprecated, use Vonage\Verification\Client::cancel()', E_USER_DEPRECATED ); if (null !== $this->useClient()) { $this->useClient()->cancel($this); } } /** * Trigger the next verification. * * @throws ClientExceptionInterface * @throws ClientException * @throws RequestException * @throws ServerException * * @deprecated Use Vonage\Verification\Client::trigger() */ public function trigger(): void { trigger_error( 'Vonage\Verify\Verification::trigger() is deprecated, use Vonage\Verification\Client::trigger()', E_USER_DEPRECATED ); if (null !== $this->useClient()) { $this->useClient()->trigger($this); } } /** * Update Verification from the API. * * @throws ClientExceptionInterface * @throws ClientException * @throws RequestException * @throws ServerException * * @deprecated Use Vonage\Verification\Client::get() to retrieve the object directly */ public function sync(): void { trigger_error( 'Vonage\Verify\Verification::sync() is deprecated, ' . 'use Vonage\Verification\Client::search() to get a new copy of this object', E_USER_DEPRECATED ); if (null !== $this->useClient()) { $this->useClient()->search($this); } } /** * Check if the user provided data has sent to the API yet * * @deprecated This object will not hold this information in the future */ public function isDirty(): bool { trigger_error( 'Vonage\Verify\Verification::isDirty() is deprecated', E_USER_DEPRECATED ); return $this->dirty; } /** * If do not set number in international format or you are not sure if number is correctly formatted, set country * with the two-character country code. For example, GB, US. Verify works out the international phone number for * you. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $country * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setCountry($country) { return $this->setRequestData('country', $country); } /** * An 11 character alphanumeric string to specify the SenderID for SMS sent by Verify. Depending on the destination * of the phone number you are applying, restrictions may apply. By default, sender_id is VERIFY. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $id * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setSenderId($id) { return $this->setRequestData('sender_id', $id); } /** * The length of the PIN. Possible values are 6 or 4 characters. The default value is 4. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $length * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setCodeLength($length) { return $this->setRequestData('code_length', $length); } /** * By default, TTS are generated in the locale that matches number. For example, the TTS for a 33* number is sent in * French. Use this parameter to explicitly control the language, accent and gender used for the Verify request. The * default language is en-us. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $language * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setLanguage($language) { return $this->setRequestData('lg', $language); } /** * Restrict verification to a certain network type. Possible values are: * - All (Default) * - Mobile * - Landline * * Note: contact support@vonage.com to enable this feature. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $type * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setRequireType($type) { return $this->setRequestData('require_type', $type); } /** * The PIN validity time from generation. This is an integer value between 30 and 3600 seconds. The default is 300 * seconds. When specified together, pin_expiry must be an integer multiple of next_event_wait. Otherwise, * pin_expiry is set to next_event_wait. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $time * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setPinExpiry($time) { return $this->setRequestData('pin_expiry', $time); } /** * An integer value between 60 and 900 seconds inclusive that specifies the wait time between attempts to deliver * the PIN. Verify calculates the default value based on the average time taken by users to complete verification. * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/overview#vrequest * * @param $time * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setWaitTime($time) { return $this->setRequestData('next_event_wait', $time); } /** * Which workflow to use, default is 1 for SMS -> TTS -> TTS * * Can only be set before the verification is created. * * @link https://developer.nexmo.com/verify/guides/workflows-and-events * * @param $workflow_id * * @throws Exception * * @return RequestArrayTrait|Verification */ public function setWorkflowId($workflow_id) { return $this->setRequestData('workflow_id', $workflow_id); } /** * Get the verification request id, if available. */ public function getRequestId() { return $this->proxyArrayAccess('request_id'); } /** * Get the number verified / to be verified. * * @see \Vonage\Verify\Verification::__construct() */ public function getNumber() { return $this->proxyArrayAccess('number'); } /** * Get the account id, if available. * * Only available after a searching for a verification. * * @see \Vonage\Verify\Client::search() */ public function getAccountId(): ?string { return $this->proxyArrayAccess('account_id'); } /** * Get the sender id, if available. * * @see \Vonage\Verify\Verification::setSenderId(); * @see \Vonage\Verify\Client::search(); */ public function getSenderId() { return $this->proxyArrayAccess('sender_id'); } /** * Get the price of the verification, if available. * * Only available after a searching for a verification. * * @see \Vonage\Verify\Client::search(); */ public function getPrice() { return $this->proxyArrayAccess('price'); } /** * Get the currency used to price the verification, if available. * * Only available after a searching for a verification. * * @see \Vonage\Verify\Client::search(); */ public function getCurrency() { return $this->proxyArrayAccess('currency'); } /** * Get the status of the verification, if available. * * Only available after a searching for a verification. * * @see \Vonage\Verify\Client::search(); */ public function getStatus() { return $this->proxyArrayAccess('status'); } /** * Get an array of verification checks, if available. Will return an empty array if no check have been made, or if * the data is not available. * * Only available after a searching for a verification. * * @see \Vonage\Verify\Client::search(); */ public function getChecks() { $checks = $this->proxyArrayAccess('checks'); if (!$checks) { return []; } foreach ($checks as $i => $check) { $checks[$i] = new Check($check); } return $checks; } /** * Get the date the verification started. * * Only available after a searching for a verification. * * @throws Exception * * @see \Vonage\Verify\Client::search(); */ public function getSubmitted() { return $this->proxyArrayAccessDate('date_submitted'); } /** * Get the date the verification stopped. * * Only available after a searching for a verification. * * @throws Exception * * @see \Vonage\Verify\Client::search(); */ public function getFinalized() { return $this->proxyArrayAccessDate('date_finalized'); } /** * Get the date of the first verification event. * * Only available after a searching for a verification. * * @throws Exception * * @see \Vonage\Verify\Client::search(); */ public function getFirstEvent() { return $this->proxyArrayAccessDate('first_event_date'); } /** * Get the date of the last verification event. * * Only available after a searching for a verification. * * @throws Exception * * @see \Vonage\Verify\Client::search(); */ public function getLastEvent() { return $this->proxyArrayAccessDate('last_event_date'); } /** * Proxies `proxyArrayAccess()` and returns a DateTime if the parameter is found. * * @param $param * * @throws Exception */ protected function proxyArrayAccessDate($param): ?DateTime { $date = $this->proxyArrayAccess($param); if ($date) { return new DateTime($date); } return null; } /** * This is hideous and will be refactored in future versions * * @param $param * * @return mixed|null * @throws ClientException */ protected function proxyArrayAccess($param) { $requestDataArray = $this->getRequestData(); if (isset($requestDataArray[$param])) { return $requestDataArray[$param]; } $responseDataArray = $this->getResponseData(); return $responseDataArray[$param] ?? null; } /** * All properties are read only. */ protected function getReadOnlyException(string $offset): RuntimeException { trigger_error( 'Using Vonage\Verify\Verification as an array is deprecated', E_USER_DEPRECATED ); return new RuntimeException( sprintf( 'can not modify `%s` using array access', $offset ) ); } /** * @deprecated Serialization will be removed in the future */ public function serialize(): string { $data = [ 'requestData' => $this->requestData ]; if ($request = @$this->getRequest()) { $data['request'] = RequestSerializer::toString($request); } if ($response = @$this->getResponse()) { $data['response'] = ResponseSerializer::toString($response); } return serialize($data); } /** * @deprecated Serialization will be removed in the future */ public function __serialize(): array { return unserialize($this->serialize()); } /** * @param string $serialized * @deprecated Serialization will be removed in the future */ public function unserialize($serialized) { $data = unserialize($serialized, [true]); $this->requestData = $data['requestData']; if (isset($data['request'])) { $this->request = RequestSerializer::fromString($data['request']); } if (isset($data['response'])) { $this->response = ResponseSerializer::fromString($data['response']); } } /** * @deprecated Serialization will be removed in the future */ public function __unserialize(array $data): void { $this->unserialize(serialize($data)); } /** * @return array<string> */ public function toArray(): array { return $this->requestData; } /** * @param array<string> $data */ public function fromArray(array $data): void { $this->requestData = $data; } } VerificationInterface.php 0000644 00000001362 15111144717 0011524 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Verify; use Vonage\Entity\EntityInterface; interface VerificationInterface extends EntityInterface { public function getNumber(); public function setCountry($country); public function setSenderId($id); public function setCodeLength($length); public function setLanguage($language); public function setRequireType($type); public function setPinExpiry($time); public function setWaitTime($time); public function setWorkflowId($workflow_id); }
Simpan