therealartz / amadeus-php
PHP library for the Amadeus Self-Service travel APIs
0.2.1
2019-10-19 15:26 UTC
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- psr/log: ^1.1
- symfony/cache: ^4.3
Requires (Dev)
- monolog/monolog: ^2.0
- phpunit/phpunit: ^8.4
- symfony/var-dumper: ^4.3
This package is auto-updated.
Last update: 2024-11-02 18:14:03 UTC
README
This library provides implementation of Client to interact with Amadeus Self-Service API on PHP.
Installation via Composer
composer require therealartz/amadeus-php
Quickstart
Setup client
use Amadeus\Client; $apiKey = 'api_key'; $apiSecret = 'api_secret'; $client = new Client($apiKey, $apiSecret);
Authentication will be performed before first request, but token needs to be stored on application side and putted in Client on each request.
// TODO: Provide some example
Shopping Flight Offers
use Amadeus\Request\Shopping\FlightOffersRequestOptions; $request = new FlightOffersRequestOptions( $origin = 'JFK', $destination = 'ORD', $departureDate = \DateTimeImmutable::createFromFormat('Y-m-d', '2020-03-01'), // Any \DateTimeInterface $returnDate = null, $adults = 2, $children = 0, $infants = 0, $seniors = 0, $travelClass = null, $nonStop = false, $currency = 'USD', $maxResults = 50, $maxPrice = null, $arrivalBy = null, $returnBy = null, $includeAirlines = [], $excludeAirlines = [] ); $results = $client->shoppingFlightOffers($request);
Logging
To enable library logging when creating Client pass an instance of Psr\Log\LoggerInterface
as fourth argument (optional):
use Amadeus\Client; use Monolog\Logger; $client = new Client( $apiKey = 'api_key', $apiSecret = 'api_secret', $isProduction = false, $logger = new Logger( 'amadeus', [ new Monolog\Handler\StreamHandler(__DIR__ . '/var/log/amadeus.log') ] ), );
Caching
To enable built-in library cache when creating Client pass an instance of Symfony\Contracts\Cache\CacheInterface
(PSR-16 not supported yet) as fifth argument (optional):
use Amadeus\Client; use Symfony\Component\Cache\Adapter\FilesystemAdapter; $client = new Client( $apiKey = 'api_key', $apiSecret = 'api_secret', $isProduction = false, $logger = null, $cache = new FilesystemAdapter('amadeus', 0, __DIR__ . '/var/cache'), );