class Yoti::Profile

Encapsulates Yoti user profile

Public Instance Methods

age_verifications() click to toggle source

Finds all the 'Age Over' and 'Age Under' derived attributes returned with the profile, and returns them wrapped in AgeVerification objects

@return [Array]

# File lib/yoti/data_type/profile.rb, line 135
def age_verifications
  find_all_age_verifications
  @age_verifications.values
end
date_of_birth() click to toggle source

Date of birth.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 68
def date_of_birth
  get_attribute(Yoti::Attribute::DATE_OF_BIRTH)
end
document_details() click to toggle source

Document Details.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 126
def document_details
  get_attribute(Yoti::Attribute::DOCUMENT_DETAILS)
end
document_images() click to toggle source

Document images.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 96
def document_images
  get_attribute(Yoti::Attribute::DOCUMENT_IMAGES)
end
email_address() click to toggle source

The user's verified email address.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 59
def email_address
  get_attribute(Yoti::Attribute::EMAIL_ADDRESS)
end
family_name() click to toggle source

Corresponds to primary name in passport, and surname in English.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 22
def family_name
  get_attribute(Yoti::Attribute::FAMILY_NAME)
end
find_age_over_verification(age) click to toggle source

Searches for an AgeVerification corresponding to an 'Age Over' check for the given age

@param [Integer] age

@return [AgeVerification|nil]

# File lib/yoti/data_type/profile.rb, line 147
def find_age_over_verification(age)
  find_age_verification(Yoti::Attribute::AGE_OVER, age)
end
find_age_under_verification(age) click to toggle source

Searches for an AgeVerification corresponding to an 'Age Under' check for the given age.

@param [Integer] age

@return [AgeVerification|nil]

# File lib/yoti/data_type/profile.rb, line 158
def find_age_under_verification(age)
  find_age_verification(Yoti::Attribute::AGE_UNDER, age)
end
full_name() click to toggle source

The user's full name.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 40
def full_name
  get_attribute(Yoti::Attribute::FULL_NAME)
end
gender() click to toggle source

Corresponds to the gender in the passport; will be one of the strings “MALE”, “FEMALE”, “TRANSGENDER” or “OTHER”.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 78
def gender
  get_attribute(Yoti::Attribute::GENDER)
end
given_names() click to toggle source

Corresponds to secondary names in passport, and first/middle names in English.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 31
def given_names
  get_attribute(Yoti::Attribute::GIVEN_NAMES)
end
nationality() click to toggle source

Corresponds to the nationality in the passport.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 87
def nationality
  get_attribute(Yoti::Attribute::NATIONALITY)
end
phone_number() click to toggle source

The user's phone number, as verified at registration time. This will be a number with + for international prefix and no spaces, e.g. “+447777123456”.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 50
def phone_number
  get_attribute(Yoti::Attribute::PHONE_NUMBER)
end
postal_address() click to toggle source

The user's postal address as a String.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 105
def postal_address
  postal_address = get_attribute(Yoti::Attribute::POSTAL_ADDRESS)
  return postal_address unless postal_address.nil?

  attribute_from_formatted_address
end
selfie() click to toggle source

Selfie is a photograph of the user.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 13
def selfie
  get_attribute(Yoti::Attribute::SELFIE)
end
structured_postal_address() click to toggle source

The user's structured postal address as a JSON.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 117
def structured_postal_address
  get_attribute(Yoti::Attribute::STRUCTURED_POSTAL_ADDRESS)
end

Protected Instance Methods

attribute_from_formatted_address() click to toggle source

Creates attribute from formatted address.

@return [Attribute, nil]

# File lib/yoti/data_type/profile.rb, line 169
def attribute_from_formatted_address
  return nil if structured_postal_address.nil?
  return nil unless structured_postal_address.value.key?('formatted_address')

  Yoti::Attribute.new(
    Yoti::Attribute::POSTAL_ADDRESS,
    structured_postal_address.value['formatted_address'],
    structured_postal_address.sources,
    structured_postal_address.verifiers
  )
end

Private Instance Methods

find_age_verification(type, age) click to toggle source

Searches for an AgeVerification corresponding to provided type and age.

@param [String] type @param [Integer] age

@return [Yoti::AgeVerification|nil]

# File lib/yoti/data_type/profile.rb, line 191
def find_age_verification(type, age)
  raise(ArgumentError, "#{age} is not a valid age") unless age.is_a?(Integer)

  find_all_age_verifications
  @age_verifications[type + age.to_s] || nil
end
find_all_age_verifications() click to toggle source

Find all age verifications and put in key value Hash.

# File lib/yoti/data_type/profile.rb, line 201
def find_all_age_verifications
  return @age_verifications unless @age_verifications.nil?

  @age_verifications = {}

  find_attributes_starting_with(Yoti::Attribute::AGE_OVER).each do |_name, attribute|
    @age_verifications[attribute.name] = Yoti::AgeVerification.new(attribute)
  end
  find_attributes_starting_with(Yoti::Attribute::AGE_UNDER).each do |_name, attribute|
    @age_verifications[attribute.name] = Yoti::AgeVerification.new(attribute)
  end
end