Class: PipeRocket::Person

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

Instance Attribute Summary collapse

Class Method 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.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pipe_rocket/person.rb', line 10

def initialize(hash)
  super(hash.except(*Person.key_field_hash.keys))
  @email = hash['email'].first['value'] if hash['email']
  @phone = hash['phone'].first['value'] if hash['phone']
  @id = hash['value'] if hash['value'].present?

  assign_custom_fields(Person.key_field_hash, hash)

  org_id = hash['org_id']
  if org_id
    @organization = case org_id
      when Integer
        Pipedrive.organizations.find(org_id)
      when Hash
        Organization.new(org_id)
      else
        nil
    end
  end
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#organizationObject

Returns the value of attribute organization.



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

def organization
  @organization
end

#phoneObject

Returns the value of attribute phone.



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

def phone
  @phone
end

Class Method Details

.key_field_hashObject

Returns hash PipeRocket::Field object



6
7
8
# File 'lib/pipe_rocket/person.rb', line 6

def self.key_field_hash
  @@key_field_hash ||= Pipedrive.person_fields.key_field_hash
end