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

Add Service_BookPriceProduct #457

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Unreleased
* Implemented ``Service_BookPriceProduct``
* Added Dockerfile/Makefile for easier development

## Release 1.13.0 (5 Apr 2021)
* Add support for multiple pax types in Fare_MasterPricerTravelBoardSearch (https://github.com/amabnl/amadeus-ws-client/pull/432) - Artem Zakharchenko
Expand Down
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ For that it's best to rely on the Amadeus Web Services Extranet functional docum

You should also remember that the request options object is an object used by users of this library, so we should be able to maintain backwards compatibility even when changing the features implemented for a message.

An example pull request to learn from: https://github.com/amabnl/amadeus-ws-client/pull/74
An example pull request to learn from: https://github.com/amabnl/amadeus-ws-client/pull/74

## Testing your changes
If you have docker installed, simply run `make test`, that will
- build a basic docker image (`make build-docker-image`)
- download a composer.phar (`make composer-download`)
- install all dependencies (`make composer-install`)
- and finally run the tests (`make phpunit`)
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
image_name = amadeus-ws-client:build
composer_version = 2.5.1

SHELL = /bin/sh

build-docker-image:
docker build -t $(image_name) -f docker/Dockerfile .

build-docker-image-once:
make verify-docker-image-exists || make build-docker-image

build-docker-image-no-cache:
docker build --no-cache -t $(image_name) -f docker/Dockerfile .

composer-download:
test -f composer.phar || wget -O composer.phar https://getcomposer.org/download/$(composer_version)/composer.phar

composer-install:
make composer-download
test -d ./vendor || docker run --rm -ti -v ~/.composer:/.composer -v $(shell pwd):/var/www -w /var/www -u $(shell id -u) $(image_name) php composer.phar install

composer-update:
make composer-download
docker run --rm -ti -v ~/.composer:/.composer -v $(shell pwd):/var/www -w /var/www -u $(shell id -u) $(image_name) php composer.phar update

phpunit:
docker run --rm -ti -v $(shell pwd):/var/www -w /var/www -u $(shell id -u) $(image_name) vendor/bin/phpunit tests/

test:
make build-docker-image-once
make composer-install
make phpunit

verify-docker-image-exists:
docker image inspect $(image_name) >/dev/null 2>&1
8 changes: 8 additions & 0 deletions docker/20-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
xdebug.mode=debug,coverage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for including this file and the Dockerfile?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, i saw you updated the readme to make testing easier

xdebug.client_port=9000
xdebug.idekey=xdebug
xdebug.discover_client_host=1
; we would receive errors from xdebug if we use the cli
; if you need xdebug logs, change this to https://xdebug.org/docs/all_settings#log_level
; @see https://stackoverflow.com/questions/65213171/disable-xdebug-3-could-not-connect-message-in-cli
xdebug.log_level=0
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM php:7.4-fpm-alpine3.16

RUN apk upgrade --no-cache --ignore alpine-baselayout \
&& apk --no-cache add git libzip-dev libxml2-dev libxslt-dev

RUN set -xe \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
coreutils \
&& docker-php-ext-install -j"$(/usr/bin/nproc)" zip soap xsl \
&& pecl install xdebug-3.1.6 \
&& docker-php-ext-enable xdebug \
&& apk del .build-deps

COPY ./docker/20-xdebug.ini /tmp/xdebug.ini
RUN cat /tmp/xdebug.ini >> $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini

COPY . /var/www
WORKDIR /var/www
1 change: 1 addition & 0 deletions docs/list-of-supported-messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ This is the list of messages that are at least partially supported at this time:
- Service_IntegratedPricing
- Service_IntegratedCatalogue
- Service_StandaloneCatalogue
- Service_BookPriceProduct
- Service_BookPriceService
- Offer_CreateOffer
- Offer_VerifyOffer
Expand Down
26 changes: 26 additions & 0 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3614,6 +3614,32 @@ Service_StandaloneCatalogue
])
);

------------------------
Service_BookPriceProduct
------------------------

Book ancillary with service reference 14 for pax with reference 2 and 3.

You'll get the service references from the ``Service_IntegratedCatalogue`` response.

.. code-block:: php

use Amadeus\Client\RequestOptions\Service\BookPriceProduct\Recommendation;
use Amadeus\Client\RequestOptions\ServiceBookPriceProductOptions;

$bookPriceProductResult = $client->serviceBookPriceProduct(
new ServiceBookPriceProductOptions([
'recommendations' => [
new Recommendation(
[
'id' => 14,
'customerRefIds' => [2, 3]
]
)
]
])
);

------------------------
Service_BookPriceService
------------------------
Expand Down
23 changes: 23 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

use Amadeus\Client\Base;
use Amadeus\Client\Exception;
use Amadeus\Client\InvalidMessageException;
use Amadeus\Client\Params;
use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException;
use Amadeus\Client\RequestOptions;
use Amadeus\Client\RequestOptions\ServiceBookPriceProductOptions;
use Amadeus\Client\Result;
use Amadeus\Client\Session\Handler\UnsupportedOperationException;

Expand Down Expand Up @@ -1694,6 +1697,26 @@ public function serviceIntegratedCatalogue(
return $this->callMessage($msgName, $options, $messageOptions);
}

/**
* Service_BookPriceProduct
*
* @param ServiceBookPriceProductOptions $options
* @param array $messageOptions (OPTIONAL)
*
* @return Result
* @throws Exception
* @throws InvalidMessageException
* @throws MessageVersionUnsupportedException
*/
public function serviceBookPriceProduct(
RequestOptions\ServiceBookPriceProductOptions $options,
$messageOptions = []
) {
$msgName = 'Service_BookPriceProduct';

return $this->callMessage($msgName, $options, $messageOptions);
}

/**
* Service_BookPriceService
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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\RequestCreator\Converter\Service;

use Amadeus\Client\RequestCreator\Converter\BaseConverter;
use Amadeus\Client\RequestOptions\ServiceBookPriceProductOptions;
use Amadeus\Client\Struct;

/**
* Service_BookPriceProduct Request converter
*
* @package Amadeus\Client\RequestCreator\Converter\Service
*/
class BookPriceProductConv extends BaseConverter
{
/**
* @param ServiceBookPriceProductOptions $requestOptions
* @param int|string $version
* @return Struct\Service\BookPriceProduct
*/
public function convert($requestOptions, $version)
{
return new Struct\Service\BookPriceProduct($requestOptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Amadeus\Client\RequestOptions\Service\BookPriceProduct;

use Amadeus\Client\LoadParamsFromArray;

class Recommendation extends LoadParamsFromArray
{
/**
* @var string|int
*/
public $id;

/**
* @var string[]|int[] One or more travelers to whom this service applies
*/
public $customerRefIds = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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\RequestOptions;

use Amadeus\Client\RequestOptions\Service\BookPriceProduct\Recommendation;

/**
* Service_BookPriceProduct Request Options
*
* @package Amadeus\Client\RequestOptions
*/
class ServiceBookPriceProductOptions extends Base
{
/**
* @var string For all OpenTravel versioned messages, the version of the message is indicated by a decimal value.
*/
public $version = '1.0';

/**
* @var Recommendation[]
*/
public $recommendations = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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\ResponseHandler\Service;

/**
* HandlerBookPriceService
*
* @package Amadeus\Client\ResponseHandler\Service
*/
class HandlerBookPriceProduct extends HandlerBookPriceService
{
}
29 changes: 29 additions & 0 deletions src/Amadeus/Client/Struct/Service/BookPriceProduct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Amadeus\Client\Struct\Service;

use Amadeus\Client\RequestOptions\ServiceBookPriceProductOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Service\BookPriceProduct\Recommendation;

class BookPriceProduct extends BaseWsMessage
{
/**
* @var Recommendation[]
*/
public $Recommendation;

public $Version;

/**
* @param ServiceBookPriceProductOptions $options
*/
public function __construct($options)
{
$this->Version = $options->version;

foreach ($options->recommendations as $recommendation) {
$this->Recommendation[] = new Recommendation($recommendation);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Amadeus\Client\Struct\Service\BookPriceProduct;

class Recommendation
{
/**
* @var string
*/
public $RecoID;

/**
* @var string[]
*/
public $CustomerRefIds;

/**
* @param \Amadeus\Client\RequestOptions\Service\BookPriceProduct\Recommendation $recommendationOptions
*/
public function __construct($recommendationOptions)
{
$this->RecoID = $recommendationOptions->id;

if (!empty($recommendationOptions->customerRefIds)) {
$this->CustomerRefIds = $recommendationOptions->customerRefIds;
}
}
}
Loading