Class: CapsuleCRM::Party

Inherits:
Base
  • Object
show all
Defined in:
lib/capsulecrm/party.rb

Direct Known Subclasses

Organisation, Person

Instance Attribute Summary

Attributes inherited from Base

#id, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #errors, find, #initialize, last_response, #new_record?

Constructor Details

This class inherits a constructor from CapsuleCRM::Base

Class Method Details

.find_all_by_email(email, options = {}) ⇒ Object



45
46
47
48
# File 'lib/capsulecrm/party.rb', line 45

def self.find_all_by_email(email, options={})
  options[:email] = email
  find_all(options)
end

.find_by_email(email) ⇒ Object

nodoc



52
53
54
# File 'lib/capsulecrm/party.rb', line 52

def self.find_by_email(email)
  find_all_by_email(email, :limit => 1, :offset => 0).first
end

.get_pathObject

nodoc



40
41
42
# File 'lib/capsulecrm/party.rb', line 40

def self.get_path
  '/api/party'
end

.search(query, options = {}) ⇒ Object

nodoc



58
59
60
61
# File 'lib/capsulecrm/party.rb', line 58

def self.search(query, options={})
  options[:q] = query
  find_all(options)
end

Instance Method Details

#addressesObject

nodoc



5
6
7
8
9
# File 'lib/capsulecrm/party.rb', line 5

def addresses
  return @addresses if @addresses
  data = raw_data['contacts']['address']
  @addresses = CapsuleCRM::Address.init_many(self, data)
end

#custom_fieldsObject

nodoc



13
14
15
16
17
18
19
20
# File 'lib/capsulecrm/party.rb', line 13

def custom_fields
  return @custom_fields if @custom_fields
  path = self.class.base_path
  path = [path, '/', id, '/customfield'].join
  last_response = self.class.get(path)
  data = last_response['customFields']['customField']
  @custom_fields = CapsuleCRM::CustomField.init_many(self, data)
end

#emailsObject

nodoc



24
25
26
27
28
# File 'lib/capsulecrm/party.rb', line 24

def emails
  return @emails if @emails
  data = raw_data['contacts']['email']
  @emails = CapsuleCRM::Email.init_many(self, data)
end

#phone_numbersObject

nodoc



32
33
34
35
36
# File 'lib/capsulecrm/party.rb', line 32

def phone_numbers
  return @phone_numbers if @phone_numbers
  data = raw_data['contacts']['phone']
  @phone_numbers = CapsuleCRM::Phone.init_many(self, data)
end