Sha256: 886db625fc53ab4cd863ff7034557f28c4331ea87648ac3a0e361be25b1dc554

Contents?: true

Size: 1.98 KB

Versions: 34

Compression:

Stored size: 1.98 KB

Contents

require "sequel"
require "pact_broker/repositories/helpers"

module PactBroker
  module Webhooks
    class WebhookEvent < Sequel::Model
      plugin :timestamps, update_on_create: true

      CONTRACT_PUBLISHED = "contract_published"
      CONTRACT_CONTENT_CHANGED = "contract_content_changed"
      VERIFICATION_PUBLISHED = "provider_verification_published"
      VERIFICATION_SUCCEEDED = "provider_verification_succeeded"
      VERIFICATION_FAILED = "provider_verification_failed"
      DEFAULT_EVENT_NAME = CONTRACT_CONTENT_CHANGED
      CONTRACT_REQUIRING_VERIFICATION_PUBLISHED = "contract_requiring_verification_published"

      EVENT_NAMES = [CONTRACT_PUBLISHED, CONTRACT_CONTENT_CHANGED, VERIFICATION_PUBLISHED, VERIFICATION_SUCCEEDED, VERIFICATION_FAILED, CONTRACT_REQUIRING_VERIFICATION_PUBLISHED]

      dataset_module do
        include PactBroker::Repositories::Helpers
      end

      def contract_published?
        name == CONTRACT_PUBLISHED
      end

      def contract_content_changed?
        name == CONTRACT_CONTENT_CHANGED
      end

      def provider_verification_published?
        name == VERIFICATION_PUBLISHED
      end

      def provider_verification_succeeded?
        name == VERIFICATION_SUCCEEDED
      end

      def provider_verification_failed?
        name == VERIFICATION_FAILED
      end

      def contract_requiring_verification_published?
        name == CONTRACT_REQUIRING_VERIFICATION_PUBLISHED
      end
    end
  end
end

# Table: webhook_events
# Columns:
#  id         | integer                     | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
#  webhook_id | integer                     |
#  name       | text                        |
#  created_at | timestamp without time zone | NOT NULL
#  updated_at | timestamp without time zone | NOT NULL
# Indexes:
#  webhook_events_pkey | PRIMARY KEY btree (id)
#  uq_webhook_id_name  | UNIQUE btree (id, name)
# Foreign key constraints:
#  webhook_events_webhook_id_fkey | (webhook_id) REFERENCES webhooks(id) ON DELETE CASCADE

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
pact_broker-2.106.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.105.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.104.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.103.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.102.2 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.102.1 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.102.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.101.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.100.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.99.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.98.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.97.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.96.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.95.1 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.95.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.94.0 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.93.4 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.93.3 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.93.2 lib/pact_broker/webhooks/webhook_event.rb
pact_broker-2.93.1 lib/pact_broker/webhooks/webhook_event.rb