Class: CapsuleCRM::Contacts
- Inherits:
-
Object
- Object
- CapsuleCRM::Contacts
- Defined in:
- lib/capsule_crm/contacts.rb
Instance Method Summary collapse
-
#addresses ⇒ Object
Public: Gets the addresses for this contacts container.
-
#addresses=(addresses) ⇒ Object
Public: Sets the addresses for this contacts container.
-
#emails ⇒ Object
Public: Gets the emails for this contacts container.
-
#emails=(emails) ⇒ Object
Public: Sets the emails for this contacts container.
-
#initialize(attributes = {}) ⇒ Contacts
constructor
Public: Initializes a new CapsuleCRM::Contacts object.
-
#phones ⇒ Object
Public: Gets the phones for this contacts container.
-
#phones=(phones) ⇒ Object
Public: Sets the phones for this contacts controller.
-
#to_capsule_json ⇒ Object
Public: Builds a hash of all contact information.
-
#websites ⇒ Object
Public: Gets the websites for this contacts container.
-
#websites=(websites) ⇒ Object
Public: Sets the websites for this contacts container.
Constructor Details
#initialize(attributes = {}) ⇒ Contacts
Public: Initializes a new CapsuleCRM::Contacts object
attributes - The Hash of attributes
:addresses - The Array of CapsuleCRM::Address objects
:emails - The Array of CapsuleCRM::Email objects
Examples
CapsuleCRM::Contacts.new
CapsuleCRM::Contacts.new(addresses: addresses, emails: emails)
Returns a CapsuleCRM::Contact
17 18 19 20 21 22 |
# File 'lib/capsule_crm/contacts.rb', line 17 def initialize(attributes = {}) self.addresses = attributes[:addresses] || attributes[:address] self.emails = attributes[:emails] || attributes[:email] self.phones = attributes[:phones] || attributes[:phone] self.websites = attributes[:websites] || attributes[:website] end |
Instance Method Details
#addresses ⇒ Object
Public: Gets the addresses for this contacts container
Examples
contacts.addresses
Returns an Array of CapsuleCRM::Address objects
47 48 49 |
# File 'lib/capsule_crm/contacts.rb', line 47 def addresses Array(@addresses) end |
#addresses=(addresses) ⇒ Object
Public: Sets the addresses for this contacts container
addresses - The Array of CapsuleCRM::Address objects
Examples
address = CapsuleCRM::Address.new(street: ‘Oranienburgerstrasse’) contacts = CapsuleCRM::Contacts.new contacts.addresses = [address] contacts.addresses << address
Returns an Array of CapsuleCRM::Address objects
36 37 38 |
# File 'lib/capsule_crm/contacts.rb', line 36 def addresses=(addresses) set_collection(CapsuleCRM::Address, addresses) end |
#emails ⇒ Object
Public: Gets the emails for this contacts container
Examples
contacts.emails
Returns an Array of CapsuleCRM::Email objects
75 76 77 |
# File 'lib/capsule_crm/contacts.rb', line 75 def emails Array(@emails) end |
#emails=(emails) ⇒ Object
Public: Sets the emails for this contacts container
emails - The Array of CapsuleCRM::Email objects
Examples
email = CapsuleCRM::Email.new(type: ‘HOME’, email_address: ‘[email protected]’) contacts = CapsuleCRM::Contacts.new contacts.emails = [email]
Returns an Array of CapsuleCRM::Email objects
63 64 65 |
# File 'lib/capsule_crm/contacts.rb', line 63 def emails=(emails) set_collection(CapsuleCRM::Email, emails) end |
#phones ⇒ Object
Public: Gets the phones for this contacts container
Examples
contacts.phones
Returns a Hash
101 102 103 |
# File 'lib/capsule_crm/contacts.rb', line 101 def phones Array(@phones) end |
#phones=(phones) ⇒ Object
Public: Sets the phones for this contacts controller
phones - The Array of CapsuleCRM::Phone objects
Examples
phone = CapsuleCRM::Phone.new(type: ‘Mobile’, phone_number: ‘1234’) contacts = CapsuleCRM::Contacts.new contacts.phones = [phone]
Returns an Array of CapsuleCRM::Phone objects
90 91 92 |
# File 'lib/capsule_crm/contacts.rb', line 90 def phones=(phones) set_collection(CapsuleCRM::Phone, phones) end |
#to_capsule_json ⇒ Object
Public: Builds a hash of all contact information
Examples
contacts.to_capsule_json
Returns a Hash
140 141 142 143 144 145 146 147 |
# File 'lib/capsule_crm/contacts.rb', line 140 def to_capsule_json { address: addresses.map(&:to_capsule_json), email: emails.map(&:to_capsule_json), phone: phones.map(&:to_capsule_json), website: websites.map(&:to_capsule_json) }.delete_if { |key, value| value.blank? }.stringify_keys end |
#websites ⇒ Object
Public: Gets the websites for this contacts container
Examples
contacts.websites
Returns a Hash
129 130 131 |
# File 'lib/capsule_crm/contacts.rb', line 129 def websites Array(@websites) end |
#websites=(websites) ⇒ Object
Public: Sets the websites for this contacts container
websites - The Array of CapsuleCRM::Website objects
Examples
website = CapsuleCRM::Website.new(
type: 'Work', web_service: 'URL', web_address: 'http://github.com'
) contacts = CapsuleCRM::Contacts.new contacts.websites = [website]
Returns an Array of CapsuleCRM::Website objects
118 119 120 |
# File 'lib/capsule_crm/contacts.rb', line 118 def websites=(websites) set_collection(CapsuleCRM::Website, websites) end |