1. Go to this page and download the library: Download fruitware/gabriel-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fruitware / gabriel-api example snippets
namespace MyProject;
use Fruitware\GabrielApi\Gabriel\Client;
use Fruitware\GabrielApi\Gabriel\Session;
use Fruitware\GabrielApi\Model\Customer;
use Fruitware\GabrielApi\Model\CustomerInterface;
use Fruitware\GabrielApi\Model\Passenger;
use Fruitware\GabrielApi\Model\PassengerInterface;
use Fruitware\GabrielApi\Model\PassengerIterator;
use Fruitware\GabrielApi\Model\Search;
use Fruitware\GabrielApi\Model\SearchInterface;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Subscriber\Log\Formatter;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
class Example
{
// init Client
Session::setCredentials('YOUR_GABRIEL_LOGIN', 'YOUR_GABRIEL_PASSWORD');
$guzzleClient = new GuzzleClient(['base_url' => 'https://b2b.airmoldova.md/']);
$client = new Client($guzzleClient);
// set cache, if you want (your class must implement Fruitware\GabrielApi\CacheInterface)
$client->setCache(new Cache());
// create a log channel for guzzle requests, if you want
$log = new Logger('gabriel_guzzle_request');
$log->pushHandler(new StreamHandler(__DIR__.'/logs/gabriel_guzzle_request.log', Logger::DEBUG));
$subscriber = new LogSubscriber($log, Formatter::SHORT);
$client->getHttpClient()->getEmitter()->attach($subscriber);
// create a log for client class, if you want (monolog/monolog
// 5. set passengers
$passengersIterator = new PassengerIterator();
$passenger = new Passenger();
$passenger
->setPassengerId(0)
->setFirstName('firstName')
->setLastName('lastName')
->setTitle(PassengerInterface::TITLE_MR)
->setGender(PassengerInterface::GENDER_MALE)
->setBirthDate(new \DateTime('1977-01-01'))
->setPassport('A0000001')
->setPassportCountry('MD')
->setPassportIssued(new \DateTime('2014-01-10'))
->setPassportExpire(new \DateTime('2017-01-10'))
->setMobilePhone('+37322123456')
->setEmail('[email protected]')
;
$passengersIterator->add($passenger);
$client->setPassengers($passengersIterator);
// 6. set customer
// 6.1 one of the passengers can be the customer, if you already call setPassengers method
$client->setCustomer($passenger);
// 6.2 or you can create a customer object
$customer = new Customer();
$customer
->setFirstName('firstName')
->setLastName('lastName')
->setTitle(CustomerInterface::TITLE_MR)
->setGender(CustomerInterface::GENDER_MALE)
->setBirthDate(new \DateTime('1977-01-01'))
->setPassport('A0000001')
->setPassportCountry('MD')
->setPassportIssued(new \DateTime('2014-01-10'))
->setPassportExpire(new \DateTime('2017-01-10'))
->setMobilePhone('+37322123456')
->setEmail('[email protected]')
;
$client->setCustomer($customer);
var_dump($client->getCurrentBooking());
// 6. set payment type
$client->setPayment(PaymentInterface::TYPE_INVOICE);
var_dump($client->getCurrentBooking());
// 7. Confirm reservation
$client->finalizeBooking();
var_dump($client->getCurrentBooking());
// 8. If you want cancel reservation
$newSessionToken = $client->reset();
var_dump($newSessionToken); // or var_dump($client->getSession()->getToken());
}
namespace MyProject;
use Fruitware\GabrielApi\Invoice\Client;
use Fruitware\GabrielApi\Invoice\Session;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Subscriber\Log\Formatter;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
class Example
{
// init Client
Session::setCredentials('YOUR_INVOICE_LOGIN', 'YOUR_INVOICE_PASSWORD');
$guzzleClient = new GuzzleClient(['base_url' => 'https://b2b.airmoldova.md/']);
$client = new Client($guzzleClient);
// create a log channel for guzzle requests, if you want
$log = new Logger('gabriel_guzzle_request');
$log->pushHandler(new StreamHandler(__DIR__.'/logs/gabriel_guzzle_request.log', Logger::DEBUG));
$subscriber = new LogSubscriber($log, Formatter::SHORT);
$client->getHttpClient()->getEmitter()->attach($subscriber);
// create a log for client class, if you want (monolog/monolog
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.