lib/yoti/activity_details.rb in yoti-1.2.1 vs lib/yoti/activity_details.rb in yoti-1.3.0
- old
+ new
@@ -21,26 +21,41 @@
# @param receipt [Hash] the receipt from the API request
# @param decrypted_profile [Object] Protobuf AttributeList decrypted object containing the profile attributes
def initialize(receipt, decrypted_profile = nil)
@decrypted_profile = decrypted_profile
@user_profile = {}
+ @extended_profile = {}
- if !@decrypted_profile.nil? && @decrypted_profile.respond_to_has_and_present?(:attributes)
+ if @decrypted_profile.is_a?(Object) && @decrypted_profile.respond_to?(:attributes)
@decrypted_profile.attributes.each do |field|
@user_profile[field.name] = Yoti::Protobuf.value_based_on_content_type(field.value, field.content_type)
+ anchor_processor = Yoti::AnchorProcessor.new(field.anchors)
+ anchors_list = anchor_processor.process
if field.name == 'selfie'
@base64_selfie_uri = Yoti::Protobuf.image_uri_based_on_content_type(field.value, field.content_type)
end
- # check if the key matches the format age_[over|under]:[1-999]
- if /age_(over|under):[1-9][0-9]?[0-9]?/.match?(field.name)
+
+ if Yoti::AgeProcessor.is_age_verification(field.name)
@age_verified = field.value == 'true'
end
+
+ @extended_profile[field.name] = Yoti::Attribute.new(field.name, field.value, anchors_list['sources'], anchors_list['verifiers'])
end
end
@user_id = receipt['remember_me_id']
@outcome = receipt['sharing_outcome']
+ end
+
+ # @return [Hash] a JSON of the address
+ def structured_postal_address
+ @user_profile['structured_postal_address']
+ end
+
+ # @return [Profile] of Yoti user
+ def profile
+ return Yoti::Profile.new(@extended_profile)
end
end
end