Module: Virtuous::Client::ContactAddress

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

Overview

Contact Address data

{
  contact_id: [Integer],
  label: [String],
  address1: [String],
  address2: [String],
  city: [String],
  state: [String],
  postal: [String],
  country: [String],
  set_as_primary: [Boolean],
  start_month: [Integer],
  start_day: [Integer],
  end_month: [Integer],
  end_day: [Integer]
}

Instance Method Summary collapse

Instance Method Details

#create_contact_address(data) ⇒ Hash

Creates an address.

Examples:

client.create_contact_address(
  contact_id: 1, label: 'Home address', address1: '324 Frank Island',
  address2: 'Apt. 366', city: 'Antonioborough', state: 'Massachusetts', postal: '27516',
  country: 'USA'
)

Parameters:

  • data (Hash)

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

Returns:

  • (Hash)

    The address that has been created.



73
74
75
# File 'lib/virtuous/client/contact_address.rb', line 73

def create_contact_address(data)
  parse(post('api/ContactAddress', format(data)))
end

#get_contact_addresses(contact_id) ⇒ Array

Gets the addresses of a contact.

Examples:

client.get_contact_addresses(1)

Parameters:

  • contact_id (Integer)

    The id of the Contact.

Returns:

  • (Array)

    An array with all the addresses of a contact.



33
34
35
36
# File 'lib/virtuous/client/contact_address.rb', line 33

def get_contact_addresses(contact_id)
  response = get("api/ContactAddress/ByContact/#{contact_id}")
  response.map { |address| parse(address) }
end

#update_contact_address(id, data) ⇒ Hash

Note:

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

Updates an address.

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

Examples:

client.update_contact_address(
  1, label: 'Home address', address1: '324 Frank Island', address2: 'Apt. 366',
  city: 'Antonioborough', state: 'Massachusetts', postal: '27516', country: 'USA'
)

Parameters:

  • id (Integer)

    The id of the address to update.

  • data (Hash)

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

Returns:

  • (Hash)

    The address that has been updated.



55
56
57
# File 'lib/virtuous/client/contact_address.rb', line 55

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