Class: Pipedrive::Deal

Inherits:
Base
  • Object
show all
Defined in:
lib/pipedrive/deal.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

all, authenticate, bad_response, create, destroy, #destroy, find, find_by_name, #initialize, #initialize_related_objects, new_list, resource_path, search, #update

Constructor Details

This class inherits a constructor from Pipedrive::Base

Instance Method Details

#activitiesObject


27
28
29
# File 'lib/pipedrive/deal.rb', line 27

def activities
  Activity.all(get "#{resource_path}/#{id}/activities")
end

#add_note(content) ⇒ Object


35
36
37
# File 'lib/pipedrive/deal.rb', line 35

def add_note content
  Note.create(deal_id: id, content: content)
end

#add_participant(opts = {}) ⇒ Object


13
14
15
16
# File 'lib/pipedrive/deal.rb', line 13

def add_participant(opts = {})
  res = post "#{resource_path}/#{id}/participants", :body => opts
  res.success? ? true : bad_response(res,opts)
end

#add_product(opts = {}) ⇒ Object


4
5
6
7
# File 'lib/pipedrive/deal.rb', line 4

def add_product(opts = {})
  res = post "#{resource_path}/#{id}/products", :body => opts
  res.success? ? res['data']['product_attachment_id'] : bad_response(res,opts)
end

#filesObject


31
32
33
# File 'lib/pipedrive/deal.rb', line 31

def files
  File.all(get "#{resource_path}/#{id}/files")
end

#notes(opts = {:sort_by => 'add_time', :sort_mode => 'desc'}) ⇒ Object


39
40
41
# File 'lib/pipedrive/deal.rb', line 39

def notes(opts = {:sort_by => 'add_time', :sort_mode => 'desc'})
  Note.all( get("/notes", :query => opts.merge(:deal_id => id) ) )
end

#participantsObject


18
19
20
# File 'lib/pipedrive/deal.rb', line 18

def participants
  Person.all(get "#{resource_path}/#{id}/participants")
end

#productsObject


9
10
11
# File 'lib/pipedrive/deal.rb', line 9

def products
  Product.all(get "#{resource_path}/#{id}/products")
end

#remove_product(product_attachment_id) ⇒ Object


22
23
24
25
# File 'lib/pipedrive/deal.rb', line 22

def remove_product product_attachment_id
  res = delete "#{resource_path}/#{id}/products", { :body => { :product_attachment_id => product_attachment_id } }
  res.success? ? nil : bad_response(res,product_attachment_id)
end