Module: ComicVine::Api::HTTPService

Defined in:
lib/comic_vine/api/http_service.rb

Constant Summary collapse

DEFAULT_MIDDLEWARE =
proc do |builder|
  builder.adapter Faraday.default_adapter
end

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.faraday_middlewareObject

Returns the value of attribute faraday_middleware.



7
8
9
# File 'lib/comic_vine/api/http_service.rb', line 7

def faraday_middleware
  @faraday_middleware
end

.http_optionsObject

Returns the value of attribute http_options.



7
8
9
# File 'lib/comic_vine/api/http_service.rb', line 7

def http_options
  @http_options
end

Class Method Details

.make_request(request) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/comic_vine/api/http_service.rb', line 26

def self.make_request(request)
  connection = Faraday.new(
    request.server, faraday_options(request.options),
    &(faraday_middleware || DEFAULT_MIDDLEWARE)
  )
  response = connection.send(request.verb, request.path, request.args)
  ComicVine::Api::Response.new(
    status: response.status.to_i, headers: response.headers,
    body: response.body
  )
end