Module: ExpediaApi::HTTPService
- Defined in:
- lib/expedia_api/http_service.rb
Constant Summary collapse
- API_SERVER =
'ews.expedia.com'- API_PATH =
'wsapi/rest/hotel/v1/search'
Class Method Summary collapse
-
.common_parameters ⇒ Object
Common Parameters required for every Call to Expedia Server.
- .faraday_options ⇒ Object
- .perform_request(request_options: {}, parameters: {}) ⇒ Object
- .proxy_options ⇒ Object
-
.server_url ⇒ Object
The address of the appropriate Expedia server.
- .use_proxy? ⇒ Boolean
Class Method Details
.common_parameters ⇒ Object
Common Parameters required for every Call to Expedia Server.
52 53 54 55 56 57 |
# File 'lib/expedia_api/http_service.rb', line 52 def common_parameters { :format => :json, :key => ExpediaApi.api_key } end |
.faraday_options ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/expedia_api/http_service.rb', line 17 def = { url: server_url } if use_proxy? [:proxy] = end end |
.perform_request(request_options: {}, parameters: {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/expedia_api/http_service.rb', line 27 def perform_request(request_options: {}, parameters: {}) args = common_parameters.merge(parameters) # figure out our options for this request # set up our Faraday connection connection = Faraday.new() do |faraday| faraday.adapter Faraday.default_adapter end connection.get(API_PATH, args) end |
.proxy_options ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/expedia_api/http_service.rb', line 41 def { uri: ExpediaApi.proxy_uri, user: ExpediaApi.proxy_user, password: ExpediaApi.proxy_password } end |
.server_url ⇒ Object
The address of the appropriate Expedia server.
return a complete server address with protocol
13 14 15 |
# File 'lib/expedia_api/http_service.rb', line 13 def server_url "http://#{API_SERVER}" end |
.use_proxy? ⇒ Boolean
37 38 39 |
# File 'lib/expedia_api/http_service.rb', line 37 def use_proxy? !!(ExpediaApi.proxy_uri && ExpediaApi.proxy_user && ExpediaApi.proxy_password) end |