Sha256: e005972a75b9eb3cc11bf0deda1b29f40aa11c789380f99f462d5e4052d2a828

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require_relative 'base_decorator'
require 'pact_broker/json'

module PactBroker

  module Api

    module Decorators

      class PactDecorator < BaseDecorator

        property :createdAt, getter: lambda { |_|  created_at.xmlschema }, writeable: false
        property :updatedAt, getter: lambda { |_| updated_at.xmlschema }, writeable: false

        def to_hash(options = {})
          ::JSON.parse(represented.json_content, PACT_PARSING_OPTIONS).merge super
        end

        link :'latest-pact' do | options |
          {
            title: "Latest version of the pact between #{represented.consumer.name} and #{represented.provider.name}",
            href: latest_pact_url(options.fetch(:base_url), represented)

          }
        end

        link :'pact-versions' do | options |
          {
            title: "All versions of the pact between #{represented.consumer.name} and #{represented.provider.name}",
            href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
          }
        end

        link :'pact-webhooks' do | options |
          {
            title: "Webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
            href: webhooks_for_pact_url(represented.consumer, represented.provider, options.fetch(:base_url))
          }
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-1.2.0 lib/pact_broker/api/decorators/pact_decorator.rb