Class: PipedriveJetrockets::Person

Inherits:
Entity
  • Object
show all
Defined in:
lib/pipedrive_jetrockets/person.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#assign_custom_fields, #transform_field_name

Constructor Details

#initialize(hash) ⇒ Person

Returns a new instance of Person.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pipedrive_jetrockets/person.rb', line 4

def initialize(hash)
  @@key_name_hash ||= Pipedrive.person_fields.key_field_hash
  super(hash.except(*@@key_name_hash.keys))
  @email = hash['email'].first['value'] if hash['email']
  @phone = hash['phone'].first['value'] if hash['phone']

  org_id = hash['org_id']
  if org_id
    if org_id.kind_of? Integer
      @organization = Pipedrive.organizations.find(org_id)
    else
      @organization = Organization.new(org_id)
    end
  end

  @id = hash['value'] if hash['value'].present?

  assign_custom_fields(@@key_name_hash, hash)
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/pipedrive_jetrockets/person.rb', line 3

def email
  @email
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/pipedrive_jetrockets/person.rb', line 3

def id
  @id
end

#organizationObject

Returns the value of attribute organization.



3
4
5
# File 'lib/pipedrive_jetrockets/person.rb', line 3

def organization
  @organization
end

#phoneObject

Returns the value of attribute phone.



3
4
5
# File 'lib/pipedrive_jetrockets/person.rb', line 3

def phone
  @phone
end