Class: PipedriveJetrockets::Deal

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#assign_custom_fields, #transform_field_name

Constructor Details

#initialize(hash) ⇒ Deal

Returns a new instance of Deal.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pipedrive_jetrockets/deal.rb', line 7

def initialize(hash)
  @@key_name_hash ||= Pipedrive.deal_fields.key_field_hash
  super(hash.except(*@@key_name_hash.keys))

  org_id = hash['org_id']
  person_id = hash['person_id']

  assign_custom_fields(@@key_name_hash, hash)

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

  if person_id
    if person_id.kind_of? Integer
      @person = Pipedrive.persons.find(person_id)
    else
      @person = Person.new(person_id)
    end
  end
end

Instance Attribute Details

#organizationObject

Returns the value of attribute organization.



6
7
8
# File 'lib/pipedrive_jetrockets/deal.rb', line 6

def organization
  @organization
end

#personObject

Returns the value of attribute person.



6
7
8
# File 'lib/pipedrive_jetrockets/deal.rb', line 6

def person
  @person
end

Instance Method Details

#display_stage_nameObject



37
38
39
# File 'lib/pipedrive_jetrockets/deal.rb', line 37

def display_stage_name
  self.stage.display_name
end

#stageObject



33
34
35
# File 'lib/pipedrive_jetrockets/deal.rb', line 33

def stage
  Pipedrive.stages.find(self.stage_id)
end