Class: AdvisorsCommandClient::Models::Contact

Inherits:
Base
  • Object
show all
Defined in:
lib/advisors_command_client/models/contact.rb

Instance Method Summary collapse

Methods inherited from Base

deep_underscore_params, #initialize, load

Constructor Details

This class inherits a constructor from AdvisorsCommandClient::Models::Base

Instance Method Details

#accountsObject



28
29
30
31
32
33
34
35
# File 'lib/advisors_command_client/models/contact.rb', line 28

def accounts
  @accounts ||= @original_hash['accounts'].map do |id|
    resp = @connection.get("accounts/#{id}")
    if resp.success?
      AdvisorsCommandClient::Models::Account.load(resp.body)
    end
  end
end

#as_jsonObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/advisors_command_client/models/contact.rb', line 37

def as_json
  json_attrs = attributes.dup
  json_attrs.delete(:nickname)
  json_attrs.delete(:employer)
  json_attrs.delete(:email)
  json_attrs.delete(:id)
  json_attrs.delete(:created_at)
  json_attrs.delete(:updated_at)

  json_attrs[:addresses] = addresses.map {|address| address.as_json }

  json_attrs.to_camelback_keys
end

#full_nameObject



24
25
26
# File 'lib/advisors_command_client/models/contact.rb', line 24

def full_name
  [name_prefix, first_name, middle_name, last_name, name_suffix].reject(&:nil?).join(' ')
end