Class: RubyRedtail::User::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-redtail/user/contacts.rb

Constant Summary collapse

CONTACT_SEARCH_FIELDS =
['LastUpdate','Name','RecAdd','PhoneNumber','Tag_Group','FirstName','LastName','FamilyName','FamilyHead','ClientStatus','ContactType','ClientSource','TaxId']
CONTACT_SEARCH_OPERANDS =
['=','>','<','!=','Like','BeginsWith','IsEmpty']

Instance Method Summary collapse

Constructor Details

#initialize(api_hash) ⇒ Contacts

Returns a new instance of Contacts.



11
12
13
# File 'lib/ruby-redtail/user/contacts.rb', line 11

def initialize(api_hash)
  @api_hash = api_hash
end

Instance Method Details

#create(params) ⇒ Object

Create New Contact



50
51
52
# File 'lib/ruby-redtail/user/contacts.rb', line 50

def create (params)
  update(0, params)
end

#search(query, page = 1) ⇒ Object

TODO: Test this properly Search Contact by Custom Query returns a paged list of Basic Contact Information, including the ContactID, based on the specified field, operand, and field value. help.redtailtechnology.com/entries/22550401



39
40
41
42
43
44
45
46
47
# File 'lib/ruby-redtail/user/contacts.rb', line 39

def search (query, page = 1)
  body = Array.new(query.length) { {} }
  query.each_with_index do |expr, i|
    body[i]["Field"] = CONTACT_SEARCH_FIELDS.index(expr[0]).to_s
    body[i]["Operand"] = CONTACT_SEARCH_OPERANDS.index(expr[1]).to_s
    body[i]["Value"] = expr[2]
  end
  build_clients_array RubyRedtail::Query.run("contacts/search?page=#{page}", @api_hash, "POST", body)["Contacts"]
end

#search_by_letter(value, page = 1) ⇒ Object

Contact Search by Letter Fetch returns a paged list of limited Contact Information, including the ContactID, based on a partial name or a single character. *value = searched beginning letter(s) *page = pagination help.redtailtechnology.com/entries/21937828-contacts-search-contacts-search



30
31
32
# File 'lib/ruby-redtail/user/contacts.rb', line 30

def search_by_letter (value, page = 1)
  build_contacts_array RubyRedtail::Query.run("contacts/search/beginswith?value=#{value}&page=#{page}", @api_hash, "GET")["Contacts"]
end

#search_by_name(value, page = 1) ⇒ Object

Contact Search by Name Fetch returns a paged list of limited Contact Information, including the ContactID *value = searched name *page = pagination help.redtailtechnology.com/entries/21937828-contacts-search-contacts-search



20
21
22
# File 'lib/ruby-redtail/user/contacts.rb', line 20

def search_by_name (value, page = 1)
  build_contacts_array RubyRedtail::Query.run("contacts/search?value=#{value}&page=#{page}", @api_hash, "GET")["Contacts"]
end