public async Task <ActionResult <CouponData> > CheckCouponAsync(string code)
        {
            var response = await _coupon.CheckCouponByCodeNumberAsync(code);

            if (!response.IsSuccessStatusCode)
            {
                return(NotFound());
            }

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

            var data = JsonConvert.DeserializeObject <CouponData>(couponResponse);

            return(Ok(data));
        }
        public async Task <ActionResult <CouponData> > CheckCouponAsync(string code)
        {
            _logger.LogInformation("----- Getting discount coupon: {Code}", code);

            var response = await _coupon.CheckCouponByCodeNumberAsync(code);

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

                if (string.IsNullOrWhiteSpace(content))
                {
                    return(StatusCode((int)response.StatusCode));
                }

                if ((int)response.StatusCode == 404)
                {
                    _logger.LogWarning("----- Coupon not found: {StatusCode} - Content: {Message}", (int)response.StatusCode, content);

                    return(StatusCode((int)response.StatusCode, content));
                }

                if (content.IndexOf('\n') > -1)
                {
                    var line = content.Substring(0, content.IndexOf('\n')).Trim();
                    _logger.LogWarning("----- Error getting discount coupon: {StatusCode} ({ReasonPhrase}) - Content: {Message}", (int)response.StatusCode, response.ReasonPhrase, line);

                    if (ExceptionRegex.IsMatch(line))
                    {
                        var message = ExceptionRegex.Match(content).Groups[1];
                        return(StatusCode((int)response.StatusCode, message));
                    }
                    else
                    {
                        return(StatusCode((int)response.StatusCode, line));
                    }
                }
            }

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

            var data = JsonConvert.DeserializeObject <CouponData>(couponResponse);

            _logger.LogInformation("----- Received discount coupon: {Code} ({@Coupon})", code, data);

            return(Ok(data));
        }