feat(xero): add xero integration
This commit is contained in:
18
packages/backend/src/apps/xero/common/add-auth-header.ts
Normal file
18
packages/backend/src/apps/xero/common/add-auth-header.ts
Normal 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;
|
9
packages/backend/src/apps/xero/common/auth-scope.ts
Normal file
9
packages/backend/src/apps/xero/common/auth-scope.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
const authScope: string[] = [
|
||||
'offline_access',
|
||||
'openid',
|
||||
'profile',
|
||||
'email',
|
||||
'accounting.transactions',
|
||||
];
|
||||
|
||||
export default authScope;
|
@@ -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;
|
Reference in New Issue
Block a user