travelosteam/amara-client

O interpretare a clientului php pentru interogarea TO Amara

dev-main 2021-08-18 11:29 UTC

This package is not auto-updated.

Last update: 2024-05-24 00:49:54 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Requirements

PHP 7.0 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require travelosteam/amara-client

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Getting Started

Downloading Offers

use TravelOS\API\Suppliers\Amara\Clients\Offer
use TravelOS\API\Suppliers\Amara\Clients\Soap\UserToken

/*
 * $user, $pass, $code from Amara TO
 * $key from amara docs
 */
$token = new UserToken($user, $pass, $code, $key);
 
$client = new Offer();
$client->setToken($token);
$archive = $client->DownloadOffer();

$file = pathinfo($archive->FileName, PATHINFO_FILENAME);
file_put_contents($file, $archive->FileContent);

Booking Offer

use TravelOS\API\Suppliers\Amara\Clients\Book
use TravelOS\API\Suppliers\Amara\Clients\Soap\ReservationRequestInfo
use TravelOS\API\Suppliers\Amara\Clients\Soap\UserToken

/*
 * $user, $pass, $code from Amara TO
 * $key from amara docs
 */
$token = new UserToken($user, $pass, $code, $key);
 
$client = new Book();
$client->setToken($token);

$reservation = new ReservationRequestInfo();
// ... add reservation data

try{
   $client->verify($reservation);
   $info = $client->book($reservation);
   var_dump($info);
} carch (\Exception $e){
    echo $e->getMessage();
}