Class: Contacts::Google

Inherits:
OAuthConsumer show all
Defined in:
lib/contacts/google.rb

Constant Summary collapse

CONSUMER_OPTIONS =
Util.frozen_hash(
  :site => "https://www.google.com",
  :request_token_path => "/accounts/OAuthGetRequestToken",
  :access_token_path => "/accounts/OAuthGetAccessToken",
  :authorize_path => "/accounts/OAuthAuthorizeToken"
)
REQUEST_TOKEN_PARAMS =
Util.frozen_hash(
  'scope' => "https://www.google.com/m8/feeds/"
)

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, #initialize_serialized, #serializable_data

Methods inherited from Consumer

#authorize, configuration, configuration_attribute, configure, deserialize, #serialize

Constructor Details

#initialize(options = {}) ⇒ Google

Returns a new instance of Google.



16
17
18
# File 'lib/contacts/google.rb', line 16

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

Instance Method Details

#contacts(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/contacts/google.rb', line 20

def contacts(options={})
  return nil if @access_token.nil?
  params = {:limit => 200}.update(options)
  google_params = translate_parameters(params)
  query = params_to_query(google_params)
  response = @access_token.get("/m8/feeds/contacts/default/thin?#{query}")
  parse_contacts(response.body)
end