Sha256: 450b5fd9b52c64375ed61d3bde85a6aa0b8ac7ea7af5fe868657c42cff034b81
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
require 'pact_broker/json' require 'pact_broker/constants' require 'ostruct' module PactBroker module Pacts class PactParams < Hash def initialize attributes merge!(attributes) end def self.from_request request, path_info json_content = request.body.to_s pact_hash = begin JSON.parse(json_content, PACT_PARSING_OPTIONS) rescue {} end new( consumer_name: path_info.fetch(:consumer_name), provider_name: path_info.fetch(:provider_name), consumer_version_number: path_info.fetch(:consumer_version_number), consumer_name_in_pact: pact_hash.fetch('consumer',{})['name'], provider_name_in_pact: pact_hash.fetch('provider',{})['name'], json_content: json_content ) end def pacticipant_names [consumer_name, provider_name] end def consumer_name self[:consumer_name] end def provider_name self[:provider_name] end def consumer_version_number self[:consumer_version_number] end def json_content self[:json_content] end def consumer_name_in_pact self[:consumer_name_in_pact] end def provider_name_in_pact self[:provider_name_in_pact] end def consumer PacticipantName.new(consumer_name, consumer_name_in_pact, 'consumer') end def provider PacticipantName.new(provider_name, provider_name_in_pact, 'provider') end class PacticipantName < Struct.new(:name, :name_in_pact, :pacticipant) def message_args { name: name, name_in_pact: name_in_pact, pacticipant: pacticipant } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems