Sha256: f0fa1bcc9ab0269add57d7b90c049e61ecbe1a9e8bcfc541a52e669671ec51ba
Contents?: true
Size: 1.43 KB
Versions: 74
Compression:
Stored size: 1.43 KB
Contents
require_relative 'base_decorator' require 'json' module PactBroker module Api module Decorators class WebhookExecutionResultDecorator < BaseDecorator class ErrorDecorator < BaseDecorator property :message property :backtrace end class HTTPResponseDecorator < BaseDecorator property :status, :getter => lambda { |_| code.to_i } property :headers, exec_context: :decorator property :body, exec_context: :decorator def headers headers_hash = represented.to_hash headers_hash.keys.each_with_object({}) do | name, new_headers_hash| new_headers_hash[name] = headers_hash[name].join(", ") end end def body begin ::JSON.parse(represented.body) rescue StandardError => e represented.body end end end property :error, :extend => ErrorDecorator property :response, :extend => HTTPResponseDecorator link :webhook do | options | { href: webhook_url(options.fetch(:webhook).uuid, options.fetch(:base_url)) } end link :'try-again' do | options | { title: 'Execute the webhook again', href: webhook_execution_url(options.fetch(:webhook), options.fetch(:base_url)) } end end end end end
Version data entries
74 entries across 74 versions & 1 rubygems