Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. {
  2. "customer":{
  3. "msisdn":"5321234568"
  4. }
  5.  
  6. services.AddHttpClient<IBosApiClient, BosApiClient>();
  7.  
  8. public class BosApiClient : IBosApiClient
  9. {
  10. private readonly HttpClient httpClient;
  11. private readonly IConfiguration configuration;
  12.  
  13. public BosApiClient(HttpClient httpClient, IConfiguration configuration)
  14. {
  15. this.configuration = configuration;
  16. httpClient.DefaultRequestHeaders.Authorization = GetAuthenticationHeader();
  17. httpClient.BaseAddress = new Uri(configuration["API_BASE_URL"]);
  18. this.httpClient = httpClient;
  19. }
  20.  
  21. public async Task<CreateCustomerWithOtpResponse> CreateCustomerWithOtp(CreateCustomerWithOtpRequest request)
  22. {
  23. var requestBody = "{'customer':{'msisdn':'5321234568'}}";
  24. HttpContent content = new StringContent(requestBody, Encoding.UTF8, "application/json");
  25.  
  26. var responseMessage = await httpClient.PostAsync(httpClient.BaseAddress + "customers/otp", content);
  27.  
  28. var responseString = await responseMessage.Content.ReadAsStringAsync();
  29.  
  30. var response = JsonConvert.DeserializeObject<CreateCustomerWithOtpResponse>(responseString);
  31.  
  32. return response;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement