amadeus-php@0.3.1: Now with a certification helper

In recent months, I’ve been working on moving an Amadeus implementation from the test environment to production. One aspect of this process was a certification process, where the messages from my system to Amadeus and vice versa had to be captured and sent for validation.

My implementation is based on my fork of the open-source community package amadeus-php. To my fork, I have added a CertificationHelper class that, when enabled, will dump the request and response files to the root directory of the project. These files can then be shared with the validating party.

The CertificationHelper is enabled by using the environmental variable AMADEUS_LOG_LEVEL to certification or my initializing the HTTP client like this:

$amadeus = Amadeus::builder()
    ->setLogLevel("certification")
    ->build();

This will generate request and response files with the following structure:

Request

# URL
POST https://test.travel.api.amadeus.com:443/v2/shopping/flight-offers

# Headers
Accept: application/json, application/vnd.amadeus+json
Authorization: Bearer ****
Content-Type: application/vnd.amadeus+json
X-HTTP-Method-Override: GET
Ama-Client-Ref: ****

# Message body
{
    "currencyCode": "DKK",
    "originDestinations": [
        ...
    ],
    "travelers": [
        ...
    ],
    "sources": [
        ...
    ],
    "searchCriteria": {
        ...
    }
}

The request file is divided into 3 sections (for readability, I have added comments to the request above): URL, Headers and Message body.

Response

# Headers
HTTP/1.1 200 OK
Date: Thu, 07 Sep 2023 10:50:23 GMT
Content-Type: application/vnd.amadeus+json
Content-Length: 487686
Connection: keep-alive
ama-client-ref: ****
Ama-Internal-Message-Version: 14.1
Ama-Request-Id: ****
Ama-Gateway-Request-Id: ****
Access-Control-Allow-Headers: origin, x-requested-with, accept, Content-Type, Authorization
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: OPTIONS, DELETE, POST, GET, PUT, PATCH
Access-Control-Expose-Headers: Ama-Request-Id, Date
Server: Amadeus
Access-Control-Allow-Origin: *

# Message body
{
    "meta": {
        "count": 139
    },
    "data": [
       ...
    ],
    "dictionaries": {
        "locations": {
            ...
        },
        "aircraft": {
           ...
        },
        "currencies": {
            "DKK": "DANISH KRONE"
        },
        "carriers": {
           ...
        }
    }
}

The response file is divided into 2 sections (for readability, I have added comments to the request above): Headers and Message body.

Debugging

In addition to the request and response messages, the CertificationHelper also dumps error messages, with similar structure to the messages above. The key difference is that the error request message only has the message body.

Leave a Reply

Your email address will not be published. Required fields are marked *