Sha256: b6dcad878a07b79b1a1cfadead674a71e96f98c6c6ca889cd61bb6a39e43e3e7

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

require 'uploadcare/rails/api/rest/base'

module Uploadcare
  module Rails
    module Api
      module Rest
        # A class that contains Webhook related methods for Uploadcare REST API
        class WebhookApi < Base
          class << self
            # Returns a list (not paginated) of webhooks
            # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhooksList
            # rubocop:disable Naming/AccessorMethodName
            def get_webhooks
              Uploadcare::Webhook.list
            end
            # rubocop:enable Naming/AccessorMethodName

            # Create a webhook
            # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhookCreate
            def create_webhook(target_url, event: 'file.uploaded', is_active: true, signing_secret: nil)
              options = { target_url: target_url, event: event, is_active: is_active, signing_secret: signing_secret }
              Uploadcare::Webhook.create(**options.compact)
            end

            # Updates a webhook
            # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/updateWebhook
            def update_webhook(id, options = {})
              Uploadcare::Webhook.update(id, options)
            end

            # Permanently deletes a webhook
            # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhookUnsubscribe
            def delete_webhook(target_url)
              Uploadcare::Webhook.delete(target_url)
            end
          end
        end
      end
    end
  end
end

Uploadcare::WebhookApi = Uploadcare::Rails::Api::Rest::WebhookApi

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
uploadcare-rails-3.4.4 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.4.3 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.4.1 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.4.0 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.4 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.3 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.2.1 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.2 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.1 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.3.0 lib/uploadcare/rails/api/rest/webhook_api.rb
uploadcare-rails-3.2.0 lib/uploadcare/rails/api/rest/webhook_api.rb