From 9e5047ddda11d262143f6da7d309c141bca9ddef Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:01:22 +0200 Subject: [PATCH] fix(integrations): add pagination for exact-online (#2565) ## Describe your changes Contributes to https://linear.app/nango/issue/NAN-1517/exact-online-templates - Add pagination for exact-online - Fix typo --- integration-templates/intercom/syncs/conversations.ts | 6 +++--- integration-templates/xero/syncs/accounts.ts | 4 ++-- integration-templates/xero/syncs/contacts.ts | 2 +- integration-templates/xero/syncs/items.ts | 2 +- packages/shared/providers.yaml | 5 +++++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/integration-templates/intercom/syncs/conversations.ts b/integration-templates/intercom/syncs/conversations.ts index 245ecda390..7b3f4bfbdc 100644 --- a/integration-templates/intercom/syncs/conversations.ts +++ b/integration-templates/intercom/syncs/conversations.ts @@ -18,7 +18,7 @@ export default async function fetchData(nango: NangoSync) { // Convert the last sync run date into a unix timestamp for easier comparison. const lastSyncDateTimestamp = nango.lastSyncDate ? nango.lastSyncDate.getTime() / 1000 : 0; - // We also define a max sync date for incremential syncs, which is conversations updated in the last X years + // We also define a max sync date for incremental syncs, which is conversations updated in the last X years const maxYearsToSync = 2; const maxSyncDate = new Date(); maxSyncDate.setFullYear(new Date().getFullYear() - maxYearsToSync); @@ -56,7 +56,7 @@ export default async function fetchData(nango: NangoSync) { const intercomConversationsPage: IntercomConversation[] = []; const intercomMessagesPage: IntercomConversationMessage[] = []; for (const conversation of resp.data.conversations) { - // For incremential syncs: Skip conversations that have not been updated since we last synced + // For incremental syncs: Skip conversations that have not been updated since we last synced // updated_at is a unix timestamp of the last change to the conversation (e.g. new message from customer, attribute changed) if (conversation.updated_at < lastSyncDateTimestamp) { continue; @@ -153,7 +153,7 @@ export default async function fetchData(nango: NangoSync) { finished = true; } - // 2.) We are in an incremential sync and the last conversation on the page is older than our last sync date + // 2.) We are in an incremental sync and the last conversation on the page is older than our last sync date if (lastSyncDateTimestamp > 0 && lastConversation.updated_at < lastSyncDateTimestamp) { finished = true; } diff --git a/integration-templates/xero/syncs/accounts.ts b/integration-templates/xero/syncs/accounts.ts index 559e951b51..13fa0543d6 100644 --- a/integration-templates/xero/syncs/accounts.ts +++ b/integration-templates/xero/syncs/accounts.ts @@ -15,7 +15,7 @@ export default async function fetchData(nango: NangoSync): Promise { } }; - // If it is an incremential sync, only fetch the changed accounts + // If it is an incremental sync, only fetch the changed accounts if (nango.lastSyncDate) { config.headers['If-Modified-Since'] = nango.lastSyncDate.toISOString().replace(/\.\d{3}Z$/, ''); // Returns yyyy-mm-ddThh:mm:ss } @@ -28,7 +28,7 @@ export default async function fetchData(nango: NangoSync): Promise { const mappedActiveContacts = activeAccounts.map(mapXeroAccount); await nango.batchSave(mappedActiveContacts, 'Account'); - // If it is an incremential refresh, mark archived contacts as deleted + // If it is an incremental refresh, mark archived contacts as deleted if (nango.lastSyncDate) { const archivedAccounts = accounts.filter((x: any) => x.Status === 'ARCHIVED'); const mappedArchivedAccounts = archivedAccounts.map(mapXeroAccount); diff --git a/integration-templates/xero/syncs/contacts.ts b/integration-templates/xero/syncs/contacts.ts index 1b5a90b35e..9f30811659 100644 --- a/integration-templates/xero/syncs/contacts.ts +++ b/integration-templates/xero/syncs/contacts.ts @@ -19,7 +19,7 @@ export default async function fetchData(nango: NangoSync): Promise { await nango.log(`Last sync date - type: ${typeof nango.lastSyncDate} JSON value: ${JSON.stringify(nango.lastSyncDate)}`); - // If it is an incremential sync, only fetch the changed contacts + // If it is an incremental sync, only fetch the changed contacts if (nango.lastSyncDate) { config.params.includeArchived = 'true'; config.headers['If-Modified-Since'] = nango.lastSyncDate.toISOString().replace(/\.\d{3}Z$/, ''); // Returns yyyy-mm-ddThh:mm:ss diff --git a/integration-templates/xero/syncs/items.ts b/integration-templates/xero/syncs/items.ts index db184dece8..ae3b408fbd 100644 --- a/integration-templates/xero/syncs/items.ts +++ b/integration-templates/xero/syncs/items.ts @@ -13,7 +13,7 @@ export default async function fetchData(nango: NangoSync): Promise { } }; - // If it is an incremential sync, only fetch the changed payments + // If it is an incremental sync, only fetch the changed payments if (nango.lastSyncDate) { config.headers['If-Modified-Since'] = nango.lastSyncDate.toISOString().replace(/\.\d{3}Z$/, ''); // Returns yyyy-mm-ddThh:mm:ss } diff --git a/packages/shared/providers.yaml b/packages/shared/providers.yaml index c0c2af2da8..f247ec20f0 100644 --- a/packages/shared/providers.yaml +++ b/packages/shared/providers.yaml @@ -841,6 +841,11 @@ exact-online: refresh_params: grant_type: refresh_token token_expiration_buffer: 30 + proxy: + base_url: https://start.exactonline.${connectionConfig.extension}/ + paginate: + type: link + link_path_in_response_body: d.__next docs: https://docs.nango.dev/integrations/all/exact-online exist: categories: