Class: Kampainer::ContactManager
- Inherits:
-
Object
- Object
- Kampainer::ContactManager
- Defined in:
- lib/kampainer/contact_manager.rb
Overview
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#create_update_attribute(params) ⇒ Integer
Attribute id.
- #delete_attribute(id) ⇒ Object
- #delete_contacts(*keys) ⇒ Object
- #get_contacts(*keys) ⇒ Object
- #immediate_upload(contact) ⇒ ContactKey
-
#initialize(session) ⇒ ContactManager
constructor
A new instance of ContactManager.
- #list_attributes(filters) ⇒ Object
- #list_test_contacts ⇒ Object
Constructor Details
#initialize(session) ⇒ ContactManager
Returns a new instance of ContactManager.
6 7 8 |
# File 'lib/kampainer/contact_manager.rb', line 6 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/kampainer/contact_manager.rb', line 4 def session @session end |
Instance Method Details
#create_update_attribute(params) ⇒ Integer
Returns attribute id.
14 15 16 17 |
# File 'lib/kampainer/contact_manager.rb', line 14 def create_update_attribute(params) params.transform_keys! { |key| key.to_s.camelcase(:lower) } call('CreateUpdateAttribute', params)[0].to_i end |
#delete_attribute(id) ⇒ Object
19 20 21 |
# File 'lib/kampainer/contact_manager.rb', line 19 def delete_attribute(id) call('DeleteAttribute', id: id) end |
#delete_contacts(*keys) ⇒ Object
24 25 26 27 |
# File 'lib/kampainer/contact_manager.rb', line 24 def delete_contacts(*keys) contact_keys = ArrayOfContactKey[keys] call('DeleteContacts', contact_keys.to_xml)[0].to_a end |
#get_contacts(*keys) ⇒ Object
30 31 32 33 34 |
# File 'lib/kampainer/contact_manager.rb', line 30 def get_contacts(*keys) filter = ContactsDataFilter.new(keys: ContactKeys[keys]) attribute_filter = ContactInformationFilter.new(include: 'static,custom,groups') call('GetContacts', filter.to_xml, attribute_filter.to_xml)[0].to_a end |
#immediate_upload(contact) ⇒ ContactKey
37 38 39 40 41 |
# File 'lib/kampainer/contact_manager.rb', line 37 def immediate_upload(contact) contact.key ||= ContactKey.new(unique_identifier: contact.email_address, id: 0) contacts = Contacts.new(Array(contact)) call('ImmediateUpload', contacts.to_xml)[0].key end |
#list_attributes(filters) ⇒ Object
46 47 48 49 |
# File 'lib/kampainer/contact_manager.rb', line 46 def list_attributes(filters) filter_xml = Attribute::Filter.new(filters).to_xml call('ListAttributes', filter_xml) end |
#list_test_contacts ⇒ Object
51 52 53 |
# File 'lib/kampainer/contact_manager.rb', line 51 def list_test_contacts call('ListTestContacts') end |