class Yoti::DocumentDetails

Constants

AUTHORITY_INDEX
COUNTRY_INDEX
EXPIRATION_INDEX
NUMBER_INDEX
TYPE_INDEX
VALIDATION_PATTERN

@deprecated will be removed in 2.0.0 - pattern is no longer used for validation.

Attributes

document_number[R]

Document number (may include letters) from the document.

@return [String]

expiration_date[R]

Expiration date of the document in DateTime format. If the document does not expire, this field will not be present. The time part of this DateTime will default to 00:00:00.

@return [DateTime]

issuing_authority[R]

Can either be a country code (for a state), or the name of the issuing authority.

@return [String]

issuing_country[R]

ISO-3166-1 alpha-3 country code, e.g. “GBR”

@return [String]

type[R]

Type of the document e.g. PASSPORT | DRIVING_LICENCE | NATIONAL_ID | PASS_CARD

@return [String]

Public Class Methods

new(value) click to toggle source

@param [String] value

# File lib/yoti/data_type/document_details.rb, line 53
def initialize(value)
  parse_value(value)
end

Private Instance Methods

parse_date_from_string(date_string) click to toggle source

Converts provided date string into DateTime

@param [String] date_string

@return [DateTime]

# File lib/yoti/data_type/document_details.rb, line 82
def parse_date_from_string(date_string)
  return nil if date_string == '-'

  DateTime.iso8601(date_string)
end
parse_value(value) click to toggle source

Parses provided value into separate attributes

@param [String] value

# File lib/yoti/data_type/document_details.rb, line 64
def parse_value(value)
  attributes = value.split(/ /)
  raise(ArgumentError, "Invalid value for #{self.class.name}") if attributes.length < 3 || attributes.include?('')

  @type = attributes[TYPE_INDEX]
  @issuing_country = attributes[COUNTRY_INDEX]
  @document_number = attributes[NUMBER_INDEX]
  @expiration_date = parse_date_from_string(attributes[EXPIRATION_INDEX]) if attributes.length > 3
  @issuing_authority = attributes[AUTHORITY_INDEX] if attributes.length > 4
end