Class: Contacts::Yahoo
- Inherits:
-
OAuthConsumer
- Object
- Consumer
- OAuthConsumer
- Contacts::Yahoo
- Defined in:
- lib/contacts/yahoo.rb
Constant Summary collapse
- CONSUMER_OPTIONS =
Util.frozen_hash( :site => "https://api.login.yahoo.com", :request_token_path => "/oauth/v2/get_request_token", :access_token_path => "/oauth/v2/get_token", :authorize_path => "/oauth/v2/request_auth" )
- REQUEST_TOKEN_PARAMS =
{}
Instance Attribute Summary
Attributes inherited from OAuthConsumer
Attributes inherited from Consumer
Instance Method Summary collapse
- #contacts(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Yahoo
constructor
A new instance of Yahoo.
- #initialize_serialized(data) ⇒ Object
- #serializable_data ⇒ Object
Methods inherited from OAuthConsumer
#authentication_url, #authorize
Methods inherited from Consumer
#authorize, configuration, configuration_attribute, configure, deserialize, #serialize
Constructor Details
#initialize(options = {}) ⇒ Yahoo
Returns a new instance of Yahoo.
15 16 17 |
# File 'lib/contacts/yahoo.rb', line 15 def initialize(={}) super(CONSUMER_OPTIONS, REQUEST_TOKEN_PARAMS) end |
Instance Method Details
#contacts(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/contacts/yahoo.rb', line 26 def contacts(={}) return nil if @access_token.nil? params = {:limit => 200}.update() yahoo_params = (params).merge('format' => 'json') guid = @access_token.params['xoauth_yahoo_guid'] uri = URI.parse("http://social.yahooapis.com/v1/user/#{guid}/contacts") uri.query = params_to_query(yahoo_params) begin response = @access_token.get(uri.to_s) rescue OAuth::Unauthorized => error # Token probably expired. @error = error. return nil end parse_contacts(response.body) end |
#initialize_serialized(data) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/contacts/yahoo.rb', line 19 def initialize_serialized(data) super if @access_token && (guid = data['guid']) @access_token.params['xoauth_yahoo_guid'] = guid end end |
#serializable_data ⇒ Object
43 44 45 46 47 |
# File 'lib/contacts/yahoo.rb', line 43 def serializable_data data = super data['guid'] = @access_token.params['xoauth_yahoo_guid'] if @access_token data end |