Class: RubyRedtail::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-redtail/contact.rb,
lib/ruby-redtail/contact/accounts.rb

Direct Known Subclasses

Client

Defined Under Namespace

Classes: Accounts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contact = {}, api_hash) ⇒ Contact

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby-redtail/contact.rb', line 6

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

Instance Attribute Details

#api_hashObject

Returns the value of attribute api_hash.



3
4
5
# File 'lib/ruby-redtail/contact.rb', line 3

def api_hash
  @api_hash
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/ruby-redtail/contact.rb', line 3

def id
  @id
end

Instance Method Details

#accountsObject



29
30
31
# File 'lib/ruby-redtail/contact.rb', line 29

def accounts
  RubyRedtail::Contact::Accounts.new self.api_hash
end

#activitiesObject



33
34
35
# File 'lib/ruby-redtail/contact.rb', line 33

def activities
  RubyRedtail::Contact::Activities.new self.api_hash
end

#addressesObject



21
22
23
# File 'lib/ruby-redtail/contact.rb', line 21

def addresses
  RubyRedtail::Contact::Addresses.new self.api_hash
end

#create_user_defined_field(params) ⇒ Object

Create User Defined Field for Contact



130
131
132
# File 'lib/ruby-redtail/contact.rb', line 130

def create_user_defined_field (params)
  update_user_defined_field(self.id, 0, params)
end

#deleteObject

Delete Contact



69
70
71
# File 'lib/ruby-redtail/contact.rb', line 69

def delete
  RubyRedtail::Query.run("contacts/#{self.id}", @api_hash, 'DELETE')['Status'] == 0
end

#departmentsObject

Fetch Contact Departments



115
116
117
# File 'lib/ruby-redtail/contact.rb', line 115

def departments
  RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, "GET")
end

#detailsObject

Fetch Contact Details



74
75
76
# File 'lib/ruby-redtail/contact.rb', line 74

def details
  RubyRedtail::Query.run("contacts/#{self.id}/details", @api_hash, "GET")
end

#familyObject

Fetch Contact Family



85
86
87
# File 'lib/ruby-redtail/contact.rb', line 85

def family
  RubyRedtail::Query.run("contacts/#{self.id}/family", @api_hash, "GET")
end

#fetch(recent = false, basic = false) ⇒ Object

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

  • 0 does nothing

  • 1 updates recently viewed



45
46
47
# File 'lib/ruby-redtail/contact.rb', line 45

def fetch (recent = false, basic = false)
  RubyRedtail::Query.run("contacts/#{self.id}?recent=#{recent ? 1 : 0}", @api_hash, "GET")
end

#fetch_basic(recent = false, basic = false) ⇒ Object

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

  • 0 does nothing

  • 1 updates recently viewed



53
54
55
# File 'lib/ruby-redtail/contact.rb', line 53

def fetch_basic (recent = false, basic = false)
  RubyRedtail::Query.run("contacts/#{self.id}/basic?recent=#{recent ? 1 : 0}", @api_hash, "GET")
end

#fetch_masterObject



59
60
61
# File 'lib/ruby-redtail/contact.rb', line 59

def fetch_master
  RubyRedtail::Query.run("contacts/#{self.id}/master", @api_hash, 'GET')
end

#inportant_informationObject

Fetch Contact Important Information



105
106
107
# File 'lib/ruby-redtail/contact.rb', line 105

def inportant_information
  RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, "GET")
end

#membershipsObject

Fetch Contact Memberships



90
91
92
# File 'lib/ruby-redtail/contact.rb', line 90

def memberships
  RubyRedtail::Query.run("contacts/#{self.id}/memberships", @api_hash, "GET")
end

#notesObject



25
26
27
# File 'lib/ruby-redtail/contact.rb', line 25

def notes
  RubyRedtail::Contact::Notes.new self.api_hash
end

#personal_profileObject

Fetch Contact Personal Profile



95
96
97
# File 'lib/ruby-redtail/contact.rb', line 95

def personal_profile
  RubyRedtail::Query.run("contacts/#{self.id}/personalprofile", @api_hash, "GET")
end

#tag_groupsObject



37
38
39
# File 'lib/ruby-redtail/contact.rb', line 37

def tag_groups
  RubyRedtail::Contact::TagGroups.new self.api_hash
end

#update(params) ⇒ Object

Update Contact



64
65
66
# File 'lib/ruby-redtail/contact.rb', line 64

def update (params)
  RubyRedtail::Query.run("contacts/#{self.id}", @api_hash, 'PUT', params)
end

#update_details(params) ⇒ Object

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



80
81
82
# File 'lib/ruby-redtail/contact.rb', line 80

def update_details (params)
  RubyRedtail::Query.run("contacts/#{self.id}/details", @api_hash, 'PUT', params)
end

#update_important_information(params) ⇒ Object

Update Contact Important Information



110
111
112
# File 'lib/ruby-redtail/contact.rb', line 110

def update_important_information (params)
  RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, 'PUT', params)
end

#update_personal_profile(personal_profile_id, params) ⇒ Object

Update Contact Personal Profile



100
101
102
# File 'lib/ruby-redtail/contact.rb', line 100

def update_personal_profile (personal_profile_id, params)
  RubyRedtail::Query.run("contacts/#{self.id}/personalprofile/#{personal_profile_id}", @api_hash, 'PUT', params)
end

#update_user_defined_field(udf_id, params) ⇒ Object

Update User Defined Field for Contact



125
126
127
# File 'lib/ruby-redtail/contact.rb', line 125

def update_user_defined_field (udf_id, params)
  RubyRedtail::Query.run("contacts/#{self.id}/udf/#{udf_id}", @api_hash, 'PUT', params)
end

#user_defined_fieldsObject

Fetch User Defined Fields for Contact



120
121
122
# File 'lib/ruby-redtail/contact.rb', line 120

def user_defined_fields
  RubyRedtail::Query.run("contacts/#{self.id}/udf", @api_hash, "GET")
end