示例#1
0
        private void p0_btn_SendVerifyPin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(p0_txtBox_VerifyPin.Text))
            {
                MessageBox.Show("Verification PIN could not be empty.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }
            if (p0_txtBox_VerifyPin.Text.Length != Config.VerifyPinLength)
            {
                MessageBox.Show($"Verification PIN must have a length of {Config.VerifyPinLength} digits.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }
            int intTest;

            if (!int.TryParse(p0_txtBox_VerifyPin.Text, out intTest))
            {
                MessageBox.Show($"Verification PIN must be a {Config.VerifyPinLength} digit number.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }

            var verifyPinBody = new VerifyPinBody
            {
                pin = p0_txtBox_VerifyPin.Text
            };

            try
            {
                var pinVerificationResponse = new UweR70_PostCallWithNonEmptyBody().VerifyClientPIN(BaseData, verifyPinBody).Result;
                MessageBox.Show($"Verification succeeded:\r\nl{pinVerificationResponse.message}", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                var errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    errorMessage = ex.InnerException.Message;
                }
                MessageBox.Show(
                    "Verification error:\r\n" +
                    $"{errorMessage}\r\n" +
                    "\r\n" +
                    "Consider that the verification PIN expired already.\r\n" +
                    "Try to login again, wait for a new verification PIN\r\n" +
                    "and try again with the new PIN.",
                    Config.TitleAppNameAndVersion,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
        public async Task <PinVerificationResponse> VerifyClientPIN(BaseData baseData, VerifyPinBody verifyPinBody)
        {
            //  @POST("https://rest-{tier}.immedia-semi.com/api/v4/account/{account}/client/{client}/pin/verify/")
            //  Observable<PinVerificationResponse> verifyClientPIN(@Path("tier") String paramString, @Path("account") long paramLong1, @Path("client") long paramLong2, @Body VerifyPinBody paramVerifyPinBody);
            var uri       = $"https://rest-{baseData.RegionTier}.immedia-semi.com/api/v4/account/{baseData.AccountId}/client/{baseData.ClientId}/pin/verify";
            var retString = await FirePostCallAsync(uri, verifyPinBody, baseData.AuthToken);

            var ret = JsonConvert.DeserializeObject <PinVerificationResponse>(retString);

            return(ret);
        }