metmax-io/cbr-api-php

CBR Top WSAPI client wrapper

dev-main 2023-07-03 10:27 UTC

README

Latest Version on Packagist Tests Total Downloads

A PHP wrapper for interacting with CBR Top Webservices API and supports the AuthenticationService, ReservationService, ReferenceDataService. This way you are able to handle the following operations:

  • Submitting a new application or changing an existing application;
  • Requesting open applications;
  • Request previously purchased capacity via TOP;
  • Reservation of requests at own capacity;
  • Requesting the results;
  • Request reference data such as the permitted products and locations, your registered instructors, your agreements with other trainers, and the available languages of the products;
  • Changing the password;

Installation

You can install the package via composer:

composer require metmax-io/cbr-api-php

Create the environment file

cp .env.dist .env

Usage

The API consists of 3 endpoints:

  • Authentication
  • ReferenceData
  • Reservation

The API's are separated in different folders but can be used similarly.

Get a list of physical CBR locations

use MetMax\Cbr\ReferenceData\ReferenceDataClientFactory;
use MetMax\Cbr\ReferenceData\Type\LocationsRequest;

$referenceData = ReferenceDataClientFactory::factory('username', 'password');
$locations = $referenceData->getLocations(new LocationsRequest());

Testing

The package php-http/vcr-plugin is being used to mock SOAP calls towards the CBR API. Responses will be stored inside the fixtures/vcr/ directory.

When a fixture isn't available, an actual HTTP call will be initiated, while the response will be stored as a fixture. If you want to update existing fixtures or creating new endpoints, make sure that the API credentials are configured within the .env file.

Run full testsuite

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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