public static async Task <bool> IsOtpSent(OTPRequestMobile otpModel)
        {
            bool isSent = false;

            _apiService = new ApiRequest();
            try
            {
                Random r        = new Random();
                var    response = await _apiService.Post <OTPRequestMobile>(otpModel, "", URLConstants.SwitchApiBaseUrl, "Spay/OTPRequestMobile", "Onboarding");

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    var val = JsonConvert.DeserializeObject <StatusMessage>(content);
                    if (val.response == "00")
                    {
                        isSent = true;
                    }
                    else
                    {
                        isSent = false;
                    }
                }
            }
            catch (Exception ex)
            {
                string log = ex.Message;
            }
            return(isSent);
        }
        public static async Task <bool> SendOTP()
        {
            bool result = false;

            try
            {
                var otpRequest = new OTPRequestMobile()
                {
                    mobile        = Customer.PhoneNumber,
                    Referenceid   = Utilities.GenerateReferenceId(),
                    RequestType   = 142,
                    Translocation = GetUserLocation,
                    email         = Customer.Email
                };

                string baseUrl  = URLConstants.SwitchApiLiveBaseUrl;
                string endpoint = "spay/OTPRequestMobile";
                string url      = baseUrl + endpoint;

                var apirequest = new ApiRequest();

                var request = await apirequest.Post(otpRequest, "", baseUrl, endpoint, "SendOTP()");

                var response = await request.Content.ReadAsStringAsync();

                if (!string.IsNullOrEmpty(response))
                {
                    var json = JsonConvert.DeserializeObject <StatusMessage>(response);
                    if (json.response == "00")
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            catch (Exception ex)
            {
                await BusinessLogic.Log(ex.ToString(), "exception response gotten for calling api ", "OTPRequestMobile ", "", "", "SendOTP()");

                result = false;
            }

            return(result);
        }
        private async void btnContinue_Clicked(object sender, System.EventArgs e)
        {
            if (BusinessLogic.IsConnectionOK() == true)
            {
                // proceed with process
                if (IsEntryValid() == true)
                {
                    var pd = await ProgressDialog.Show("Sending Request. Please Wait...");

                    var response = await _getUserInfo(txtUsername.Text);

                    if (response.Status == true)
                    {
                        var request = new OTPRequestMobile();
                        request.email  = response.UserEmail;
                        request.mobile = response.PhoneNumber;

                        var otpResponse = await _getCustomerotp(request);

                        await pd.Dismiss();

                        if (otpResponse.response == "00")
                        {
                            MessageDialog.Show("INFO", "An OTP has been sent to your registered phone number and email", DialogType.Info, "OK", null);
                            await Navigation.PushAsync(new  SetNewPinPage(response.PhoneNumber, response.UserEmail));
                        }
                        else
                        {
                            MessageDialog.Show("Error", "Sorry, We were unable to send you an OTP at he moment, kindly try again later.", PopUps.DialogType.Error, "Ok", null);
                        }
                    }
                    else
                    {
                        await pd.Dismiss();

                        MessageDialog.Show("Error", "Sorry, We were unable to find your username. Kindly verify that the username exists and try again.", PopUps.DialogType.Error, "Ok", null);
                    }
                }
            }
            else
            {
                MessageDialog.Show("OOPS", "Sorry, it appears you do not have internet connectivity on your device. Kindly reconnect and try again", DialogType.Error, "DISMISS", null);
                return;
            }
            // perform next opertion
        }
        private async Task <StatusMessage> _getCustomerotp(OTPRequestMobile request)
        {
            request.Referenceid   = Utilities.GenerateReferenceId();
            request.Translocation = "23499,8909090";
            request.RequestType   = 142;

            var otpResponse = await httpService.Post <OTPRequestMobile>(request, "", URLConstants.SwitchApiLiveBaseUrl, "Spay/OTPRequestMobile", "ForgotPassword");

            if (otpResponse.IsSuccessStatusCode)
            {
                var response = await otpResponse.Content.ReadAsStringAsync();

                var Message = JsonConvert.DeserializeObject <StatusMessage>(response);
                return(Message);
            }
            return(null);
        }
        async Task <bool> DoAccountVerification()
        {
            bool status = false;
            var  pd     = await ProgressDialog.Show("Processing Request..... Please wait.");

            Random r = new Random();

            r.Next(1000, 9999);
            var otpRequest = new OTPRequestMobile()
            {
                mobile        = _vm.WalletPhone,
                Referenceid   = "00055" + DateTime.Now.ToString("yymmddHHmmss") + r.Next().ToString(),
                RequestType   = 142,
                Translocation = GlobalStaticFields.GetUserLocation,
                email         = _vm.Email
            };
            // lets check if the user exist before now.
            var user = new UserAlreadyExist()
            {
                Phone     = _vm.WalletPhone,
                UserEmail = _vm.Email
            };
            var userResponse = await OnBoardingService.VerifyRegistrationStatus(user);

            if (userResponse == true) // value should be compared against true. this condition was changed on purpose for test
            {
                await pd.Dismiss();

                MessageDialog.Show("OOPS", "Sorry, It appears that you already onboarded. Kindly review your details and try again, or contact our switch support.", DialogType.Error, "DISMISS", null);
            }
            else
            {
                var otpresponse = await OnBoardingService.IsOtpSent(otpRequest);

                if (otpresponse)
                {
                    await pd.Dismiss();

                    MessageDialog.Show("SUCCESS", $"An OTP has been sent to your mobile number {phone} and Email {_vm.Email}", DialogType.Success, "OK", null);

                    status = true;
                }
            }
            return(status);
        }