Class: Contacts::Yahoo

Inherits:
OAuthConsumer show all
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 =
Util.frozen_hash

Instance Attribute Summary

Attributes inherited from OAuthConsumer

#access_token, #request_token

Attributes inherited from Consumer

#error

Instance Method Summary collapse

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.



12
13
14
# File 'lib/contacts/yahoo.rb', line 12

def initialize(options={})
  super(CONSUMER_OPTIONS, REQUEST_TOKEN_PARAMS)
end

Instance Method Details

#contacts(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/contacts/yahoo.rb', line 23

def contacts(options={})
  return nil if @access_token.nil?
  params = {:limit => 200}.update(options)
  yahoo_params = translate_contacts_options(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)
    parse_contacts(response.body)
  rescue
    return nil
  end
end

#initialize_serialized(data) ⇒ Object



16
17
18
19
20
21
# File 'lib/contacts/yahoo.rb', line 16

def initialize_serialized(data)
  super
  if @access_token && (guid = data['guid'])
    @access_token.params['xoauth_yahoo_guid'] = guid
  end
end

#serializable_dataObject



38
39
40
41
42
# File 'lib/contacts/yahoo.rb', line 38

def serializable_data
  data = super
  data['guid'] = @access_token.params['xoauth_yahoo_guid'] if @access_token
  data
end