Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerMika committed Mar 8, 2016
2 parents 6f74d9f + 1165164 commit 07624ef
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ coding_style:
general:
size: 1
build: true
environment:
php:
version: 5.6
environment:
php:
version: 5.6
2 changes: 1 addition & 1 deletion docs/about-get-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ This is the list of messages that are at least partially supported at this time:
- Air_FlightInfo
- Offer_VerifyOffer
- Offer_ConfirmAirOffer
- Offer_ConfirmHotelOffer
- MiniRule_GetFromPricingRec
- Ticket_CreateTSTFromPricing
- Command_Cryptic
Expand All @@ -128,7 +129,6 @@ On the to-do list / work in progress:
- Fare_DisplayBookingCodeInformation
- Fare_CalculateMileage
- Info_EncodeDecodeCity
- Offer_ConfirmHotelOffer
- Offer_ConfirmCarOffer
- PointOfRef_Search
- PointOfRef_CategoryList
Expand Down
4 changes: 2 additions & 2 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can easily switch from stateful to stateless messages at runtime with:
$client->setStateful(true); //Enable stateful messages
It's also possible to specify the default stateful setting at construction time of the client *(it is enabled by default)*:
It's also possible to specify the default stateful setting at construction time of the client **(stateful is enabled by default)**:

.. code-block:: php
Expand All @@ -32,7 +32,7 @@ It's also possible to specify the default stateful setting at construction time
'sessionHandlerParams' => [
//... other parameters omitted for clarity ...
'stateful' => false,
],
]
]);
$client = new Client($params);
Expand Down
14 changes: 14 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ public function getLastRequest()
return $this->sessionHandler->getLastRequest();
}

/**
* Get session information for authenticated session
*
* - sessionId
* - sequenceNr
* - securityToken
*
* @return array|null
*/
public function getSessionInfo()
{
return $this->sessionHandler->getSessionData();
}

/**
* Get the last raw XML message that was received
*
Expand Down
2 changes: 1 addition & 1 deletion src/Amadeus/Client/RequestOptions/MiniRule/Pricing.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Pricing extends LoadParamsFromArray
/**
* Offer element tattoo
*/
const TYPE_OFFER = "OFR";
const TYPE_OFFER = "OF";

/**
* Transitional Stored Ticket
Expand Down
8 changes: 2 additions & 6 deletions src/Amadeus/Client/Struct/Offer/ConfirmHotel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@
use Amadeus\Client\RequestOptions\Offer\PaymentDetails as PaymentDetailsOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\InvalidArgumentException;
use Amadeus\Client\Struct\Offer\ConfirmHotel\CcInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\CreditCardInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GlobalBookingInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GroupCreditCardInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GuaranteeOrDeposit;
use Amadeus\Client\Struct\Offer\ConfirmHotel\HotelProductReference;
use Amadeus\Client\Struct\Offer\ConfirmHotel\OccupantList;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PaymentDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PaymentInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PnrInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\ReferenceDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RepresentativeParties;
use Amadeus\Client\Struct\Offer\ConfirmHotel\Reservation;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomList;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomRateDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomStayData;
use Amadeus\Client\Struct\Offer\ConfirmHotel\TattooReference;

Expand Down Expand Up @@ -84,7 +80,7 @@ class ConfirmHotel extends BaseWsMessage
public function __construct(OfferConfirmHotelOptions $params)
{
if (!empty($params->recordLocator)) {
$this->pnrInfo = new PnrInfo($params->recordLocator);
$this->pnrInfo = new PnrInfo($params->recordLocator, null, Reservation::CONTROLTYPE_PNR_IDENTIFICATION);
}

if (!empty($params->offerReference)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class HotelProductReference
/**
* Up to 2 elements
*
* @var ReferenceDetails[]
* @var ReferenceDetails
*/
public $referenceDetails = [];
public $referenceDetails;

/**
* HotelProductReference constructor.
*/
public function __construct()
{
$this->referenceDetails[] = new ReferenceDetails();
$this->referenceDetails = new ReferenceDetails(ReferenceDetails::TYPE_BOOKING_CODE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
class Reservation
{
const CONTROLTYPE_PNR_IDENTIFICATION = "P";
/**
* 1A Amadeus
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class RoomRateDetails
public $marker;

/**
* @var HotelProductReference
* @var HotelProductReference[]
*/
public $hotelProductReference;
public $hotelProductReference = [];

public $specialInfo;

Expand All @@ -48,6 +48,6 @@ class RoomRateDetails
*/
public function __construct()
{
$this->hotelProductReference = new HotelProductReference();
$this->hotelProductReference[] = new HotelProductReference();
}
}
12 changes: 12 additions & 0 deletions tests/Amadeus/Client/Struct/Offer/ConfirmHotelOfferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,22 @@ public function testCanConfirmHotelOfferFullOption()
$msg = new ConfirmHotel($opt);

$this->assertEquals('ABC123', $msg->pnrInfo->reservation->controlNumber);
$this->assertEquals(ConfirmHotel\Reservation::CONTROLTYPE_PNR_IDENTIFICATION, $msg->pnrInfo->reservation->controlType);
$this->assertEquals(2, $msg->roomStayData[0]->tattooReference->reference->number);
$this->assertEquals(ConfirmHotel\Reference::QUAL_OFFER_TATTOO, $msg->roomStayData[0]->tattooReference->reference->qualifier);

$this->assertEquals(PassengerReference::TYPE_BOOKING_HOLDER_OCCUPANT, $msg->roomStayData[0]->globalBookingInfo->representativeParties[0]->occupantList->passengerReference->type);
$this->assertEquals(1, $msg->roomStayData[0]->globalBookingInfo->representativeParties[0]->occupantList->passengerReference->value);

$this->assertEquals(ConfirmHotel\ReferenceDetails::TYPE_BOOKING_CODE, $msg->roomStayData[0]->roomList[0]->roomRateDetails->hotelProductReference[0]->referenceDetails->type);

$this->assertEquals(ConfirmHotel\PaymentDetails::FOP_CREDIT_CARD, $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->paymentInfo->paymentDetails->formOfPaymentCode);
$this->assertEquals(ConfirmHotel\PaymentDetails::PAYMENT_GUARANTEED, $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->paymentInfo->paymentDetails->paymentType);
$this->assertEquals(ConfirmHotel\PaymentDetails::SERVICE_HOTEL, $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->paymentInfo->paymentDetails->serviceToPay);

$this->assertEquals('4444333322221111', $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->groupCreditCardInfo->creditCardInfo->ccInfo->cardNumber);
$this->assertEquals('David Bowie', $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->groupCreditCardInfo->creditCardInfo->ccInfo->ccHolderName);
$this->assertEquals('1117', $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->groupCreditCardInfo->creditCardInfo->ccInfo->expiryDate);
$this->assertEquals('AX', $msg->roomStayData[0]->roomList[0]->guaranteeOrDeposit->groupCreditCardInfo->creditCardInfo->ccInfo->vendorCode);
}
}
29 changes: 29 additions & 0 deletions tests/Amadeus/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,35 @@ public function testCanDoSignOutCall()
$this->assertEquals($messageResult, $response);
}

public function testCanGetSessionInfo()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();

$mockedSession = [
'sessionId' => '01ZWHV5EMT',
'sequenceNumber' => '1',
'securityToken' => '3WY60GB9B0FX2SLIR756QZ4G2'
];

$mockSessionHandler
->expects($this->once())
->method('getSessionData')
->will($this->returnValue($mockedSession));

$par = new Params();
$par->sessionHandler = $mockSessionHandler;
$par->requestCreatorParams = new Params\RequestCreatorParams([
'receivedFrom' => 'some RF string',
'originatorOfficeId' => 'BRUXXXXXX'
]);

$client = new Client($par);

$actual = $client->getSessionInfo();

$this->assertEquals($mockedSession, $actual);
}



public function dataProviderMakeMessageOptions()
Expand Down

0 comments on commit 07624ef

Please sign in to comment.