class PipedriveApi::Stage
name: Stage
name (String) pipeline_id: ID of the pipeline to add stage to (Integer) deal_probability: Deal
success probability percentage. Used/shown when deal weighted values are used (Integer) rotten_flag: Whether deals in this stage can become rotten (Enumerator 0, 1) rotten_days: Number of days the deals not updated in this stage would become rotten. Applies only if rotten_flag is set (Integer)
Public Class Methods
new(opts = {})
click to toggle source
# File lib/pipedrive_api/stage.rb, line 9 def initialize(opts = {}) set_values(attrs.merge(opts)) @connection = Faraday.new("https://#{PipedriveApi.config.domain}.#{BASE_URL}#{PipedriveApi.config.version}/") @connection.headers = PipedriveApi.config.headers @connection.params = PipedriveApi.config.params end
Public Instance Methods
all()
click to toggle source
# File lib/pipedrive_api/stage.rb, line 20 def all response = @connection.get 'stages' JSON.parse response.body end
attrs()
click to toggle source
# File lib/pipedrive_api/stage.rb, line 16 def attrs { name: '', pipeline_id: 0, deal_probability: 0, rotten_flag: 0, rotten_days: 0 } end
create(opts = {})
click to toggle source
# File lib/pipedrive_api/stage.rb, line 31 def create(opts = {}) raise 'You must provide an stage name' if opts[:name].nil? || opts[:name] == '' raise 'You must provide an stage pipeline_id' if opts[:pipeline_id].nil? || opts[:pipeline_id] == '' response = @connection.post 'stages', opts JSON.parse response.body end
delete(id)
click to toggle source
# File lib/pipedrive_api/stage.rb, line 45 def delete(id) raise 'You must pass an ID' if id.nil? || id == '' response = @connection.delete "stages/#{id}" JSON.parse response.body end
details(id)
click to toggle source
# File lib/pipedrive_api/stage.rb, line 25 def details(id) raise 'You must provide an ID' if id.nil? || id == '' response = @connection.get "stages/#{id}" JSON.parse response.body end
update(opts = {})
click to toggle source
# File lib/pipedrive_api/stage.rb, line 38 def update(opts = {}) raise 'You must provide an stage name' if opts[:name].nil? || opts[:name] == '' raise 'You must provide an stage pipeline_id' if opts[:pipeline_id].nil? || opts[:pipeline_id] == '' response = @connection.put "stages/#{opts[:id]}", opts JSON.parse response.body end