Module: Virtuous::Client::Individual

Included in:
Virtuous::Client
Defined in:
lib/virtuous/client/individual.rb

Overview

Individual data

{
  contact_id: [Integer],
  first_name: [String],
  last_name: [String],
  contact_methods: [
    {
      type: [String],
      value: [String],
      is_opted_in: [Boolean],
      is_primary: [Boolean]
    }
  ],
  prefix: [String],
  middle_name: [String],
  suffix: [String],
  gender: [String],
  set_as_primary: [Boolean],
  set_as_secondary: [Boolean],
  birth_month: [Integer],
  birth_day: [Integer],
  birth_year: [Integer],
  approximate_age: [Integer],
  is_deceased: [Boolean],
  deceased_date: [Date],
  passion: [String],
  avatar_url: [String],
  custom_fields: [
    {
      name: [String],
      value: [String],
      display_name: [String]
    }
  ],
  custom_collections: [
    {
      name: [String],
      fields: [
        {
          name: [String],
          value: [String]
        }
      ]
    }
  ]
}

Instance Method Summary collapse

Instance Method Details

#create_individual(data) ⇒ Hash

Creates an individual.

Examples:

client.create_individual(first_name: 'John', last_name: 'Doe', contact_id: 1)

Parameters:

  • data (Hash)

    A hash containing the individual details. Refer to the Individual data section above to see the available attributes.

Returns:

  • (Hash)

    The individual that has been created.



90
91
92
# File 'lib/virtuous/client/individual.rb', line 90

def create_individual(data)
  parse(post('api/ContactIndividual', format(data)))
end

#delete_individual(id) ⇒ Object

Delete an individual.

Examples:

client.delete_individual(1)

Parameters:

  • id (Integer)

    The id of the individual to delete.



120
121
122
# File 'lib/virtuous/client/individual.rb', line 120

def delete_individual(id)
  delete("api/ContactIndividual/#{id}")
end

#find_individual_by_email(email) ⇒ Hash

Fetches an individual record by email.

Examples:

client.find_individual_by_email('[email protected]')

Parameters:

  • email (String)

    The email of the individual.

Returns:

  • (Hash)

    The individual information in a hash.



62
63
64
# File 'lib/virtuous/client/individual.rb', line 62

def find_individual_by_email(email)
  parse(get('api/ContactIndividual/Find', { email: email }))
end

#get_individual(id) ⇒ Hash

Fetches an individual record by id.

Examples:

client.get_individual(1)

Parameters:

  • id (Integer)

    The id of the individual.

Returns:

  • (Hash)

    The individual information in a hash.



75
76
77
# File 'lib/virtuous/client/individual.rb', line 75

def get_individual(id)
  parse(get("api/ContactIndividual/#{id}"))
end

#update_individual(id, data) ⇒ Hash

Note:

Excluding a property will remove it's value from the object.

Updates an individual.

If you're only updating a single property, the entire model is still required.

Examples:

client.update_individual(1, first_name: 'New', last_name: 'Name')

Parameters:

  • id (Integer)

    The id of the individual to update.

  • data (Hash)

    A hash containing the individual details. Refer to the Individual data section above to see the available attributes.

Returns:

  • (Hash)

    The individual that has been updated.



109
110
111
# File 'lib/virtuous/client/individual.rb', line 109

def update_individual(id, data)
  parse(put("api/ContactIndividual/#{id}", format(data)))
end