public async Task EnqueueUpsertedItems( DateTime upsertedAfterUtc, FortnoxConfiguration configuration) { await EnqueueUpsertedCustomers(upsertedAfterUtc, configuration); await EnqueueUpsertedInvoices(upsertedAfterUtc, configuration); }
internal static async Task <FortnoxDataCopier> Create( ILogger logger, WebcrmClientFactory webcrmClientFactory, FortnoxConfiguration configuration) { var webcrmClient = await webcrmClientFactory.Create(configuration.WebcrmApiKey); var fortnoxApiKeys = new FortnoxApiKeys(configuration.FortnoxAccessToken, configuration.FortnoxClientSecret); return(new FortnoxDataCopier(logger, fortnoxApiKeys, webcrmClient)); }
internal async Task EnqueueUpsertedInvoices( DateTime upsertedAfterUtc, FortnoxConfiguration configuration) { var fortnoxApiKeys = new FortnoxApiKeys(configuration.FortnoxAccessToken, configuration.FortnoxClientSecret); var fortnoxClient = new FortnoxClient(fortnoxApiKeys); // Convert utc date we pass in to either CEST or CET. var dateTimeSinceUpsertedSwedish = upsertedAfterUtc.FromUtcToSwedish(); var upsertedInvoices = await fortnoxClient.GetRecentlyUpsertedInvoices(dateTimeSinceUpsertedSwedish); Logger.LogInformation($"Found {upsertedInvoices.Count} upserted invoices in Fortnox upserted since {dateTimeSinceUpsertedSwedish:yyyy-MM-dd HH:mm:ss}."); foreach (var invoice in upsertedInvoices) { var payload = new UpsertDeliveryFromFortnoxPayload(invoice.CustomerNumber, invoice.DocumentNumber, configuration.WebcrmSystemId); await FortnoxQueue.Enqueue(new FortnoxQueueMessage(FortnoxQueueAction.UpsertFortnoxDelivery, payload)); } }
public async Task SaveFortnoxConfiguration(FortnoxConfiguration configuration) { await FortnoxCollection.UpsertDocumentAsync(configuration); }
public async Task DeleteFortnoxConfiguration(FortnoxConfiguration configuration) { await FortnoxCollection.DeleteDocumentAsync(configuration.SelfLink); }