-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (wip) add sync logic for accounts
- Loading branch information
1 parent
936095a
commit 7e3fe23
Showing
8 changed files
with
111 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,53 @@ | ||
import {initXeroSDK} from '@opensdks/sdk-xero' | ||
import type {ConnectorServer} from '@usevenice/cdk' | ||
import type {xeroSchemas} from './def' | ||
import {nangoProxyLink} from '@usevenice/cdk' | ||
import {rxjs} from '@usevenice/util' | ||
import {type xeroSchemas} from './def' | ||
|
||
export const xeroServer = { | ||
newInstance: ({settings}) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
newInstance: ({settings, fetchLinks}) => { | ||
const xero = initXeroSDK({ | ||
headers: {authorization: `Bearer ${settings.access_token}`}, | ||
headers: { | ||
authorization: `Bearer ${settings.oauth.credentials.access_token}`, | ||
}, | ||
links: (defaultLinks) => [ | ||
(req, next) => { | ||
if (xero.clientOptions.baseUrl) { | ||
req.headers.set( | ||
nangoProxyLink.kBaseUrlOverride, | ||
xero.clientOptions.baseUrl, | ||
) | ||
} | ||
return next(req) | ||
}, | ||
...fetchLinks, | ||
...defaultLinks, | ||
], | ||
}) | ||
// TODO(@jatin): Add logic here to handle sync. | ||
return xero | ||
}, | ||
sourceSync: ({instance: xero}) => { | ||
// TODO(@jatin): Add logic here to handle sync. | ||
// TODO: ensure instance has typesafety for some reason the types are not present here :/. | ||
console.log('[xero] Starting sync', xero) | ||
const getAll = async () => { | ||
const result = await xero.client.GET('/Accounts', { | ||
params: { | ||
header: { | ||
'xero-tenant-id': '35325d8f-5087-4c6d-b413-c3f740c26f2e', // TODO: Remove hardcoding | ||
}, | ||
}, | ||
}) | ||
console.log('result', result) | ||
return result.data?.Accounts | ||
} | ||
|
||
getAll() | ||
.then((res) => console.log('[data test]', res)) | ||
.catch((err) => console.log('error', err)) | ||
|
||
return rxjs.empty() | ||
}, | ||
} satisfies ConnectorServer<typeof xeroSchemas> | ||
|
||
export default xeroServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.