sabre_dev_studio-flight 1.0.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 +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +54 -0
  6. data/Rakefile +20 -0
  7. data/lib/sabre_dev_studio-flight/airports_at_cities_lookup.rb +13 -0
  8. data/lib/sabre_dev_studio-flight/api.rb +209 -0
  9. data/lib/sabre_dev_studio-flight/city_pairs_lookup.rb +13 -0
  10. data/lib/sabre_dev_studio-flight/destination_finder.rb +13 -0
  11. data/lib/sabre_dev_studio-flight/fare_range.rb +13 -0
  12. data/lib/sabre_dev_studio-flight/instaflights_search.rb +13 -0
  13. data/lib/sabre_dev_studio-flight/lead_price_calendar.rb +13 -0
  14. data/lib/sabre_dev_studio-flight/low_fare_forecast.rb +13 -0
  15. data/lib/sabre_dev_studio-flight/multiairport_city_lookup.rb +13 -0
  16. data/lib/sabre_dev_studio-flight/shop/streamlined_destinations.rb +38 -0
  17. data/lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb +225 -0
  18. data/lib/sabre_dev_studio-flight/theme_airport_lookup.rb +13 -0
  19. data/lib/sabre_dev_studio-flight/travel_seasonality.rb +13 -0
  20. data/lib/sabre_dev_studio-flight/travel_theme_lookup.rb +13 -0
  21. data/lib/sabre_dev_studio-flight/version.rb +5 -0
  22. data/lib/sabre_dev_studio-flight.rb +6 -0
  23. data/sabre_dev_studio-flight.gemspec +24 -0
  24. data/test/api_test.rb +194 -0
  25. data/test/fixtures/air_shopping_themes.json +113 -0
  26. data/test/fixtures/airports_at_cities_lookup.json +26 -0
  27. data/test/fixtures/city_pairs.json +16708 -0
  28. data/test/fixtures/destination_air_shop.json +481 -0
  29. data/test/fixtures/fare_range.json +35 -0
  30. data/test/fixtures/future_dates_lead_fare_shop.json +2525 -0
  31. data/test/fixtures/low_fare_forecast.json +28 -0
  32. data/test/fixtures/multiairport_city_lookup.json +164 -0
  33. data/test/fixtures/single_date_air_shop.json +352 -0
  34. data/test/fixtures/theme_airport_lookup.json +77 -0
  35. data/test/fixtures/theme_airports.json +32 -0
  36. data/test/fixtures/travel_seasonality.json +379 -0
  37. data/test/test_helper.rb +32 -0
  38. metadata +149 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3aef44f104778538aeb4cef85864b2ca9b91f8a0
4
+ data.tar.gz: 071fb30d493fcf0743d0f89dee455ff509abe73f
5
+ SHA512:
6
+ metadata.gz: 46dc3d1c2b15205a1cabadd5ae4f7e978d389b5b425f3d103beaa94d558d208699b917d92e392fc70af91a54c5972b941a4cf6505af6aa30414b8b3c611cff56
7
+ data.tar.gz: e66af9d560f8c2589ac9d73c23c30d0ee15d23271062a5399f7beb0b9805e0be22e2a25e359ee51f459621262a9b432bb5433096dbf90d79b75b363f5ccbcdc3
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ scratch
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ source 'http://ctovm2419.dev.sabre.com:9292'
3
+
4
+ # Specify your gem's dependencies in sabre_dev_studio-flight.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sabre Corp
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # SabreDevStudio::Flight
2
+
3
+ Access the Travel Platform Services Flight API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sabre_dev_studio-flight'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sabre_dev_studio-flight
18
+
19
+ ## Usage
20
+ Once you've registered for your account at http://developer.sabre.com, grab your credentials and plug them into the `configure` block.
21
+
22
+ irb -r ./lib/sabre_dev_studio-flight.rb
23
+
24
+ SabreDevStudio.configure do |c|
25
+ c.user = 'USER'
26
+ c.group = 'GROUP'
27
+ c.domain = 'DOMAIN'
28
+ c.password = 'PASSWORD'
29
+ c.uri = 'https://api.test.sabre.com'
30
+ end
31
+ options = {
32
+ :origin => 'LAS',
33
+ :departuredate => '2014-06-22',
34
+ :returndate => '2014-06-23',
35
+ :theme => 'MOUNTAINS'
36
+ }
37
+ fares = SabreDevStudio::Flight::Api.destination_air_shop(options)
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ ## License
48
+
49
+ See LICENSE.txt
50
+
51
+ ## Disclaimer of Warranty and Limitation of Liability
52
+
53
+ This software and any compiled programs created using this software are furnished “as is” without warranty of any kind, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. No oral or written information or advice given by Sabre, its agents or employees shall create a warranty or in any way increase the scope of this warranty, and you may not rely on any such information or advice.
54
+ Sabre does not warrant, guarantee, or make any representations regarding the use, or the results of the use, of this software, compiled programs created using this software, or written materials in terms of correctness, accuracy, reliability, currentness, or otherwise. The entire risk as to the results and performance of this software and any compiled applications created using this software is assumed by you. Neither Sabre nor anyone else who has been involved in the creation, production or delivery of this software shall be liable for any direct, indirect, consequential, or incidental damages (including damages for loss of business profits, business interruption, loss of business information, and the like) arising out of the use of or inability to use such product even if Sabre has been advised of the possibility of such damages.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rdoc/task'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/*test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ desc 'Run tests'
12
+ task :default => :test
13
+
14
+ RDoc::Task.new do |rdoc|
15
+ rdoc.main = 'README.md'
16
+ rdoc.title = 'Sabre Dev Studio Flight Shop Gem'
17
+ rdoc.options << '--line-numbers --inline-source'
18
+ rdoc.rdoc_dir = 'doc'
19
+ rdoc.rdoc_files.include('README.md', 'lib/*.rb', 'lib/**')
20
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Airports At Cities Lookup
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/airports_at_cities_lookup
9
+ class AirportsAtCitiesLookup < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,209 @@
1
+ require File.expand_path('../airports_at_cities_lookup', __FILE__)
2
+ require File.expand_path('../city_pairs_lookup', __FILE__)
3
+ require File.expand_path('../destination_finder', __FILE__)
4
+ require File.expand_path('../fare_range', __FILE__)
5
+ require File.expand_path('../instaflights_search', __FILE__)
6
+ require File.expand_path('../lead_price_calendar', __FILE__)
7
+ require File.expand_path('../low_fare_forecast', __FILE__)
8
+ require File.expand_path('../multiairport_city_lookup', __FILE__)
9
+ require File.expand_path('../theme_airport_lookup', __FILE__)
10
+ require File.expand_path('../travel_seasonality', __FILE__)
11
+ require File.expand_path('../travel_theme_lookup', __FILE__)
12
+
13
+ module SabreDevStudio
14
+ module Flight
15
+ class Api
16
+ ##
17
+ # List of Air Shopping Themes
18
+ #
19
+ # ==== Documentation:
20
+ # https://developer.sabre.com/docs/read/rest_apis/travel_theme_lookup
21
+ #
22
+ # ==== Example:
23
+ # air_shopping_themes = SabreDevStudio::Flight::Api.travel_theme_lookup
24
+ def self.travel_theme_lookup
25
+ endpoint = '/v1/shop/themes'
26
+ SabreDevStudio::Flight::TravelThemeLookup.new(endpoint)
27
+ end
28
+ class << self; alias_method :air_shopping_themes, :travel_theme_lookup; end
29
+
30
+ ##
31
+ # Theme Airport Lookup
32
+ #
33
+ # ==== Documentation:
34
+ # https://developer.sabre.com/docs/read/rest_apis/theme_airport_lookup
35
+ #
36
+ # ==== Example:
37
+ # airports = SabreDevStudio::Flight::Api.theme_airport_lookup('BEACH')
38
+ def self.theme_airport_lookup(theme)
39
+ endpoint = "/v1/shop/themes/#{theme}"
40
+ SabreDevStudio::Flight::ThemeAirportLookup.new(endpoint)
41
+ end
42
+
43
+ ##
44
+ # Shop for a destination (from a list of generalized destinations) given a date range
45
+ #
46
+ # ==== Documentation:
47
+ # https://developer.sabre.com/docs/read/rest_apis/destination_finder
48
+ #
49
+ # Note: Timezones are specific to the departure and arrival airports (but not specified).
50
+ #
51
+ # ==== Example:
52
+ # options = {
53
+ # :origin => 'LAS',
54
+ # :departuredate => '2014-06-22',
55
+ # :returndate => '2014-06-23',
56
+ # :theme => 'MOUNTAINS'
57
+ # }
58
+ # fares = SabreDevStudio::Flight::Api.destination_finder(options)
59
+ def self.destination_finder(options)
60
+ endpoint = '/v1/shop/flights/fares'
61
+ SabreDevStudio::Flight::DestinationFinder.new(endpoint, options)
62
+ end
63
+ class << self; alias_method :destination_air_shop, :destination_finder; end
64
+
65
+ ##
66
+ # Future Dates Lead Fare Search, aka "Calendar Lead"
67
+ #
68
+ # ==== Documentation:
69
+ # https://developer.sabre.com/docs/read/rest_apis/lead_price_calendar
70
+ #
71
+ # Note: Timezones are specific to the departure and arrival airports (but not specified).
72
+ #
73
+ # ==== Example:
74
+ # options = {
75
+ # :origin => 'ATL',
76
+ # :destination => 'LAS',
77
+ # :lengthofstay => 5
78
+ # }
79
+ # fares = SabreDevStudio::Flight::Api.lead_price_calendar(options)
80
+ def self.lead_price_calendar(options)
81
+ endpoint = '/v1/shop/flights/fares'
82
+ SabreDevStudio::Flight::LeadPriceCalendar.new(endpoint, options)
83
+ end
84
+ class << self; alias_method :future_dates_lead_fare_shop, :lead_price_calendar; end
85
+
86
+ ##
87
+ # Shop for a fare with an origin for a destination with departure and return dates
88
+ #
89
+ # ==== Documentation:
90
+ # https://developer.sabre.com/docs/read/rest_apis/instaflights_search
91
+ #
92
+ # ==== Example:
93
+ # options = {
94
+ # :origin => 'ATL',
95
+ # :destination => 'LAS',
96
+ # :departuredate => '2014-06-22',
97
+ # :returndate => '2014-06-23',
98
+ # :limit => 10,
99
+ # :sortby => 'totalfare',
100
+ # :order => 'asc',
101
+ # :sortby2 => 'departuretime',
102
+ # :order2 => 'dsc'
103
+ # }
104
+ # itineraries = SabreDevStudio::Flight::Api.instaflights_search(options); nil
105
+ def self.instaflights_search(options)
106
+ endpoint = '/v1/shop/flights'
107
+ SabreDevStudio::Flight::InstaflightsSearch.new(endpoint, options)
108
+ end
109
+ class << self; alias_method :single_date_air_shop, :instaflights_search; end
110
+
111
+ ##
112
+ # Low Fare Forecast
113
+ #
114
+ # ==== Documentation:
115
+ # https://developer.sabre.com/docs/rest_apis/low_fare_forecast
116
+ #
117
+ # ==== Example:
118
+ # options = {
119
+ # :origin => 'JFK',
120
+ # :destination => 'LAX',
121
+ # :departuredate => '2014-10-01',
122
+ # :returndate => '2014-10-05'
123
+ # }
124
+ # forecast = SabreDevStudio::Flight::Api.low_fare_forecast(options)
125
+ def self.low_fare_forecast(options)
126
+ endpoint = '/v1/forecast/flights/fares'
127
+ SabreDevStudio::Flight::LowFareForecast.new(endpoint, options)
128
+ end
129
+
130
+ ##
131
+ # Fare Range
132
+ #
133
+ # ==== Documentation:
134
+ # https://developer.sabre.com/docs/read/rest_apis/fare_range
135
+ #
136
+ # ==== Example:
137
+ # options = {
138
+ # :origin => 'JFK',
139
+ # :destination => 'LAX',
140
+ # :earliestdeparturedate => '2014-06-01',
141
+ # :latestdeparturedate => '2014-06-01',
142
+ # :lengthofstay => 4
143
+ # }
144
+ # fare_range = SabreDevStudio::Flight::Api.fare_range(options)
145
+ def self.fare_range(options)
146
+ endpoint = '/v1/historical/flights/fares'
147
+ SabreDevStudio::Flight::FareRange.new(endpoint, options)
148
+ end
149
+
150
+ ##
151
+ # Travel Seasonality
152
+ #
153
+ # ==== Documentation:
154
+ # https://developer.sabre.com/docs/read/rest_apis/travel_seasonality
155
+ #
156
+ # ==== Example:
157
+ # travel_seasonality = SabreDevStudio::Flight::Api.travel_seasonality('DFW')
158
+ def self.travel_seasonality(destination)
159
+ endpoint = "/v1/historical/flights/#{destination}/seasonality"
160
+ SabreDevStudio::Flight::TravelSeasonality.new(endpoint)
161
+ end
162
+
163
+ ##
164
+ # City Pairs Lookup
165
+ #
166
+ # ==== Documentation:
167
+ # https://developer.sabre.com/docs/read/rest_apis/city_pairs_lookup
168
+ #
169
+ # ==== Example:
170
+ # options = {
171
+ # :origincountry => 'US',
172
+ # :destinationcountry => 'US'
173
+ # }
174
+ # city_pairs = SabreDevStudio::Flight::Api.city_pairs_lookup
175
+ def self.city_pairs_lookup(options)
176
+ endpoint = '/v1/lists/airports/supported/origins-destinations'
177
+ SabreDevStudio::Flight::CityPairsLookup.new(endpoint, options)
178
+ end
179
+
180
+ ##
181
+ # Multi-Airport City Lookup
182
+ #
183
+ # ==== Documentation:
184
+ # https://developer.sabre.com/docs/read/rest_apis/multiairport_city_lookup
185
+ #
186
+ # ==== Example:
187
+ # options = { :country => 'US' }
188
+ # city_pairs = SabreDevStudio::Flight::Api.multiairport_city_lookup(options)
189
+ def self.multiairport_city_lookup(options)
190
+ endpoint = '/v1/lists/cities'
191
+ SabreDevStudio::Flight::MultiairportCityLookup.new(endpoint, options)
192
+ end
193
+
194
+ ##
195
+ # Airports At Cities Lookup
196
+ #
197
+ # ==== Documentation:
198
+ # https://developer.sabre.com/docs/read/rest_apis/airports_at_cities_lookup
199
+ #
200
+ # ==== Example:
201
+ # options = { :city => 'NYC' }
202
+ # city_pairs = SabreDevStudio::Flight::Api.airports_at_cities_lookup(options)
203
+ def self.airports_at_cities_lookup(options)
204
+ endpoint = '/v1/lists/airports'
205
+ SabreDevStudio::Flight::AirportsAtCitiesLookup.new(endpoint, options)
206
+ end
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # City Pairs Lookup
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/city_pairs_lookup
9
+ class CityPairsLookup < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Shop for a destination (from a list of generalized destinations) given a date range
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/destination_finder
9
+ class DestinationFinder < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Fare Range
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/fare_range
9
+ class FareRange < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Shop for a fare with an origin for a destination with departure and return dates
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/instaflights_search
9
+ class InstaflightsSearch < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Future Dates Lead Fare Search, aka "Calendar Lead"
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/lead_price_calendar
9
+ class LeadPriceCalendar < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Low Fare Forecast
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/rest_apis/low_fare_forecast
9
+ class LowFareForecast < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SabreDevStudio
2
+ module Flight
3
+
4
+ ##
5
+ # Multi-Airport City Lookup
6
+ #
7
+ # ==== Documentation:
8
+ # https://developer.sabre.com/docs/read/rest_apis/multiairport_city_lookup
9
+ class MultiairportCityLookup < SabreDevStudio::RequestObject
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ =begin
2
+
3
+ options = {
4
+ :origin => 'LAS',
5
+ :departuredate => '2014-06-01',
6
+ :returndate => '2014-06-05'
7
+ }
8
+ destinations = SabreDevStudio::Flight::Api.destination_air_shop(options); nil
9
+ streamlined_destinations = SabreDevStudio::Flight::Shop::StreamlinedDestinations.new(destinations.response); nil
10
+ pp streamlined_destinations; nil
11
+
12
+ =end
13
+
14
+ module SabreDevStudio
15
+ module Flight
16
+ module Shop
17
+ class StreamlinedDestinations
18
+ attr_reader :destinations
19
+
20
+ def initialize(bulky_destinations)
21
+ @destinations = Hash.new
22
+ streamline(bulky_destinations['FareInfo'])
23
+ end
24
+
25
+ private
26
+
27
+ def streamline(bulky_destinations)
28
+ destinations = {}
29
+ bulky_destinations.each do |dest|
30
+ destinations[dest['DestinationLocation']] = dest['LowestFare'].ceil
31
+ end
32
+ arr = destinations.sort_by {|k,v| v}
33
+ @destinations = Hash[*arr.flatten]
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end