Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added office ids to Master Pricer #44

Merged
merged 4 commits into from
Feb 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,11 @@ class FareMasterPricerTbSearch extends Base
* @var Fare\MPFareFamily[]
*/
public $fareFamilies = [];

/**
* Office IDs
*
* @var string[]
*/
public $officeIds = [];
}
47 changes: 47 additions & 0 deletions src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* amadeus-ws-client
*
* Copyright 2015 Amadeus Benelux NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package Amadeus
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
*/

namespace Amadeus\Client\Struct\Fare\MasterPricer;

/**
* OfficeIdDetails
*
* @package Amadeus\Client\Struct\Fare\MasterPricer
* @author Mike Hernas <mike@ahoy.io>
*/
class OfficeIdDetails
{
/**
* OfficeId Information
*
* @var OfficeIdInformation
*/
public $officeIdInformation;

/**
* @param string $officeId
*/
public function __construct($officeId)
{
$this->officeIdInformation = new OfficeIdInformation($officeId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* amadeus-ws-client
*
* Copyright 2015 Amadeus Benelux NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package Amadeus
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
*/

namespace Amadeus\Client\Struct\Fare\MasterPricer;

/**
* OfficeIdInformation
*
* @package Amadeus\Client\Struct\Fare\MasterPricer
* @author Mike Hernas <mike@ahoy.io>
*/
class OfficeIdInformation
{
/**
* OfficeId Identification
*
* @var OfficeIdentification
*/
public $officeIdentification;

/**
* @param string $officeId
*/
public function __construct($officeId)
{
$this->officeIdentification = new OfficeIdentification($officeId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* amadeus-ws-client
*
* Copyright 2015 Amadeus Benelux NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package Amadeus
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
*/

namespace Amadeus\Client\Struct\Fare\MasterPricer;

/**
* OfficeIdentification
*
* @package Amadeus\Client\Struct\Fare\MasterPricer
* @author Mike Hernas <mike@ahoy.io>
*/
class OfficeIdentification
{
/**
* Agent Sign In
*
* @var string
*/
public $agentSignin;

/**
* @param string $officeId
*/
public function __construct($officeId)
{
$this->agentSignin = $officeId;
}
}
14 changes: 13 additions & 1 deletion src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MasterPricerTravelBoardSearch extends BaseWsMessage
*/
public $feeOption;
/**
* @var mixed
* @var MasterPricer\OfficeIdDetails[]
*/
public $officeIdDetails;

Expand Down Expand Up @@ -164,6 +164,10 @@ protected function loadOptions($options)
$this->loadItinerary($itinerary, $segmentCounter);
}

foreach ($options->officeIds as $officeId) {
$this->loadOfficeId($officeId);
}

if ($this->checkAnyNotEmpty(
$options->cabinClass,
$options->cabinOption,
Expand All @@ -188,6 +192,14 @@ protected function loadOptions($options)
$this->loadFareFamilies($options->fareFamilies);
}

/**
* @param string $officeId
*/
protected function loadOfficeId($officeId)
{
$this->officeIdDetails[] = new MasterPricer\OfficeIdDetails($officeId);
}

/**
* @param MPPassenger $passenger
* @param int $counter BYREF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,45 @@ public function testCanMakeMessageWithPublishedUnifaresCorporateUnifares()
$this->assertEquals(FareMasterPricerTbSearch::CORPORATE_QUALIFIER_UNIFARE, $message->fareOptions->corporate->corporateId[0]->corporateQualifier);
}

public function testCanMakeMessageWithManyOfficeIDs()
{
$opt = new FareMasterPricerTbSearch([
'nrOfRequestedResults' => 30,
'nrOfRequestedPassengers' => 1,
'passengers' => [
new MPPassenger([
'type' => MPPassenger::TYPE_ADULT,
'count' => 1
])
],
'itinerary' => [
new MPItinerary([
'departureLocation' => new MPLocation(['city' => 'BER']),
'arrivalLocation' => new MPLocation(['city' => 'MOW']),
'date' => new MPDate([
'dateTime' => new \DateTime('2017-05-01T00:00:00+0000', new \DateTimeZone('UTC'))
])
])
],
'flightOptions' => [
FareMasterPricerTbSearch::FLIGHTOPT_PUBLISHED,
FareMasterPricerTbSearch::FLIGHTOPT_UNIFARES,
FareMasterPricerTbSearch::FLIGHTOPT_CORPORATE_UNIFARES,
],
'officeIds' => ['A', 'B']
]);

$message = new MasterPricerTravelBoardSearch($opt);

$this->assertCount(2, $message->officeIdDetails);
$this->assertEquals('A',
$message->officeIdDetails[0]->officeIdInformation->officeIdentification->agentSignin
);
$this->assertEquals('B',
$message->officeIdDetails[1]->officeIdInformation->officeIdentification->agentSignin
);
}

public function testCanMakeMessageWithPriceToBeat()
{
$opt = new FareMasterPricerTbSearch([
Expand Down