class RubyRedtail::Contact

Attributes

api_hash[RW]
id[RW]

Public Class Methods

new(contact = {}, api_hash) click to toggle source

help.redtailtechnology.com/entries/21654562-authentication-methods

# File lib/ruby-redtail/contact.rb, line 12
def initialize(contact = {}, api_hash)
  @api_hash = api_hash
  
  raise ArgumentError unless contact['ContactID']
  @id = contact['ContactID']
  
  raise ArgumentError if contact.class != Hash
  contact.each do |key, value|
    key = key.underscore
    self.class.send :attr_accessor, key
    instance_variable_set "@#{key}", value
  end
end

Public Instance Methods

create_user_defined_field(params) click to toggle source

Create User Defined Field for Contact

# File lib/ruby-redtail/contact.rb, line 136
def create_user_defined_field (params)
  update_user_defined_field(@id, 0, params)
end
delete() click to toggle source

Delete Contact

# File lib/ruby-redtail/contact.rb, line 75
def delete
  RubyRedtail::Query.run("contacts/#{@id}", @api_hash, 'DELETE')['Status'] == 0
end
departments() click to toggle source

Fetch Contact Departments

# File lib/ruby-redtail/contact.rb, line 121
def departments
  RubyRedtail::Query.run("contacts/#{@id}/importantinfo", @api_hash, "GET")
end
details() click to toggle source

Fetch Contact Details

# File lib/ruby-redtail/contact.rb, line 80
def details
  RubyRedtail::Query.run("contacts/#{@id}/details", @api_hash, "GET")
end
family() click to toggle source

Fetch Contact Family

# File lib/ruby-redtail/contact.rb, line 91
def family
  RubyRedtail::Query.run("contacts/#{@id}/family", @api_hash, "GET")
end
fetch(recent = false, basic = false) click to toggle source

Fetch Contact By Contact Id Optional parameter: ?recent={recent}*

  • {0} does nothing

  • {1} updates recently viewed

# File lib/ruby-redtail/contact.rb, line 51
def fetch (recent = false, basic = false)
  RubyRedtail::Query.run("contacts/#{@id}?recent=#{recent ? 1 : 0}", @api_hash, "GET")
end
fetch_basic(recent = false, basic = false) click to toggle source

Fetch Basic Contact By Contact Id Optional parameter: ?recent={recent}*

  • {0} does nothing

  • {1} updates recently viewed

# File lib/ruby-redtail/contact.rb, line 59
def fetch_basic (recent = false, basic = false)
  RubyRedtail::Query.run("contacts/#{@id}/basic?recent=#{recent ? 1 : 0}", @api_hash, "GET")
end
fetch_master() click to toggle source

Master Fetch Contact help.redtailtechnology.com/entries/22846682-master-fetch-contacts-contactid-master

# File lib/ruby-redtail/contact.rb, line 65
def fetch_master
  RubyRedtail::Query.run("contacts/#{@id}/master", @api_hash, 'GET')
end
inportant_information() click to toggle source

Fetch Contact Important Information

# File lib/ruby-redtail/contact.rb, line 111
def inportant_information
  RubyRedtail::Query.run("contacts/#{@id}/importantinfo", @api_hash, "GET")
end
memberships() click to toggle source

Fetch Contact Memberships

# File lib/ruby-redtail/contact.rb, line 96
def memberships
  RubyRedtail::Query.run("contacts/#{@id}/memberships", @api_hash, "GET")
end
personal_profile() click to toggle source

Fetch Contact Personal Profile

# File lib/ruby-redtail/contact.rb, line 101
def personal_profile
  RubyRedtail::Query.run("contacts/#{@id}/personalprofile", @api_hash, "GET")
end
tag_groups() click to toggle source

def addresses

RubyRedtail::Contact::Addresses.new @api_hash

end

def notes

RubyRedtail::Contact::Notes.new @api_hash

end

def accounts

RubyRedtail::Contact::Accounts.new @api_hash

end

def activities

RubyRedtail::Contact::Activities.new @api_hash

end

# File lib/ruby-redtail/contact.rb, line 43
def tag_groups
  build_tag_groups_array RubyRedtail::Query.run("contacts/#{@contact_id}/taggroups", @api_hash, "GET")
end
update(params) click to toggle source

Update Contact

# File lib/ruby-redtail/contact.rb, line 70
def update (params)
  RubyRedtail::Query.run("contacts/#{@id}", @api_hash, 'PUT', params)
end
update_details(params) click to toggle source

Update Contact Details Is this required? (Deprecated on API website). Ask Client?

# File lib/ruby-redtail/contact.rb, line 86
def update_details (params)
  RubyRedtail::Query.run("contacts/#{@id}/details", @api_hash, 'PUT', params)
end
update_important_information(params) click to toggle source

Update Contact Important Information

# File lib/ruby-redtail/contact.rb, line 116
def update_important_information (params)
  RubyRedtail::Query.run("contacts/#{@id}/importantinfo", @api_hash, 'PUT', params)
end
update_personal_profile(personal_profile_id, params) click to toggle source

Update Contact Personal Profile

# File lib/ruby-redtail/contact.rb, line 106
def update_personal_profile (personal_profile_id, params)
  RubyRedtail::Query.run("contacts/#{@id}/personalprofile/#{personal_profile_id}", @api_hash, 'PUT', params)
end
update_user_defined_field(udf_id, params) click to toggle source

Update User Defined Field for Contact

# File lib/ruby-redtail/contact.rb, line 131
def update_user_defined_field (udf_id, params)
  RubyRedtail::Query.run("contacts/#{@id}/udf/#{udf_id}", @api_hash, 'PUT', params)
end
user_defined_fields() click to toggle source

Fetch User Defined Fields for Contact

# File lib/ruby-redtail/contact.rb, line 126
def user_defined_fields
  RubyRedtail::Query.run("contacts/#{@id}/udf", @api_hash, "GET")
end

Private Instance Methods

build_tag_group(tag_group_hash) click to toggle source
# File lib/ruby-redtail/contact.rb, line 142
def build_tag_group tag_group_hash
  if tag_group_hash
    RubyRedtail::TagGroup.new(tag_group_hash,@api_hash)
  else
    raise RubyRedtail::AuthenticationError
  end
end
build_tag_groups_array(tag_group_hashes) click to toggle source
# File lib/ruby-redtail/contact.rb, line 150
def build_tag_groups_array tag_group_hashes
  if tag_group_hashes
    tag_group_hashes.collect { |tag_group_hash| build_tag_group tag_group_hash }
  else
    raise RubyRedtail::AuthenticationError
  end
end