Sha256: 87d8bd10471b84b2a9165e208c71719e1d1a507a62ccf1286786c545aab3bfa4

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

module Trizetto
  module Api
    module Eligibility
      module WebService
        # Wraps a validation error returned in the SOAP response body
        #
        # <b>Example</b>
        #
        #   failure = ValidationFailure.new({affected_fields: {string: "InsuranceNum"}, message: "Please enter InsuranceNum."}`)
        #   failure.affected_fields   # =>["InsuranceNum"]
        #   failure.message           # => "Please enter InsuranceNum."
        #
        class ValidationFailure

          # An array of strings indicating which fields had a validation failure.
          #
          # While the WSDL has this as an array, in practice, there is one field in that array
          #
          # <b>WSDL Reference</b>
          #
          #   <s:element minOccurs="0" maxOccurs="1" name="AffectedFields" type="tns:ArrayOfString" />
          #
          attr_accessor :affected_fields

          # The validation error associated with the affected fields
          #
          # <b>WSDL Reference</b>
          #
          #   <s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string" />
          #
          attr_accessor :message

          # Initialize the Validation failure from a parsed DoInquiry response hash
          #
          def initialize(validation_failure_hash)
            self.affected_fields = Array((validation_failure_hash.dig(:affected_fields) || {})[:string])
            self.message         = validation_failure_hash[:message]
          end

          def to_h
            {affected_fields: affected_fields, message: message}
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trizetto-api-0.2.4 lib/trizetto/api/eligibility/web_service/validation_failure.rb
trizetto-api-0.2.3 lib/trizetto/api/eligibility/web_service/validation_failure.rb
trizetto-api-0.2.2 lib/trizetto/api/eligibility/web_service/validation_failure.rb
trizetto-api-0.2.1 lib/trizetto/api/eligibility/web_service/validation_failure.rb