Module: ExpediaApi::HTTPService
- Defined in:
- lib/expedia_api/http_service.rb
Constant Summary collapse
- API_SERVER =
'ews.expedia.com'
Class Method Summary collapse
-
.common_parameters ⇒ Object
Common Parameters required for every Call to Expedia Server.
- .faraday_options ⇒ Object
- .perform_request(request_options: {}, parameters: {}, uri:) ⇒ 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.
51 52 53 54 55 56 |
# File 'lib/expedia_api/http_service.rb', line 51 def common_parameters { :format => :json, :key => ExpediaApi.api_key } end |
.faraday_options ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/expedia_api/http_service.rb', line 16 def = { url: server_url } if use_proxy? [:proxy] = end end |
.perform_request(request_options: {}, parameters: {}, uri:) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/expedia_api/http_service.rb', line 26 def perform_request(request_options: {}, parameters: {}, uri:) 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(uri, args) end |
.proxy_options ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/expedia_api/http_service.rb', line 40 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
12 13 14 |
# File 'lib/expedia_api/http_service.rb', line 12 def server_url "http://#{API_SERVER}" end |
.use_proxy? ⇒ Boolean
36 37 38 |
# File 'lib/expedia_api/http_service.rb', line 36 def use_proxy? !!(ExpediaApi.proxy_uri && ExpediaApi.proxy_user && ExpediaApi.proxy_password) end |