Sha256: 5a865d8b5ef05bd0a4c099b8fdc1f0627e2111f885bf1b2a8b6766e2258bf9f8

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Yoti
  module DocScan
    module Support
      class SupportedDocumentsResponse
        # @return [Array<SupportedCountry>]
        attr_reader :supported_countries

        #
        # @param [Hash] response
        #
        def initialize(response)
          if response['supported_countries'].nil?
            @supported_countries = []
          else
            Validation.assert_is_a(Array, response['supported_countries'], 'supported_countries')
            @supported_countries = response['supported_countries'].map { |country| SupportedCountry.new(country) }
          end
        end
      end

      class SupportedCountry
        # @return [String]
        attr_reader :code

        # @return [Array<SupportedDocument>]
        attr_reader :supported_documents

        #
        # @param [Hash] country
        #
        def initialize(country)
          Validation.assert_is_a(String, country['code'], 'code', true)
          @code = country['code']

          if country['supported_documents'].nil?
            @supported_documents = []
          else
            Validation.assert_is_a(Array, country['supported_documents'], 'supported_documents')
            @supported_documents = country['supported_documents'].map { |document| SupportedDocument.new(document) }
          end
        end
      end

      class SupportedDocument
        # @return [String]
        attr_reader :type

        #
        # @param [Hash] document
        #
        def initialize(document)
          Validation.assert_is_a(String, document['type'], 'type', true)
          @type = document['type']
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yoti-1.10.0 lib/yoti/doc_scan/support/supported_documents.rb
yoti-1.9.0 lib/yoti/doc_scan/support/supported_documents.rb
yoti-1.8.0 lib/yoti/doc_scan/support/supported_documents.rb
yoti-1.7.1 lib/yoti/doc_scan/support/supported_documents.rb
yoti-1.7.0 lib/yoti/doc_scan/support/supported_documents.rb