class PipeRocket::Deal
Attributes
organization[RW]
person[RW]
Public Class Methods
key_field_hash()
click to toggle source
Returns hash {custom_field_key: PipeRocket::Field
object}
# File lib/pipe_rocket/deal.rb, line 9 def self.key_field_hash @@key_field_hash ||= Pipedrive.deal_fields.key_field_hash end
new(hash)
click to toggle source
Calls superclass method
# File lib/pipe_rocket/deal.rb, line 13 def initialize(hash) super(hash.except(*Deal.key_field_hash.keys)) org_id = hash['org_id'] person_id = hash['person_id'] assign_custom_fields(Deal.key_field_hash, hash) if org_id @organization = case org_id when Integer Pipedrive.organizations.find(org_id) when Hash Organization.new(org_id) else nil end end if person_id @person = case person_id when Integer Pipedrive.persons.find(person_id) when Hash Person.new(person_id) else nil end end end
Public Instance Methods
display_stage_name()
click to toggle source
Returns stage name like PipelineName:StageName
# File lib/pipe_rocket/deal.rb, line 50 def display_stage_name self.stage.display_name end
files()
click to toggle source
# File lib/pipe_rocket/deal.rb, line 54 def files mail_files = Pipedrive.deals.deal_mail_messages(self.id).inject([]) do |res, message| res + message.files end Pipedrive.deals.deal_files(self.id) + mail_files end
stage()
click to toggle source
Returns PipeRocket::Stage
object corresponding to current deal stage
# File lib/pipe_rocket/deal.rb, line 45 def stage Pipedrive.stages.find(self.stage_id) end