Class: Tvdbjson::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/tvdbjson/request.rb

Constant Summary collapse

BASE_URI =
"https://api.thetvdb.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
12
13
14
15
# File 'lib/tvdbjson/request.rb', line 7

def initialize(options = {})
  @url = "#{BASE_URI}#{options[:uri]}"
  @body = options[:body]
  @headers = {
    'Accept-Language' => 'en',
    'Content-Type' => 'application/json',
    'User-Agent' => "Tvdbjson Ruby Gem v#{Tvdbjson::VERSION}"
  }.merge(options[:header])
end

Instance Attribute Details

#authenticationObject

Returns the value of attribute authentication.



5
6
7
# File 'lib/tvdbjson/request.rb', line 5

def authentication
  @authentication
end

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/tvdbjson/request.rb', line 5

def body
  @body
end

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'lib/tvdbjson/request.rb', line 5

def headers
  @headers
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/tvdbjson/request.rb', line 5

def url
  @url
end

Instance Method Details

#getObject



17
18
19
# File 'lib/tvdbjson/request.rb', line 17

def get
  HTTParty.get(@url, :headers => @headers, :body => @body.to_json)
end

#postObject



21
22
23
# File 'lib/tvdbjson/request.rb', line 21

def post
  HTTParty.post(@url, :headers => @headers, :body => @body.to_json)
end