Beispiel #1
0
        public async Task <PayOperatorResultDto> ValidadePayAtOperator(PayOperatorFilterDto payOperatorFilterDto)
        {
            var jsonContent = new StringContent(JsonConvert.SerializeObject(payOperatorFilterDto), Encoding.UTF8, "application/json");
            var postRequest = new PostMethodRequestDto(
                url: "https://5f53af5ee5de110016d51ae5.mockapi.io/api/v1/",
                method: "CreditCardPayment",
                bodyRequest: jsonContent
                );
            var postResult = HttpPostService.HttpPost(postRequest);
            var result     = new List <PayOperatorResultDto>();

            if (postResult.StatusCode == HttpStatusCode.Created)
            {
                result = JsonConvert.DeserializeObject <List <PayOperatorResultDto> >(postResult.ContentResult);
            }
            return(await Task.FromResult(result.FirstOrDefault()));
        }
        public async Task <PostMethodResultDto> CallPostMethod(MethodRequestDto webHookMethodRequestDto)
        {
            var jsonContent = new StringContent(JsonConvert.SerializeObject(webHookMethodRequestDto), Encoding.UTF8, "application/json");
            var postRequest = new PostMethodRequestDto(
                url: _webHookUrl,
                method: _webHookMethod,
                bodyRequest: jsonContent
                );
            var result    = HttpPostService.HttpPost(postRequest);
            var msgResult = (result.StatusCode == HttpStatusCode.OK)
                ? "Método executado com sucesso"
                : "Falha na execução do método";

            return(await Task.FromResult(new PostMethodResultDto
            {
                StatusCode = result.StatusCode,
                ContentResult = msgResult
            }));
        }