Sha256: facd9a9bc9be083412bf5be0cfe0ac63dccb2be4b5a6b145d9ad8d9ffc94f02f

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

require "hashie"

module ShipEngine
  module Domain
    class Webhooks
      def initialize
        @client = ShipEngine::Client.new
      end

      def list_webhooks(params: {})
        response = @client.get(
          path: ShipEngine::Constants::PATHS.v1.webhooks.root,
          options: params
        )

        response.body.map { |webhook| Hashie::Mash.new(webhook) }
      end

      def create_webhook(params: {})
        response = @client.post(
          path: ShipEngine::Constants::PATHS.v1.webhooks.root,
          options: params
        )

        Hashie::Mash.new(response.body)
      end

      def webhook_by_id(webhook_id:, params: {})
        response = @client.get(
          path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
          options: params
        )

        Hashie::Mash.new(response.body)
      end

      def update_webhook_by_id(webhook_id:, params: {})
        response = @client.put(
          path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
          options: params
        )

        Hashie::Mash.new(response.body)
      end

      def delete_webhook_by_id(webhook_id:, params: {})
        response = @client.delete(
          path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
          options: params
        )

        Hashie::Mash.new(response.body)
      end

      def process_webhook(resource_url:, params: {})
        response = @client.get(
          path: resource_url,
          options: params
        )

        Hashie::Mash.new(response.body)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shipengine_ruby-0.0.7 lib/shipengine/domains/webhooks.rb
shipengine_ruby-0.0.6 lib/shipengine/domains/webhooks.rb
shipengine_ruby-0.0.5 lib/shipengine/domains/webhooks.rb