Sha256: f4698f86b803a819c1f550e43c34be4114fecf2b7777b7ae82cefaee8bc8a480

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Pixela
  class Webhook
    # @!attribute [r] client
    # @return [Pixela::Client]
    attr_reader :client

    # @!attribute [r] webhook_hash
    # @return [String]
    attr_reader :webhook_hash

    # @param client       [Pixela::Client]
    # @param webhook_hash [String]
    def initialize(client:, webhook_hash:)
      @client       = client
      @webhook_hash = webhook_hash
    end

    # Invoke the webhook registered in advance.
    #
    # @return [Hashie::Mash]
    #
    # @raise [Pixela::PixelaError] API is failed
    #
    # @see https://docs.pixe.la/#/invoke-webhook
    #
    # @example
    #   client.webhook("<webhookHash>").invoke
    def invoke
      client.invoke_webhook(webhook_hash: webhook_hash)
    end

    # Delete the registered Webhook.
    #
    # @return [Hashie::Mash]
    #
    # @raise [Pixela::PixelaError] API is failed
    #
    # @see https://docs.pixe.la/#/delete-webhook
    #
    # @example
    #   client.webhook("<webhookHash>").delete
    def delete
      client.delete_webhook(webhook_hash: webhook_hash)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pixela-0.5.2 lib/pixela/webhook.rb