예제 #1
0
 public async Task EnqueueUpsertedItems(
     DateTime upsertedAfterUtc,
     FortnoxConfiguration configuration)
 {
     await EnqueueUpsertedCustomers(upsertedAfterUtc, configuration);
     await EnqueueUpsertedInvoices(upsertedAfterUtc, configuration);
 }
예제 #2
0
        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));
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
 public async Task SaveFortnoxConfiguration(FortnoxConfiguration configuration)
 {
     await FortnoxCollection.UpsertDocumentAsync(configuration);
 }
예제 #5
0
 public async Task DeleteFortnoxConfiguration(FortnoxConfiguration configuration)
 {
     await FortnoxCollection.DeleteDocumentAsync(configuration.SelfLink);
 }