Module: Infusionsoft::Client::Contact

Included in:
Infusionsoft::Client
Defined in:
lib/infusionsoft/client/contact.rb

Overview

Contact service is used to manage contacts. You can add, update and find contacts in addition to managing follow up sequences, tags and action sets.

Instance Method Summary collapse

Instance Method Details

#contact_add(data, optin_status = nil) ⇒ Integer

Creates a new contact record from the data passed in the associative array.

“Opted in” using the verviage supplied here.

Examples:

{ :Email => '[email protected]', :FirstName => 'first_name', :LastName => 'last_name' }, 'New Signup'

Parameters:

  • data (Hash)

    contains the mappable contact fields and it’s data.

  • (Optional) (String)

    email opt in verbiage. The contact will then be

Returns:

  • (Integer)

    the id of the newly added contact



14
15
16
17
18
19
# File 'lib/infusionsoft/client/contact.rb', line 14

def contact_add(data, optin_status=nil)
  contact_id = xmlrpc('ContactService.add', data)
  email = data['Email'] || data[:Email]
  if optin_status && email; email_optin(email, optin_status); end
  return contact_id
end

#contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, merchant_account_id, credit_card_id, affiliate_id, days_till_charge) ⇒ Object

Creates a new recurring order for a contact.

Parameters:

  • contact_id (Integer)
  • allow_duplicate (Boolean)
  • cprogram_id (Integer)
  • merchant_account_id (Integer)
  • credit_card_id (Integer)
  • affiliate_id (Integer)


190
191
192
193
194
# File 'lib/infusionsoft/client/contact.rb', line 190

def contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, ,
                                credit_card_id, affiliate_id, days_till_charge)
  response = xmlrpc('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
                      , credit_card_id, affiliate_id, days_till_charge)
end

#contact_add_to_campaign(contact_id, campaign_id) ⇒ Boolean

Adds a contact to a follow-up sequence (campaigns were the original name of follow-up sequences).

Parameters:

  • contact_id (Integer)
  • campaign_id (Integer)

Returns:

  • (Boolean)

    returns true/false if the contact was added to the follow-up sequence successfully



89
90
91
# File 'lib/infusionsoft/client/contact.rb', line 89

def contact_add_to_campaign(contact_id, campaign_id)
  response = xmlrpc('ContactService.addToCampaign', contact_id, campaign_id)
end

#contact_add_to_group(contact_id, group_id) ⇒ Boolean

Adds a tag to a contact

Parameters:

  • contact_id (Integer)
  • group_id (Integer)

Returns:

  • (Boolean)

    returns true/false if the tag was added successfully



153
154
155
# File 'lib/infusionsoft/client/contact.rb', line 153

def contact_add_to_group(contact_id, group_id)
  response = xmlrpc('ContactService.addToGroup', contact_id, group_id)
end

#contact_add_with_dup_check(data, check_type, optin_status = nil) ⇒ Integer

Adds or updates a contact record based on matching data

“Opted in” using the verviage supplied here.

Examples:

{ :Email => '[email protected]', :FirstName => 'first_name', :LastName => 'last_name' }, 'Email', 'New Signup'

Parameters:

  • data (Array<Hash>)

    the contact data you want added

  • check_type (String)

    available options are ‘Email’, ‘EmailAndName’, ‘EmailAndNameAndCompany’

  • (Optional) (String)

    email opt in verbiage. The contact will then be

Returns:

  • (Integer)

    id of the contact added or updated



39
40
41
42
43
44
# File 'lib/infusionsoft/client/contact.rb', line 39

def contact_add_with_dup_check(data, check_type, optin_status=nil)
  contact_id = xmlrpc('ContactService.addWithDupCheck', data, check_type)
  email = data['Email'] || data[:Email]
  if optin_status && email; email_optin(email, optin_status); end
  return contact_id
end

#contact_find_by_email(email, selected_fields) ⇒ Array<Hash>

Finds all contacts with the supplied email address in any of the three contact record email addresses.

Parameters:

  • email (String)
  • selected_fields (Array)

    the list of fields you want with it’s data

Returns:

  • (Array<Hash>)

    the list of contacts with it’s fields and data



79
80
81
# File 'lib/infusionsoft/client/contact.rb', line 79

def contact_find_by_email(email, selected_fields)
  response = xmlrpc('ContactService.findByEmail', email, selected_fields)
end

#contact_get_next_campaign_step(contact_id, campaign_id) ⇒ Integer

Returns the Id number of the next follow-up sequence step for the given contact.

Parameters:

  • contact_id (Integer)
  • campaign_id (Integer)

Returns:

  • (Integer)

    id number of the next unfishished step in the given follow up sequence for the given contact



99
100
101
# File 'lib/infusionsoft/client/contact.rb', line 99

def contact_get_next_campaign_step(contact_id, campaign_id)
  response = xmlrpc('ContactService.getNextCampaignStep', contact_id, campaign_id)
end


169
170
171
# File 'lib/infusionsoft/client/contact.rb', line 169

def contact_link_contact(remoteApp, remoteId, localId)
  response = xmlrpc('ContactService.linkContact', remoteApp, remoteId, localId)
end

#contact_load(id, selected_fields) ⇒ Array

Loads a contact from the database

Examples:

this is what you would get back

{ "FirstName" => "John", "LastName" => "Doe" }

Parameters:

  • id (Integer)
  • selected_fields (Array)

    the list of fields you want back

Returns:

  • (Array)

    the fields returned back with it’s data



69
70
71
# File 'lib/infusionsoft/client/contact.rb', line 69

def contact_load(id, selected_fields)
  response = xmlrpc('ContactService.load', id, selected_fields)
end


174
175
176
# File 'lib/infusionsoft/client/contact.rb', line 174

def contact_locate_contact_link(locate_map_id)
  response = xmlrpc('ContactService.locateContactLink', locate_map_id)
end


178
179
180
# File 'lib/infusionsoft/client/contact.rb', line 178

def contact_mark_link_updated(locate_map_id)
  response = xmlrpc('ContactService.markLinkUpdated', locate_map_id)
end

#contact_merge(contact_id, duplicate_contact_id) ⇒ Object

Merge two contacts together.

Parameters:

  • contact_id (Integer)
  • duplicate_contact_id (Integer)


25
26
27
# File 'lib/infusionsoft/client/contact.rb', line 25

def contact_merge(contact_id, duplicate_contact_id)
  response = xmlrpc('ContactService.merge', contact_id, duplicate_contact_id)
end

#contact_pause_campaign(contact_id, campaign_id) ⇒ Boolean

Pauses a follow-up sequence for the given contact record

Parameters:

  • contact_id (Integer)
  • campaign_id (Integer)

Returns:

  • (Boolean)

    returns true/false if the sequence was paused



108
109
110
# File 'lib/infusionsoft/client/contact.rb', line 108

def contact_pause_campaign(contact_id, campaign_id)
  response = xmlrpc('ContactService.pauseCampaign', contact_id, campaign_id)
end

#contact_remove_from_campaign(contact_id, campaign_id) ⇒ Boolean

Removes a follow-up sequence from a contact record

Parameters:

  • contact_id (Integer)
  • campaign_id (Integer)

Returns:

  • (Boolean)

    returns true/false if removed



117
118
119
# File 'lib/infusionsoft/client/contact.rb', line 117

def contact_remove_from_campaign(contact_id, campaign_id)
  response = xmlrpc('ContactService.removeFromCampaign', contact_id, campaign_id)
end

#contact_remove_from_group(contact_id, group_id) ⇒ Boolean

Removes a tag from a contact (groups were the original name of tags).

Parameters:

  • contact_id (Integer)
  • group_id (Integer)

Returns:

  • (Boolean)

    returns true/false if tag was removed successfully



144
145
146
# File 'lib/infusionsoft/client/contact.rb', line 144

def contact_remove_from_group(contact_id, group_id)
  response = xmlrpc('ContactService.removeFromGroup', contact_id, group_id)
end

#contact_reschedule_campaign_step(list_of_contacts, step_id) ⇒ Boolean

Immediately performs the given follow-up sequence step_id for the given contacts.

Parameters:

  • list_of_contacts (Array<Integer>)
  • ) (Integer)

    step_id

Returns:

  • (Boolean)

    returns true/false if the step was rescheduled



135
136
137
# File 'lib/infusionsoft/client/contact.rb', line 135

def contact_reschedule_campaign_step(list_of_contacts, step_id)
  response = xmlrpc('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
end

#contact_resume_campaign(contact_id, campaign_id) ⇒ Boolean

Resumes a follow-up sequence that has been stopped/paused for a given contact.

Parameters:

  • contact_id (Integer)
  • campaign_id (Ingeger)

Returns:

  • (Boolean)

    returns true/false if sequence was resumed



126
127
128
# File 'lib/infusionsoft/client/contact.rb', line 126

def contact_resume_campaign(contact_id, campaign_id)
  response = xmlrpc('ConactService.resumeCampaignForContact', contact_id, campaign_id)
end

#contact_run_action_set(contact_id, action_set_id) ⇒ Array<Hash>

Runs an action set on a given contact record

Examples:

here is a list of what you get back

[{ 'Action' => 'Create Task', 'Message' => 'task1 (Task) sent successfully', 'isError' =>
nil }]

Parameters:

  • contact_id (Integer)
  • action_set_id (Integer)

Returns:

  • (Array<Hash>)

    A list of details on each action run



165
166
167
# File 'lib/infusionsoft/client/contact.rb', line 165

def contact_run_action_set(contact_id, action_set_id)
  response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id)
end

#contact_run_action_set_with_params(contact_id, action_set_id, data) ⇒ Object

Executes an action sequence for a given contact, passing in runtime params for running affiliate signup actions, etc

Parameters:

  • contact_id (Integer)
  • action_set_id (Integer)
  • data (Hash)


202
203
204
# File 'lib/infusionsoft/client/contact.rb', line 202

def contact_run_action_set_with_params(contact_id, action_set_id, data)
  response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id, data)
end

#contact_update(contact_id, data, optin_status = nil) ⇒ Integer

Updates a contact in the database.

“Opted in” using the verviage supplied here.

Examples:

{ :FirstName => 'first_name', :StreetAddress1 => '123 N Street' }, 'New Signup'

Parameters:

  • contact_id (Integer)
  • data (Hash)

    contains the mappable contact fields and it’s data

  • (Optional) (String)

    email opt in verbiage. The contact will then be

Returns:

  • (Integer)

    the id of the contact updated



55
56
57
58
59
60
# File 'lib/infusionsoft/client/contact.rb', line 55

def contact_update(contact_id, data, optin_status=nil)
  contact_id = xmlrpc('ContactService.update', contact_id, data)
  email = data['Email'] || data[:Email]
  if optin_status && email; email_optin(email, optin_status); end
  return contact_id
end