Ejemplo n.º 1
0
 private static void AddDisplayAttribute <T>(string name, string icon, BaseAttribute baseAttribute, DisplayAttributes displayAttributes)
 {
     if (baseAttribute is YotiAttribute <T> yotiAttribute)
     {
         displayAttributes.Add(name, icon, yotiAttribute.GetAnchors(), yotiAttribute.GetValue());
     }
 }
Ejemplo n.º 2
0
        private static DisplayAttributes CreateDisplayAttributes(ReadOnlyCollection <BaseAttribute> attributes)
        {
            var displayAttributes = new DisplayAttributes();

            foreach (var yotiAttribute in attributes)
            {
                switch (yotiAttribute.GetName())
                {
                case Yoti.Auth.Constants.UserProfile.FullNameAttribute:
                    // Do nothing - we are displaying this already
                    break;

                case Yoti.Auth.Constants.UserProfile.GivenNamesAttribute:
                    AddDisplayAttribute <string>("Given name", "yoti-icon-profile", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.FamilyNameAttribute:
                    AddDisplayAttribute <string>("Family name", "yoti-icon-profile", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.NationalityAttribute:
                    AddDisplayAttribute <string>("Nationality", "yoti-icon-nationality", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.PostalAddressAttribute:
                    AddDisplayAttribute <string>("Postal Address", "yoti-icon-address", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.StructuredPostalAddressAttribute:
                    AddDisplayAttribute <Dictionary <string, JToken> >("Structured Postal Address", "yoti-icon-address", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.PhoneNumberAttribute:
                    AddDisplayAttribute <string>("Mobile number", "yoti-icon-phone", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.EmailAddressAttribute:
                    AddDisplayAttribute <string>("Email address", "yoti-icon-email", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute:
                    AddDisplayAttribute <DateTime>("Date of birth", "yoti-icon-calendar", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.SelfieAttribute:
                    // Do nothing - we already display the selfie
                    break;

                case Yoti.Auth.Constants.UserProfile.GenderAttribute:
                    AddDisplayAttribute <string>("Gender", "yoti-icon-gender", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.DocumentDetailsAttribute:
                    AddDisplayAttribute <DocumentDetails>("Document Details", "yoti-icon-profile", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.DocumentImagesAttribute:
                    AddDisplayAttribute <List <Image> >("Document Images", "yoti-icon-profile", yotiAttribute, displayAttributes);
                    break;

                case Yoti.Auth.Constants.UserProfile.IdentityProfileReportAttribute:
                    AddDisplayAttribute <Dictionary <string, JToken> >("Identity Profile Report", "yoti-icon-profile", yotiAttribute, displayAttributes);
                    break;

                default:
                    if (yotiAttribute is YotiAttribute <string> stringAttribute)
                    {
                        if (stringAttribute.GetName().Contains(":"))
                        {
                            displayAttributes.Add(new DisplayAttribute("Age Verification/", "Age verified", "yoti-icon-verified", stringAttribute.GetAnchors(), stringAttribute.GetValue()));
                            break;
                        }

                        AddDisplayAttribute <string>(stringAttribute.GetName(), "yoti-icon-profile", yotiAttribute, displayAttributes);
                    }
                    break;
                }
            }

            return(displayAttributes);
        }