Skip to content

Commit

Permalink
Add docs for multiwsdl, fixed some code issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerMika committed Sep 15, 2016
1 parent 13e4b59 commit a8951f8
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 151 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 2016-09

* Implemented SalesReports_DisplayQueryReport
* Added support for multiple WSDL's (interfaces) in a WSAP(https://github.com/amabnl/amadeus-ws-client/issues/5)
* Added support for multiple WSDL's (interfaces) in a WSAP (https://github.com/amabnl/amadeus-ws-client/issues/5)
* PSR-2 code style enforced via StyleCI

# 2016-08
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ For now, if you want the bleeding edge, point your composer.json towards `dev-de
- [List of supported messages](docs/list-of-supported-messages.rst)
- [How to](docs/how-to.rst)
- [Examples](docs/samples.rst)

[Changelog](CHANGELOG.md)
40 changes: 40 additions & 0 deletions docs/how-to.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,40 @@ After doing multiple calls with a stateful session, there are two ways to end th
['endSession' => true]
);
***************************
WSAP's with multiple WSDL's
***************************

Amadeus sometimes provides you with multiple WSDL files in a single WSAP. New features in the Amadeus Web Services are sometimes implemented as "interfaces". This library supports those interfaces *(although at the time of writing, it does not yet support any message that can be found in an interface WSDL)*.

You can provide all the WSDL's in your WSAP by passing an array of wsdl's in the Client Params:


use Amadeus\Client;
use Amadeus\Client\Params;

//Set up the client with necessary parameters:

$params = new Params([
'sessionHandlerParams' => [
'soapHeaderVersion' => Client::HEADER_V4,
'wsdl' => [
'/home/user/mytestproject/data/amadeuswsdl/1ASIWXXXXXX_PDT_20160101_080000.wsdl',
'/home/user/mytestproject/data/amadeuswsdl/1ASIWXXXXXX_PDT_MediaServer_1.0_4.0.wsdl'
],
'logger' => new Psr\Log\NullLogger(),
'authParams' => [
'officeId' => 'BRUXX1111',
'userId' => 'WSBENXXX',
'passwordData' => 'dGhlIHBhc3N3b3Jk'
]
]
]);

$client = new Client($params);

You can now call messages from any of the loaded WSDL while staying in the same session & context.

************************************
Handling sessions with Soap Header 2
************************************
Expand All @@ -87,6 +121,12 @@ You can restore a previous current session after you retrieved it from your sess

.. code-block:: php
$previousSessionData = [
'sessionId' => 'XFHZEKLRZHREJ',
'sequenceNumber' => 5,
'securityToken' => 'RKLERJEZLKRHZEJKLRHEZJKLREZRHEZK'
];
$client->setSessionData($previousSessionData);
*********************
Expand Down
32 changes: 3 additions & 29 deletions src/Amadeus/Client/Struct/DocIssuance/DocIssuanceDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,14 @@

namespace Amadeus\Client\Struct\DocIssuance;

use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\DateTime;

/**
* DocIssuanceDateTime
*
* @package Amadeus\Client\Struct\DocIssuance
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class DocIssuanceDateTime
class DocIssuanceDateTime extends DateTime
{
/**
* @var string
*/
public $year;

/**
* @var string
*/
public $month;

/**
* @var string
*/
public $day;

/**
* DocIssuanceDateTime constructor.
*
* @param \DateTime $date
*/
public function __construct($date)
{
if ($date instanceof \DateTime) {
$this->year = $date->format('Y');
$this->month = $date->format('n');
$this->day = $date->format('j');
}
}
}
118 changes: 3 additions & 115 deletions src/Amadeus/Client/Struct/Pnr/AddMultiElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
use Amadeus\Client\Struct\Pnr\AddMultiElements\AirAuxItinerary;
use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsIndiv;
use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsMaster;
use Amadeus\Client\Struct\Pnr\AddMultiElements\DateOfBirth;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementData;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementItinerary;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementPassenger;
use Amadeus\Client\Struct\Pnr\AddMultiElements\Fop;
use Amadeus\Client\Struct\Pnr\AddMultiElements\FopExtension;
use Amadeus\Client\Struct\Pnr\AddMultiElements\FormOfPayment;
Expand All @@ -50,16 +48,13 @@
use Amadeus\Client\Struct\Pnr\AddMultiElements\MiscellaneousRemark;
use Amadeus\Client\Struct\Pnr\AddMultiElements\NewFopsDetails;
use Amadeus\Client\Struct\Pnr\AddMultiElements\OriginDestinationDetails;
use Amadeus\Client\Struct\Pnr\AddMultiElements\Passenger;
use Amadeus\Client\Struct\Pnr\AddMultiElements\PassengerData;
use Amadeus\Client\Struct\Pnr\AddMultiElements\Reference;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ReferenceForDataElement;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ReferenceForSegment;
use Amadeus\Client\Struct\Pnr\AddMultiElements\ServiceRequest;
use Amadeus\Client\Struct\Pnr\AddMultiElements\StructuredAddress;
use Amadeus\Client\Struct\Pnr\AddMultiElements\TicketElement;
use Amadeus\Client\Struct\Pnr\AddMultiElements\TravellerInfo;
use Amadeus\Client\Struct\Pnr\AddMultiElements\Traveller as PnrAddMultiTraveller;

/**
* Structure class for representing the PNR_AddMultiElements request message
Expand Down Expand Up @@ -111,7 +106,7 @@ public function __construct(PnrAddMultiElementsBase $params = null)
*
* For doing specific actions like ignoring or saving PNR.
*
* @param $params
* @param PnrAddMultiElementsOptions $params
*/
protected function loadBare(PnrAddMultiElementsOptions $params)
{
Expand Down Expand Up @@ -254,122 +249,15 @@ protected function addTravellers($travellers)
*/
protected function createTraveller($traveller)
{
$createdTraveller = new TravellerInfo(
ElementManagementPassenger::SEG_NAME,
$traveller->lastName
);

if (!is_null($traveller->number)) {
$createdTraveller->elementManagementPassenger->reference = new Reference(
Reference::QUAL_PASSENGER,
$traveller->number
);
}

if ($traveller->firstName !== null || $traveller->travellerType !== null) {
$createdTraveller->passengerData[0]->travellerInformation->passenger[] = new Passenger(
$traveller->firstName,
$traveller->travellerType
);
}

if ($traveller->withInfant === true || $traveller->infant !== null) {
$createdTraveller = $this->addInfant($createdTraveller, $traveller);
}

if ($traveller->dateOfBirth instanceof \DateTime) {
$createdTraveller->passengerData[0]->dateOfBirth = new DateOfBirth(
$traveller->dateOfBirth->format('dmY')
);
}

return $createdTraveller;
}

/**
* Add infant
*
* 3 scenario's:
* - infant without additional information
* - infant with only first name provided
* - infant with first name, last name & date of birth provided.
*
* @param TravellerInfo $travellerInfo
* @param Traveller $traveller
* @return TravellerInfo
*/
protected function addInfant($travellerInfo, $traveller)
{
$travellerInfo->passengerData[0]->travellerInformation->traveller->quantity = 2;

if ($traveller->withInfant && is_null($traveller->infant)) {
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo);
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator =
Passenger::INF_NOINFO;
} elseif ($traveller->infant instanceof Traveller) {
if (empty($traveller->infant->lastName)) {
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo);
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator =
Passenger::INF_GIVEN;

$tmpInfantPassenger = new Passenger(
$traveller->infant->firstName,
Passenger::PASST_INFANT
);

$travellerInfo->passengerData[0]->travellerInformation->passenger[] = $tmpInfantPassenger;
} else {
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo);
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator =
Passenger::INF_FULL;

$tmpInfant = new PassengerData($traveller->infant->lastName);
$tmpInfant->travellerInformation->passenger[] = new Passenger(
$traveller->infant->firstName,
Passenger::PASST_INFANT
);

if ($traveller->infant->dateOfBirth instanceof \DateTime) {
$tmpInfant->dateOfBirth = new DateOfBirth(
$traveller->infant->dateOfBirth->format('dmY')
);
}

$travellerInfo->passengerData[] = $tmpInfant;
}
}

return $travellerInfo;
}

/**
* If there is no passenger node at
* $travellerInfo->passengerData[0]->travellerInformation->passenger[0]
* create one
*
* @param TravellerInfo $travellerInfo
* @return TravellerInfo
*/
protected function makePassengerIfNeeded($travellerInfo)
{
if (count($travellerInfo->passengerData[0]->travellerInformation->passenger) < 1) {
$travellerInfo->passengerData[0]->travellerInformation->passenger[0] = new Passenger(null, null);
}

return $travellerInfo;
return new TravellerInfo($traveller);
}

/**
* @param TravellerGroup $group
*/
protected function addTravellerGroup($group)
{
$groupInfo = new TravellerInfo(ElementManagementPassenger::SEG_GROUPNAME, $group->name);

$groupInfo->passengerData[0]->travellerInformation->traveller->quantity = $group->nrOfTravellers;
$groupInfo->passengerData[0]->travellerInformation->traveller->qualifier = PnrAddMultiTraveller::QUAL_GROUP;

$this->travellerInfo[] = $groupInfo;
$this->travellerInfo[] = new TravellerInfo(null, $group);

$this->addTravellers($group->travellers);
}
Expand Down
Loading

0 comments on commit a8951f8

Please sign in to comment.