Class: Videolog::Base
Constant Summary collapse
- ENDPOINT =
"http://api.videolog.tv"
Instance Attribute Summary collapse
-
#authorized ⇒ Object
readonly
Returns the value of attribute authorized.
Class Method Summary collapse
Instance Method Summary collapse
-
#authorize(options = {}) ⇒ Object
TODO: send some logic to Auth.
- #authorize!(options = {}) ⇒ Object
- #get_json(path, options = {}, &block) ⇒ Object
-
#initialize(auth_options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(auth_options = {}) ⇒ Base
Returns a new instance of Base.
15 16 17 |
# File 'lib/videolog/base.rb', line 15 def initialize(={}) () end |
Instance Attribute Details
#authorized ⇒ Object (readonly)
Returns the value of attribute authorized.
7 8 9 |
# File 'lib/videolog/base.rb', line 7 def @authorized end |
Class Method Details
.get_json(path, options = {}, &block) ⇒ Object
9 10 11 12 13 |
# File 'lib/videolog/base.rb', line 9 def self.get_json(path, ={}, &block) response = get("#{path}.json", , &block) validate_response! response.parsed_response response.parsed_response end |
Instance Method Details
#authorize(options = {}) ⇒ Object
TODO: send some logic to Auth
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/videolog/base.rb', line 29 def (={}) # TODO: send some logic to Auth @auth = Videolog::Auth.new @authorized = false unless [:username].nil? && [:password].nil? @auth.auth_hash = Videolog::Auth.get_auth_hash([:username], [:password]) end unless [:dev_token].nil? @auth.dev_token = [:dev_token] @authorized = true end end |
#authorize!(options = {}) ⇒ Object
43 44 45 46 |
# File 'lib/videolog/base.rb', line 43 def (={}) () raise AuthorizationNeeded unless end |
#get_json(path, options = {}, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/videolog/base.rb', line 19 def get_json(path, ={}, &block) if headers = {'Token' => @auth.dev_token} headers.merge!({'Autenticacao' => @auth.auth_hash}) unless @auth.auth_hash.nil? = {headers: headers}.merge() end self.class.get_json(path, , &block) end |