예제 #1
0
        ///////////////////////////////////////////////////     MAIN
        static async Task Main()
        {
            client.BaseAddress = new Uri(Constants.URL_BASE_PARAM);

            //RunAllAsync().GetAwaiter().GetResult();
            AuthRequestModel r1 = new AuthRequestModel()
            {
                ClientId = "Messenger", ClientPassword = "******"
            };
            GetDataRequestModel r2 = new GetDataRequestModel()
            {
                CustomerId = "00000102"
            };


            CloseOperationRequestModel r6 = new CloseOperationRequestModel()
            {
                AcceptTermsData = 322322, TransactionId = "asdasdasdw"
            };

            try
            {
                var abs = await GetResponseAsync("auth", r1); /////////// METHOD WITH JSONSERALIZER

                //AuthResponseModel authTest = await authRequest(r1);
                ShowAuth(abs);


                GetDataResponseModel getDataT = await GetDataResponseAsync("GetData", r2, abs);

                ShowGetData(getDataT);
                SendDataRequestModel r3 = new SendDataRequestModel()
                {
                    TransactionId = getDataT.TransactionId, UserEmail = "*****@*****.**", UserKeyword = "ABC"
                };


                SendDataResponseModel sendDataT = await SendDataResponseAsync("SendData", r3, abs.AuthKey);

                ShowSendData(sendDataT);

                GenerateSmsRequestModel r4 = new GenerateSmsRequestModel()
                {
                    TransactionId = sendDataT.TransactionId
                };

                GenerateSmsResponseModel generateSmsT = await GenerateSMSResponseAsync("GenerateSMS", r4, abs.AuthKey);

                ShowGenerateSms(generateSmsT);

                ValidateSmsRequestModel r5 = new ValidateSmsRequestModel()
                {
                    Code = "6666", TransactionId = generateSmsT.TransactionId
                };

                ValidateSmsResponseModel validateSmsT = await ValidateSMSResponseAsync("ValidateSMS", r5, abs.AuthKey);

                ShowValidateSms(validateSmsT);

                CloseOperationResponseModel closeOperationT = await CloseOperationResponseAsync("CloseOperation", r6, abs.AuthKey);

                ShowCloseOperation(closeOperationT);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
예제 #2
0
        private static async Task <SendDataResponseModel> SendDataResponseAsync(string requestname, SendDataRequestModel requestname2, string token)
        {
            //var clint = HttpClientFactory;
            var request   = new HttpRequestMessage(HttpMethod.Post, requestname);
            var serialize = JsonSerializer.Serialize(requestname2);

            //request.RequestUri = new Uri(Constants.URL_BASE_PARAM);
            //httpClientFactory cln = new Uri()

            request.Content = new StringContent(serialize, System.Text.Encoding.UTF8, "application/json");
            //request.Headers = new HttpRequestHeaders()
            //var clientIH = httpClientFactory.CreateClient("VerifyService"); //getClient
            //var clientIH = httpClientFactory.CreateClient("VerifyService");
            //client.BaseAddress = new Uri(Constants.URL_BASE_PARAM);
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            //clientIH.BaseAddress = new Uri(Constants.URL_BASE_PARAM);

            //var response = await clientIH.SendAsync(request);
            var response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                using var responseStream = await response.Content.ReadAsStreamAsync();//////////  INSPECTION POINT TO VISUALIZE THE VALUES OF INPUTS!!!!!!!

                var responseModel = await JsonSerializer.DeserializeAsync <SendDataResponseModel>(responseStream);

                return(responseModel);
            }
            else
            {
                // using var responseStream2 = await response.Content.ReadAsStreamAsync();
                // var responseModel = await JsonSerializer.DeserializeAsync<AuthResponseModel>(responseStream2);
                // return responseModel;
                return(new SendDataResponseModel()
                {
                    ResponseCode = (int)response.StatusCode
                });
                //return <AuthResponseModel> ;
            }
        }