Module: Infusionsoft::Client::Data

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

Overview

The Data service is used to manipulate most data in Infusionsoft. It permits you to work on any available tables and has a wide range of uses.

Instance Method Summary collapse

Instance Method Details

#data_add(table, data) ⇒ Integer

Adds a record with the data provided.

Parameters:

  • table (String)

    the name of the Infusiosoft database table

  • data (Hash)

    the fields and it’s data

Returns:

  • (Integer)

    returns the id of the record added



11
12
13
# File 'lib/infusionsoft/client/data.rb', line 11

def data_add(table, data)
  response = xmlrpc('DataService.add', table, data)
end

#data_add_custom_field(field_type, name, data_type, header_id) ⇒ Object

Adds a custom field to Infusionsoft

Parameters:



96
97
98
# File 'lib/infusionsoft/client/data.rb', line 96

def data_add_custom_field(field_type, name, data_type, header_id)
  response = xmlrpc('DataService.addCustomField', field_type, name, data_type, header_id)
end

#data_authenticate_user(username, password) ⇒ Integer

Authenticate an Infusionsoft username and password(md5 hash). If the credentials match it will return back a User ID, if the credentials do not match it will send back an error message

Parameters:

  • username (String)
  • password (String)

Returns:

  • (Integer)

    id of the authenticated user



107
108
109
# File 'lib/infusionsoft/client/data.rb', line 107

def data_authenticate_user(username, password)
  response = xmlrpc('DataService.authenticateUser', username, password)
end

#data_delete(table, id) ⇒ Boolean

Deletes the record (specified by id) in the given table from the database.

Parameters:

  • table (String)
  • id (Integer)

Returns:

  • (Boolean)

    returns true/false if the record was successfully deleted



44
45
46
# File 'lib/infusionsoft/client/data.rb', line 44

def data_delete(table, id)
  response = xmlrpc('DataService.delete', table, id)
end

#data_find_by_field(table, limit, page, field_name, field_value, selected_fields) ⇒ Array<Hash>

This will locate all records in a given table that match the criteria for a given field.

Parameters:

  • table (String)
  • limit (Integer)

    how many records you would like to return (max is 1000)

  • page (Integer)

    the page of results (each page is max 1000 records)

  • field_name (String)
  • field_value (String, Integer, Date)
  • selected_fields (Array)

Returns:

  • (Array<Hash>)

    returns the array of records with a hash of the fields and values



57
58
59
60
# File 'lib/infusionsoft/client/data.rb', line 57

def data_find_by_field(table, limit, page, field_name, field_value, selected_fields)
  response = xmlrpc('DataService.findByField', table, limit, page, field_name,
                 field_value, selected_fields)
end

#data_get_app_setting(module_name, setting) ⇒ String

Note:

to find the module and option names, view the HTML field name within the Infusionsoft settings. You will see something such as name=“Contact_WebModule0optiontypes” . The portion before the underscore is the module name. “Contact” in this example. The portion after the 0 is the setting name, “optiontypes” in this example.

This method will return back the data currently configured in a user configured application setting.

Parameters:

  • module (String)
  • setting (String)

Returns:

  • (String)

    current values in given application setting



121
122
123
# File 'lib/infusionsoft/client/data.rb', line 121

def data_get_app_setting(module_name, setting)
  response = xmlrpc('DataService.getAppSetting', module_name, setting)
end

#data_get_temporary_key(vendor_key, username, password_hash) ⇒ String

Returns a temporary API key if given a valid Vendor key and user credentials.

Parameters:

  • vendor_key (String)
  • username (String)
  • password_hash (String)

    an md5 hash of users password

Returns:

  • (String)

    temporary API key



131
132
133
# File 'lib/infusionsoft/client/data.rb', line 131

def data_get_temporary_key(vendor_key, username, password_hash)
  response = xmlrpc('DataService.getTemporaryKey', username, password_hash)
end

#data_load(table, id, selected_fields) ⇒ Hash

This method will load a record from the database given the primary key.

Examples:

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

Parameters:

  • table (String)
  • id (Integer)
  • selected_fields (Array)

Returns:

  • (Hash)

    the field names and their data



23
24
25
# File 'lib/infusionsoft/client/data.rb', line 23

def data_load(table, id, selected_fields)
  response = xmlrpc('DataService.load', table, id, selected_fields)
end

#data_query(table, limit, page, data, selected_fields) ⇒ Array<Hash>

Queries records in a given table to find matches on certain fields.

Parameters:

  • table (String)
  • limit (Integer)
  • page (Integer)
  • data (Hash)

    the data you would like to query on. { :FirstName => ‘first_name’ }

  • selected_fields (Array)

    the fields and values you want back

Returns:

  • (Array<Hash>)

    the fields and associated values



70
71
72
# File 'lib/infusionsoft/client/data.rb', line 70

def data_query(table, limit, page, data, selected_fields)
  response = xmlrpc('DataService.query', table, limit, page, data, selected_fields)
end

#data_query_order_by(table, limit, page, data, selected_fields, by, ascending) ⇒ Array<Hash>

Queries records in a given table to find matches on certain fields.

Parameters:

  • table (String)
  • limit (Integer)
  • page (Integer)
  • data (Hash)

    the data you would like to query on. { :FirstName => ‘first_name’ }

  • selected_fields (Array)

    the fields and values you want back

  • field (String)

    by which to order the output results

  • true (Boolean)

    ascending, false descending

Returns:

  • (Array<Hash>)

    the fields and associated values



84
85
86
# File 'lib/infusionsoft/client/data.rb', line 84

def data_query_order_by(table, limit, page, data, selected_fields, by, ascending)
  response = xmlrpc('DataService.query', table, limit, page, data, selected_fields, by, ascending)
end

#data_update(table, id, data) ⇒ Integer

Updates the specified record (indicated by ID) with the data provided.

Examples:

{ :FirstName => 'John', :Email => '[email protected]' }

Parameters:

  • table (String)
  • id (Integer)
  • data (Hash)

    this is the fields and values you would like to update

Returns:

  • (Integer)

    id of the record updated



35
36
37
# File 'lib/infusionsoft/client/data.rb', line 35

def data_update(table, id, data)
  response = xmlrpc('DataService.update', table, id, data)
end

#data_update_custom_field(field_id, field_values) ⇒ Boolean

Updates a custom field. Every field can have it’s display name and group id changed, but only certain data types will allow you to change values(dropdown, listbox, radio, etc).

Parameters:

  • field_id (Integer)
  • field_values (Hash)

Returns:

  • (Boolean)

    returns true/false if it was updated



141
142
143
# File 'lib/infusionsoft/client/data.rb', line 141

def data_update_custom_field(field_id, field_values)
  response = xmlrpc('DataService.updateCustomField', field_id, field_values)
end