amadeus 0.1.0 → 1.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +10 -0
- data/LICENSE +15 -0
- data/README.md +157 -19
- data/amadeus.gemspec +26 -16
- data/lib/amadeus.rb +31 -4
- data/lib/amadeus/client.rb +120 -0
- data/lib/amadeus/client/access_token.rb +61 -0
- data/lib/amadeus/client/decorator.rb +27 -0
- data/lib/amadeus/client/errors.rb +76 -0
- data/lib/amadeus/client/http.rb +137 -0
- data/lib/amadeus/client/location.rb +13 -0
- data/lib/amadeus/client/pagination.rb +103 -0
- data/lib/amadeus/client/request.rb +145 -0
- data/lib/amadeus/client/request/hash.rb +32 -0
- data/lib/amadeus/client/response.rb +62 -0
- data/lib/amadeus/client/response/parser.rb +72 -0
- data/lib/amadeus/client/validator.rb +62 -0
- data/lib/amadeus/namespaces/core.rb +51 -0
- data/lib/amadeus/namespaces/reference_data.rb +41 -0
- data/lib/amadeus/namespaces/reference_data/location.rb +42 -0
- data/lib/amadeus/namespaces/reference_data/locations.rb +45 -0
- data/lib/amadeus/namespaces/reference_data/locations/airports.rb +38 -0
- data/lib/amadeus/namespaces/reference_data/urls.rb +27 -0
- data/lib/amadeus/namespaces/reference_data/urls/checkin_links.rb +33 -0
- data/lib/amadeus/namespaces/shopping.rb +66 -0
- data/lib/amadeus/namespaces/shopping/flight_dates.rb +33 -0
- data/lib/amadeus/namespaces/shopping/flight_destinations.rb +30 -0
- data/lib/amadeus/namespaces/shopping/flight_offers.rb +36 -0
- data/lib/amadeus/namespaces/shopping/hotel.rb +56 -0
- data/lib/amadeus/namespaces/shopping/hotel/hotel_offers.rb +44 -0
- data/lib/amadeus/namespaces/shopping/hotel/offer.rb +58 -0
- data/lib/amadeus/namespaces/shopping/hotel_offers.rb +37 -0
- data/lib/amadeus/namespaces/travel.rb +26 -0
- data/lib/amadeus/namespaces/travel/analytics.rb +37 -0
- data/lib/amadeus/namespaces/travel/analytics/air_traffics.rb +37 -0
- data/lib/amadeus/namespaces/travel/analytics/fare_searches.rb +46 -0
- data/lib/amadeus/version.rb +4 -1
- metadata +161 -23
- data/.gitignore +0 -12
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class ReferenceData
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v2/reference-data/urls+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.reference_data.urls
|
13
|
+
#
|
14
|
+
class Urls < Amadeus::Client::Decorator
|
15
|
+
# The namespace for the CheckinLinks APIs:
|
16
|
+
#
|
17
|
+
# @return [Amadeus::Namespaces::ReferenceData::Urls::CheckinLinks]
|
18
|
+
# @example
|
19
|
+
# amadeus.reference_data.urls.checkin_links
|
20
|
+
#
|
21
|
+
def checkin_links
|
22
|
+
Amadeus::Namespaces::ReferenceData::Urls::CheckinLinks.new(client)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class ReferenceData
|
6
|
+
class Urls
|
7
|
+
# A namespaced client for the
|
8
|
+
# +/v2/reference-data/urls/checkin-links+ endpoints
|
9
|
+
#
|
10
|
+
# Access via the +Amadeus::Client+ object
|
11
|
+
#
|
12
|
+
# amadeus = Amadeus::Client.new
|
13
|
+
# amadeus.reference_data.urls.checkin_links
|
14
|
+
#
|
15
|
+
class CheckinLinks < Amadeus::Client::Decorator
|
16
|
+
# Returns the checkin links for an airline, for the
|
17
|
+
# language of your choice
|
18
|
+
#
|
19
|
+
# @option params [String] :airline airline ID - required
|
20
|
+
# @option params [String] :language (en-GB) the locale for the links
|
21
|
+
# @return [Amadeus::Response] a parsed response
|
22
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
23
|
+
# @example Find a the checkin links for Branson AirExpress
|
24
|
+
# amadeus.reference_data.urls.checkin_links.get(airline: '1X')
|
25
|
+
#
|
26
|
+
def get(params = {})
|
27
|
+
client.get('/v2/reference-data/urls/checkin-links', params)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
# A namespaced client for the
|
6
|
+
# +/v1/shopping+ endpoints
|
7
|
+
#
|
8
|
+
# Access via the +Amadeus::Client+ object
|
9
|
+
#
|
10
|
+
# amadeus = Amadeus::Client.new
|
11
|
+
# amadeus.shopping
|
12
|
+
#
|
13
|
+
class Shopping < Amadeus::Client::Decorator
|
14
|
+
# The namespace for the FlightDestinations API:
|
15
|
+
#
|
16
|
+
# @return [Amadeus::Namespaces::Shopping::FlightDestinations]
|
17
|
+
# @example
|
18
|
+
# amadeus.shopping.flight_destinations
|
19
|
+
#
|
20
|
+
def flight_destinations
|
21
|
+
Amadeus::Namespaces::Shopping::FlightDestinations.new(client)
|
22
|
+
end
|
23
|
+
|
24
|
+
# The namespace for the FlightOffers API:
|
25
|
+
#
|
26
|
+
# @return [Amadeus::Namespaces::Shopping::FlightOffers]
|
27
|
+
# @example
|
28
|
+
# amadeus.shopping.flight_offers
|
29
|
+
#
|
30
|
+
def flight_offers
|
31
|
+
Amadeus::Namespaces::Shopping::FlightOffers.new(client)
|
32
|
+
end
|
33
|
+
|
34
|
+
# The namespace for the FlightDates API:
|
35
|
+
#
|
36
|
+
# @return [Amadeus::Namespaces::Shopping::FlightDates]
|
37
|
+
# @example
|
38
|
+
# amadeus.shopping.flight_dates
|
39
|
+
#
|
40
|
+
def flight_dates
|
41
|
+
Amadeus::Namespaces::Shopping::FlightDates.new(client)
|
42
|
+
end
|
43
|
+
|
44
|
+
# The namespace for the HotelOffers API:
|
45
|
+
#
|
46
|
+
# @return [Amadeus::Namespaces::Shopping::HotelOffers]
|
47
|
+
# @example
|
48
|
+
# amadeus.shopping.hotel_offers
|
49
|
+
#
|
50
|
+
def hotel_offers
|
51
|
+
Amadeus::Namespaces::Shopping::HotelOffers.new(client)
|
52
|
+
end
|
53
|
+
|
54
|
+
# The namespace for the Hotels API:
|
55
|
+
#
|
56
|
+
# @param [Number] hotel_id The ID for the hotel to find offers for
|
57
|
+
# @return [Amadeus::Namespaces::Shopping::Hotels]
|
58
|
+
# @example
|
59
|
+
# amadeus.shopping.hotels
|
60
|
+
#
|
61
|
+
def hotels(hotel_id = nil)
|
62
|
+
Amadeus::Namespaces::Shopping::Hotel.new(client, hotel_id)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v1/shopping/flight-dates+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.shopping.flight_dates
|
13
|
+
#
|
14
|
+
class FlightDates < Amadeus::Client::Decorator
|
15
|
+
# Find the cheapest flight dates from an origin to a destination.
|
16
|
+
#
|
17
|
+
# @option params [String] :origin City/Airport IATA code from which the
|
18
|
+
# flight will depart. BOS, for example.
|
19
|
+
# @option params [String] :destination City/Airport IATA code to which
|
20
|
+
# the flight is going. BOS, for example.
|
21
|
+
# @return [Amadeus::Response] a parsed response
|
22
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
23
|
+
# @example Find the cheapest flight from London Heathrow to Paris
|
24
|
+
# amadeus.shopping.flight_dates.get(origin: 'LHR',
|
25
|
+
# destination: 'PAR')
|
26
|
+
#
|
27
|
+
def get(params = {})
|
28
|
+
client.get('/v1/shopping/flight-dates', params)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v1/shopping/flight-destinations+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.shopping.flight_destinations
|
13
|
+
#
|
14
|
+
class FlightDestinations < Amadeus::Client::Decorator
|
15
|
+
# Find the cheapest destinations where you can fly to.
|
16
|
+
#
|
17
|
+
# @option params [String] :origin City/Airport IATA code from which the
|
18
|
+
# flight will depart. BOS, for example.
|
19
|
+
# @return [Amadeus::Response] a parsed response
|
20
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
21
|
+
# @example Find the cheapest destination from London Heathrow
|
22
|
+
# amadeus.shopping.flight_destinations.get(origin: 'LHR')
|
23
|
+
#
|
24
|
+
def get(params = {})
|
25
|
+
client.get('/v1/shopping/flight-destinations', params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v1/shopping/flight-offers+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.shopping.flight_offers
|
13
|
+
#
|
14
|
+
class FlightOffers < Amadeus::Client::Decorator
|
15
|
+
# Find the cheapest bookable flights.
|
16
|
+
#
|
17
|
+
# @option params [String] :origin City/Airport IATA code from which the
|
18
|
+
# flight will depart. BOS, for example.
|
19
|
+
# @option params [String] :destination City/Airport IATA code to which
|
20
|
+
# the traveler is going. PAR, for example
|
21
|
+
# @return [Amadeus::Response] a parsed response
|
22
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
23
|
+
# @example Find the cheapest destination from London to Paris for Xmas
|
24
|
+
# amadeus.shopping.flight_offers.get(
|
25
|
+
# origin: 'LHR',
|
26
|
+
# destination: 'LAX',
|
27
|
+
# departureDate: '2017-12-24'
|
28
|
+
# )
|
29
|
+
#
|
30
|
+
def get(params = {})
|
31
|
+
client.get('/v1/shopping/flight-offers', params)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v1/shopping/hotels+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.shopping.hotels(123)
|
13
|
+
#
|
14
|
+
class Hotel < Amadeus::Client::Decorator
|
15
|
+
# the Hotel ID
|
16
|
+
attr_reader :hotel_id
|
17
|
+
|
18
|
+
# Initialize this namespaced client with an
|
19
|
+
# {Amadeus::Client} instance and a Hotel ID
|
20
|
+
#
|
21
|
+
# @param [Amadeus::Client] client
|
22
|
+
# @param [Number] hotel_id
|
23
|
+
#
|
24
|
+
def initialize(client, hotel_id)
|
25
|
+
super(client)
|
26
|
+
@hotel_id = hotel_id
|
27
|
+
end
|
28
|
+
|
29
|
+
# The namespace for the Hotels::Offers API:
|
30
|
+
#
|
31
|
+
# @param [Number] offer_id The ID for the offer to find details for
|
32
|
+
# @return [Amadeus::Namespaces::Shopping::Hotels::Offers]
|
33
|
+
# @example
|
34
|
+
# amadeus.shopping.hotels('SMPARCOL').offers(234)
|
35
|
+
#
|
36
|
+
def offers(offer_id = nil)
|
37
|
+
Amadeus::Namespaces::Shopping::Hotel::Offer.new(
|
38
|
+
client, @hotel_id, offer_id
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# The namespace for the Hotels::HotelOffers API:
|
43
|
+
#
|
44
|
+
# @return [Amadeus::Namespaces::Shopping::Hotels::HotelOffers]
|
45
|
+
# @example
|
46
|
+
# amadeus.shopping.hotels('SMPARCOL').hotel_offers
|
47
|
+
#
|
48
|
+
def hotel_offers
|
49
|
+
Amadeus::Namespaces::Shopping::Hotel::HotelOffers.new(
|
50
|
+
client, @hotel_id
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
class Hotel
|
7
|
+
# A namespaced client for the
|
8
|
+
# +/v1/shopping/hotels/:id/hotel-offers+ endpoints
|
9
|
+
#
|
10
|
+
# Access via the +Amadeus::Client+ object
|
11
|
+
#
|
12
|
+
# amadeus = Amadeus::Client.new
|
13
|
+
# amadeus.shopping.hotels.hotel_offers
|
14
|
+
#
|
15
|
+
class HotelOffers < Amadeus::Client::Decorator
|
16
|
+
# the Hotel ID
|
17
|
+
attr_reader :hotel_id
|
18
|
+
|
19
|
+
# Initialize this namespaced client with an
|
20
|
+
# {Amadeus::Client} instance and a Hotel ID
|
21
|
+
#
|
22
|
+
# @param [Amadeus::Client] client
|
23
|
+
# @param [Number] hotel_id
|
24
|
+
#
|
25
|
+
def initialize(client, hotel_id)
|
26
|
+
super(client)
|
27
|
+
@hotel_id = hotel_id
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get one hotel and its available offers
|
31
|
+
#
|
32
|
+
# @return [Amadeus::Response] a parsed response
|
33
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
34
|
+
# @example Search for hotels in London
|
35
|
+
# amadeus.shopping.hotels('SMPARCOL').hotel_offers.get
|
36
|
+
#
|
37
|
+
def get(params = {})
|
38
|
+
client.get("/v1/shopping/hotels/#{@hotel_id}/hotel-offers", params)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
class Hotel
|
7
|
+
# A namespaced client for the
|
8
|
+
# +/v1/shopping/hotels/:id/offers+ endpoints
|
9
|
+
#
|
10
|
+
# Access via the +Amadeus::Client+ object
|
11
|
+
#
|
12
|
+
# amadeus = Amadeus::Client.new
|
13
|
+
# amadeus.shopping.hotels.offers
|
14
|
+
#
|
15
|
+
class Offer < Amadeus::Client::Decorator
|
16
|
+
# the Hotel ID
|
17
|
+
attr_reader :hotel_id
|
18
|
+
# the Offer ID
|
19
|
+
attr_reader :offer_id
|
20
|
+
|
21
|
+
# Initialize this namespaced client with an
|
22
|
+
# {Amadeus::Client} instance, a Hotel ID, and an Offer ID
|
23
|
+
#
|
24
|
+
# @param [Amadeus::Client] client
|
25
|
+
# @param [Number] hotel_id
|
26
|
+
# @param [Number] offer_id
|
27
|
+
#
|
28
|
+
def initialize(client, hotel_id, offer_id)
|
29
|
+
super(client)
|
30
|
+
@hotel_id = hotel_id
|
31
|
+
@offer_id = offer_id
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get room and rate details
|
35
|
+
#
|
36
|
+
# @return [Amadeus::Response] a parsed response
|
37
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
38
|
+
# @example Search for hotels in London
|
39
|
+
# amadeus.shopping.hotels('SMPARCOL')
|
40
|
+
# .offers('AC7D4DA2C322A73AF0824318A4965DA2805A3FC2').get
|
41
|
+
#
|
42
|
+
def get(params = {})
|
43
|
+
@offer_id ||= begin
|
44
|
+
offer_id = params[:id] || params['id']
|
45
|
+
params.delete(:id)
|
46
|
+
params.delete('id')
|
47
|
+
offer_id
|
48
|
+
end
|
49
|
+
|
50
|
+
client.get(
|
51
|
+
"/v1/shopping/hotels/#{@hotel_id}/offers/#{@offer_id}", params
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
class Shopping
|
6
|
+
# A namespaced client for the
|
7
|
+
# +/v1/shopping/hotel-offers+ endpoints
|
8
|
+
#
|
9
|
+
# Access via the +Amadeus::Client+ object
|
10
|
+
#
|
11
|
+
# amadeus = Amadeus::Client.new
|
12
|
+
# amadeus.shopping.hotel_offers
|
13
|
+
#
|
14
|
+
class HotelOffers < Amadeus::Client::Decorator
|
15
|
+
# Search for hotels and retrieve availability and rates information
|
16
|
+
#
|
17
|
+
# @option params [String] :cityCode City IATA code
|
18
|
+
# @option params [Double] :latitude latitude of geographic location to
|
19
|
+
# search around. Example: 52.5238
|
20
|
+
# @option params [Double] :longitude Longitude of geographic location to
|
21
|
+
# search around. Example: 13.3835
|
22
|
+
# @option params [String] :hotels Comma separated list of Amadeus hotel
|
23
|
+
# codes to request. Example: RTPAR001
|
24
|
+
# @return [Amadeus::Response] a parsed response
|
25
|
+
# @raise [Amadeus::Base] an exception if the call failed
|
26
|
+
# @example Search for hotels in London
|
27
|
+
# amadeus.shopping.hotel_offers.get(
|
28
|
+
# cityCode: 'PAR'
|
29
|
+
# )
|
30
|
+
#
|
31
|
+
def get(params = {})
|
32
|
+
client.get('/v1/shopping/hotel-offers', params)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Amadeus
|
4
|
+
module Namespaces
|
5
|
+
# A namespaced client for the
|
6
|
+
# +/v1/travel+ endpoints
|
7
|
+
#
|
8
|
+
# Access via the +Amadeus::Client+ object
|
9
|
+
#
|
10
|
+
# amadeus = Amadeus::Client.new
|
11
|
+
# amadeus.travel
|
12
|
+
#
|
13
|
+
class Travel < Amadeus::Client::Decorator
|
14
|
+
# The namespace for the travel Analytics APIs:
|
15
|
+
#
|
16
|
+
# @return [Amadeus::Namespaces::Travel::Analytics]
|
17
|
+
# @example
|
18
|
+
# amadeus.travel.analytics.air_traffics
|
19
|
+
# amadeus.travel.analytics.fare_searches
|
20
|
+
#
|
21
|
+
def analytics
|
22
|
+
Amadeus::Namespaces::Travel::Analytics.new(client)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|