Created
January 11, 2021 13:47
-
-
Save rahulsahay19/d74c1d6e1e822a4e55099eb944185642 to your computer and use it in GitHub Desktop.
httpClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BookMyEvent.Services.ShoppingCart.DTOs; | |
using BookMyEvent.Services.ShoppingCart.Extensions; | |
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace BookMyEvent.Services.ShoppingCart.Services | |
{ | |
public class DiscountService : IDiscountService | |
{ | |
private readonly HttpClient _httpClient; | |
public DiscountService(HttpClient httpClient) | |
{ | |
_httpClient = httpClient; | |
} | |
public async Task<Coupon> GetCoupon(Guid userId) | |
{ | |
var response = await _httpClient.GetAsync($"/api/discount/user/{userId}"); | |
if (!response.IsSuccessStatusCode) | |
{ | |
return null; | |
} | |
return await response.ReadContentAs<Coupon>(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment