feat(xero): add xero integration

This commit is contained in:
Rıdvan Akca
2023-11-08 14:46:44 +03:00
parent 373d29eeab
commit 9200e1011b
13 changed files with 242 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
return requestConfig;
if ($.auth.data?.accessToken) {
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
}
if ($.auth.data?.tenantId) {
requestConfig.headers['Xero-tenant-id'] = $.auth.data.tenantId as string;
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -0,0 +1,9 @@
const authScope: string[] = [
'offline_access',
'openid',
'profile',
'email',
'accounting.transactions',
];
export default authScope;

View File

@@ -0,0 +1,8 @@
import { IGlobalVariable } from '@automatisch/types';
const getCurrentUser = async ($: IGlobalVariable) => {
const { data: currentUser } = await $.http.get('/connections');
return currentUser[0];
};
export default getCurrentUser;