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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +10 -0
  3. data/LICENSE +15 -0
  4. data/README.md +157 -19
  5. data/amadeus.gemspec +26 -16
  6. data/lib/amadeus.rb +31 -4
  7. data/lib/amadeus/client.rb +120 -0
  8. data/lib/amadeus/client/access_token.rb +61 -0
  9. data/lib/amadeus/client/decorator.rb +27 -0
  10. data/lib/amadeus/client/errors.rb +76 -0
  11. data/lib/amadeus/client/http.rb +137 -0
  12. data/lib/amadeus/client/location.rb +13 -0
  13. data/lib/amadeus/client/pagination.rb +103 -0
  14. data/lib/amadeus/client/request.rb +145 -0
  15. data/lib/amadeus/client/request/hash.rb +32 -0
  16. data/lib/amadeus/client/response.rb +62 -0
  17. data/lib/amadeus/client/response/parser.rb +72 -0
  18. data/lib/amadeus/client/validator.rb +62 -0
  19. data/lib/amadeus/namespaces/core.rb +51 -0
  20. data/lib/amadeus/namespaces/reference_data.rb +41 -0
  21. data/lib/amadeus/namespaces/reference_data/location.rb +42 -0
  22. data/lib/amadeus/namespaces/reference_data/locations.rb +45 -0
  23. data/lib/amadeus/namespaces/reference_data/locations/airports.rb +38 -0
  24. data/lib/amadeus/namespaces/reference_data/urls.rb +27 -0
  25. data/lib/amadeus/namespaces/reference_data/urls/checkin_links.rb +33 -0
  26. data/lib/amadeus/namespaces/shopping.rb +66 -0
  27. data/lib/amadeus/namespaces/shopping/flight_dates.rb +33 -0
  28. data/lib/amadeus/namespaces/shopping/flight_destinations.rb +30 -0
  29. data/lib/amadeus/namespaces/shopping/flight_offers.rb +36 -0
  30. data/lib/amadeus/namespaces/shopping/hotel.rb +56 -0
  31. data/lib/amadeus/namespaces/shopping/hotel/hotel_offers.rb +44 -0
  32. data/lib/amadeus/namespaces/shopping/hotel/offer.rb +58 -0
  33. data/lib/amadeus/namespaces/shopping/hotel_offers.rb +37 -0
  34. data/lib/amadeus/namespaces/travel.rb +26 -0
  35. data/lib/amadeus/namespaces/travel/analytics.rb +37 -0
  36. data/lib/amadeus/namespaces/travel/analytics/air_traffics.rb +37 -0
  37. data/lib/amadeus/namespaces/travel/analytics/fare_searches.rb +46 -0
  38. data/lib/amadeus/version.rb +4 -1
  39. metadata +161 -23
  40. data/.gitignore +0 -12
  41. data/.rspec +0 -2
  42. data/.travis.yml +0 -5
  43. data/CODE_OF_CONDUCT.md +0 -74
  44. data/Gemfile +0 -4
  45. data/LICENSE.txt +0 -21
  46. data/Rakefile +0 -6
  47. data/bin/console +0 -14
  48. data/bin/setup +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 21a68d7b0cd8c5b0c65f4310534feacc0d8f7dc1
4
- data.tar.gz: bd34e47eac5eba5834999dc38ee089c6615a2037
2
+ SHA256:
3
+ metadata.gz: 64a5992be2ac96248448636c4da2b68bf58228bb1cca410838befdedfdb67e18
4
+ data.tar.gz: 50971ce13f1a050a9dea262172d7cb1a1e4f1d8a4474e1dc828e0f10c07f09cb
5
5
  SHA512:
6
- metadata.gz: 9bcaab897433ed26c146f3f0179858af0c47a0f91cbc965463c61e7a7577ab9f9e8f9b6e1fc5e3092535ec3e7e0721dda79c7ac4308c5e28c3df9494aed7f674
7
- data.tar.gz: 7961bef9c1ed883a2b0cdbbf1fb1eb7e9d8cfe12741128ce068e46c82abaa012c7c057b39c6200d10c1655c94fc63572716eb9ebc7a279cf52d0878e01873a83
6
+ metadata.gz: 2a5180f26962a7f72a160c629532678ae6d6b895b09ebbedc6fb28d56f760a5d9bda4872af7e31194d64a634557042babffc6e1aeb93bbfc3e3905652c6afa29
7
+ data.tar.gz: d2d5eb93d0f483528c32b6a807ce82c990df84318f8ece68fd1afbb12768d9277a009df25e8c061812090b8fa148585cf0551e3b7842d0836cb602929a6b70b7
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0.beta1 - 2018-03-23
4
+
5
+ * First Beta release with support for all the initial API endpoints
6
+
7
+ ## 0.1.0 - 2017-07-07
8
+
9
+ * Initial release
10
+ * Just a placeholder for the `amadeus` gem name
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2017 Amadeus IT Group SA
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
7
+ persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,43 +1,181 @@
1
- # Amadeus
1
+ # Amadeus Ruby SDK
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/amadeus`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/amadeus.svg)](https://badge.fury.io/rb/amadeus)
4
+ [![Build Status](https://travis-ci.org/amadeus4dev/amadeus-ruby.svg?branch=master)][travis]
5
+ [![Contact Support](https://img.shields.io/badge/contact-support-blue.svg)][support]
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
7
+ Amadeus provides a set of APIs for the travel industry. Flights, Hotels, Locations and more.
8
+
9
+ For more details see the [Ruby documentation](https://developer.amadeus.com/docs/ruby) on [Amadeus.com](https://developer.amadeus.com).
6
10
 
7
11
  ## Installation
8
12
 
9
- Add this line to your application's Gemfile:
13
+ This gem requires Ruby 2.2+. You can install install it directly or via bundler.
10
14
 
11
- ```ruby
15
+ ```sh
12
16
  gem 'amadeus'
13
17
  ```
14
18
 
15
- And then execute:
19
+ __Next__: [Get Started with the Ruby SDK.](https://developer.amadeus.com/docs/ruby/get_started/initialize)
20
+
21
+ ## Getting Started
22
+
23
+ To send make your first API call you will need to [register for an Amadeus Developer Account](https://developer.amadeus.com/register) and [set up your first application](https://dashboard.developer.amadeus.com/applications).
24
+
25
+ ```rb
26
+ require 'amadeus'
27
+
28
+ amadeus = Amadeus::Client.new({
29
+ client_id: '[YOUR_CLIENT_ID]',
30
+ client_secret: '[YOUR_CLIENT_SECRET]'
31
+ })
32
+
33
+ begin
34
+ puts amadeus.reference_data.urls.checkin_links.get({ airline: '1X' })
35
+ # => {"meta"=>{"count"=>2, "links"=>{"self"=>"https://test.api.amadeus.com...
36
+ rescue Amadeus::ResponseError => error
37
+ puts error
38
+ end
39
+ ```
40
+
41
+ __Next__: [Learn more about checkin links](https://developer.amadeus.com/docs/ruby/get_started/checkin_links) with our Ruby SDK.
42
+
43
+ ## Initialization
44
+
45
+ The client can be initialized directly.
46
+
47
+ ```rb
48
+ # Initialize using parameters
49
+ amadeus = Amadeus::Client.new(client_id: '...', client_secret: '...')
50
+ ```
51
+
52
+ Alternatively it can be initialized without any paramters if the environment variables `AMADEUS_CLIENT_ID` and `AMADEUS_CLIENT_SECRET` are present.
16
53
 
17
- $ bundle
54
+ ```rb
55
+ amadeus = Amadeus::Client.new
56
+ ```
57
+
58
+ Your credentials can be found on the [Amadeus dashboard](https://dashboard.developer.amadeus.com/client_ids). [Sign up](https://developer.amadeus.com/register) for an account today.
18
59
 
19
- Or install it yourself as:
60
+ By default the environment for the SDK is the `:test` environment. To switch to a production (paid-for) environment please switch the hostname as follows:
61
+
62
+ ```rb
63
+ amadeus = Amadeus::Client.new(hostname: :production)
64
+ ```
20
65
 
21
- $ gem install amadeus
66
+ __Next__: [Learn more about our initializing the Ruby SDK](https://developer.amadeus.com/docs/ruby/get_started_initialize) in our documentation.
22
67
 
23
- ## Usage
68
+ ## Documentation
24
69
 
25
- TODO: Write usage instructions here
70
+ Amadeus has a large set of APIs, and our documentation is here to get you started today.
26
71
 
27
- ## Development
72
+ * [Get Started](https://developer.amadeus.com/docs/ruby/get_started) documentation
73
+ * [Initialize the SDK](https://developer.amadeus.com/docs/ruby/get_started/initialize)
74
+ * [Find an Airport](https://developer.amadeus.com/docs/ruby/get_started/find_an_airport)
75
+ * [Book a Flight](https://developer.amadeus.com/docs/ruby/get_started/book_a_flight)
76
+ * [Get Flight Inspiration](https://developer.amadeus.com/docs/ruby/get_started/get_flight_inspiration)
28
77
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+ Alternatively, head over to our [Reference](https://developer.amadeus.com/docs/ruby/reference) documentation for in-depth information about every SDK method, it's arguments and return types.
30
79
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
80
+ Additionally, this SDK has extensive documentation of itself available on [RubyDoc.info](http://www.rubydoc.info/gems/amadeus/0.1.0).
32
81
 
33
- ## Contributing
82
+ ## Making API calls
83
+
84
+ This library conveniently maps every API path to a similar path.
85
+
86
+ For example, `GET /v2/reference-data/urls/checkin-links?airline=1X` would be:
87
+
88
+ ```rb
89
+ amadeus.reference_data.urls.checkin_links.get(airline: '1X')
90
+ ```
91
+
92
+ Similarly, to select a resource by ID, you can pass in the ID to the path.
93
+
94
+ For example, `GET /v1/shopping/hotel/123/hotel-offers` would be:
95
+
96
+ ```rb
97
+ amadeus.hotels(123).hotel_offers.get(...)
98
+ ```
99
+
100
+ You can make any arbitrary API call as well directly with the `.get` method:
101
+
102
+ ```rb
103
+ amadeus.get('/v2/reference-data/urls/checkin-links', airline: '1X')
104
+ ```
105
+
106
+ ## Response
107
+
108
+ Every API call returns a `Amadeus::Response` object. If the API call contained
109
+ a JSON response it will parse the JSON into the `.result` attribute. If this data
110
+ also contains a `data` key, it will make that available as the `.data`
111
+ attribute. The raw body of the response is always avaulable as the `.body` attribute.
112
+
113
+ ```rb
114
+ response = amadeus.reference_data.locations.get(
115
+ keyword: 'LON',
116
+ subType: Amadeus::Location::ANY
117
+ )
118
+
119
+ p reponse.body #=> The raw response, as a string
120
+ p reponse.result #=> The body parsed as JSON, if the result was parsable
121
+ p response.data #=> The list of locations, extracted from the JSON
122
+ ```
123
+
124
+ ## Pagination
125
+
126
+ If an API endpoint supports pagination, the other pages are available under the
127
+ `.next`, `.previous`, `.last` and `.first` methods.
128
+
129
+ ```rb
130
+ response = amadeus.reference_data.locations.get(
131
+ keyword: 'LON',
132
+ subType: Amadeus::Location::ANY
133
+ )
134
+
135
+ amadeus.next(response) #=> returns a new response for the next page
136
+ ```
137
+
138
+ If a page is not available, the method will return `nil`.
139
+
140
+ ## Logging & Debugging
141
+
142
+ The SDK makes it easy to add your own logger.
143
+
144
+ ```rb
145
+ require 'logger'
146
+
147
+ amadeus = Amadeus::Client.new(
148
+ client_id: '...',
149
+ client_secret: '...',
150
+ logger: Logger.new(STDOUT)
151
+ )
152
+ ```
153
+
154
+ Additionally, to enable more verbose logging, you can set the appropriate level on your own logger, though the easiest way would be to enable debugging via a parameter on initialization, or using the `AMADEUS_LOG_LEVEL` environment variable.
155
+
156
+ ```rb
157
+ require 'logger'
158
+
159
+ amadeus = Amadeus::Client.new(
160
+ client_id: '...',
161
+ client_secret: '...',
162
+ log_level: 'debug'
163
+ )
164
+ ```
165
+
166
+ ## Development & Contributing
167
+
168
+ Want to contribute? Read our [Contributors Guide](.github/CONTRIBUTING.md) for guidance on installing and running this code in a development environment.
34
169
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/amadeus. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
170
 
37
171
  ## License
38
172
 
39
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
173
+ This library is released under the [MIT License](LICENSE).
174
+
175
+ ## Help
40
176
 
41
- ## Code of Conduct
177
+ Our [developer support team](https://developer.amadeus.com/developers) is here to help you. You can find us on [Twitter](#), [StackOverflow](#), and [email](#).
42
178
 
43
- Everyone interacting in the Amadeus project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/amadeus/blob/master/CODE_OF_CONDUCT.md).
179
+ [gem]: https://rubygems.org/gems/amadeus
180
+ [travis]: http://travis-ci.org/amadeus4dev/amadeus-ruby
181
+ [support]: http://developer.amadeus.com/support
@@ -1,27 +1,37 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "amadeus/version"
4
+ require 'amadeus/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "amadeus"
7
+ spec.name = 'amadeus'
8
8
  spec.version = Amadeus::VERSION
9
- spec.authors = ["Cristiano Betta"]
10
- spec.email = ["cristiano@betta.io"]
9
+ spec.authors = ['Amadeus', 'Cristiano Betta']
10
+ spec.email = ['developer@amadeus.com', 'cristiano@betta.io']
11
11
 
12
- spec.summary = "Placeholder gem for Amadeus API"
13
- spec.description = "Placeholder gem for Amadeus API"
14
- spec.homepage = "https://github.com/cbetta/amadeus"
15
- spec.license = "MIT"
12
+ spec.summary = 'Ruby library for the Amadeus travel APIs'
13
+ spec.description = 'Ruby library for the Amadeus travel APIs'
14
+ spec.homepage = 'https://github.com/amadeusdev/amadeus-ruby'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
18
+ f.match(/^(test|spec|features|.github|docs|.gitignore|.rspec)/) ||
19
+ f.match(/^(.rubocop.yml|.simplecov|.travis.yml|.yardopts)/) ||
20
+ f.match(/^(CODE_OF_CONDUCT|Rakefile|Guardfile|Gemfile)/)
19
21
  end
20
- spec.bindir = "exe"
22
+ spec.bindir = 'exe'
21
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
23
25
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency 'awesome_print', '~> 1.8.0'
27
+ spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'guard', '~> 2.14.1'
29
+ spec.add_development_dependency 'guard-rake', '~> 1.0.0'
30
+ spec.add_development_dependency 'guard-yard', '~> 2.2.0'
31
+ spec.add_development_dependency 'rake', '~> 12.3'
32
+ spec.add_development_dependency 'rspec', '~> 3.7'
33
+ spec.add_development_dependency 'rubocop', '~> 0.52.1'
34
+ spec.add_development_dependency 'simplecov', '~> 0.15.1'
35
+ spec.add_development_dependency 'vcr', '~> 4.0.0'
36
+ spec.add_development_dependency 'webmock', '~> 3.3.0'
27
37
  end
@@ -1,5 +1,32 @@
1
- require "amadeus/version"
1
+ # frozen_string_literal: true
2
2
 
3
- module Amadeus
4
- # Your code goes here...
5
- end
3
+ require 'amadeus/version'
4
+ require 'amadeus/client/location'
5
+ require 'amadeus/client/response'
6
+ require 'amadeus/client/decorator'
7
+ require 'amadeus/client/access_token'
8
+ require 'amadeus/client/errors'
9
+ require 'amadeus/client'
10
+
11
+ require 'amadeus/namespaces/travel'
12
+ require 'amadeus/namespaces/shopping'
13
+ require 'amadeus/namespaces/reference_data'
14
+ require 'amadeus/namespaces/reference_data/urls'
15
+ require 'amadeus/namespaces/reference_data/urls/checkin_links'
16
+ require 'amadeus/namespaces/reference_data/location'
17
+ require 'amadeus/namespaces/reference_data/locations'
18
+ require 'amadeus/namespaces/reference_data/locations/airports'
19
+ require 'amadeus/namespaces/shopping/flight_destinations'
20
+ require 'amadeus/namespaces/shopping/flight_offers'
21
+ require 'amadeus/namespaces/shopping/flight_dates'
22
+ require 'amadeus/namespaces/shopping/hotel_offers'
23
+ require 'amadeus/namespaces/shopping/hotel'
24
+ require 'amadeus/namespaces/shopping/hotel/offer'
25
+ require 'amadeus/namespaces/shopping/hotel/hotel_offers'
26
+ require 'amadeus/namespaces/travel/analytics'
27
+ require 'amadeus/namespaces/travel/analytics/fare_searches'
28
+ require 'amadeus/namespaces/travel/analytics/air_traffics'
29
+
30
+ # The namespace for the files used to make API
31
+ # calls to the Amadeus travel APIs
32
+ module Amadeus; end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'amadeus/client/validator'
5
+ require 'amadeus/namespaces/core'
6
+ require 'amadeus/client/http'
7
+ require 'amadeus/client/pagination'
8
+
9
+ module Amadeus
10
+ # The Amadeus client library for accessing
11
+ # the travel APIs
12
+ class Client
13
+ include Validator
14
+ include HTTP
15
+ include Pagination
16
+ include Amadeus::Namespaces
17
+
18
+ # The API key used to authenticate against the API
19
+ attr_reader :client_id
20
+ # The API secret used to authenticate against the API
21
+ attr_reader :client_secret
22
+ # The logger used to output warnings and debug messages
23
+ attr_reader :logger
24
+ # If this client is running in debug, warn, or silent mode
25
+ attr_reader :log_level
26
+ # The short name of the host used to make API calls against
27
+ attr_reader :hostname
28
+ # The host domain used to make API calls against
29
+ attr_reader :host
30
+ # Wether to use HTTPS to connect
31
+ attr_reader :ssl
32
+ # The port to connect to, if not the default 443
33
+ attr_reader :port
34
+ # A custom App ID to be passed in the User Agent to the server
35
+ attr_reader :custom_app_id
36
+ # A custom App version to be passed in the User Agent to the server
37
+ attr_reader :custom_app_version
38
+ # The Net:HTTP compatible HTTP client in use
39
+ attr_reader :http
40
+
41
+ # The available hosts for this API
42
+ HOSTS = {
43
+ test: 'test.api.amadeus.com',
44
+ production: 'production.api.amadeus.com'
45
+ }.freeze
46
+
47
+ # Initialize using your credentials:
48
+ #
49
+ # amadeus = Amadeus::Client.new(
50
+ # client_id: 'YOUR_CLIENT_ID',
51
+ # client_secret: 'YOUR_CLIENT_SECRET'
52
+ # )
53
+ #
54
+ # Alternatively, initialize the library using
55
+ # the environment variables +AMADEUS_CLIENT_ID+
56
+ # and +AMADEUS_CLIENT_SECRET+
57
+ #
58
+ # amadeus = Amadeus::Client.new
59
+ #
60
+ # @option options [string] :clientId the API key used to authenticate the
61
+ # API
62
+ # @option options [string] :clientSecret the API secret used to authenticate
63
+ # the API
64
+ # @option options [Object] :logger ('Logger') a `Logger`-compatible logger
65
+ # that accepts a debug call
66
+ # @option options [string] :log_level ('warn') if this client is running in
67
+ # debug, warn, or silent mode
68
+ # @option options [string] :hostname ('production') the name of the server
69
+ # API calls are made to (`production` or `test`)
70
+ # @option options [string] :custom_app_id (null) a custom App ID to be
71
+ # passed in the User Agent to the server.
72
+ # @option options [string] :custom_app_version (null) a custom App Version
73
+ # number to be passed in the User Agent to the server.
74
+ # @option options [Object] :http (Net::HTTP) an optional
75
+ # Node/HTTPS-compatible client that accepts a 'request()' call with an
76
+ # array of options.
77
+ # @option options [boolean] :ssl (true) if this client is will use HTTPS
78
+ def initialize(options = {})
79
+ initialize_client_credentials(options)
80
+ initialize_logger(options)
81
+ initialize_host(options)
82
+ initialize_custom_app(options)
83
+ initialize_http(options)
84
+
85
+ recognized_options = %i[client_id client_secret
86
+ logger host hostname
87
+ custom_app_id custom_app_version
88
+ http log_level ssl port]
89
+ warn_on_unrecognized_options(options, logger, recognized_options)
90
+ end
91
+
92
+ private
93
+
94
+ def initialize_client_credentials(options)
95
+ @client_id = init_required(:client_id, options)
96
+ @client_secret = init_required(:client_secret, options)
97
+ end
98
+
99
+ def initialize_logger(options)
100
+ @logger = init_optional(:logger, options, Logger.new(STDOUT))
101
+ @log_level = init_optional(:log_level, options, 'warn')
102
+ end
103
+
104
+ def initialize_host(options)
105
+ @hostname = init_optional(:hostname, options, :test).to_sym
106
+ @host = init_optional(:host, options, HOSTS[hostname])
107
+ @ssl = init_optional(:ssl, options, true)
108
+ @port = init_optional(:port, options, 443)
109
+ end
110
+
111
+ def initialize_custom_app(options)
112
+ @custom_app_id = init_optional(:custom_app_id, options, nil)
113
+ @custom_app_version = init_optional(:custom_app_version, options, nil)
114
+ end
115
+
116
+ def initialize_http(options)
117
+ @http = init_optional(:http, options, Net::HTTP)
118
+ end
119
+ end
120
+ end