Class: Netflix::Client
- Inherits:
-
Object
- Object
- Netflix::Client
- Defined in:
- lib/netflix/client.rb
Class Attribute Summary collapse
-
.app_name ⇒ Object
Returns the value of attribute app_name.
-
.consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
.consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
Instance Method Summary collapse
- #handle_oauth_callback(request_token, oauth_verifier) ⇒ Object
-
#initialize(user_access_token = nil, user_access_secret = nil) ⇒ Client
constructor
attr_accessor :oauth_consumer, :oauth_access_token.
-
#oauth ⇒ Object
launches the Netflix OAuth page, and asks for the pin this is interactive (i.e. irb or commandline).
- #oauth_via_callback(callback_url) ⇒ Object
- #user(user_id) ⇒ Object
Constructor Details
#initialize(user_access_token = nil, user_access_secret = nil) ⇒ Client
attr_accessor :oauth_consumer, :oauth_access_token
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/netflix/client.rb', line 11 def initialize(user_access_token=nil, user_access_secret=nil) @oauth_consumer = OAuth::Consumer.new(Client.consumer_key, Client.consumer_secret, :site => "http://api.netflix.com", :request_token_url => "http://api.netflix.com/oauth/request_token", :access_token_url => "http://api.netflix.com/oauth/access_token", :authorize_url => "https://api-user.netflix.com/oauth/login") if user_access_token && user_access_secret @oauth_access_token = oauth_access_token(user_access_token, user_access_secret) #automatically determine if error should be thrown based on response codes @oauth_access_token.extend(ResponseErrorDecorator) elsif !!user_access_token ^ !!user_access_secret raise ArgumentError 'Must specify both user_access_token and user_access_secret if specifying either' end end |
Class Attribute Details
.app_name ⇒ Object
Returns the value of attribute app_name.
6 7 8 |
# File 'lib/netflix/client.rb', line 6 def app_name @app_name end |
.consumer_key ⇒ Object
Returns the value of attribute consumer_key.
6 7 8 |
# File 'lib/netflix/client.rb', line 6 def consumer_key @consumer_key end |
.consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
6 7 8 |
# File 'lib/netflix/client.rb', line 6 def consumer_secret @consumer_secret end |
Instance Method Details
#handle_oauth_callback(request_token, oauth_verifier) ⇒ Object
55 56 57 |
# File 'lib/netflix/client.rb', line 55 def handle_oauth_callback(request_token, oauth_verifier) access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier) end |
#oauth ⇒ Object
launches the Netflix OAuth page, and asks for the pin this is interactive (i.e. irb or commandline)
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/netflix/client.rb', line 36 def oauth request_token = @oauth_consumer.get_request_token = request_token.(:oauth_consumer_key => Netflix::Client.consumer_key) Launchy.open() puts "Go to browser, a page has been opened to establish oauth" printf "Pin from Netflix:" pin = gets.chomp access_token = request_token.get_access_token(:oauth_verifier => pin) end |
#oauth_via_callback(callback_url) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/netflix/client.rb', line 47 def oauth_via_callback(callback_url) request_token = @oauth_consumer.get_request_token(:oauth_callback => callback_url, :application_name => Netflix::Client.app_name) = request_token.(:oauth_consumer_key => Netflix::Client.consumer_key) [request_token, ] end |