Skip to content

Commit

Permalink
fix(integrations): add pagination for exact-online (NangoHQ#2565)
Browse files Browse the repository at this point in the history
## Describe your changes

Contributes to
https://linear.app/nango/issue/NAN-1517/exact-online-templates

- Add pagination for exact-online
- Fix typo
  • Loading branch information
bodinsamuel authored Jul 30, 2024
1 parent 23a32dd commit 9e5047d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions integration-templates/intercom/syncs/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions integration-templates/xero/syncs/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function fetchData(nango: NangoSync): Promise<void> {
}
};

// 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
}
Expand All @@ -28,7 +28,7 @@ export default async function fetchData(nango: NangoSync): Promise<void> {
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);
Expand Down
2 changes: 1 addition & 1 deletion integration-templates/xero/syncs/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async function fetchData(nango: NangoSync): Promise<void> {

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
Expand Down
2 changes: 1 addition & 1 deletion integration-templates/xero/syncs/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function fetchData(nango: NangoSync): Promise<void> {
}
};

// 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
}
Expand Down
5 changes: 5 additions & 0 deletions packages/shared/providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9e5047d

Please sign in to comment.