class Pipedrive::WebhooksApi

Attributes

api_client[RW]

Public Class Methods

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

Public Instance Methods

webhooks_get(opts = {}) click to toggle source

Get all webhooks Returns data about all webhooks of a company. @param [Hash] opts the optional parameters @return [Object]

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 26
def webhooks_get(opts = {})
  data, _status_code, _headers = webhooks_get_with_http_info(opts)
  data
end
webhooks_get_with_http_info(opts = {}) click to toggle source

Get all webhooks Returns data about all webhooks of a company. @param [Hash] opts the optional parameters @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 35
def webhooks_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.webhooks_get ...'
  end
  # resource path
  local_var_path = '/webhooks'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

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

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

  # return_type
  return_type = opts[:return_type] || 'Object' 

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

  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: WebhooksApi#webhooks_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
webhooks_id_delete(id, opts = {}) click to toggle source

Delete existing webhook Deletes the specified webhook. @param id [Integer] The ID of the webhook to delete @param [Hash] opts the optional parameters @return [BaseResponse]

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 83
def webhooks_id_delete(id, opts = {})
  data, _status_code, _headers = webhooks_id_delete_with_http_info(id, opts)
  data
end
webhooks_id_delete_with_http_info(id, opts = {}) click to toggle source

Delete existing webhook Deletes the specified webhook. @param id [Integer] The ID of the webhook to delete @param [Hash] opts the optional parameters @return [Array<(BaseResponse, Integer, Hash)>] BaseResponse data, response status code and response headers

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 93
def webhooks_id_delete_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.webhooks_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 WebhooksApi.webhooks_id_delete"
  end
  # resource path
  local_var_path = '/webhooks/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

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

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

  # return_type
  return_type = opts[:return_type] || 'BaseResponse' 

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

  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: WebhooksApi#webhooks_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
webhooks_post(subscription_url, event_action, event_object, opts = {}) click to toggle source

Create a new webhook Creates a new webhook and returns its details. Note that specifying an event which triggers the webhook combines 2 parameters - 'event_action' and 'event_object'. E.g., use '.' for getting notifications about all events, 'added.deal' for any newly added deals, 'deleted.persons' for any deleted persons, etc. See <a href="https://pipedrive.readme.io/docs/guide-for-webhookspipedrive.readme.io/docs/guide-for-webhooks?ref=api_reference">https://pipedrive.readme.io/docs/guide-for-webhooks> for more details. @param subscription_url [String] A full, valid, publicly accessible URL. Determines where to send the notifications. Please note that you cannot use Pipedrive API endpoints as the subscription_url. @param event_action [String] Type of action to receive notifications about. Wildcard will match all supported actions. @param event_object [String] Type of object to receive notifications about. Wildcard will match all supported objects. @param [Hash] opts the optional parameters @option opts [Integer] :user_id The ID of the user this webhook will be authorized with. If not set, current authorized user will be used. Note that this does not filter only certain user&#39;s events — rather, this specifies the user&#39;s permissions under which each event is checked. Events about objects the selected user is not entitled to access are not sent. If you want to receive notifications for all events, a top-level admin user should be used. @option opts [String] :http_auth_user HTTP basic auth username of the subscription URL endpoint (if required). @option opts [String] :http_auth_password HTTP basic auth password of the subscription URL endpoint (if required). @return [Object]

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 150
def webhooks_post(subscription_url, event_action, event_object, opts = {})
  data, _status_code, _headers = webhooks_post_with_http_info(subscription_url, event_action, event_object, opts)
  data
end
webhooks_post_with_http_info(subscription_url, event_action, event_object, opts = {}) click to toggle source

Create a new webhook Creates a new webhook and returns its details. Note that specifying an event which triggers the webhook combines 2 parameters - &#39;event_action&#39; and &#39;event_object&#39;. E.g., use &#39;.&#39; for getting notifications about all events, &#39;added.deal&#39; for any newly added deals, &#39;deleted.persons&#39; for any deleted persons, etc. See &lt;a href&#x3D;&quot;pipedrive.readme.io/docs/guide-for-webhooks?ref=api_reference">https://pipedrive.readme.io/docs/guide-for-webhooks</a>; for more details. @param subscription_url [String] A full, valid, publicly accessible URL. Determines where to send the notifications. Please note that you cannot use Pipedrive API endpoints as the subscription_url. @param event_action [String] Type of action to receive notifications about. Wildcard will match all supported actions. @param event_object [String] Type of object to receive notifications about. Wildcard will match all supported objects. @param [Hash] opts the optional parameters @option opts [Integer] :user_id The ID of the user this webhook will be authorized with. If not set, current authorized user will be used. Note that this does not filter only certain user&#39;s events — rather, this specifies the user&#39;s permissions under which each event is checked. Events about objects the selected user is not entitled to access are not sent. If you want to receive notifications for all events, a top-level admin user should be used. @option opts [String] :http_auth_user HTTP basic auth username of the subscription URL endpoint (if required). @option opts [String] :http_auth_password HTTP basic auth password of the subscription URL endpoint (if required). @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers

# File lib/pipedrive-openapi-client/api/webhooks_api.rb, line 165
def webhooks_post_with_http_info(subscription_url, event_action, event_object, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.webhooks_post ...'
  end
  # verify the required parameter 'subscription_url' is set
  if @api_client.config.client_side_validation && subscription_url.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_url' when calling WebhooksApi.webhooks_post"
  end
  # verify the required parameter 'event_action' is set
  if @api_client.config.client_side_validation && event_action.nil?
    fail ArgumentError, "Missing the required parameter 'event_action' when calling WebhooksApi.webhooks_post"
  end
  # verify enum value
  allowable_values = ["added", "updated", "merged", "deleted", "*"]
  if @api_client.config.client_side_validation && !allowable_values.include?(event_action)
    fail ArgumentError, "invalid value for \"event_action\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'event_object' is set
  if @api_client.config.client_side_validation && event_object.nil?
    fail ArgumentError, "Missing the required parameter 'event_object' when calling WebhooksApi.webhooks_post"
  end
  # verify enum value
  allowable_values = ["activity", "activityType", "deal", "note", "organization", "person", "pipeline", "product", "stage", "user", "*"]
  if @api_client.config.client_side_validation && !allowable_values.include?(event_object)
    fail ArgumentError, "invalid value for \"event_object\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/webhooks'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # 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['subscription_url'] = subscription_url
  form_params['event_action'] = event_action
  form_params['event_object'] = event_object
  form_params['user_id'] = opts[:'user_id'] if !opts[:'user_id'].nil?
  form_params['http_auth_user'] = opts[:'http_auth_user'] if !opts[:'http_auth_user'].nil?
  form_params['http_auth_password'] = opts[:'http_auth_password'] if !opts[:'http_auth_password'].nil?

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

  # return_type
  return_type = opts[:return_type] || 'Object' 

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

  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: WebhooksApi#webhooks_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end