How to use the amadeus.Client function in amadeus

To help you get started, we’ve selected a few amadeus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amadeus4dev / amadeus-python / specs / mixins / parser_spec.py View on Github external
http_response.status_code = '200'
                    http_response.getheaders().returns(
                        [('Content-Type', 'application/json')]
                    )
                    http_response.read().returns('{')

                response = Response(http_response, self.request)
                expect(lambda: response._parse(self.client)).to(
                    raise_error(ParserError)
                )

    with context('Response._detect_error'):
        with before.all:
            http_response = Stub()
            request = Stub(Request)
            self.client = Stub(Client)
            self.client.log_level = 'silent'
            self.response = Response(http_response, request)

        with it('should raise a network error if no status code was found'):
            self.response.status_code = None
            self.response.parsed = False
            expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(NetworkError)
            )

        with it('should raise a server error if a 500 occured'):
            self.response.status_code = 500
            self.response.parsed = False
            expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(ServerError)
            )
github amadeus4dev / amadeus-python / specs / client_spec.py View on Github external
from mamba import description, it
from expects import expect, be_none, equal

from amadeus import Client, Location

with description('Client') as self:
    with it('should exist'):
        expect(Client).not_to(be_none)

    with it('should have helper locations'):
        expect(Location).not_to(be_none)
        expect(Location.ANY).to(equal('AIRPORT,CITY'))
github amadeus4dev / amadeus-python / samples / hotel_search / hotel_search.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

try:
    # Get list of Hotels by city code
    hotels_by_city = amadeus.shopping.hotel_offers.get(cityCode='LON')
    # print(hotels_by_city.data)
    # Get list of offers for a specific hotel
    hotel_offers = amadeus.shopping.hotel_offers_by_hotel.get(hotelId = 'BGLONBGB')
    # print(hotel_offers.data)
    # Confirm the availability of a specific offer
    # print(hotel_offers.data)
    offer_availability = amadeus.shopping.hotel_offer(hotel_offers.data['offers'][0]['id']).get()
    # print(offer_availability.data)

except ResponseError as error:
    print(error)
    raise error
github amadeus4dev / amadeus-python / specs / mixins / validator_spec.py View on Github external
                expect(lambda: Client(**self.valid_params)).to(
                    raise_error(ValueError)
github amadeus4dev / amadeus-python / samples / flight_offers_price / flight_offers_price.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

print('Flight Offers Search')
try:
    '''
    Confirm availability and price from SYD to BKK in summer 2020
    '''
    flights = amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK',
                                                        departureDate='2020-07-01', adults=1).data
    response_one_flight = amadeus.shopping.flight_offers.pricing.post(flights[0])
    print(response_one_flight.data)

    response_two_flights = amadeus.shopping.flight_offers.pricing.post(flights[0:2])
    print(response_two_flights.data)
except ResponseError as error:
    raise error
github amadeus4dev / amadeus-python / samples / flight_delay_prediction / flight_delay_prediction.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

print('Flight Delay Prediction')
try:
    '''
    Will there be a delay from BRU to FRA? If so how much delay?
    '''
    response = amadeus.travel.predictions.flight_delay.get(originLocationCode='NCE', destinationLocationCode='IST',
                                                           departureDate='2020-08-01', departureTime='18:20:00',
                                                           arrivalDate='2020-08-01', arrivalTime='22:15:00',
                                                           aircraftCode='321', carrierCode='TK',
                                                           flightNumber='1816', duration='PT31H10M')
    print(response.data)
except ResponseError as error:
    raise error
github amadeus4dev / amadeus-python / samples / airport_and_city_search / airport_and_city_search.py View on Github external
from amadeus import Client, ResponseError
from amadeus import Location

amadeus = Client()

print('Airport and City Search')
try:
    '''
    Which cities or airports start with 'r'?
    '''
    response = amadeus.reference_data.locations.get(keyword='r',
                                                    subType=Location.ANY)
    print(response.data)
except ResponseError as error:
    raise error
github amadeus4dev / amadeus-python / samples / airport_on_time_performance / airport_on_time_performance.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

print('Aiport on Time Performance')
try:
    '''
    Will there be a delay in the JFK airport on the 1st of September?
    '''
    response = amadeus.airport.predictions.on_time.get(airportCode='JFK', date='2020-09-01')
    print(response.data)
except ResponseError as error:
    raise error
github amadeus4dev / amadeus-python / samples / hotel_ratings / hotel_ratings.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

print('Hotel Ratings')
try:
    '''
    What travelers think about this hotel?
    '''
    response = amadeus.e_reputation.hotel_sentiments.get(hotelIds = 'ADNYCCTB')
    print(response.data)
except ResponseError as error:
    raise error
github amadeus4dev / amadeus-python / samples / trip_purpose_prediction / trip_purpose_prediction.py View on Github external
from amadeus import Client, ResponseError

amadeus = Client()

print('Trip Purpose Prediction')
try:
    '''
    The passenger is traveling for leisure or business?
    '''
    response = amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD',
                                                           departureDate='2020-08-01', returnDate='2020-08-12',
                                                           searchDate='2020-06-11')
    print(response.data)
except ResponseError as error:
    raise error