class Yoti::ActivityDetails

Details of an activity between a user and the application.

Attributes

age_verified[R]

The age under/over attribute

@deprecated will be removed in 2.0.0 - replaced by:

@return [Boolean]

base64_selfie_uri[R]

Base64 encoded selfie image

@return [String]

extra_data[R]

Extra data

@return [ExtraData]

outcome[R]

The outcome of the profile request, eg: SUCCESS

@return [String]

parent_remember_me_id[R]

Return the Parent Remember Me ID, which is a unique, stable identifier for a user in the context of an organisation.

You can use it to identify returning users. This value is consistent for a given user across different applications belonging to a single organisation.

@return [String]

receipt_id[R]

Receipt ID identifying a completed activity

@return [String]

remember_me_id[R]

Return the Remember Me ID, which is a unique, stable identifier for a user in the context of an application.

You can use it to identify returning users. This value will be different for the same user in different applications.

@return [String]

timestamp[R]

Time and date of the sharing activity

@return [Time]

user_id[R]

@deprecated replaced by :remember_me_id

@return [String]

user_profile[R]

The decoded profile attributes

@deprecated replaced by :profile

@return [Hash]

Public Class Methods

new(receipt, decrypted_profile = nil, decrypted_application_profile = nil, extra_data = nil) click to toggle source

@param receipt [Hash] the receipt from the API request @param decrypted_profile [Object] Protobuf AttributeList decrypted object containing the profile attributes @param decrypted_application_profile [Object] Protobuf AttributeList decrypted object containing profile attributes for the application profile @param extra_data [Yoti::Share::ExtraData|nil] Processed extra data object or nil

if absent from the receipt
# File lib/yoti/activity_details.rb, line 101
def initialize(receipt, decrypted_profile = nil, decrypted_application_profile = nil, extra_data = nil)
  @remember_me_id = receipt['remember_me_id']
  @user_id = @remember_me_id
  @receipt_id = receipt['receipt_id']
  @parent_remember_me_id = receipt['parent_remember_me_id']
  @outcome = receipt['sharing_outcome']
  @timestamp = receipt['timestamp'] ? Time.parse(receipt['timestamp']) : nil
  @extended_user_profile = process_decrypted_profile(decrypted_profile)
  @extended_application_profile = process_decrypted_profile(decrypted_application_profile)
  @extra_data = extra_data
  @user_profile = @extended_user_profile.transform_values(&:value)
end

Public Instance Methods

application_profile() click to toggle source

Profile of an application, with convenience methods to access well-known attributes

@return [ApplicationProfile]

# File lib/yoti/activity_details.rb, line 140
def application_profile
  Yoti::ApplicationProfile.new(@extended_application_profile)
end
profile() click to toggle source

The user profile with shared attributes and anchor information, returned by Yoti if the request was successful

@return [Profile]

# File lib/yoti/activity_details.rb, line 131
def profile
  Yoti::Profile.new(@extended_user_profile)
end
structured_postal_address() click to toggle source

The user's structured postal address as JSON

@deprecated replaced by Yoti::Profile#structured_postal_address

@return [Hash]

# File lib/yoti/activity_details.rb, line 121
def structured_postal_address
  user_profile['structured_postal_address']
end

Protected Instance Methods

process_age_verified(attribute) click to toggle source

Processes age verification

@deprecated will be removed in 2.0.0

@param [Yoti::Protobuf::Attrpubapi::Attribute] attribute

# File lib/yoti/activity_details.rb, line 200
def process_age_verified(attribute)
  @age_verified = attribute.value == 'true' if Yoti::AgeProcessor.is_age_verification(attribute.name)
end
process_attribute(attribute) click to toggle source

Converts protobuf attribute into Attribute

@param [Yoti::Protobuf::Attrpubapi::Attribute] attribute

@return [Attribute, nil]

# File lib/yoti/activity_details.rb, line 176
def process_attribute(attribute)
  # Application Logo can be empty, return nil when this occurs.
  return nil if attribute.name == Yoti::Attribute::APPLICATION_LOGO && attribute.value == ''

  attr_value = Yoti::Protobuf.value_based_on_content_type(attribute.value, attribute.content_type)
  attr_value = Yoti::Protobuf.value_based_on_attribute_name(attr_value, attribute.name)

  # Handle selfies for backwards compatibility.
  if attribute.name == Yoti::Attribute::SELFIE && attr_value.is_a?(Yoti::Image)
    @base64_selfie_uri = attr_value.base64_content
    attr_value = attr_value.content
  end

  anchors_list = Yoti::AnchorProcessor.new(attribute.anchors).process
  Yoti::Attribute.new(attribute.name, attr_value, anchors_list['sources'], anchors_list['verifiers'], anchors_list)
end
process_decrypted_profile(decrypted_profile) click to toggle source

Process the decrypted profile into key-value hash

@param [Yoti::Protobuf::Attrpubapi::AttributeList] decrypted_profile

@return [Hash]

# File lib/yoti/activity_details.rb, line 153
def process_decrypted_profile(decrypted_profile)
  return {} unless decrypted_profile.is_a?(Object)
  return {} unless decrypted_profile.respond_to?(:attributes)

  profile_data = {}
  decrypted_profile.attributes.each do |attribute|
    begin
      profile_data[attribute.name] = process_attribute(attribute)
      process_age_verified(attribute)
    rescue StandardError => e
      Yoti::Log.logger.warn("#{e.message} (Attribute: #{attribute.name})")
    end
  end
  profile_data
end