Class: RubyRedtail::Contact

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

Direct Known Subclasses

Client

Defined Under Namespace

Classes: Accounts, TagGroups

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
# 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

Instance Attribute Details

#api_hashObject

Returns the value of attribute api_hash.



9
10
11
# File 'lib/ruby-redtail/contact.rb', line 9

def api_hash
  @api_hash
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/ruby-redtail/contact.rb', line 9

def id
  @id
end

Instance Method Details

#accountsObject



35
36
37
# File 'lib/ruby-redtail/contact.rb', line 35

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

#activitiesObject



39
40
41
# File 'lib/ruby-redtail/contact.rb', line 39

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

#addressesObject



27
28
29
# File 'lib/ruby-redtail/contact.rb', line 27

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

#create_user_defined_field(params) ⇒ Object

Create User Defined Field for Contact



136
137
138
# File 'lib/ruby-redtail/contact.rb', line 136

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

#deleteObject

Delete Contact



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

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

#departmentsObject

Fetch Contact Departments



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

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

#detailsObject

Fetch Contact Details



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

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

#familyObject

Fetch Contact Family



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

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



51
52
53
# File 'lib/ruby-redtail/contact.rb', line 51

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



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

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

#fetch_masterObject



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

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

#inportant_informationObject

Fetch Contact Important Information



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

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

#membershipsObject

Fetch Contact Memberships



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

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

#notesObject



31
32
33
# File 'lib/ruby-redtail/contact.rb', line 31

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

#personal_profileObject

Fetch Contact Personal Profile



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

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

#tag_groupsObject



43
44
45
# File 'lib/ruby-redtail/contact.rb', line 43

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

#update(params) ⇒ Object

Update Contact



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

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?



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

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



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

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



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

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



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

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



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

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