Class: Tvdbjson::Request
- Inherits:
-
Object
- Object
- Tvdbjson::Request
- Defined in:
- lib/tvdbjson/request.rb
Constant Summary collapse
- BASE_URI =
"https://api.thetvdb.com"
Instance Attribute Summary collapse
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #post ⇒ Object
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( = {}) @url = "#{BASE_URI}#{[:uri]}" @body = [:body] @headers = { 'Accept-Language' => 'en', 'Content-Type' => 'application/json', 'User-Agent' => "Tvdbjson Ruby Gem v#{Tvdbjson::VERSION}" }.merge([:header]) end |
Instance Attribute Details
#authentication ⇒ Object
Returns the value of attribute authentication.
5 6 7 |
# File 'lib/tvdbjson/request.rb', line 5 def authentication @authentication end |
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/tvdbjson/request.rb', line 5 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/tvdbjson/request.rb', line 5 def headers @headers end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/tvdbjson/request.rb', line 5 def url @url end |
Instance Method Details
#get ⇒ Object
17 18 19 |
# File 'lib/tvdbjson/request.rb', line 17 def get HTTParty.get(@url, :headers => @headers, :body => @body.to_json) end |
#post ⇒ Object
21 22 23 |
# File 'lib/tvdbjson/request.rb', line 21 def post HTTParty.post(@url, :headers => @headers, :body => @body.to_json) end |