Class: Zohoho::Crm

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/zohoho/crm.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password, apikey) ⇒ Crm

Returns a new instance of Crm.



9
10
11
# File 'lib/zohoho/crm.rb', line 9

def initialize(username, password, apikey)
  @conn = Zohoho::Connection.new 'ZohoCRM', username, password, apikey
end

Instance Method Details

#add_contact(name) ⇒ Object



27
28
29
30
31
32
# File 'lib/zohoho/crm.rb', line 27

def add_contact(name)
  first_name, last_name = parse_name(name)
  xmlData = parse_data({'First Name' => first_name, 'Last Name' => last_name}, 'Contacts')  
 record = @conn.call('Contacts', 'insertRecords', {:xmlData => xmlData, :newFormat => 1}, :post) 
 record['Id']    
end

#auth_urlObject



13
14
15
# File 'lib/zohoho/crm.rb', line 13

def auth_url
  @conn.ticket_url
end

#contact(name) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/zohoho/crm.rb', line 17

def contact(name)
  first_name, last_name = parse_name(name)
  contacts = find_contacts_by_last_name(last_name)
  contacts.select! {|c|
    if c['First Name'].nil? then c['First Name'] = '' end
    first_name.match(c['First Name'])
  } 
  contacts.first
end

#post_note(entity_id, note_title, note_content) ⇒ Object



34
35
36
37
38
# File 'lib/zohoho/crm.rb', line 34

def post_note(entity_id, note_title, note_content)
  xmlData = parse_data({'entityId' => entity_id, 'Note Title' => note_title, 'Note Content' => note_content}, 'Notes')
  record = @conn.call('Notes', 'insertRecords', {:xmlData => xmlData, :newFormat => 1}, :post) 
  record['Id']
end