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, find, find_by_name, #initialize, new_list, resource_path, #update

Constructor Details

This class inherits a constructor from Pipedrive::Base

Instance Method Details

#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)
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



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

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)
end