public static async Task <List <MiddlewareResponse> > CreateBulkInvoiceMiddlewareAsync(AuthenticationProvider authenticationProvider, List <OrderResource> orders) { try { List <MiddlewareResponse> result = new List <MiddlewareResponse>(); // Create the HTTP client to perform the request using (HttpClient client = new HttpClient()) { await authenticationProvider.SetAccessTokenAsync(client); foreach (var order in orders) { InvoiceProcessResource resource = Mappers.ToInvoiceProcess(order); string res = await MiddlewareController.InsertInvoiceToIEAsync(client, resource); MiddlewareResponse r = JsonSerializer.Deserialize <MiddlewareResponse>(res); result.Add(r); } } return(result); } catch (Exception exception) { throw new Exception(exception.Message); } }
public static async Task <string> CreateInvoiceMiddlewareAsync(AuthenticationProvider authenticationProvider, OrderResource order) { try { // Converter objeto order para invoice InvoiceProcessResource resource = Mappers.ToInvoiceProcess(order); // Inserir invoice do IE return(await MiddlewareController.InsertInvoiceToIEAsync(authenticationProvider, resource).ConfigureAwait(false)); } catch (Exception exception) { throw new Exception(exception.Message); } }