Code Monkey home page Code Monkey logo

amadeus-python's People

Contributors

akshitsingla avatar alnacle avatar anthonyroux avatar basil08 avatar cbetta avatar gustavo-bertoldi avatar minjikarin avatar samheyman avatar siddydutta avatar sprutner avatar torresc24 avatar tsolakoua avatar xianqiliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amadeus-python's Issues

Network error

Description

Trying to test the api for deployment in Django app and receiving the error.
while this same works in Node.

Steps to Reproduce

installed the package from pypi

Versions

What version of Python/Pip are you running? What Operating System are you on?
MacOs python3.9

Checklist

Please make sure you checked the following:

  • Which version of Python are you using?

  • 3.9

  • Did you download the latest version of this package?
    yes

  • File "/Users//Desktop/code/python/nktecs/nktecs/home/flight_backend.py", line 26, in
    res1 = amadeus.shopping.flight_offers_search.get(
    File "/Users/manindersingh/Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/shopping/_flight_offers_search.py", line 32, in get
    return self.client.get('/v2/shopping/flight-offers', **params)
    File "/Users/
    /Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/http.py", line 40, in get
    return self.request('GET', path, params)
    File "/Users//Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/http.py", line 112, in request
    self.__access_token()._bearer_token()
    File "/Users/
    /Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/client/access_token.py", line 18, in _bearer_token
    return 'Bearer {0}'.format(self.__token())
    File "/Users//Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/client/access_token.py", line 26, in __token
    self.__update_access_token()
    File "/Users/
    /Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/client/access_token.py", line 40, in __update_access_token
    response = self.__fetch_access_token()
    File "/Users//Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/client/access_token.py", line 45, in __fetch_access_token
    return self.client._unauthenticated_request(
    File "/Users/
    /Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/http.py", line 126, in _unauthenticated_request
    return self.__execute(request)
    File "/Users//Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/http.py", line 152, in __execute
    response._detect_error(self)
    File "/Users/
    /Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/parser.py", line 16, in _detect_error
    self.__raise_error(error, client)
    File "/Users/*/Desktop/code/python/nktecs/env/lib/python3.9/site-packages/amadeus/mixins/parser.py", line 67, in __raise_error
    raise error
    amadeus.client.errors.NetworkError: [---]

Flight data not showing after a specific month

Description

Hi @tsolakoua, I am using the Amadues Python SDK to create a flight data dashboard. I was try to use the functions to get most booked and most travelled destinations, but no results are coming after `2018-03'. Can you please look into it?

Steps to Reproduce

  1. Run pip install amadeus in your terminal
  2. Run the scripts mentioned in the description with valid credentials
  3. Enter dates in parameter after 2018-03

Expected Behavior: Get the required data till present month

Actual Behavior: Data available only after 2018-03

Stable Behavior? All the time

Versions

What version of Python/Pip are you running? What Operating System are you on?

  • Python 3.9.7
  • Amadues 5.1.0
  • OS - Windows 10
  • pip 21.2.3

Checklist

Please make sure you checked the following:

  • Which version of Python are you using? - Yes
  • Did you download the latest version of this package? - Yes

Repository description contains an invalid link

Hey - noticed that the link in this repository's description (https://developer.amadeus.com) is invalid - the first part of the url should be developers - https://developers.amadeus.com. As far as I can tell, the other urls in the readme are correct.

Python 3.5 or lower: example throws exception despite 200 status response

Description

When running the example given in the Getting Started section, the response status is 200 but an exception is thrown. The user just sees: Error: Status 200 []

Steps to Reproduce

  1. Copy example from Getting started
  2. Run with python 3.5 (or lower)
  3. Verify exception thrown despite 200 status response

Expected Behavior: with python 3.6 you get an array of airline check-in urls

Versions

Python 3.5

Checklist

Please make sure you checked the following:

  • Are you running Python 2.7 or 3.6?
  • Did you download the latest version of this package?

Error on module import

Hi,

Hope you're doing well

I'm trying to use the amadeus api with Python but i'm getting an error
I followed all the step in the readme file but whenever i run my python script, i get an error 'cannot import name Client'
It's the same for 'ResponseError' too

Traceback (most recent call last):
File "amadeus.py", line 1, in
from amadeus import Client,ResponseError
File "/mnt/c/wamp64/www/python/amadeus.py", line 1, in
from amadeus import Client,ResponseError
ImportError: cannot import name Client

I'm using pip 21.1.2 and Python 3.7 and i'm on Windows 10

Maybe you can help me ?
I don't know what i'm doing wrong.

Thanks in advance

NotFound Exception error when using DELETE verb

APIs using the DELETE method raises a NotFound exception error.

Traceback (most recent call last):
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/flight_order_management.py", line 13, in <module>
    raise error
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/flight_order_management.py", line 7, in <module>
    response = amadeus.booking.flight_order('eJzTd9cPCjX2Mg8HAAs1Alg%3D').delete()
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/booking/_flight_order.py", line 34, in delete
    return self.client.delete('/v1/booking/flight-orders/{0}'
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 89, in delete
    return self.request('DELETE', path, params)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 113, in request
    return self._unauthenticated_request(
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 129, in _unauthenticated_request
    return self.__execute(request)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 155, in __execute
    response._detect_error(self)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/parser.py", line 16, in _detect_error
    self.__raise_error(error, client)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/parser.py", line 58, in __raise_error
    raise error
amadeus.client.errors.NotFoundError: [404]

How do I get detailed code of error?

Description

ResponseError contains code, etc. ClientError, and error itself, which is status code, etc. 400 - ClientError

but, in debug mode, i get more detailed error, like this:
Response {'body': '{"errors":[{"status":400,"code":4926,"title":"INVALID DATA ' 'RECEIVED","detail":"This location code is unknown"}]}', 'data': None, 'headers': <http.client.HTTPMessage object at 0x0000018895192640>, 'http_response': <HTTPError 400: 'Bad Request'>, 'parsed': True, 'request': <amadeus.client.request.Request object at 0x0000018895192220>, 'result': {'errors': [{'code': 4926, 'detail': 'This location code is unknown', 'status': 400, 'title': 'INVALID DATA RECEIVED'}]}, 'status_code': 400}
how do i get its code(4926, in the example above) and detail, title, and handle it?

AttributeError for flight_offers_search

I have been trying to migrate from Flight Low-fare Search to Flight Offers Search.

On running the following block of code from the examples:

try:
    '''
    Find the cheapest flights from SYD to BKK
    '''
    response = amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2020-07-01', adults=1)
    # print(response.data)
except ResponseError as error:
    raise error

I get:

Traceback (most recent call last):

  File "<ipython-input-7-ee2011bb3023>", line 5, in <module>
    response = amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2020-07-01', adults=1)

AttributeError: 'Shopping' object has no attribute 'flight_offers_search'

I have been running the old API, that is to be decommissioned, successfully for almost six months now without any issues. Can someone please help me here with the new API?

Flight Cheapest Date Search

Description

Not an issue, sorry, but unable to GET any usable data! Cannot get meaningful data using DFW as the origin airport. For example, cheapest flight date search does not return any data. Non-stop flights are not listed when seeking flights between DFW and DOH or DXB during December 2020.

Steps to Reproduce

  1. Ran amadeus.shopping.flight_offers.get(origin='DFW', destination='DOH', departureDate='2020-12-12')
    Response had a whole lot of solid data but JSONata exerciser reported:
    ERROR IN INPUT DATA: JSON.parse: unexpected non-whitespace character after JSON data at line 2852 column 1 of the JSON data Had to suspend JSON parsing.

  2. Ran amadeus.shopping.flight_dates.get(origin='DFW', destination='LHR')
    Response was Error 500 as noted below.

  3. Struggling to get usable (i.e. practical data with origin as DFW) for testing purposes. Would like to get my code/parsing working in test mode before embarking on production pricing schedule. I understand the challenges in servicing international customers but there should be some elementary filters and sorting to suppress valid but unworkable data (e.g. routing such as DFW->HKG->DOH or DFW->ORD->FRA->AMM->DOH; may be useful in some customers but for introductory testing this subset is highly debatable unless one has extended development time).

  4. All workarounds remain unproductive (cannot call it unsuccessful!):

  • Javascript
  • Python (with and without Jupyter)
  • Test at https://test.api.amadeus.com/v1/shopping/ confirmed the challenges previous two steps.

Expected Behavior: Response object containing valid data

Actual Behavior: Error status 500

{
  "errors": [
    {
      "status": 500,
      "code": 141,
      "title": "SYSTEM ERROR HAS OCCURRED",
      "detail": "DATA DOMAIN NOT FOUND FOR REQUEST"
    }
  ]
}

Stable Behavior? 100% for any city pair originating from DFW

Versions

Python 3.7
Ubuntu 19.10

Checklist

Please make sure you checked the following:

  • Running Python 3.7
  • Installed using pip v18.1 in /usr/lib/python3/dist-packages/pip (python 3.7)

amadeus.shopping.flight_dates.get() giving HTTP Error 404: Not Found

Description

Attempting to run code from README (https://github.com/amadeus4dev/amadeus-python) fails

Flight Cheapest Date Search:
amadeus.shopping.flight_dates.get(origin='NYC', destination='MAD')

Steps to Reproduce

  1. Run
from amadeus import Client, ResponseError

amadeus = Client(
    client_id=AMADEUS_ID,
    client_secret=AMADEUS_SECRET
)

try:
    response = amadeus.shopping.flight_dates.get(origin='NYC', destination='MAD')
    print(response.data)
except ResponseError as error:
    print(error)
except Exception as e:
    print(e)

Expected Behavior:

To get a response object

Actual Bahavior:

HTTP Error 404: Not Found

Stable Behavior? [What percentage of the time does it reproduce?]

Right now it is stable, 100% reproducibility.

Versions

Python: python2.7

Pip: pip 19.0.1

Checklist

Please make sure you checked the following:

Are you running Python 2.7 or 3.6? Yes

Did you download the latest version of this package? Yes

Todos before launch

  • Enable travis
  • Make the project public
  • Remove docs from repo
  • Bump version to 1.0.0
  • Update changelog
  • Release 1.0.0
  • Remove checklist issue and this issue
  • Check and fix all links in README

"Your password must not contain more than 10 characters."

Description

I know that it is a bit offtopic here, but I see no better place to report it.

https://developers.amadeus.com/create-account is extremely discouraging and suggests that Amadeus is not following best practices - at least in area of security.

"Your password must not contain more than 10 characters." is a quite absurd error message. Basic password security is that (a) passwords should be hashed, not stored as plaintext (b) passwords should be as long as possible.

Steps to Reproduce

  1. register at https://developers.amadeus.com/create-account as required in the readme
  2. enter a password of a sensible length

__Expected Behavior: no problems

Actual Behavior: "Your password must not contain more than 10 characters."

Stable Behavior? 100%

Specification

Amadeus SDK Specification Document

Requirement Prioritization

The following document follows the MoSCoW method of prioritising rules. Please follow the following guidelines when evaluating rules.

  • MUST - Rules labeled as must are requirements that should not be deviated from at any cost
  • SHOULD - Rules labeled as should are requirements that could be deviated from if needed, though this will have to be documented and cleared with all stakeholders before it can be disregarded.
  • COULD - Rules labeled as could are requirements that are desirable but not necessary and therefore would be nice to have where time and resources permit.

We do not use the fourth won't level in this specification.

Limitations

Currently this specification is limited due to various reasons. This means that currently:

  • This specification mostly focusses on read-only API methods
  • This specification assumes a language that has objects, or object-like features
  • This specification does not assume the SDK is automatically generated

Maintenance Requirements

1. Source Control

  • 1.1 The source code for the SDK must be maintained within Git version control
  • 1.2 Development of new features should happen on feature branches
  • 1.3 Feature branches should pass all tests and linting before they can be merged into the master branch
  • 1.4 Source control should contain tags for each release of the SDK
  • 1.5 The master branch should be kept in a condition that allows for direct use through checkout
  • 1.6 The source code must be hosted publicly
  • 1.7 The source code should use GitHub for public hosting
  • 1.8 The source code should not include build packages, compiled assets, or any other intermediary files used to package the source code into a release

2. Releases & Versioning

  • 2.1 The SDK must use Semantic Versioning to increment the version number as changes are made
  • 2.2 The version number of the SDK could be incremented when the SDK has gathered enough changes to warrant a new release
  • 2.3 For every release a tag must created within Git
  • 2.4 New releases should be deployed automatically to the package manager using the CI server
  • 2.5 For every new release the CHANGELOG file must to be updated with the Major, Minor and Patch changes
  • 2.6 Releases must be pushed to package managers as an Amadeus user not exclusively under any personal accounts
  • 2.7 The version number of the SDK should be independent of the API version
  • 2.8 A release package should not include unnecessary source code files or intermediarry files for the SDK.
  • 2.9 A release package must include the documentation README file
  • 2.10 A release package must include the LICENSE file
  • 2.11 A release package should include the CHANGELOG file
  • 2.12 The name of the SDK should follow language best practices, and be one of amadeus, Amadeus, or amadeus/amadeus.
  • 2.13 If the preferred name of the SDK is not available, it could be one of amadeus-sdk, AmadeusSDK, or amadeusdev/amadeus.
  • 2.14 The name of the SDK must exclude the programming language (e.g. not amadeus-php) or a reference to this being an SDK client library (e.g. not amadeus-sdk)
    practices, and be one of amadeus, Amadeus, or amadeus/amadeus.
  • 2.15 As soon as the first public version of the library has been signed off, the version should be bumped to 1.0.0

3. CI Server

  • 3.1 A Continuous Integration (CI) server must be used to automatically test any branch of the Git repository
  • 3.2 The CI server should be Travis CI.
  • 3.3 The CI server must test against all current LTS language versions
  • 3.4 The CI server could test against popular non-LTS versions
  • 3.5 The CI server could test on different platforms, including Windows, Linux, and macOS.
  • 3.6 The CI server should test new Git tags, and build and push the package to the package manager

Additional Content Requirements

4. Documentation

  • 4.1 The SDKs must include a README file
    • 4.1.1 The README file should include a version badge
    • 4.1.2 The README file should include a test status badge
    • 4.1.3 The README file must link to the LICENSE file
    • 4.1.4 The README file should be written in Markdown
    • 4.1.5 The README file must have instructions on how to install the SDK using a package manager
    • 4.1.6 The README file could have instructions on how to install the SDK from version control
    • 4.1.7 The README file must have instructions on how to initialise the SDK with the API credentials
      • 4.1.7.1 Where possible, the initialised client variable should be named amadeus. For example, amadeus = new Amadeus::Client()
    • 4.1.8 The README file should document all the different ways the SDK can be initialized
    • 4.1.9 The README file must include a basic sample on how to make a first API call
    • 4.1.10 The README file must link to the developer portal
    • 4.1.11 The README file should link to documentation on the developer portal
    • 4.1.12 The README file must document any installation requirements and prerequisites
    • 4.1.13 The README file should to official support channels
    • 4.1.14 The README file must document where a developer can find their API credentials
  • 4.2 The SDKs should have its public methods documented in a way that allows for autogenerated method documentation. For example, for Ruby this would be yard and for Java this would be using Javadoc.
  • 4.3 The SDKs could use the CI server or any other build tool to autogenerate the method documentation on deploy
  • 4.4 The GitHub repository should have a title in the format "Ruby library for the Amadeus travel APIs"
  • 4.5 The GitHub repository should have the following tags: amadeus, travel, flights, hotels, sdk, library
  • 4.6 The SDKs must include a CHANGELOG file
  • 4.7 The SDKs must include a CODE_OF_CONDUCT file
  • 4.8 The SDKs must include a CONTRIBUTING file
    • 4.8.1 The Contribution Guidelines should include instructions on how to run the SDK in development/testing mode.
  • 4.9 The SDKs must include a ISSUE_TEMPLATE file
  • 4.10 The SDKs must include a PULL_REQUEST_TEMPLATE file
  • 4.11 The SDKs must include a SUPPORT file

Templates for a lot of these files have been provided in the templates folder

5. Testing

  • 5.1 The SDKs must be thoroughly tested
  • 5.2 The tests should have integration tests to make the API calls
  • 5.3 The tests should test response objects
  • 5.4 The tests must not actually make any HTTP calls to the API in testing and instead use some kind of VCR method
  • 5.5 The tests must not include actual API credentials

6. Linting

  • 6.1 The SDKs must have their files linted
  • 6.2 The linting must ensure that tabs/spaces are consistently used
  • 6.3 The linting should ensure no trailing whitespace is left in the code
  • 6.4 The linting should ensure quotes and brackets are consistently applied
  • 6.5 The linting could ensure semicolons are present when needed
  • 6.6 The linting could ensure comments are present on public methods

Dependencies & Infrastructure Requirements

7. Dependencies

  • 7.1 The SDK must limit its runtime dependencies
  • 7.2 The SDK should have no runtime dependencies
  • 7.3 The SDK could use any amount of development and test dependencies

8. HTTP Client

  • 8.1 The SDK must use a well supported HTTP client
  • 8.2 A HTTP client from the standard libraries should be used
  • 8.3 The HTTP should support proxies
  • 8.4 The SDK could allow a developer to provide an alternative HTTP client

9. Logging

  • 9.1 The SDK must be able to log activities to a logger
  • 9.2 The logger should use the default runtime log
  • 9.3 The logger must allow enabling/disabling of debug mode per instance
  • 9.4 The logger should allow a developer to provide an alternative logger
  • 9.5 When debugging is enabled, the logger should log (and only log) the request object, response object, and optionally any raw HTTP response object of no response object could be formed.

10. Reporting

  • 10.1 The SDK must identify requests to the API as originating from the SDK
  • 10.2 The SDK must report the SDK version number to the API
  • 10.3 The SDK should report the language version number to the API
  • 10.4 The HTTP client should use the following format user agent to identify the library:
    • Specification: library_name/library_version language_name/language_version
    • Example with known language version: amadeus-ruby/1.0.0 ruby/2.4.2
  • 10.5 The SDK should allow a developer to provide an additional custom app id and custom app version to be passed along in the user agent.
    • Specification: library_name/library_version language_name/language_version app_name/app_version
    • Example: amadeus-ruby/1.0.0 ruby/2.4.2 test_ios_app/1.0.0

Initialization & Interaction Requirements

11. Initialization

  • 11.1 The SDK could be included or imported when needed, and where applicable must use the amadeus, com.amadeus.developer, or Amadeus package name
  • 11.2 The SDK should reside in its own namespace and avoid polluting the global namespace
  • 11.3 The actual client object for the SDK should exist as a subclass within the Amadeus namespace where the language allows. For for example Amadeus::Client in Ruby, or Amadeus\Client in PHP
  • 11.4 The SDK client must allow for the creation of multiple clients per runtime environment, allowing the creation of multiple clients with different credentials
  • 11.5 The SDK client must be able to accept SDK credentials as method parameters
  • 11.6 The SDK client should accept the SDK credentials implicitly as environment variables AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET
  • 11.7 The SDK client must accept a parameter to turn set the logger level
  • 11.8 The SDK client should be able to implicitly accept the debug level as environment variable AMADEUS_DEBUG
  • 11.9 The SDK client should be able to accept an alternative logger object
  • 11.10 The SDK client could accept an alternative HTTP client
  • 11.11 The SDK client must allow selection of the base URL by name (test and production)
  • 11.12 The SDK client must allow for setting a custom base URL directly

12. Namespacing

  • 12.1 The SDK should use namespaced methods to create a match between the API and the SDK
    • GET /v1/flights : amadeus.flights.get
    • GET /v2/hotels/offers: amadeus.hotels.offers.get
  • 12.2 The SDK could use resource IDs as parameters to the namespace, or as a name or unnamed parameter to the call used to execute the API call
    • GET /v1/hotels/123 : amadeus.hotels(123)
    • GET /v1/hotels/123 : amadeus.hotels.get(123)
    • GET /v1/hotels/123 : amadeus.hotels.get(id: 123)
  • 12.3 The SDK should limit API calls when selecting sub resources. All of these should make 1 API call only
    • GET /v1/hotels/123/hotel-offers : amadeus.hotels(123).offers
    • GET /v1/hotels/123/hotel-offers : amadeus.hotels.get(123).offers
    • GET /v1/hotels/123/hotel-offers : amadeus.hotels.get(id: 123).offers
  • 12.4 The SDK could drop the HTTP verb methods where lazy loading is possible
    • GET /v1/flights/123/legs : amadeus.flights(123).legs() (should make 1 API call only)
    • GET /v1/flights/123/legs/345 : amadeus.flights(123).legs(345) (should make 1 API call only)
  • 12.5- The SDK could convert the API namespace (e.g. reference-data) to a more idiomatic format (e.g. reference_data or ReferenceData)

13. Method Syntax

  • 13.1 The SDK API calls should allow for a method to fetch all records for a resource with or without any parameters
    • Example: amadeus.flights().get() : GET /v1/flights
    • Example: amadeus.flights().get({ foo: 123 } : GET /v1/flights?foo=123
  • 13.2 The SDK API calls should allow for a method to take a record ID to fetch a specific resource
    • Example: amadeus.flights(123).get() : GET /v1/flights/123
  • 13.3 When making a POST or PUT request, the SDK API calls should accept a key/value data structure for the data to be submitted
    • Example: amadeus.flights().post({ from: "LHR", to: "LAX" })
  • 13.4 In asynchronous programming languages, the SDK API calls should allow for a callback method to be provided, or a promise to be returned
    • Example with callback amadeus.flights().get(params, callback_function)
    • Example with promise amadeus.flights().get(params).then(...).catch(...)
  • 13.5 The SDK API calls should return a response object

14. Error Handling

  • 14.1 The SDK should raise a ResponseError for any request that did not result a HTTP 200 or 201 response code
  • 14.2 The SDK should differentiate between different errors
    • 14.2.1 The SDK should raise a NetworkError when a transport error occurs (e.g. if the API could not be reached, or unexpected data was returned from the API)
    • 14.2.2 The SDK should raise a AuthenticationError when incorrect credentials were provided
    • 14.2.3 The SDK should raise a NotFoundError when the API call returned a 404
    • 14.2.4 The SDK should raise a ClientError when a generic client error occurs (e.g. incorrect data was sent to the API, basically any 4XXX error)
    • 14.2.5 The SDK should raise a ServerError if the API returned a 5XX error]
    • 14.2.6 The SDK should raise a ParserError if the response was JSON but could not be parsed
  • 14.3 The response error object must contain a reference to the response object, which itself has a reference to the request object that made the call
  • 14.4 The response error object should contain a code attribute containing the name of the error, e.g. NetworkError.
  • 14.5 The response error object should contain a description attribute containing the parsed JSON from the API, if the API errored and contained JSON.
  • 14.6 The SDK should not validate submitted data within the SDK, instead leaving this task to the API and raising exceptions on receiving an error response from the API

API Mapping Requirements

15. API Calls

  • 15.1 The SDK should define the reference-data namespace
  • 15.2 The SDK should define the shopping namespace
    • 15.2.1 The SDK must implement the GET /v1/shopping/flight-destinations endpoint
      • Example: amadeus.shopping.flight_destinations.get({ origin: 'LAX' })
    • 15.2.2 The SDK must implement the GET /v1/shopping/flight-offers endpoint
      • Example: amadeus.shopping.flight_offers.get({ origin: 'LAX', destination: 'LHR', departureDate: '2020-12-01' })
    • 15.2.3 The SDK must implement the GET /v1/shopping/flight-dates endpoint
      • Example: amadeus.shopping.flight_dates.get({ origin: 'LAX', destination: 'LHR' })
  • 15.3 The SDK should define the travel/analytics namespace
  • 15.4 The SDK should define the shopping/hotels namespace

16. Responses

  • 16.1 The SDK must return a response object where possible, instead of the JSON data directly
  • 16.2 The response object must contain a result attribute with the parsed JSON content if the content could be parsed
  • 16.4 The response object must contain a data attribute with the content from the data key from the result hash, if it is present
  • 16.5 The response object must be parsed as well when an error occurred
  • 16.6 An error must be thrown if the response was JSON but could not be parsed
  • 16.7 The response object must contain a statusCode attribute with HTTP status code of the response
  • 16.8 The response object must contain a request attribute with the details of the original request made
  • 16.9 The response object should contain a parsed attribute which should be true when the JSON was successfully parsed
  • 16.10 The response object should be able to deal with any new parameters returned from the API without needing an SDK update. In other words, the class definition of response objects should not define the attributes of the object statically
  • 16.11 The response object should remain lightweight and not contain any instance variables besides those needed to track what the API returned, keeping the logged output of the instance to the important details of the API call.

17. Requests

  • 17.1 The SDK must keep track of the details of a request in a request object that's accessible through the response object
  • 17.2 The request object must track the host, port, verb, path, params, bearerToken, headers (including User Agent) used for the call
  • 17.3 The request object should remain lightweight and not contain any instance variables besides those needed to track what API call was made, keeping the logged output of the instance to the important details of the API call.

18. Pagination

  • 18.1 The SDK must allow for easy pagination of responses
  • 18.2 The SDK must expose .next, .first, .last, .previous methods on the API client to find the relevant page for a response
    • Example given a previous response: let next_response = amadeus.next(response);
  • 18.3 The SDK should not expose any pagination function on the response objects, as this would require the response objects to keep a reference to the API client, limiting the ability to easily debug a response object

Key Developer Experience Interactions

19. Successful Path Interactions

  • 19.1 Finding a location by type should allow for using a built in type
    • Ruby example: locations = amadeus.reference_data.locations.get(keyword: 'lon', subType: Amadeus::Location::Airport)
    • Node example: let locations = amadeus.referenceData.locations.get({ keyword: 'lon', subType: Amadeus.location.airport });
  • 19.2 Making a query using a location code should be able to use the response from a location query
    • Ruby example: amadeus.foo.bar(origin: locations.data.first['iataCode'])
    • Node example: amadeus.foo.bar({ origin: locations.data.first.iataCode });

20. Unsuccessful Path Interactions

  • 20.1 When incorrect credentials are provided, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.get('/foo/bar')
W, [2018-02-19T16:06:29.881202 #67814]  WARN -- Amadeus AuthenticationError: {
  "error": "invalid_client",
  "error_description": "Client credentials are invalid",
  "code": 38187,
  "title": "Invalid parameters"
}
Node example:
amadeus.client.get('/foo/bar').then(...).catch(...);
Amadeus AuthenticationError { error: 'invalid_client',
  error_description: 'Client credentials are invalid',
  code: 38187,
  title: 'Invalid parameters' }
Python example:
amadeus.get('/foo/bar')
Amadeus AuthenticationError: {'code': 38187,
 'error': 'invalid_client',
 'error_description': 'Client credentials are invalid',
 'title': 'Invalid parameters'}

  • 20.2 When an unknown path is provided, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.get('/foo/bar')
W, [2018-02-19T16:06:13.523516 #67786]  WARN -- Amadeus NotFoundError: [
  {
    "code": 38196,
    "title": "Resource not found",
    "detail": "The targeted resource doesn't exist",
    "status": 404
  }
]
Node example:
amadeus.client.get('/foo/bar').then(...).catch(...);
Amadeus NotFoundError [ { code: 38196,
    title: 'Resource not found',
    detail: 'The targeted resource doesn\'t exist',
    status: 404 } ]
Python example:
amadeus.get('/foo/bar')
Amadeus NotFoundError: [{'code': 38196,
  'detail': "The targeted resource doesn't exist",
  'status': 404,
  'title': 'Resource not found'}]

  • 20.3 When incorrect params are provided, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.reference_data.locations.get(
  subType: Amadeus::Location::ANY
)
W, [2018-02-19T16:05:55.923870 #67772]  WARN -- Amadeus ClientError: [
  {
    "status": 400,
    "code": 32171,
    "title": "MANDATORY DATA MISSING",
    "detail": "Missing mandatory query parameter",
    "source": {

      "parameter": "keyword"
    }
  }
]
Node example:
amadeus.referenceData.locations.get({
  keyword: 'lon'
}).then(...).catch(...);
Amadeus ClientError [ { status: 400,
    code: 32171,
    title: 'MANDATORY DATA MISSING',
    detail: 'Missing mandatory query parameter',
    source: { parameter: 'subType' } } ]
Ruby example:
amadeus.reference_data.locations.get(
  subType: Amadeus::Location::ANY
)
Amadeus ClientError: [{'code': 32171,
  'detail': 'Missing mandatory query parameter',
  'source': {'parameter': 'keyword'},
  'status': 400,
  'title': 'MANDATORY DATA MISSING'}]

  • 20.4 When a server error occurs, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.get('/something/that/errors/');
W, [2018-02-19T16:07:42.651272 #67846]  WARN -- Amadeus ServerError: [
  {
    "code": 38189,
    "title": "Internal error",
    "detail": "An internal error occured, please contact your administrator",
    "status": 500
  }
]
Node example:
amadeus.get('/something/that/errors/').then(...).catch(...);
Amadeus ServerError [ { code: 38189,
    title: 'Internal error',
    detail: 'An internal error occured, please contact your administrator',
    status: 500 } ]
Python example:
amadeus.get('/something/that/errors/');
Amadeus ClientError: [{'code': 38189,
    "code": 38189,
    "title": "Internal error",
    "detail": "An internal error occured, please contact your administrator",
    "status": 500 }]

  • 20.5 When a network error occurs, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.get('/something/that/errors/');
W, [2018-02-19T16:13:14.374444 #68060]  WARN -- Amadeus NetworkError: nil
Node example:
amadeus.get('/something/that/errors/').then(...).catch(...);
Amadeus NetworkError null
Python example:
amadeus.get('/something/that/errors/');
Amadeus NetworkError: None

  • 20.6 When a rate limit occurs, the error returned should be clear even when debug mode is off
Ruby example:
amadeus.get('/something/that/rate/limits/');
W, [2018-02-19T16:07:42.651272 #67846]  WARN -- Amadeus ServerError: [
  { 
    code: 38194,
    title: 'Too many requests',
    detail: 'The network rate limit is exceeded, please try again later',
    status: 429 
  }
]
Node example:
amadeus.get('/something/that/errors/').then(...).catch(...);
Amadeus ClientError [ { code: 38194,
    title: 'Too many requests',
    detail: 'The network rate limit is exceeded, please try again later',
    status: 429 } ]
Python example:
amadeus.get('/something/that/rate/limits/');
Amadeus ClientError: [{'code': 38194,
  'detail': 'The network rate limit is exceeded, please try again later',
  'status': 429,
  'title': 'Too many requests'}]

Specific Language Requirements

23. Python

  • 23.1 The SDK should support Python 2 and 3

Add support for SeatMap Display

Description

Add support for SeatMap Display

Steps to Reproduce

I wrote a new feature to the SDK to enable querying /v1/shopping/seatmaps. Per the contribution guidelines, I'm submitting an new Issue

Versions

Python 3.7.4

amadeus.shopping.flight_destinations.get(origin='LHR') causes server error

Description

Attempting to run code from documentation ( https://amadeus4dev.github.io/amadeus-python/#shopping-flights ) fails

Steps to Reproduce

  1. Run
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='<SNIP>',
    client_secret='<SNIP>'
)



try:
    response = amadeus.shopping.flight_destinations.get(origin='LHR')
    print(response.data)
    print(response.result)
    print(response.body)
    print(response)
except ResponseError as error:
    print("Error")
    print(error)
    print(error.code)

Expected Behavior: [What you expect to happen]

Code based on https://amadeus4dev.github.io/amadeus-python/#shopping-flights and readme will work

Actual Behavior: [What actually happens]

Error
[500]

ServerError

Stable Behavior? [What percentage of the time does it reproduce?]

Today it is stable, 100% reproducibility.

Versions

(not filled as based on #21 it seems that it will be ignored anyway - if any human is reading this please let me known and I will finish report)

What version of Python/Pip are you running? What Operating System are you on?

Checklist

Please make sure you checked the following:

  • Are you running Python 2.7 or 3.6?
  • Did you download the latest version of this package?

Flight Search Returns airline codes 6X and 7X

Description

Performing a flight search between SIN and LHR, in the returned results I can see that some of the shortest flight time results are from carrier code "6X" and "7X" which the dictionary claims is 'Amadeus Six' and 'Amadeus Seven".

I am unsure what these airlines refer to, and whether this is only the case for the testing data set.

Steps to Reproduce

response = amadeus.shopping.flight_offers_search.get( originLocationCode="SIN", destinationLocationCode="LHR", departureDate="2021-02-01", adults=1)

Expected Behavior:

Carrier codes do not represent fictional airlines.

Actual Behavior:
Carrier codes include "6X" and "7X"

Stable Behavior?
Seems to be.

Versions

Mac OS, Python 3.8.

Requests to the `hotel-offers` API fails with 401

Description

Request to the /v2/shopping/hotel-offers fails with 401 error.

My code snippet

client = Client(
    client_id='some api key',
    client_secret='some api secret'
)

client.shopping.hotel_offers.get(cityCode='LON')

Expected Behavior: I expect normal API call with valid response.

Actual Behavior: amadeus.client.errors.AuthenticationError: [401]

Versions

I use python3.9 and latest version of Amadeus client

The main point is the fact that this code snippet works great.

client = Client(
    client_id='some api key',
    client_secret='some api secret'
)

client.shopping.flight_offers_search.get(originLocationCode='LON', destinationLocationCode='LIS', departureDate='2022-10-04', adults=1)

Number of results in a request not customizable

Description

(Python 2.7)

There's no way to customize the number of results in a request. In amadeus 0.1.2, the parameter number_of_results was used to limit results in the interest of time (or other).

Either:

  • This may already be a feature of 1.1.0, and if so, it was not properly documented
  • This is not yet a feature of 1.1.0 and (I believe) it should be added

I'm sure I'd be able to help in either one of these circumstances, whether it be an enhancement or a documentation fix.

Mandatory grant_type form parameter missing

Generating token

I was working on a simple project which required the use of Amadeus API (Flight Offers Search). The given token is active only for 30min.
So a new token is to be generated each time the previous one expires. Amadeus has given an API to generate token using oauth 2.0.

Guide to generate new token
https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262

Steps to Reproduce

  1. POST request to the URL (https://test.api.amadeus.com/v1/security/oauth2/token) with necessary parameters in body
  2. Run the python code given below

Expected response from API:

image

Reply we get by making POST request

Note: I'm using Thunder Client to manage requests

client_id and client_secret are changed

image

Python code to reproduce the above mentioned error

from requests import post
from dotenv import load_dotenv
from os import environ

URL = "https://test.api.amadeus.com/v1/security/oauth2/token"

load_dotenv()

header = {}

header['content-type'] = "application/x-www-form-urlencoded"

r = post(URL,
  headers=header,
  auth=(environ.get("API_KEY"),environ.get("API_SECRET")),
  json={
    "grant_type": "client_credentials",
    "scope":"user_count"
  }
)

response = r.json()

print(response)

However I can generate new token directly in Thunder Client.
image

Versions

Python 3.9.6
Operating System : Windows 10

ParseError Exception with 204 status code responses

Description

Delete operation in Flight Order Management API returns 204 response which contains no body. The response is not properly handled by the SDK raising a ParseError exception.

Using the following code snippet:

try:
    response = amadeus.booking.flight_order('foobar').delete()
except ResponseError as error:
    raise error

The SDK breaks:

Traceback (most recent call last):
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/flight_order_management.py", line 13, in <module>
    raise error
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/flight_order_management.py", line 7, in <module>
    response = amadeus.booking.flight_order('eJzTd9cPCjX2Mg8HAAs1Alg%3D').delete()
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/booking/_flight_order.py", line 34, in delete
    return self.client.delete('/v1/booking/flight-orders/{0}'
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 89, in delete
    return self.request('DELETE', path, params)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 113, in request
    return self._unauthenticated_request(
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 129, in _unauthenticated_request
    return self.__execute(request)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/http.py", line 155, in __execute
    response._detect_error(self)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/parser.py", line 16, in _detect_error
    self.__raise_error(error, client)
  File "/Users/anavarro/src/github.com/alnacle/amadeus-python/amadeus/mixins/parser.py", line 58, in __raise_error
    raise error
amadeus.client.errors.ParserError: [204]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.