public async Task <IActionResult> ConnectionAsync( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Authorization/Connection")] HttpRequest req , ILogger log ) { var xeroToken = await _tokenStore.GetStoredToken(); var tenants = await _client.GetConnectionsAsync(xeroToken); return(new JsonResult(tenants)); }
/// <summary> /// Get Invoice details from Xero and convert them to Cosmos DB document entity /// </summary> /// <param name="eg"></param> /// <returns></returns> private async Task <IEnumerable <InvoiceEntity> > GetInvoicesAsync(IGrouping <Guid, Event> eg) { var tenantId = eg.Key.ToString(); var token = await _tokenStore.GetStoredToken(tenantId); var invoiceIds = eg.Select(e => e.ResourceId).ToList(); var response = await _accountingApi.GetInvoicesAsync(token.AccessToken, tenantId, iDs : invoiceIds); return(response._Invoices.Select(i => { var inv = i.IsOrMap <InvoiceEntity>(); inv.Id = i.InvoiceID?.ToString(); inv.Pk = tenantId; return inv; })); }