amadeus 3.2.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -1
  3. data/README.md +52 -52
  4. data/amadeus.gemspec +12 -10
  5. data/lib/amadeus.rb +19 -4
  6. data/lib/amadeus/client/direction.rb +2 -4
  7. data/lib/amadeus/client/errors.rb +5 -4
  8. data/lib/amadeus/client/location.rb +2 -2
  9. data/lib/amadeus/client/request/hash.rb +1 -1
  10. data/lib/amadeus/namespaces/airport.rb +25 -0
  11. data/lib/amadeus/namespaces/airport/predictions.rb +27 -0
  12. data/lib/amadeus/namespaces/airport/predictions/on_time.rb +32 -0
  13. data/lib/amadeus/namespaces/analytics.rb +25 -0
  14. data/lib/amadeus/namespaces/analytics/itinerary_price_metrics.rb +38 -0
  15. data/lib/amadeus/namespaces/booking.rb +25 -0
  16. data/lib/amadeus/namespaces/booking/hotel_bookings.rb +52 -0
  17. data/lib/amadeus/namespaces/core.rb +50 -0
  18. data/lib/amadeus/namespaces/e_reputation.rb +25 -0
  19. data/lib/amadeus/namespaces/e_reputation/hotel_sentiments.rb +31 -0
  20. data/lib/amadeus/namespaces/reference_data/locations.rb +13 -1
  21. data/lib/amadeus/namespaces/reference_data/locations/point_of_interest.rb +44 -0
  22. data/lib/amadeus/namespaces/safety.rb +34 -0
  23. data/lib/amadeus/namespaces/safety/safety_rated_location.rb +32 -0
  24. data/lib/amadeus/namespaces/safety/safety_rated_locations.rb +46 -0
  25. data/lib/amadeus/namespaces/safety/safety_rated_locations/by_square.rb +41 -0
  26. data/lib/amadeus/namespaces/shopping.rb +4 -4
  27. data/lib/amadeus/namespaces/shopping/flight_offers_search.rb +61 -0
  28. data/lib/amadeus/namespaces/shopping/{flight_offers → flight_offers_search}/prediction.rb +7 -6
  29. data/lib/amadeus/namespaces/travel.rb +10 -1
  30. data/lib/amadeus/namespaces/travel/analytics/air_traffic.rb +0 -23
  31. data/lib/amadeus/namespaces/travel/predictions.rb +37 -0
  32. data/lib/amadeus/namespaces/travel/predictions/flight_delay.rb +55 -0
  33. data/lib/amadeus/namespaces/travel/predictions/trip_purpose.rb +46 -0
  34. data/lib/amadeus/version.rb +1 -1
  35. metadata +41 -26
  36. data/lib/amadeus/namespaces/shopping/flight_offers.rb +0 -47
  37. data/lib/amadeus/namespaces/travel/analytics/air_traffic/searched.rb +0 -46
  38. data/lib/amadeus/namespaces/travel/analytics/air_traffic/searched_by_destination.rb +0 -54
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class Airport
6
+ class Predictions
7
+ # A namespaced client for the
8
+ # +/v1/airport/predictions/on_time+ endpoints
9
+ #
10
+ # Access via the +Amadeus::Client+ object
11
+ #
12
+ # amadeus = Amadeus::Client.new
13
+ # amadeus.airport.predictions.on_time
14
+ #
15
+ class OnTime < Amadeus::Client::Decorator
16
+ # Returns a prediction on airport performance.
17
+ #
18
+ # @option params [String] :airportCode IATA code of the airport
19
+ # @option params [String] :date date of the prediction, in the future
20
+ # @return [Amadeus::Response] a parsed response
21
+ # @raise [Amadeus::Base] an exception if the call failed
22
+ # @example
23
+ # amadeus.airport.predictions.on_time.get(airportCode: 'JFK', date: '2020-09-01')
24
+ #
25
+ def get(params = {})
26
+ client.get('/v1/airport/predictions/on-time', params)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ # A namespaced client for the
6
+ # +/v1/analytics+ endpoints
7
+ #
8
+ # Access via the +Amadeus::Client+ object
9
+ #
10
+ # amadeus = Amadeus::Client.new
11
+ # amadeus.analytics
12
+ #
13
+ class Analytics < Amadeus::Client::Decorator
14
+ # The namespace for the Analytics-ItineraryPriceMetrics API:
15
+ #
16
+ # @return [Amadeus::Namespaces::Analytics::ItineraryPriceMetrics]
17
+ # @example
18
+ # amadeus.analytics.itinerary_price_metrics
19
+ #
20
+ def itinerary_price_metrics
21
+ Amadeus::Namespaces::Analytics::ItineraryPriceMetrics.new(client)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class Analytics
6
+ # A namespaced client for the
7
+ # +/v1/analytics/itinerary-price-metrics+ endpoint
8
+ #
9
+ # Access via the +Amadeus::Client+ object
10
+ #
11
+ # amadeus = Amadeus::Client.new
12
+ # amadeus.analytics.itinerary_price_metrics
13
+ #
14
+ class ItineraryPriceMetrics < Amadeus::Client::Decorator
15
+ # Returns historical flight prices by date and route so you can see how current ticket
16
+ # prices stack up against the historical average
17
+ #
18
+ # @option params [String] :originIataCode IATA code of the airport to depart from
19
+ # @option params [String] :destinationIataCode IATA code of the airport to arrive at
20
+ # @option params [String] :departureDate date to depart on, formatted as YYYY-MM-DD
21
+ # @option params [String] :currencyCode the preferred currency (ISO 4217) - optional
22
+ # @option params [Boolean] :oneWay retrieve prices for one-way only - optional
23
+ # @return [Amadeus::Response] a parsed response
24
+ # @raise [Amadeus::Base] an exception if the call failed
25
+ # @example
26
+ # amadeus.analytics.itinerary_price_metrics.get(
27
+ # originIataCode: 'AMS',
28
+ # destinationIataCode: 'CDG',
29
+ # departureDate: '2021-06-18'
30
+ # )
31
+ #
32
+ def get(params = {})
33
+ client.get('/v1/analytics/itinerary-price-metrics', params)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ # A namespaced client for the
6
+ # +/v1/booking+ endpoints
7
+ #
8
+ # Access via the +Amadeus::Client+ object
9
+ #
10
+ # amadeus = Amadeus::Client.new
11
+ # amadeus.booking
12
+ #
13
+ class Booking < Amadeus::Client::Decorator
14
+ # The namespace for the Booking APIs:
15
+ #
16
+ # @return [Amadeus::Namespaces::Booking::HotelBookings]
17
+ # @example
18
+ # amadeus.booking.hotel_bookings
19
+ #
20
+ def hotel_bookings
21
+ Amadeus::Namespaces::Booking::HotelBookings.new(client)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class Booking
6
+ # A namespaced client for the
7
+ # +/v1/booking/hotel_bookings+ endpoints
8
+ #
9
+ # Access via the +Amadeus::Client+ object
10
+ #
11
+ # amadeus = Amadeus::Client.new
12
+ # amadeus.booking.hotel_bookings
13
+ #
14
+ class HotelBookings < Amadeus::Client::Decorator
15
+ # Book a specific room
16
+ #
17
+ # The parameters guests and payments can be passed as dictionary
18
+ # or list of dictionaries. If they are dictionary in this method they are
19
+ # converted to a list of dictionaries.
20
+ #
21
+ # @option params [String] :hotelIds list of hotel ids separated by comas
22
+ # @return [Amadeus:Response] a parsed response
23
+ # @raise [Amadeus:Base] an exception if the call failed
24
+ # @example book for a hotel offer
25
+ # amadeus.booking.hotel_bookings.post(
26
+ # hotel_offer_id, guests, payments
27
+ # )
28
+ #
29
+ def post(hotel_offer_id, guests, payments)
30
+ body = prepare_body(hotel_offer_id, guests, payments)
31
+
32
+ client.post('/v1/booking/hotel-bookings', body.to_json)
33
+ end
34
+
35
+ def prepare_body(hotel_offer_id, guests, payments)
36
+ guests_info = [], pay_info = []
37
+
38
+ guests.is_a?(Array) ? guests_info.push(guests).flatten! : guests_info.push(guests)
39
+ payments.is_a?(Array) ? pay_info.push(payments).flatten! : pay_info.push(payments)
40
+
41
+ {
42
+ 'data' => {
43
+ 'offerId' => hotel_offer_id,
44
+ 'guests' => guests_info,
45
+ 'payments' => pay_info
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -37,6 +37,16 @@ module Amadeus
37
37
  Shopping.new(self)
38
38
  end
39
39
 
40
+ # The namespace for the booking APIs:
41
+ #
42
+ # @return [Amadeus::Namespaces::Booking]
43
+ # @example Some of the further namespaces available
44
+ # amadeus.booking.hotel_bookings
45
+ #
46
+ def booking
47
+ Booking.new(self)
48
+ end
49
+
40
50
  # The namespace for the travel analytics APIs:
41
51
  #
42
52
  # @return [Amadeus::Namespaces::Travel]
@@ -47,5 +57,45 @@ module Amadeus
47
57
  def travel
48
58
  Travel.new(self)
49
59
  end
60
+
61
+ # The namespace for the E Reputation APIs:
62
+ #
63
+ # @return [Amadeus::Namespaces::EReputation]
64
+ # @example Some of the further namespaces available
65
+ # amadeus.e_reputation.hotel_sentiments
66
+ #
67
+ def e_reputation
68
+ EReputation.new(self)
69
+ end
70
+
71
+ # The namespace for the Airport APIs:
72
+ #
73
+ # @return [Amadeus::Namespaces::Airport]
74
+ # @example Some of the further namespaces available
75
+ # amadeus.airport.predictions
76
+ #
77
+ def airport
78
+ Airport.new(self)
79
+ end
80
+
81
+ # The namespace for the Safety related APIs:
82
+ #
83
+ # @return [Amadeus::Namespaces::Safety]
84
+ # @example Some of the further namespaces available
85
+ # amadeus.safety.safety_rated_locations
86
+ #
87
+ def safety
88
+ Safety.new(self)
89
+ end
90
+
91
+ # The namespace for the Analytics related APIs:
92
+ #
93
+ # @return [Amadeus::Namespaces::Analytics]
94
+ # @example Some of the further namespaces available
95
+ # amadeus.analytics.itinerary_price_metrics
96
+ #
97
+ def analytics
98
+ Analytics.new(self)
99
+ end
50
100
  end
51
101
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ # A namespaced client for the
6
+ # +/v2/e-reputation+ endpoints
7
+ #
8
+ # Access via the +Amadeus::Client+ object
9
+ #
10
+ # amadeus = Amadeus::Client.new
11
+ # amadeus.e_reputation
12
+ #
13
+ class EReputation < Amadeus::Client::Decorator
14
+ # The namespace for the E Reputation APIs:
15
+ #
16
+ # @return [Amadeus::Namespaces::EReputation::HotelSentiments]
17
+ # @example
18
+ # amadeus.e_reputation.hotel_sentiments
19
+ #
20
+ def hotel_sentiments
21
+ Amadeus::Namespaces::EReputation::HotelSentiments.new(client)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class EReputation
6
+ # A namespaced client for the
7
+ # +/v2/e-reputation/hotel-sentiments+ endpoints
8
+ #
9
+ # Access via the +Amadeus::Client+ object
10
+ #
11
+ # amadeus = Amadeus::Client.new
12
+ # amadeus.e_reputation.hotel_sentiments
13
+ #
14
+ class HotelSentiments < Amadeus::Client::Decorator
15
+ # For a given list of hotels, returns the sentiment analysis of each hotel
16
+ #
17
+ # @option params [String] :hotelIds list of hotel ids separated by comas
18
+ # @return [Amadeus:Response] a parsed response
19
+ # @raise [Amadeus:Base] an exception if the call failed
20
+ # @example Search for hotels in London
21
+ # amadeus.e_reputation.hotel_sentiments.get(
22
+ # hotelIds: 'GUNYCAXZ,CTLONCMB'
23
+ # )
24
+ #
25
+ def get(params = {})
26
+ client.get('/v2/e-reputation/hotel-sentiments', params)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -22,7 +22,7 @@ module Amadeus
22
22
  Amadeus::Namespaces::ReferenceData::Locations::Airports.new(client)
23
23
  end
24
24
 
25
- # The namespace for the Point Of Interest API:
25
+ # The namespace for the Points Of Interest API:
26
26
  #
27
27
  # @return [Amadeus::Namespaces::ReferenceData::Locations::PointsOfInterest]
28
28
  # @example
@@ -32,6 +32,18 @@ module Amadeus
32
32
  Amadeus::Namespaces::ReferenceData::Locations::PointsOfInterest.new(client)
33
33
  end
34
34
 
35
+ # The namespace for the Point Of Interest API:
36
+ #
37
+ # @return [Amadeus::Namespaces::ReferenceData::Locations::PointOfInterest]
38
+ # @example
39
+ # amadeus.reference_data.locations.point_of_interest
40
+ #
41
+ def point_of_interest(location_id)
42
+ Amadeus::Namespaces::ReferenceData::Locations::PointOfInterest.new(
43
+ client, location_id
44
+ )
45
+ end
46
+
35
47
  # Returns a list of airports and cities matching a given keyword.
36
48
  #
37
49
  # @option params [String] :keyword keyword that should represent the
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class ReferenceData
6
+ class Locations
7
+ # A namespaced client for the
8
+ # +/v1/reference-data/locations/pois/:location_id+ endpoints
9
+ #
10
+ # Access via the +Amadeus::Client+ object
11
+ #
12
+ # amadeus = Amadeus::Client.new
13
+ # amadeus.reference_data.locations.point_of_interest('9CB40CB5D0')
14
+ #
15
+ class PointOfInterest < Amadeus::Client::Decorator
16
+ # the Location ID
17
+ attr_reader :poi_location_id
18
+
19
+ # Initialize this namespaced client with an
20
+ # {Amadeus::Client} instance and an optional Location ID
21
+ #
22
+ # @param [Amadeus::Client] client
23
+ # @param [Number] poi_location_id
24
+ #
25
+ def initialize(client, poi_location_id = nil)
26
+ super(client)
27
+ @poi_location_id = poi_location_id
28
+ end
29
+
30
+ # Returns details for a specific poi
31
+ #
32
+ # @return [Amadeus::Response] a parsed response
33
+ # @raise [Amadeus::Base] an exception if the call failed
34
+ # @example Retrieve poi information of '9CB40CB5D0'
35
+ # amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get
36
+ #
37
+ def get(params = {})
38
+ client.get("/v1/reference-data/locations/pois/#{@poi_location_id}", params)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ # A namespaced client for the
6
+ # +/v1/safety+ endpoints
7
+ #
8
+ # Access via the +Amadeus::Client+ object
9
+ #
10
+ # amadeus = Amadeus::Client.new
11
+ # amadeus.safety
12
+ #
13
+ class Safety < Amadeus::Client::Decorator
14
+ # The namespace for the Safety APIs:
15
+ #
16
+ # @return [Amadeus::Namespaces::Safety::SafetyRetedLocations]
17
+ # @example
18
+ # amadeus.safety.safety_rated_locations
19
+ #
20
+ def safety_rated_locations
21
+ Amadeus::Namespaces::Safety::SafetyRatedLocations.new(client)
22
+ end
23
+
24
+ #
25
+ # @return [Amadeus::Namespaces::Safety::SafetyRetedLocation]
26
+ # @example
27
+ # amadeus.safety.safety_rated_location
28
+ #
29
+ def safety_rated_location(location_id)
30
+ Amadeus::Namespaces::Safety::SafetyRatedLocation.new(client, location_id)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amadeus
4
+ module Namespaces
5
+ class Safety
6
+ # amadeus.safety.safety_rated_location('Q930400801').get()
7
+ class SafetyRatedLocation < Amadeus::Client::Decorator
8
+ attr_reader :safe_location_id
9
+
10
+ #
11
+ # @param [Amadeus::Client] client
12
+ # @param [Number] safe_location_id
13
+ #
14
+ def initialize(client, safe_location_id = nil)
15
+ super(client)
16
+ @safe_location_id = safe_location_id
17
+ end
18
+
19
+ # Returns details for a specific place
20
+ #
21
+ # @return [Amadeus::Response] a parsed response
22
+ # @raise [Amadeus::Base] an exception if the call failed
23
+ # @example Retrieve safety information of 'Q930402753'
24
+ # amadeus.safety.safety_rated_location('Q930402753').get
25
+ #
26
+ def get(params = {})
27
+ client.get("/v1/safety/safety-rated-locations/#{@safe_location_id}", params)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end