Sha256: 5deb7c2f673d1c79e90ce703940dd06f39f69342e4b65289fab7990f2b2863c7

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

# Formats a message string into application/problem+json format.

module PactBroker
  module Api
    module Decorators
      class CustomErrorProblemJsonDecorator

        # @option title [String]
        # @option type [String]
        # @option detail [String]
        # @option status [Integer] HTTP status code
        def initialize(title:, type:, detail:, status: )
          @title = title
          @type = type
          @detail = detail
          @status = status
        end

        # @return [Hash]
        def to_hash(user_options: {}, **__other)
          {
            "title" => @title,
            "type" => "#{user_options[:base_url]}/problem/#{@type}",
            "detail" => @detail,
            "status" => @status
          }
        end

        # @return [String] JSON
        def to_json(*args, **kwargs)
          to_hash(*args, **kwargs).to_json
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb
pact_broker-2.111.0 lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb
pact_broker-2.109.1 lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb
pact_broker-2.109.0 lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb
pact_broker-2.108.0 lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb