Class: Shelbytv::Base
- Inherits:
-
Object
- Object
- Shelbytv::Base
- Defined in:
- lib/shelbytv/base.rb
Constant Summary collapse
- API =
"http://api.shelby.tv/v2/"
Instance Attribute Summary collapse
-
#auth_secret ⇒ Object
Returns the value of attribute auth_secret.
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#request_token ⇒ Object
Returns the value of attribute request_token.
Instance Method Summary collapse
- #access_token(oauth_verifier) ⇒ Object
- #authorize_url ⇒ Object
- #channels ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
- #post(path, params = {}) ⇒ Object
- #user ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 |
# File 'lib/shelbytv/base.rb', line 9 def initialize(*args) if args.size == 2 @consumer_key, @consumer_secret = args elsif args.size == 4 @consumer_key, @consumer_secret, @auth_token, @auth_secret = args else raise ArgumentError, "You need to pass in the consumer tokens as well as the auth tokens" end end |
Instance Attribute Details
#auth_secret ⇒ Object
Returns the value of attribute auth_secret.
7 8 9 |
# File 'lib/shelbytv/base.rb', line 7 def auth_secret @auth_secret end |
#auth_token ⇒ Object
Returns the value of attribute auth_token.
7 8 9 |
# File 'lib/shelbytv/base.rb', line 7 def auth_token @auth_token end |
#request_token ⇒ Object
Returns the value of attribute request_token.
7 8 9 |
# File 'lib/shelbytv/base.rb', line 7 def request_token @request_token end |
Instance Method Details
#access_token(oauth_verifier) ⇒ Object
46 47 48 |
# File 'lib/shelbytv/base.rb', line 46 def access_token(oauth_verifier) @request_token.get_access_token(:oauth_verifier => oauth_verifier) end |
#authorize_url ⇒ Object
40 41 42 43 44 |
# File 'lib/shelbytv/base.rb', line 40 def consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, { :site=>"http://dev.shelby.tv" }) @request_token = consumer.get_request_token @request_token. end |
#channels ⇒ Object
19 20 21 |
# File 'lib/shelbytv/base.rb', line 19 def channels Shelbytv::ChannelProxy.new(self) end |
#get(path, params = {}) ⇒ Object
31 32 33 34 |
# File 'lib/shelbytv/base.rb', line 31 def get(path, params={}) query = params.map { |k,v| "#{k}=#{v}" }.join("&") JSON.parse(client.get(API + path + "?" + OAuth::Helper.escape(query)).body) end |
#post(path, params = {}) ⇒ Object
36 37 38 |
# File 'lib/shelbytv/base.rb', line 36 def post(path, params={}) JSON.parse(client.get(API + path, params)) end |