Sha256: d263bb8e0550c98fa17eee1cea491568e0cb1b2040fc8c88fd424177e9b7b71b

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

module Workarea
  module ShipStation
    class Webhook
      class Error < RuntimeError; end
      class Error::NotFound < RuntimeError; end
      class Error::UnhandledWebhook < RuntimeError; end

      def self.process(attrs)
        resource = attrs["resource_type"]
        begin
          klass = "Workarea::ShipStation::Webhook::#{resource.downcase.classify}".constantize
        rescue NameError => _error
          raise Error::UnhandledWebhook, "no class defined to handle #{resource}"
        end
        klass.new(attrs).process
      end

      attr_reader :attrs

      def initialize(attrs)
        @attrs = attrs
      end

      def process; end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-ship_station-1.0.1 app/services/workarea/ship_station/webhook.rb
workarea-ship_station-1.0.0 app/services/workarea/ship_station/webhook.rb