Class: Rdio::BaseApi
Overview
Basis for making web-service calls and constructing the values. Subclasses should declare the api by calling ‘call’, ‘return_object’, and ‘create_object’
Direct Known Subclasses
Constant Summary collapse
- PATH =
'/1/'
Instance Attribute Summary collapse
-
#oauth ⇒ Object
readonly
Returns the value of attribute oauth.
Instance Method Summary collapse
-
#access_token=(token) ⇒ Object
Token -> Void.
-
#authorize ⇒ Object
Forces authorization.
- #call(method, args, requires_auth = false) ⇒ Object
- #get_pin ⇒ Object
-
#get_pin=(get_pin) ⇒ Object
(string -> string) -> (string -> string).
- #initialize(key = nil, secret = nil) ⇒ BaseApi constructor
- #return_object(type, method, args, requires_auth = false) ⇒ Object
Constructor Details
Instance Attribute Details
#oauth ⇒ Object (readonly)
Returns the value of attribute oauth.
260 261 262 |
# File 'lib/rdio/base.rb', line 260 def oauth @oauth end |
Instance Method Details
#access_token=(token) ⇒ Object
Token -> Void
Sets both unauthorized and authorized tokens to token
290 291 292 293 |
# File 'lib/rdio/base.rb', line 290 def access_token=(token) @access_token_auth = token @access_token_no_auth = token end |
#authorize ⇒ Object
Forces authorization
333 334 335 |
# File 'lib/rdio/base.rb', line 333 def access_token true end |
#call(method, args, requires_auth = false) ⇒ Object
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/rdio/base.rb', line 295 def call(method,args,requires_auth=false) # # Convert object with keys just to use their keys # args = Rdio::convert_args args if Rdio::log_methods Rdio::log "Called method: #{method}(#{args}) : auth=#{requires_auth}" end new_args = {} new_args['method'] = method args.each do |k,v| new_args[k] = v.to_k.to_s end url = PATH if Rdio::log_posts Rdio::log "Post to url=#{url} method=#{method} args=#{args}" end # # For backwards compatibility the response may have a 'body' # attribute or a tuple could be returned. Handle both cases. # resp,data = access_token(requires_auth).post url,new_args begin return resp.body rescue end return data end |
#get_pin ⇒ Object
282 283 284 |
# File 'lib/rdio/base.rb', line 282 def get_pin @oauth.get_pin end |
#get_pin=(get_pin) ⇒ Object
(string -> string) -> (string -> string)
Sets the function that will return a pin given an authorization url for the contained RdioOAuth instance
278 279 280 |
# File 'lib/rdio/base.rb', line 278 def get_pin=(get_pin) @oauth.get_pin = get_pin end |