first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
IHttpRequestOptions,
|
||||
INodeCredentialTestResult,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
async function validateCredentials(
|
||||
this: ICredentialTestFunctions,
|
||||
decryptedCredentials: ICredentialDataDecryptedObject,
|
||||
): Promise<any> {
|
||||
const credentials = decryptedCredentials;
|
||||
|
||||
const { subdomain, apiKey } = credentials as {
|
||||
subdomain: string;
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
const options: IHttpRequestOptions = {
|
||||
method: 'GET',
|
||||
auth: {
|
||||
username: apiKey,
|
||||
password: 'x',
|
||||
},
|
||||
url: `https://api.bamboohr.com/api/gateway.php/${subdomain}/v1/employees/directory`,
|
||||
};
|
||||
|
||||
return await this.helpers.request(options);
|
||||
}
|
||||
|
||||
export async function bambooHrApiCredentialTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
try {
|
||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: 'The API Key included in the request is invalid',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Connection successful!',
|
||||
} as INodeCredentialTestResult;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * as loadOptions from './loadOptions';
|
||||
export * as credentialTest from './credentialTest';
|
||||
@@ -0,0 +1,187 @@
|
||||
import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../transport';
|
||||
|
||||
// Get all the available channels
|
||||
export async function getTimeOffTypeID(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'meta/time_off/types';
|
||||
|
||||
const response = await apiRequest.call(this, requestMethod, endPoint, body);
|
||||
const timeOffTypeIds = response.body.timeOffTypes;
|
||||
|
||||
for (const item of timeOffTypeIds) {
|
||||
returnData.push({
|
||||
name: item.name,
|
||||
value: item.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
const sort = (a, b) => {
|
||||
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
export async function getCompanyFileCategories(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'files/view/';
|
||||
|
||||
const response = await apiRequest.call(this, requestMethod, endPoint, body);
|
||||
const categories = response.categories;
|
||||
|
||||
for (const category of categories) {
|
||||
returnData.push({
|
||||
name: category.name,
|
||||
value: category.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getEmployeeDocumentCategories(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const id = this.getCurrentNodeParameter('employeeId') as string;
|
||||
|
||||
const endPoint = `employees/${id}/files/view/`;
|
||||
|
||||
const response = await apiRequest.call(this, requestMethod, endPoint, body);
|
||||
const categories = response.categories;
|
||||
|
||||
for (const category of categories) {
|
||||
returnData.push({
|
||||
name: category.name,
|
||||
value: category.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getEmployeeLocations(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'meta/lists/';
|
||||
|
||||
//do not request all data?
|
||||
const fields = (await apiRequest.call(this, requestMethod, endPoint, body, {})) as [
|
||||
{ fieldId: number; options: [{ id: number; name: string }] },
|
||||
];
|
||||
|
||||
const options = fields.filter((field) => field.fieldId === 18)[0].options;
|
||||
|
||||
for (const option of options) {
|
||||
returnData.push({
|
||||
name: option.name,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getDepartments(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'meta/lists/';
|
||||
|
||||
//do not request all data?
|
||||
const fields = (await apiRequest.call(this, requestMethod, endPoint, body, {})) as [
|
||||
{ fieldId: number; options: [{ id: number; name: string }] },
|
||||
];
|
||||
|
||||
const options = fields.filter((field) => field.fieldId === 4)[0].options;
|
||||
|
||||
for (const option of options) {
|
||||
returnData.push({
|
||||
name: option.name,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getDivisions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'meta/lists/';
|
||||
|
||||
//do not request all data?
|
||||
const fields = (await apiRequest.call(this, requestMethod, endPoint, body, {})) as [
|
||||
{ fieldId: number; options: [{ id: number; name: string }] },
|
||||
];
|
||||
|
||||
const options = fields.filter((field) => field.fieldId === 1355)[0].options;
|
||||
|
||||
for (const option of options) {
|
||||
returnData.push({
|
||||
name: option.name,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getEmployeeFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const endPoint = 'employees/directory';
|
||||
|
||||
const { fields } = await apiRequest.call(this, requestMethod, endPoint, body);
|
||||
|
||||
for (const field of fields) {
|
||||
returnData.push({
|
||||
name: field.name || field.id,
|
||||
value: field.id,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort(sort);
|
||||
|
||||
returnData.unshift({
|
||||
name: '[All]',
|
||||
value: 'all',
|
||||
});
|
||||
|
||||
return returnData;
|
||||
}
|
||||
Reference in New Issue
Block a user