class Pipedrive::GoalsApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/pipedrive-openapi-client/api/goals_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

goals_find_get(opts = {}) click to toggle source

Find goals Returns data about goals based on criteria. For searching, append `{searchField}={searchValue}` to the URL, where `searchField` can be any one of the lowest-level fields in dot-notation (e.g. `type.params.pipeline_id`; `title`). `searchValue` should be the value you are looking for on that field. Additionally, `is_active=<true|false>` can be provided to search for only active/inactive goals. When providing `period.start`, `period.end` must also be provided and vice versa. @param [Hash] opts the optional parameters @option opts [String] :type_name Type of the goal. If provided, everyone&#39;s goals will be returned. @option opts [String] :title Title of the goal. @option opts [Boolean] :is_active Whether goal is active or not. (default to true) @option opts [Integer] :assignee_id ID of the user who&#39;s goal to fetch. When omitted, only your goals will be returned. @option opts [String] :assignee_type Type of the goal&#39;s assignee. If provided, everyone&#39;s goals will be returned. @option opts [Float] :expected_outcome_target Numeric value of the outcome. If provided, everyone&#39;s goals will be returned. @option opts [String] :expected_outcome_tracking_metric Tracking metric of the expected outcome of the goal. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :expected_outcome_currency_id Numeric ID of the goal&#39;s currency. Only applicable to goals with &#x60;expected_outcome.tracking_metric&#x60; with value &#x60;sum&#x60;. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_pipeline_id ID of the pipeline or &#x60;null&#x60; for all pipelines. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_stage_id ID of the stage. Applicable to only &#x60;deals_progressed&#x60; type of goals. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_activity_type_id ID of the activity type. Applicable to only &#x60;activities_completed&#x60; or &#x60;activities_added&#x60; types of goals. If provided, everyone&#39;s goals will be returned. @option opts [Date] :period_start Start date of the period for which to find goals. Date in format of YYYY-MM-DD. When &#x60;period.start&#x60; is provided, &#x60;period.end&#x60; must be provided too. @option opts [Date] :period_end End date of the period for which to find goals. Date in format of YYYY-MM-DD. @return [nil]

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 39
def goals_find_get(opts = {})
  goals_find_get_with_http_info(opts)
  nil
end
goals_find_get_with_http_info(opts = {}) click to toggle source

Find goals Returns data about goals based on criteria. For searching, append &#x60;{searchField}&#x3D;{searchValue}&#x60; to the URL, where &#x60;searchField&#x60; can be any one of the lowest-level fields in dot-notation (e.g. &#x60;type.params.pipeline_id&#x60;; &#x60;title&#x60;). &#x60;searchValue&#x60; should be the value you are looking for on that field. Additionally, &#x60;is_active&#x3D;&lt;true|false&gt;&#x60; can be provided to search for only active/inactive goals. When providing &#x60;period.start&#x60;, &#x60;period.end&#x60; must also be provided and vice versa. @param [Hash] opts the optional parameters @option opts [String] :type_name Type of the goal. If provided, everyone&#39;s goals will be returned. @option opts [String] :title Title of the goal. @option opts [Boolean] :is_active Whether goal is active or not. @option opts [Integer] :assignee_id ID of the user who&#39;s goal to fetch. When omitted, only your goals will be returned. @option opts [String] :assignee_type Type of the goal&#39;s assignee. If provided, everyone&#39;s goals will be returned. @option opts [Float] :expected_outcome_target Numeric value of the outcome. If provided, everyone&#39;s goals will be returned. @option opts [String] :expected_outcome_tracking_metric Tracking metric of the expected outcome of the goal. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :expected_outcome_currency_id Numeric ID of the goal&#39;s currency. Only applicable to goals with &#x60;expected_outcome.tracking_metric&#x60; with value &#x60;sum&#x60;. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_pipeline_id ID of the pipeline or &#x60;null&#x60; for all pipelines. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_stage_id ID of the stage. Applicable to only &#x60;deals_progressed&#x60; type of goals. If provided, everyone&#39;s goals will be returned. @option opts [Integer] :type_params_activity_type_id ID of the activity type. Applicable to only &#x60;activities_completed&#x60; or &#x60;activities_added&#x60; types of goals. If provided, everyone&#39;s goals will be returned. @option opts [Date] :period_start Start date of the period for which to find goals. Date in format of YYYY-MM-DD. When &#x60;period.start&#x60; is provided, &#x60;period.end&#x60; must be provided too. @option opts [Date] :period_end End date of the period for which to find goals. Date in format of YYYY-MM-DD. @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 61
def goals_find_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GoalsApi.goals_find_get ...'
  end
  allowable_values = ["deals_won", "deals_progressed", "activities_completed", "activities_added", "deals_started"]
  if @api_client.config.client_side_validation && opts[:'type_name'] && !allowable_values.include?(opts[:'type_name'])
    fail ArgumentError, "invalid value for \"type_name\", must be one of #{allowable_values}"
  end
  allowable_values = ["true", "false"]
  if @api_client.config.client_side_validation && opts[:'is_active'] && !allowable_values.include?(opts[:'is_active'])
    fail ArgumentError, "invalid value for \"is_active\", must be one of #{allowable_values}"
  end
  allowable_values = ["person", "company", "team"]
  if @api_client.config.client_side_validation && opts[:'assignee_type'] && !allowable_values.include?(opts[:'assignee_type'])
    fail ArgumentError, "invalid value for \"assignee_type\", must be one of #{allowable_values}"
  end
  allowable_values = ["quantity", "sum"]
  if @api_client.config.client_side_validation && opts[:'expected_outcome_tracking_metric'] && !allowable_values.include?(opts[:'expected_outcome_tracking_metric'])
    fail ArgumentError, "invalid value for \"expected_outcome_tracking_metric\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/goals/find'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'type.name'] = opts[:'type_name'] if !opts[:'type_name'].nil?
  query_params[:'title'] = opts[:'title'] if !opts[:'title'].nil?
  query_params[:'is_active'] = opts[:'is_active'] if !opts[:'is_active'].nil?
  query_params[:'assignee.id'] = opts[:'assignee_id'] if !opts[:'assignee_id'].nil?
  query_params[:'assignee.type'] = opts[:'assignee_type'] if !opts[:'assignee_type'].nil?
  query_params[:'expected_outcome.target'] = opts[:'expected_outcome_target'] if !opts[:'expected_outcome_target'].nil?
  query_params[:'expected_outcome.tracking_metric'] = opts[:'expected_outcome_tracking_metric'] if !opts[:'expected_outcome_tracking_metric'].nil?
  query_params[:'expected_outcome.currency_id'] = opts[:'expected_outcome_currency_id'] if !opts[:'expected_outcome_currency_id'].nil?
  query_params[:'type.params.pipeline_id'] = opts[:'type_params_pipeline_id'] if !opts[:'type_params_pipeline_id'].nil?
  query_params[:'type.params.stage_id'] = opts[:'type_params_stage_id'] if !opts[:'type_params_stage_id'].nil?
  query_params[:'type.params.activity_type_id'] = opts[:'type_params_activity_type_id'] if !opts[:'type_params_activity_type_id'].nil?
  query_params[:'period.start'] = opts[:'period_start'] if !opts[:'period_start'].nil?
  query_params[:'period.end'] = opts[:'period_end'] if !opts[:'period_end'].nil?

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: GoalsApi#goals_find_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
goals_id_delete(id, opts = {}) click to toggle source

Delete existing goal Marks goal as deleted. @param id [String] ID of the goal to be deleted. @param [Hash] opts the optional parameters @return [nil]

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 136
def goals_id_delete(id, opts = {})
  goals_id_delete_with_http_info(id, opts)
  nil
end
goals_id_delete_with_http_info(id, opts = {}) click to toggle source

Delete existing goal Marks goal as deleted. @param id [String] ID of the goal to be deleted. @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 146
def goals_id_delete_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GoalsApi.goals_id_delete ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling GoalsApi.goals_id_delete"
  end
  # resource path
  local_var_path = '/goals/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: GoalsApi#goals_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
goals_id_put(id, opts = {}) click to toggle source

Update existing goal Updates existing goal. @param id [String] ID of the goal to be updated. @param [Hash] opts the optional parameters @option opts [String] :title Title of the goal. @option opts [Object] :assignee Who is this goal assigned to. It requires the following JSON structure: { \&quot;id\&quot;: \&quot;1\&quot;, \&quot;type\&quot;: \&quot;person\&quot; }. &#x60;type&#x60; can be either &#x60;person&#x60;, &#x60;company&#x60; or &#x60;team&#x60;. ID of the assignee person, company or team. @option opts [Object] :type Type of the goal. It requires the following JSON structure: { \&quot;name\&quot;: \&quot;deals_started\&quot;, \&quot;params\&quot;: { \&quot;pipeline_id\&quot;: 1 } }. Type can be one of: &#x60;deals_won&#x60;,&#x60;deals_progressed&#x60;,&#x60;activities_completed&#x60;,&#x60;activities_added&#x60; or &#x60;deals_started&#x60;. &#x60;params&#x60; can include &#x60;pipeline_id&#x60;, &#x60;stage_id&#x60; or &#x60;activity_type_id&#x60;. &#x60;stage_id&#x60; is related to only &#x60;deals_progressed&#x60; type of goals and &#x60;activity_type_id&#x60; to &#x60;activities_completed&#x60; or &#x60;activities_added&#x60; types of goals. To track goal in all pipelines set &#x60;pipeline_id&#x60; as &#x60;null&#x60;. @option opts [Object] :expected_outcome Expected outcome of the goal. Expected outcome can be tracked either by &#x60;quantity&#x60; or by &#x60;sum&#x60;. It requires the following JSON structure: { \&quot;target\&quot;: \&quot;50\&quot;, \&quot;tracking_metric\&quot;: \&quot;quantity\&quot; } or { \&quot;target\&quot;: \&quot;50\&quot;, \&quot;tracking_metric\&quot;: \&quot;sum\&quot;, \&quot;currency_id\&quot;: 1 }. &#x60;currency_id&#x60; should only be added to &#x60;sum&#x60; type of goals. @option opts [Object] :duration Date when the goal starts and ends. It requires the following JSON structure: { \&quot;start\&quot;: \&quot;2019-01-01\&quot;, \&quot;end\&quot;: \&quot;2022-12-31\&quot; }. Date in format of YYYY-MM-DD. @option opts [String] :interval Date when the goal starts and ends. It requires the following JSON structure: { \&quot;start\&quot;: \&quot;2019-01-01\&quot;, \&quot;end\&quot;: \&quot;2022-12-31\&quot; }. Date in format of YYYY-MM-DD. @return [nil]

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 202
def goals_id_put(id, opts = {})
  goals_id_put_with_http_info(id, opts)
  nil
end
goals_id_put_with_http_info(id, opts = {}) click to toggle source

Update existing goal Updates existing goal. @param id [String] ID of the goal to be updated. @param [Hash] opts the optional parameters @option opts [String] :title Title of the goal. @option opts [Object] :assignee Who is this goal assigned to. It requires the following JSON structure: { \&quot;id\&quot;: \&quot;1\&quot;, \&quot;type\&quot;: \&quot;person\&quot; }. &#x60;type&#x60; can be either &#x60;person&#x60;, &#x60;company&#x60; or &#x60;team&#x60;. ID of the assignee person, company or team. @option opts [Object] :type Type of the goal. It requires the following JSON structure: { \&quot;name\&quot;: \&quot;deals_started\&quot;, \&quot;params\&quot;: { \&quot;pipeline_id\&quot;: 1 } }. Type can be one of: &#x60;deals_won&#x60;,&#x60;deals_progressed&#x60;,&#x60;activities_completed&#x60;,&#x60;activities_added&#x60; or &#x60;deals_started&#x60;. &#x60;params&#x60; can include &#x60;pipeline_id&#x60;, &#x60;stage_id&#x60; or &#x60;activity_type_id&#x60;. &#x60;stage_id&#x60; is related to only &#x60;deals_progressed&#x60; type of goals and &#x60;activity_type_id&#x60; to &#x60;activities_completed&#x60; or &#x60;activities_added&#x60; types of goals. To track goal in all pipelines set &#x60;pipeline_id&#x60; as &#x60;null&#x60;. @option opts [Object] :expected_outcome Expected outcome of the goal. Expected outcome can be tracked either by &#x60;quantity&#x60; or by &#x60;sum&#x60;. It requires the following JSON structure: { \&quot;target\&quot;: \&quot;50\&quot;, \&quot;tracking_metric\&quot;: \&quot;quantity\&quot; } or { \&quot;target\&quot;: \&quot;50\&quot;, \&quot;tracking_metric\&quot;: \&quot;sum\&quot;, \&quot;currency_id\&quot;: 1 }. &#x60;currency_id&#x60; should only be added to &#x60;sum&#x60; type of goals. @option opts [Object] :duration Date when the goal starts and ends. It requires the following JSON structure: { \&quot;start\&quot;: \&quot;2019-01-01\&quot;, \&quot;end\&quot;: \&quot;2022-12-31\&quot; }. Date in format of YYYY-MM-DD. @option opts [String] :interval Date when the goal starts and ends. It requires the following JSON structure: { \&quot;start\&quot;: \&quot;2019-01-01\&quot;, \&quot;end\&quot;: \&quot;2022-12-31\&quot; }. Date in format of YYYY-MM-DD. @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 218
def goals_id_put_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GoalsApi.goals_id_put ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling GoalsApi.goals_id_put"
  end
  allowable_values = ["weekly", "monthly", "quarterly", "yearly"]
  if @api_client.config.client_side_validation && opts[:'interval'] && !allowable_values.include?(opts[:'interval'])
    fail ArgumentError, "invalid value for \"interval\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/goals/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['title'] = opts[:'title'] if !opts[:'title'].nil?
  form_params['assignee'] = opts[:'assignee'] if !opts[:'assignee'].nil?
  form_params['type'] = opts[:'type'] if !opts[:'type'].nil?
  form_params['expected_outcome'] = opts[:'expected_outcome'] if !opts[:'expected_outcome'].nil?
  form_params['duration'] = opts[:'duration'] if !opts[:'duration'].nil?
  form_params['interval'] = opts[:'interval'] if !opts[:'interval'].nil?

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: GoalsApi#goals_id_put\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
goals_id_results_get(id, period_start, period_end, opts = {}) click to toggle source

Get result of a goal Gets progress of a goal for specified period. @param id [String] ID of the goal that the results are looked for. @param period_start [Date] Start date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD. @param period_end [Date] End date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD. @param [Hash] opts the optional parameters @return [nil]

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 282
def goals_id_results_get(id, period_start, period_end, opts = {})
  goals_id_results_get_with_http_info(id, period_start, period_end, opts)
  nil
end
goals_id_results_get_with_http_info(id, period_start, period_end, opts = {}) click to toggle source

Get result of a goal Gets progress of a goal for specified period. @param id [String] ID of the goal that the results are looked for. @param period_start [Date] Start date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD. @param period_end [Date] End date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD. @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 294
def goals_id_results_get_with_http_info(id, period_start, period_end, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GoalsApi.goals_id_results_get ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling GoalsApi.goals_id_results_get"
  end
  # verify the required parameter 'period_start' is set
  if @api_client.config.client_side_validation && period_start.nil?
    fail ArgumentError, "Missing the required parameter 'period_start' when calling GoalsApi.goals_id_results_get"
  end
  # verify the required parameter 'period_end' is set
  if @api_client.config.client_side_validation && period_end.nil?
    fail ArgumentError, "Missing the required parameter 'period_end' when calling GoalsApi.goals_id_results_get"
  end
  # resource path
  local_var_path = '/goals/{id}/results'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'period.start'] = period_start
  query_params[:'period.end'] = period_end

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: GoalsApi#goals_id_results_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
goals_post(opts = {}) click to toggle source

Add a new goal Adds a new goal. @param [Hash] opts the optional parameters @return [nil]

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 353
def goals_post(opts = {})
  goals_post_with_http_info(opts)
  nil
end
goals_post_with_http_info(opts = {}) click to toggle source

Add a new goal Adds a new goal. @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/pipedrive-openapi-client/api/goals_api.rb, line 362
def goals_post_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GoalsApi.goals_post ...'
  end
  # resource path
  local_var_path = '/goals'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: GoalsApi#goals_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end