Class: Pipedrive::WebhooksApi

Inherits:
Object
  • Object
show all
Defined in:
lib/pipedrive-openapi-client/api/webhooks_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ WebhooksApi



19
20
21
# File 'lib/pipedrive-openapi-client/api/webhooks_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/pipedrive-openapi-client/api/webhooks_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#webhooks_get(opts = {}) ⇒ Object

Get all webhooks Returns data about all webhooks of a company.



26
27
28
29
# 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 = {}) ⇒ Array<(Object, Integer, Hash)>

Get all webhooks Returns data about all webhooks of a company.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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 = {}) ⇒ BaseResponse

Delete existing webhook Deletes the specified webhook.



83
84
85
86
# 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 = {}) ⇒ Array<(BaseResponse, Integer, Hash)>

Delete existing webhook Deletes the specified webhook.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# 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 = {}) ⇒ Object

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="pipedrive.readme.io/docs/guide-for-webhooks?ref=api_reference">pipedrive.readme.io/docs/guide-for-webhooks</a> for more details.

Options Hash (opts):

  • :user_id (Integer)

    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.

  • :http_auth_user (String)

    HTTP basic auth username of the subscription URL endpoint (if required).

  • :http_auth_password (String)

    HTTP basic auth password of the subscription URL endpoint (if required).



150
151
152
153
# 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 = {}) ⇒ Array<(Object, Integer, Hash)>

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&#x3D;api_reference&quot;&gt;pipedrive.readme.io/docs/guide-for-webhooks&lt;/a&gt; for more details.

Options Hash (opts):

  • :user_id (Integer)

    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.

  • :http_auth_user (String)

    HTTP basic auth username of the subscription URL endpoint (if required).

  • :http_auth_password (String)

    HTTP basic auth password of the subscription URL endpoint (if required).



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# 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