Module: TheTvDB::Connection

Extended by:
Connection
Included in:
API, Connection
Defined in:
lib/the_tv_db/connection.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



13
14
15
16
17
18
19
20
21
# File 'lib/the_tv_db/connection.rb', line 13

def connection
  @connection ||= Faraday.new(:url => TheTvDB::ENDPOINT) do |faraday|
    faraday.response :logger if ENV['DEBUG'] # log requests to STDOUT
    faraday.adapter  :net_http # make requests with NetHTTP
    faraday.use      TheTvDB::Response::Xmlize
    faraday.use      TheTvDB::Response::Unzip
    faraday.use      TheTvDB::Response::RaiseError
  end
end

#request(path, params = {}) ⇒ Object



23
24
25
26
# File 'lib/the_tv_db/connection.rb', line 23

def request(path, params={})
  response = connection.get(path, params)
  response.body
end