Skip to content

Nascom/ItsmeApiClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ItsmeApiClient

PHP client to connect to the itsme API.

Installation

The package is available via composer:

$ composer require nascom/itsme-api-client

Basic usage

First, you'll need to provide a client that can make HTTP requests. For now, only Guzzle is supported.

<?php

use Nascom\ItsmeApiClient\Http\ApiClient\ApiClient;
use Nascom\ItsmeApiClient\Http\ApiClient\Service;
use Nascom\ItsmeApiClient\Http\ApiClient\ApiClientFactory;

$guzzleClient = new \GuzzleHttp\Client(['base_uri' => Service::PRODUCTION]);
$client = new ApiClient($guzzleClient);

// Alternatively, you can use the ApiClientFactory.
$client = ApiClientFactory::production();

Making requests

Every API endpoint has a corresponding Request class. These classes have to be passed to the client's handle() method.

Creating a transaction:

<?php

use Nascom\ItsmeApiClient\Request\Transaction\CreateTransactionRequest;

$transactionRequest = new CreateTransactionRequest($token, $service, $redirectUrl);
$transaction = $client->handle($transactionRequest);

echo $transaction->getAuthenticationUrl();

Retrieve status after validation of itsme:

<?php

use Nascom\ItsmeApiClient\Request\Status\RetrieveStatusRequest;

$statusRequest = new RetrieveStatusRequest($_SESSION['token']);
$status = $client->handle($statusRequest);

echo $status->getEmailAddress();

About

PHP Client to connect to the itsme API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages