Class: GoogleAppsApi::Contacts::Api
- Defined in:
- lib/google_apps_api/contacts.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from BaseApi
Instance Method Summary collapse
- #create_contact(contact, *args) ⇒ Object
-
#initialize(*args) ⇒ Api
constructor
A new instance of Api.
- #remove_contact(contact, *args) ⇒ Object
- #retrieve_all_contacts(*args) ⇒ Object
Methods inherited from BaseApi
Constructor Details
#initialize(*args) ⇒ Api
Returns a new instance of Api.
8 9 10 |
# File 'lib/google_apps_api/contacts.rb', line 8 def initialize(*args) super(:contacts, *args) end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/google_apps_api/contacts.rb', line 6 def token @token end |
Instance Method Details
#create_contact(contact, *args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/google_apps_api/contacts.rb', line 23 def create_contact(contact, *args) req = <<-DESCXML <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'> <atom:category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact' /> <atom:title type='text'>#{contact.name}</atom:title> DESCXML contact.emails.each_pair do |loc, email| req += <<-DESCXML <gd:email rel='http://schemas.google.com/g/2005##{loc}' primary='#{contact.primary_email == loc ? 'true' : 'false'}' address='#{email}' displayName='#{contact.name}' /> DESCXML end req += "</atom:entry>" = args..merge(:body => req.strip) request(:create_contact, ) end |
#remove_contact(contact, *args) ⇒ Object
17 18 19 20 21 |
# File 'lib/google_apps_api/contacts.rb', line 17 def remove_contact(contact, *args) = args..merge(:contact => contact.id_escaped, :merge_headers => {"If-Match" => "*"}) request(:remove_contact, ) end |
#retrieve_all_contacts(*args) ⇒ Object
12 13 14 15 |
# File 'lib/google_apps_api/contacts.rb', line 12 def retrieve_all_contacts(*args) = args. request(:retrieve_all_contacts, ) end |