/**
         * Set user address.
         */
        private async Task <APIGatewayProxyResponse> VerifyEmailWithDetails(IDataStores dataStores,
                                                                            IDictionary <string, string> requestHeaders,
                                                                            JObject requestBody)
        {
            Debug.Untested();
            Debug.AssertValid(dataStores);
            Debug.AssertValid(requestHeaders);
            Debug.AssertValidOrNull(requestBody);

            try {
                // Log call
                LoggingHelper.LogMessage($"UserIdentityService::VerifyEmailWithDetails()");

                // Get the NoSQL DB client
                AmazonDynamoDBClient dbClient = (AmazonDynamoDBClient)dataStores.GetNoSQLDataStore().GetDBClient();
                Debug.AssertValid(dbClient);

                // Check inputs
                VerifyEmailWithDetailsRequest verifyEmailWithDetailsRequest = UserIdentityService_VerifyEmailWithDetails_LogicLayer.CheckValidVerifyEmailWithDetailsRequest(requestBody);
                Debug.AssertValid(verifyEmailWithDetailsRequest);

                // Perform logic
                await UserIdentityService_VerifyEmailWithDetails_LogicLayer.VerifyEmailWithDetails(dbClient, verifyEmailWithDetailsRequest);

                // Respond
                return(new APIGatewayProxyResponse {
                    StatusCode = APIHelper.STATUS_CODE_NO_CONTENT
                });
            } catch (Exception exception) {
                Debug.Tested();
                return(APIHelper.ResponseFromException(exception));
            }
        }
        /**
         * Verify email with details.
         */
        private static async Task DoVerifyEmailWithDetails(AmazonDynamoDBClient dbClient, User user, Link link, VerifyEmailWithDetailsRequest verifyEmailWithDetailsRequest)
        {
            Debug.Untested();
            Debug.AssertValid(dbClient);
            Debug.AssertValid(user);
            Debug.AssertValid(link);
            Debug.AssertValid(verifyEmailWithDetailsRequest);

            // Make changes
            user.EmailAddressVerified = DateTime.Now;
            user.GivenName            = verifyEmailWithDetailsRequest.givenName;
            user.FamilyName           = verifyEmailWithDetailsRequest.familyName;
            user.PasswordHash         = Helper.Hash(verifyEmailWithDetailsRequest.password);
            user.DateOfBirth          = (DateTime)APIHelper.DateFromAPIDateString(verifyEmailWithDetailsRequest.dateOfBirth);
            user.Address1             = verifyEmailWithDetailsRequest.address1;
            user.Address2             = verifyEmailWithDetailsRequest.address2;
            user.Address3             = verifyEmailWithDetailsRequest.address3;
            user.Address4             = verifyEmailWithDetailsRequest.address4;
            user.City       = verifyEmailWithDetailsRequest.city;
            user.Region     = verifyEmailWithDetailsRequest.region;
            user.Country    = verifyEmailWithDetailsRequest.country;
            user.PostalCode = verifyEmailWithDetailsRequest.postalCode;
            user.AllowNonEssentialEmails = verifyEmailWithDetailsRequest.allowNonEssentialEmails;

            // Save the user
            await IdentityServiceDataLayer.SaveUser(dbClient, user);

            // Revoke the link
            link.Revoked = true;
            //??++SAVE LINK
        }
        /**
         * Verify email with details.
         */
        public static async Task VerifyEmailWithDetails(AmazonDynamoDBClient dbClient, VerifyEmailWithDetailsRequest verifyEmailWithDetailsRequest)
        {
            Debug.Untested();
            Debug.AssertValid(dbClient);
            Debug.AssertValid(verifyEmailWithDetailsRequest);
            Debug.AssertString(verifyEmailWithDetailsRequest.verifyEmailLinkId);
            Debug.AssertEmail(verifyEmailWithDetailsRequest.emailAddress);

            // Find a valid link
            Link link = await IdentityServiceLogicLayer.FindValidLink(dbClient, verifyEmailWithDetailsRequest.verifyEmailLinkId, IdentityServiceLogicLayer.LINK_TYPE_VERIFY_EMAIL_ADDRESS);

            Debug.AssertValidOrNull(link);
            if (link != null)
            {
                // Valid link exits
                Debug.Tested();
                Debug.AssertID(link.UserID);

                // Find user
                User user = await IdentityServiceLogicLayer.FindUserByID(dbClient, link.UserID);

                Debug.AssertValidOrNull(user);
                if (user != null)
                {
                    // User exists
                    Debug.Untested();
                    Debug.AssertEmail(user.EmailAddress);
                    Debug.AssertValidOrNull(user.EmailAddressVerified);

                    if (user.EmailAddressVerified == null)
                    {
                        // Email address not verified
                        Debug.Untested();

                        if (user.EmailAddress == verifyEmailWithDetailsRequest.emailAddress)
                        {
                            // Verifying correct email address
                            Debug.Untested();

                            // Change user and revoke link
                            await DoVerifyEmailWithDetails(dbClient, user, link, verifyEmailWithDetailsRequest);
                        }
                        else
                        {
                            Debug.Tested();
                            throw new Exception(SharedLogicLayer.ERROR_UNRECOGNIZED_EMAIL_ADDRESS, new Exception(SharedLogicLayer.ERROR_UNRECOGNIZED_EMAIL_ADDRESS));
                        }
                    }
                    else
                    {
                        Debug.Untested();
                        throw new Exception(IdentityServiceLogicLayer.ERROR_EMAIL_ALREADY_VERIFIED, new Exception(IdentityServiceLogicLayer.EMAIL_ALREADY_VERIFIED));
                    }
                }
                else
                {
                    // User does not exist (may have been deleted)
                    Debug.Untested();
                    throw new Exception(SharedLogicLayer.ERROR_INVALID_LINK_USER, new Exception(SharedLogicLayer.ERROR_INVALID_LINK_USER));
                }
            }
            else
            {
                Debug.Tested();
                throw new Exception(SharedLogicLayer.ERROR_INVALID_LINK, new Exception(SharedLogicLayer.ERROR_INVALID_LINK));
            }
        }