Sha256: 59807c993635804863b9f4b025cd06a3e3b4ad510d220129acd52b7057f83568

Contents?: true

Size: 1.75 KB

Versions: 12

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

module MailerLite
  module Clients
    # MailerLite Webhooks
    module Webhooks
      # Get webhooks
      #
      # @see https://developers.mailerlite.com/v2/reference#webhooks-1
      #
      # @return [Hash] Response from API.
      def webhooks
        connection.get('webhooks')
      end

      # Get single webhook
      #
      # @see https://developers.mailerlite.com/v2/reference#webhooksid
      #
      # @param id [Integer] ID of a webhook
      #
      # @return [Hash] Response from API.
      def webhook(id)
        connection.get("webhooks/#{id}")
      end

      # Create webhook
      #
      # @see https://developers.mailerlite.com/v2/reference#webhooks-2
      #
      # @param url [String] Your URL where callbacks are sent.
      # @param event [String] Subscribed event.
      #
      # @return [Hash] Response from API.
      def create_webhook(url, event)
        connection.post('webhooks', url: url, event: event)
      end

      # Update webhook
      #
      # @see https://developers.mailerlite.com/v2/reference#webhooksid-1
      #
      # @param id [Integer] ID of webhook.
      # @param options [Hash] A customizable set of options.
      # @option options [String] :url Your URL where callbacks are sent
      # @option options [String] :event Subscribed event
      #
      # @return [Hash] Response from API.
      def update_webhook(id, options = {})
        connection.put("webhooks/#{id}", options)
      end

      # Remove webhook
      #
      # @see https://developers.mailerlite.com/v2/reference#webhooksid-2
      #
      # @param id [Integer] ID of webhook.
      #
      # @return [Hash] Response from API.
      def delete_webhook(id)
        connection.delete("webhooks/#{id}")
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mailerlite-1.16.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.15.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.14.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.13.1 lib/mailerlite/clients/webhooks.rb
mailerlite-1.13.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.12.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.11.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.10.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.9.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.8.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.7.0 lib/mailerlite/clients/webhooks.rb
mailerlite-1.6.1 lib/mailerlite/clients/webhooks.rb