Module: Infusionsoft::Client::Contact

Included in:
Infusionsoft::Client
Defined in:
lib/infusion-api/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) ⇒ Integer

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

Examples:

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

Parameters:

  • data (Hash)

    contains the mappable contact fields and it’s data

Returns:

  • (Integer)

    the id of the newly added contact



12
13
14
15
16
# File 'lib/infusion-api/client/contact.rb', line 12

def contact_add(data)
  contact_id = get('ContactService.add', data)
  if data.has_key?("Email"); email_optin(data["Email"], "requested information"); 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)


169
170
171
172
173
# File 'lib/infusion-api/client/contact.rb', line 169

def contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, ,
                                credit_card_id, affiliate_id, days_till_charge)
  response = get('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



68
69
70
# File 'lib/infusion-api/client/contact.rb', line 68

def contact_add_to_campaign(contact_id, campaign_id)
  response = get('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



132
133
134
# File 'lib/infusion-api/client/contact.rb', line 132

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

#contact_add_with_dup_check(data, check_type) ⇒ Integer

Adds or updates a contact record based on matching data

Parameters:

  • data (Array<Hash>)

    the contact data you want added

  • check_type (String)

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

Returns:

  • (Integer)

    id of the contact added or updated



24
25
26
# File 'lib/infusion-api/client/contact.rb', line 24

def contact_add_with_dup_check(data, check_type)
  response = get('ContactService.addWithDupCheck', data, check_type)
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



58
59
60
# File 'lib/infusion-api/client/contact.rb', line 58

def contact_find_by_email(email, selected_fields)
  response = get('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



78
79
80
# File 'lib/infusion-api/client/contact.rb', line 78

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


148
149
150
# File 'lib/infusion-api/client/contact.rb', line 148

def contact_link_contact(remoteApp, remoteId, localId)
  response = get('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



48
49
50
# File 'lib/infusion-api/client/contact.rb', line 48

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


153
154
155
# File 'lib/infusion-api/client/contact.rb', line 153

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


157
158
159
# File 'lib/infusion-api/client/contact.rb', line 157

def contact_mark_link_updated(locate_map_id)
  response = get('ContactService.markLinkUpdated', locate_map_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



87
88
89
# File 'lib/infusion-api/client/contact.rb', line 87

def contact_pause_campaign(contact_id, campaign_id)
  response = get('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



96
97
98
# File 'lib/infusion-api/client/contact.rb', line 96

def contact_remove_from_campaign(contact_id, campaign_id)
  response = get('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



123
124
125
# File 'lib/infusion-api/client/contact.rb', line 123

def contact_remove_from_group(contact_id, group_id)
  response = get('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



114
115
116
# File 'lib/infusion-api/client/contact.rb', line 114

def contact_reschedule_campaign_step(list_of_contacts, step_id)
  response = get('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



105
106
107
# File 'lib/infusion-api/client/contact.rb', line 105

def contact_resume_campaign(contact_id, campaign_id)
  response = get('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



144
145
146
# File 'lib/infusion-api/client/contact.rb', line 144

def contact_run_action_set(contact_id, action_set_id)
  response = get('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)


181
182
183
# File 'lib/infusion-api/client/contact.rb', line 181

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

#contact_update(contact_id, data) ⇒ Integer

Updates a contact in the database.

Examples:

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

Parameters:

  • contact_id (Integer)
  • data (Hash)

    contains the mappable contact fields and it’s data

Returns:

  • (Integer)

    the id of the contact updated



35
36
37
38
39
# File 'lib/infusion-api/client/contact.rb', line 35

def contact_update(contact_id, data)
  bool = get('ContactService.update', contact_id, data)
  if data.has_key?("Email"); email_optin(data["Email"], "requested information"); end
  return bool
end