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
7 8 9 10 11 12 13 |
# File 'lib/tvdbjson/request.rb', line 7 def initialize( = {}) @url = "#{BASE_URI}#{options[:uri]}" @body = [:body] unless ![:body] @headers = { 'Accept' => 'application/json' }.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
15 16 17 |
# File 'lib/tvdbjson/request.rb', line 15 def get HTTParty.get(@url, :headers => @headers) end |
#post ⇒ Object
19 20 21 |
# File 'lib/tvdbjson/request.rb', line 19 def post HTTParty.post(@url, :headers => @headers, :body => @body.to_json) end |