Class: GoogleAppsApi::Contacts::Api

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/google_apps_api/contacts.rb

Instance Attribute Summary collapse

Attributes inherited from BaseApi

#domain

Instance Method Summary collapse

Methods inherited from BaseApi

#entity

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

#tokenObject (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 = "  <atom:entry xmlns:atom='http://www.w3.org/2005/Atom'\n      xmlns:gd='http://schemas.google.com/g/2005'>\n    <atom:category scheme='http://schemas.google.com/g/2005#kind'\n      term='http://schemas.google.com/contact/2008#contact' />\n    <atom:title type='text'>\#{contact.name}</atom:title>\n  DESCXML\n  \n  contact.emails.each_pair do |loc, email|\n    req += <<-DESCXML\n    <gd:email rel='http://schemas.google.com/g/2005#\#{loc}'\n      primary='\#{contact.primary_email == loc ? 'true' : 'false'}'\n      address='\#{email}' displayName='\#{contact.name}' />\n    DESCXML\n  end\n  \n  req += \"</atom:entry>\"\n  \n  options = args.extract_options!.merge(:body => req.strip)\n  \n  request(:create_contact, options)\n  \nend\n"

#remove_contact(contact, *args) ⇒ Object



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

def remove_contact(contact, *args)
  options = args.extract_options!.merge(:contact => contact.id_escaped, :merge_headers => {"If-Match" => "*"})
  
  request(:remove_contact, options)
end

#retrieve_all_contacts(*args) ⇒ Object



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

def retrieve_all_contacts(*args)
  options = args.extract_options!
  request(:retrieve_all_contacts, options)
end