Class: Theoldreader::API::Service
- Inherits:
-
Object
- Object
- Theoldreader::API::Service
- Includes:
- Singleton
- Defined in:
- lib/theoldreader/api/service.rb
Constant Summary collapse
- HOST =
'theoldreader.com'- BASE_PATH =
'/reader/api/0'- DEFAULT_MIDDLEWARE =
Proc.new do |builder| builder.request :url_encoded builder.adapter Faraday.default_adapter end
- FARADAY_OPTIONS =
%w{request proxy ssl builder url parallel_manager params headers builder_class}.map(&:to_sym)
Instance Attribute Summary collapse
-
#faraday_middleware ⇒ Object
Returns the value of attribute faraday_middleware.
-
#http_options ⇒ Object
config of the http options for all requests from the client http_options can be set through Service.instance.http_options = false.
Instance Method Summary collapse
-
#initialize ⇒ Service
constructor
A new instance of Service.
- #make_request(verb, path, params, headers, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Service
Returns a new instance of Service.
24 25 26 |
# File 'lib/theoldreader/api/service.rb', line 24 def initialize @http_options = {} end |
Instance Attribute Details
#faraday_middleware ⇒ Object
Returns the value of attribute faraday_middleware.
19 20 21 |
# File 'lib/theoldreader/api/service.rb', line 19 def faraday_middleware @faraday_middleware end |
#http_options ⇒ Object
config of the http options for all requests from the client http_options can be set through Service.instance.http_options = false
22 23 24 |
# File 'lib/theoldreader/api/service.rb', line 22 def @http_options end |
Instance Method Details
#make_request(verb, path, params, headers, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/theoldreader/api/service.rb', line 28 def make_request(verb, path, params, headers, = {}) # use ssl by default [:use_ssl] ||= true [:base_path] ||= BASE_PATH [:host] ||= HOST # per request options will override the client options = .merge() conn = Faraday.new(service_url([:use_ssl], [:host], [:base_path]), (), &(faraday_middleware || DEFAULT_MIDDLEWARE)) response = conn.send(verb, path, params, headers) Theoldreader::API::Response.new(response.status.to_i, response.body, response.headers) end |