/////////////////////////////////////////////////// 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(); }
//static HttpClient client = new HttpClient(); //private static readonly IHttpClientFactory httpClientFactory; //HttpClient httpClientFactory; //client.BaseAddress = new Uri(Constants.URL_BASE_PARAM); private static async Task <AuthResponseModel> GetResponseAsync(string requestname, AuthRequestModel parameter) { //var clint = HttpClientFactory; var request = new HttpRequestMessage(HttpMethod.Post, requestname); var serialize = JsonSerializer.Serialize(parameter); //request.RequestUri = new Uri(Constants.URL_BASE_PARAM); //httpClientFactory cln = new Uri() request.Content = new StringContent(serialize, System.Text.Encoding.UTF8, "application/json"); //var clientIH = httpClientFactory.CreateClient("VerifyService"); //getClient //var clientIH = httpClientFactory.CreateClient("VerifyService"); //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 <AuthResponseModel>(responseStream); return(responseModel); } else { // using var responseStream2 = await response.Content.ReadAsStreamAsync(); // var responseModel = await JsonSerializer.DeserializeAsync<AuthResponseModel>(responseStream2); // return responseModel; return(new AuthResponseModel() { ResponseCode = (int)response.StatusCode }); //return <AuthResponseModel> ; } }