class PolarAccesslinkApiGem::WebhooksApi

Attributes

api_client[RW]

Public Class Methods

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

Public Instance Methods

create_webhook(webhook_request, opts = {}) click to toggle source

Create webhook Create new webhook. When creating webhook the Accesslink sends a ping message to the url in request body. The ping message must be answered with 200 OK or otherwise the webhook is not created. **Note!** Save the signature_secret_key from response since this is the only chance to get it. @param webhook_request [WebhookRequest] Webhook to create. @param [Hash] opts the optional parameters @return [CreatedWebhook]

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 27
def create_webhook(webhook_request, opts = {})
  data, _status_code, _headers = create_webhook_with_http_info(webhook_request, opts)
  data
end
create_webhook_with_http_info(webhook_request, opts = {}) click to toggle source

Create webhook Create new webhook. When creating webhook the Accesslink sends a ping message to the url in request body. The ping message must be answered with 200 OK or otherwise the webhook is not created. **Note!** Save the signature_secret_key from response since this is the only chance to get it. @param webhook_request [WebhookRequest] Webhook to create. @param [Hash] opts the optional parameters @return [Array<(CreatedWebhook, Integer, Hash)>] CreatedWebhook data, response status code and response headers

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 37
def create_webhook_with_http_info(webhook_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.create_webhook ...'
  end
  # verify the required parameter 'webhook_request' is set
  if @api_client.config.client_side_validation && webhook_request.nil?
    fail ArgumentError, "Missing the required parameter 'webhook_request' when calling WebhooksApi.create_webhook"
  end
  # resource path
  local_var_path = '/v3/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/json'])

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

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(webhook_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreatedWebhook'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Basic']

  new_options = opts.merge(
    :operation => :"WebhooksApi.create_webhook",
    :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#create_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
delete_webhook(webhook_id, opts = {}) click to toggle source

Delete webhook Delete webhook by id. @param webhook_id [Integer] Webhook id to delete @param [Hash] opts the optional parameters @return [nil]

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 92
def delete_webhook(webhook_id, opts = {})
  delete_webhook_with_http_info(webhook_id, opts)
  nil
end
delete_webhook_with_http_info(webhook_id, opts = {}) click to toggle source

Delete webhook Delete webhook by id. @param webhook_id [Integer] Webhook id to delete @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 102
def delete_webhook_with_http_info(webhook_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.delete_webhook ...'
  end
  # verify the required parameter 'webhook_id' is set
  if @api_client.config.client_side_validation && webhook_id.nil?
    fail ArgumentError, "Missing the required parameter 'webhook_id' when calling WebhooksApi.delete_webhook"
  end
  # resource path
  local_var_path = '/v3/webhooks/{webhook-id}'.sub('{' + 'webhook-id' + '}', CGI.escape(webhook_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[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Basic']

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

Get webhook Returns created webhook if exists. @param [Hash] opts the optional parameters @return [WebhookInfo]

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 154
def get_webhook(opts = {})
  data, _status_code, _headers = get_webhook_with_http_info(opts)
  data
end
get_webhook_with_http_info(opts = {}) click to toggle source

Get webhook Returns created webhook if exists. @param [Hash] opts the optional parameters @return [Array<(WebhookInfo, Integer, Hash)>] WebhookInfo data, response status code and response headers

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 163
def get_webhook_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.get_webhook ...'
  end
  # resource path
  local_var_path = '/v3/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[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookInfo'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Basic']

  new_options = opts.merge(
    :operation => :"WebhooksApi.get_webhook",
    :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#get_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
update_webhook(webhook_id, webhook_patch, opts = {}) click to toggle source

Update webhook Edit webhook event types and/or url. When updating webhook url the Accesslink sends a ping message to the new address. The ping message must be answered with 200 OK or otherwise the webhook is not updated. @param webhook_id [Integer] Webhook id to update @param webhook_patch [WebhookPatch] New value(s) for events and/or url. @param [Hash] opts the optional parameters @return [WebhookInfo]

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 213
def update_webhook(webhook_id, webhook_patch, opts = {})
  data, _status_code, _headers = update_webhook_with_http_info(webhook_id, webhook_patch, opts)
  data
end
update_webhook_with_http_info(webhook_id, webhook_patch, opts = {}) click to toggle source

Update webhook Edit webhook event types and/or url. When updating webhook url the Accesslink sends a ping message to the new address. The ping message must be answered with 200 OK or otherwise the webhook is not updated. @param webhook_id [Integer] Webhook id to update @param webhook_patch [WebhookPatch] New value(s) for events and/or url. @param [Hash] opts the optional parameters @return [Array<(WebhookInfo, Integer, Hash)>] WebhookInfo data, response status code and response headers

# File lib/polar-accesslink-api-gem/api/webhooks_api.rb, line 224
def update_webhook_with_http_info(webhook_id, webhook_patch, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.update_webhook ...'
  end
  # verify the required parameter 'webhook_id' is set
  if @api_client.config.client_side_validation && webhook_id.nil?
    fail ArgumentError, "Missing the required parameter 'webhook_id' when calling WebhooksApi.update_webhook"
  end
  # verify the required parameter 'webhook_patch' is set
  if @api_client.config.client_side_validation && webhook_patch.nil?
    fail ArgumentError, "Missing the required parameter 'webhook_patch' when calling WebhooksApi.update_webhook"
  end
  # resource path
  local_var_path = '/v3/webhooks/{webhook-id}'.sub('{' + 'webhook-id' + '}', CGI.escape(webhook_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'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(webhook_patch)

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookInfo'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Basic']

  new_options = opts.merge(
    :operation => :"WebhooksApi.update_webhook",
    :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(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#update_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end