Class: Kampainer::ContactManager

Inherits:
Object
  • Object
show all
Defined in:
lib/kampainer/contact_manager.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sessionObject (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.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • attribute_name (String)
  • attribute_type (String)
  • default_value (String|??)

Returns:

  • (Integer)

    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

Parameters:

  • *keys

    One or more keys of contacts to delete.



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

Parameters:

  • *keys

    One or more contact keys.



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

Returns:



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

Parameters:

  • filters (Hash)

    a customizable set of options

Options Hash (filters):

  • include_all_default_attributes (Boolean)
  • include_all_custom_attributes (Boolean)
  • include_all_system_attributes (Boolean)


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_contactsObject



51
52
53
# File 'lib/kampainer/contact_manager.rb', line 51

def list_test_contacts
  call('ListTestContacts')
end