jincor/verify-php-client

A PHP library which encapsulates interaction with Jincor Verify service

dev-master 2017-11-30 13:21 UTC

This package is not auto-updated.

Last update: 2024-05-16 18:24:49 UTC


README

This is a client library which encapsulates interaction with Jincor Verify. With its help you can:

  1. Initiate verification process for methods: email, google_auth.
  2. Validate code.
  3. Invalidate code.

Usage

Initialize Verify client

To interact with the HTTP protocol use Guzzle. Headers Accept: application/vnd.jincor+json; version=1 , Content-Type: application/json, Authorization: Bearer JWT_TOKEN are mandatory.

$verifyClient = new VerifyClient(new Client([
    'base_uri' => 'verify:3000',
    'headers' => [
        'Accept'        => 'application/vnd.jincor+json; version=1',
        'Content-Type'  => 'application/json',
        'Authorization' => 'Bearer JWT_TOKEN',
    ]
]));

Initiate Verification process

$verificationDetails = $verifyClient->initiate(
    (new EmailVerification())
        ->setTemplate('{{{CODE}}}')
        ->setConsumer('test@test.com')
        ->setExpiredOn('01:00:00')
);

Validate Code

$result = $verifyClient->validate(new EmailValidationData(
    new Uuid('d6b78279-db85-467e-b965-c938d043ffac'),
    '123456'
));
// true

Invalidate Code

$result = $verifyClient->invalidate(new GoogleAuthInvalidationData(
    new Uuid('d6b78279-db85-467e-b965-c938d043ffab')
));
// true

More details can be received in the tests.

Project setup

  1. Clone the repo
  2. cd /path/to/repo
  3. docker-compose build - build development containers
  4. docker-compose up -d - run container
  5. docker-compose exec workspace composer install

Local testing

To run all tests just type docker-compose exec workspace ./vendor/bin/codecept run

Credits

License

The MIT License (MIT). Please see License File for more information.