@orchesty/connector-calendly 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +190 -0
  3. package/coverage/clover.xml +115 -0
  4. package/coverage/coverage-final.json +6 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +161 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +210 -0
  13. package/coverage/lcov-report/src/Batch/CalendlyListEventsBatch.ts.html +316 -0
  14. package/coverage/lcov-report/src/Batch/index.html +116 -0
  15. package/coverage/lcov-report/src/CalendlyApplication.ts.html +334 -0
  16. package/coverage/lcov-report/src/Connector/CalendlyGetUserConnector.ts.html +220 -0
  17. package/coverage/lcov-report/src/Connector/CalendlyInviteUserConnector.ts.html +220 -0
  18. package/coverage/lcov-report/src/Connector/index.html +131 -0
  19. package/coverage/lcov-report/src/index.html +116 -0
  20. package/coverage/lcov-report/test/dataProvider.ts.html +190 -0
  21. package/coverage/lcov-report/test/index.html +116 -0
  22. package/coverage/lcov.info +172 -0
  23. package/dist/Batch/CalendlyListEventsBatch.d.ts +7 -0
  24. package/dist/Batch/CalendlyListEventsBatch.js +28 -0
  25. package/dist/CalendlyApplication.d.ts +19 -0
  26. package/dist/CalendlyApplication.js +98 -0
  27. package/dist/Connector/CalendlyGetUserConnector.d.ts +24 -0
  28. package/dist/Connector/CalendlyGetUserConnector.js +23 -0
  29. package/dist/Connector/CalendlyInviteUserConnector.d.ts +22 -0
  30. package/dist/Connector/CalendlyInviteUserConnector.js +23 -0
  31. package/dist/package.json +22 -0
  32. package/jest.config.js +13 -0
  33. package/package.json +22 -0
  34. package/src/Batch/CalendlyListEventsBatch.ts +77 -0
  35. package/src/Batch/__tests__/CalendlyListEventsBatch.ts +17 -0
  36. package/src/Batch/__tests__/Data/CalendlyListEventsBatch/input.json +6 -0
  37. package/src/Batch/__tests__/Data/CalendlyListEventsBatch/mock.json +45 -0
  38. package/src/Batch/__tests__/Data/CalendlyListEventsBatch/output.json +11 -0
  39. package/src/CalendlyApplication.ts +83 -0
  40. package/src/Connector/CalendlyGetUserConnector.ts +45 -0
  41. package/src/Connector/CalendlyInviteUserConnector.ts +45 -0
  42. package/src/Connector/__tests__/CalendlyGetUserConnector.ts +17 -0
  43. package/src/Connector/__tests__/CalendlyInviteUserConnector.ts +17 -0
  44. package/src/Connector/__tests__/Data/CalendlyGetUserConnector/input.json +8 -0
  45. package/src/Connector/__tests__/Data/CalendlyGetUserConnector/mock.json +18 -0
  46. package/src/Connector/__tests__/Data/CalendlyGetUserConnector/output.json +19 -0
  47. package/src/Connector/__tests__/Data/CalendlyInviteUserConnector/input.json +9 -0
  48. package/src/Connector/__tests__/Data/CalendlyInviteUserConnector/mock.json +15 -0
  49. package/src/Connector/__tests__/Data/CalendlyInviteUserConnector/output.json +16 -0
  50. package/test/dataProvider.ts +35 -0
  51. package/tsconfig.json +8 -0
  52. package/tsconfig.prod.json +13 -0
  53. package/tsconfig.prod.tsbuildinfo +1 -0
@@ -0,0 +1,77 @@
1
+ import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
4
+
5
+ export const NAME = 'calendly-list-events-batch';
6
+
7
+ export default class CalendlyListEventsBatch extends ABatchNode {
8
+
9
+ public getName(): string {
10
+ return NAME;
11
+ }
12
+
13
+ public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
14
+ const token = dto.getBatchCursor('');
15
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
16
+ const req = await this.getApplication().getRequestDto(
17
+ dto,
18
+ appInstall,
19
+ HttpMethods.GET,
20
+ `scheduled_events${token}`,
21
+ );
22
+ const resp = await this.getSender().send<IResponse>(req, [200]);
23
+ const response = resp.getJsonBody();
24
+
25
+ dto.setItemList(response.collection ?? []);
26
+ if (response.pagination.next_page_token) {
27
+ const nextToken = `?page_token=${response.pagination.next_page_token}`;
28
+ dto.setBatchCursor(nextToken);
29
+ }
30
+
31
+ return dto;
32
+ }
33
+
34
+ }
35
+
36
+ /* eslint-disable @typescript-eslint/naming-convention */
37
+
38
+ interface IResponse {
39
+ collection: IOutput[];
40
+ pagination: {
41
+ count: number;
42
+ next_page: string;
43
+ previous_page: string;
44
+ next_page_token: string;
45
+ previous_page_token: string;
46
+ };
47
+ }
48
+
49
+ interface IOutput {
50
+ uri: string;
51
+ name: string;
52
+ status: string;
53
+ start_time: Date;
54
+ end_time: Date;
55
+ event_type: string;
56
+ location: {
57
+ type: string;
58
+ location: string;
59
+ };
60
+ invitees_counter: {
61
+ total: number;
62
+ active: number;
63
+ limit: number;
64
+ };
65
+ created_at: Date;
66
+ updated_at: Date;
67
+ event_memberships: {
68
+ user: string;
69
+ }[];
70
+ event_guests: {
71
+ email: string;
72
+ created_at: Date;
73
+ updated_at: Date;
74
+ }[];
75
+ }
76
+
77
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,17 @@
1
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
+ import init from '../../../test/dataProvider';
4
+ import { NAME as CALENDLY_LIST_EVENTS_BATCH } from '../CalendlyListEventsBatch';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for CalendlyListEventsBatch', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testBatch(CALENDLY_LIST_EVENTS_BATCH);
16
+ });
17
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {}
6
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "http": "GET https://api.calendly.com/scheduled_events",
3
+ "code": 200,
4
+ "body": {
5
+ "collection": [
6
+ {
7
+ "uri": "https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2",
8
+ "name": "15 Minute Meeting",
9
+ "status": "active",
10
+ "start_time": "2019-08-24T14:15:22.123456Z",
11
+ "end_time": "2019-08-24T14:15:22.123456Z",
12
+ "event_type": "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2",
13
+ "location": {
14
+ "type": "physical",
15
+ "location": "Calendly Office"
16
+ },
17
+ "invitees_counter": {
18
+ "total": 0,
19
+ "active": 0,
20
+ "limit": 0
21
+ },
22
+ "created_at": "2019-01-02T03:04:05.092125Z",
23
+ "updated_at": "2019-01-02T03:04:05.092125Z",
24
+ "event_memberships": [
25
+ {
26
+ "user": "https://api.calendly.com/users/GBGBDCAADAEDCRZ2"
27
+ }
28
+ ],
29
+ "event_guests": [
30
+ {
31
+ "email": "user@example.com",
32
+ "created_at": "2022-04-21T17:10:48.484945Z",
33
+ "updated_at": "2022-04-21T17:11:01.758636Z"
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "pagination": {
39
+ "count": 1,
40
+ "next_page": "https://api.calendly.com/scheduled_events?count=1&page_token=sNjq4TvMDfUHEl7zHRR0k0E1PCEJWvdi",
41
+ "previous_page": "https://api.calendly.com/scheduled_events?count=1&page_token=VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H",
42
+ "previous_page_token": "VJs2rfDYeY8ahZpq0QI1O114LJkNjd7H"
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"uri\":\"https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2\",\"name\":\"15 Minute Meeting\",\"status\":\"active\",\"start_time\":\"2019-08-24T14:15:22.123456Z\",\"end_time\":\"2019-08-24T14:15:22.123456Z\",\"event_type\":\"https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2\",\"location\":{\"type\":\"physical\",\"location\":\"Calendly Office\"},\"invitees_counter\":{\"total\":0,\"active\":0,\"limit\":0},\"created_at\":\"2019-01-02T03:04:05.092125Z\",\"updated_at\":\"2019-01-02T03:04:05.092125Z\",\"event_memberships\":[{\"user\":\"https://api.calendly.com/users/GBGBDCAADAEDCRZ2\"}],\"event_guests\":[{\"email\":\"user@example.com\",\"created_at\":\"2022-04-21T17:10:48.484945Z\",\"updated_at\":\"2022-04-21T17:11:01.758636Z\"}]}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,83 @@
1
+ import CoreFormsEnum, { getFormName } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
2
+ import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
3
+ import Field from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field';
4
+ import FieldType from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType';
5
+ import Form from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form';
6
+ import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
7
+ import AOAuth2Application from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application';
8
+ import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
9
+ import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
10
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
11
+ import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
12
+ import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
13
+
14
+ export const NAME = 'calendly';
15
+ export default class CalendlyApplication extends AOAuth2Application {
16
+
17
+ public getName(): string {
18
+ return NAME;
19
+ }
20
+
21
+ public getPublicName(): string {
22
+ return 'Calendly';
23
+ }
24
+
25
+ public getDescription(): string {
26
+ return 'Simple scheduling tool for businesses that eliminates email back and forth. It helps save time and increase sales.';
27
+ }
28
+
29
+ public getLogo(): string {
30
+ return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9ImxvZ29zYW5kdHlwZXNfY29tIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiCgkgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOm5vbmU7fQoJLnN0MXtmaWxsOiMwMDZCRkY7fQoJLnN0MntmaWxsOiMwQUU4RjA7fQo8L3N0eWxlPgo8Zz4KCTxnIGlkPSJMYXllcl8zIj4KCQk8cGF0aCBpZD0iTGF5ZXJfMy0yIiBjbGFzcz0ic3QwIiBkPSJNLTUuNC01LjRoMTEwLjd2MTEwLjdILTUuNFYtNS40eiIvPgoJPC9nPgoJPHBhdGggY2xhc3M9InN0MSIgZD0iTTk2LjgsNTguNmMtMi4xLTEuNS02LjMtMy40LTkuOS00LjZjMC40LTIuMywwLjUtNS4yLTAuMS04LjZoMHYtMC4xaDB2MC4xYzMuNi0wLjYsNy0yLjEsOS45LTQuMwoJCWMyLjgtMi4xLDIuMy00LjUsMS45LTUuOWMtMy41LTExLjMtMTEtMjEuMS0yMS0yNy40Yy0xMC02LjMtMjItOC44LTMzLjgtNy4xQzMyLjIsMi42LDIxLjUsOC41LDEzLjcsMTcuNWMtNy43LDktMTIsMjAuNS0xMiwzMi4zCgkJczQuMywyMy40LDEyLDMyLjNjNy43LDksMTguNSwxNC45LDMwLjIsMTYuN2MxMS43LDEuOCwyMy43LTAuNywzMy44LTcuMWMxMC02LjMsMTcuNS0xNiwyMS0yNy40Qzk5LjEsNjMuMSw5OS43LDYwLjcsOTYuOCw1OC42egoJCSBNOTMuNyw2Mi45QzkwLjUsNzMsODMuOSw4MS43LDc0LjksODcuM2MtOSw1LjYtMTkuNyw3LjktMzAuMSw2LjNjLTEwLjUtMS42LTIwLTYuOS0yNi45LTE0LjlDMTEsNzAuNyw3LjIsNjAuNCw3LjIsNDkuOQoJCVMxMSwyOSwxNy45LDIxYzYuOS04LDE2LjUtMTMuMywyNi45LTE0LjlDNTUuMyw0LjUsNjYsNi44LDc0LjksMTIuNGM5LDUuNiwxNS42LDE0LjMsMTguNywyNC40YzAsMCwwLDAuMSwwLDAuMQoJCWMtMS41LDEuMS01LjEsMi40LTguMiwzLjRsMC0wLjFjLTAuNS0xLjEtMS0yLjItMS42LTMuMmwtNS04LjdjLTIuMy0zLjktNS41LTcuMi05LjQtOS40cy04LjQtMy41LTEyLjktMy41SDQ2LjQKCQljLTQuNSwwLTksMS4yLTEyLjksMy41Yy0zLjksMi4zLTcuMiw1LjUtOS40LDkuNGwtNSw4LjdjLTIuMywzLjktMy41LDguNC0zLjUsMTIuOXMxLjIsOSwzLjUsMTIuOWw1LDguN2MyLjMsMy45LDUuNSw3LjIsOS40LDkuNAoJCWMzLjksMi4zLDguNCwzLjUsMTIuOSwzLjVoMTAuMWM0LjUsMCw5LTEuMiwxMi45LTMuNXM3LjItNS41LDkuNC05LjRsNS04LjdjMC42LTEsMS4xLTIuMSwxLjYtMy4ybDAtMC4xYzAsMCwwLDAsMCwwaDAKCQlDODguNCw1OS45LDkxLjMsNjEuMSw5My43LDYyLjlDOTMuNyw2Mi45LDkzLjcsNjIuOSw5My43LDYyLjl6Ii8+Cgk8cGF0aCBjbGFzcz0ic3QyIiBkPSJNODUuNSw0MC4zYy0xLjEsMC4yLTIuMywwLjMtMy40LDAuM2MtNy41LDAtMTAuMy0yLjUtMTMuNi01LjRjLTMuMi0yLjgtNy4xLTYuMy0xNC4yLTYuM0g1MAoJCWMtNS4yLDAtOS45LDEuOS0xMy4yLDUuM2MtMy4zLDMuMy01LjEsNy45LTUuMSwxMi44djUuOGMwLDQuOSwxLjgsOS41LDUuMSwxMi44YzMuNCwzLjQsOCw1LjMsMTMuMiw1LjNoNC4zCgkJYzcuMSwwLDExLjEtMy41LDE0LjItNi4zYzMuMy0yLjksNi4xLTUuNCwxMy42LTUuNGMxLjEsMCwyLjMsMC4xLDMuNCwwLjNjMC42LTEuNiwxLjYtNS44LDEuNS01LjVjLTEuNy0wLjItMy4zLTAuMS01LTAuMQoJCWMtMTcuMywwLTE2LjQsMTEuNy0yNy44LDExLjdoLTQuM2MtNy45LDAtMTMtNS42LTEzLTEyLjh2LTUuOGMwLTcuMiw1LjItMTIuOCwxMy0xMi44aDQuM2MxMS40LDAsMTAuNSwxMS43LDI3LjgsMTEuNwoJCWMxLjYsMCwzLjMtMC4xLDQuOS0wLjR2LTAuMUM4Ni42LDQzLjYsODYuMSw0MS45LDg1LjUsNDAuM0w4NS41LDQwLjN6Ii8+CjwvZz4KPC9zdmc+Cg==';
31
+ }
32
+
33
+ public getAuthUrl(): string {
34
+ return 'https://auth.calendly.com/oauth/authorize';
35
+ }
36
+
37
+ public getTokenUrl(): string {
38
+ return 'https://auth.calendly.com/oauth/token';
39
+ }
40
+
41
+ public getRequestDto(
42
+ dto: AProcessDto,
43
+ applicationInstall: ApplicationInstall,
44
+ method: HttpMethods,
45
+ _url?: string,
46
+ data?: unknown,
47
+ ): RequestDto {
48
+ const url = `https://api.calendly.com/${_url}`;
49
+ const request = new RequestDto(url ?? '', method, dto);
50
+ request.setHeaders({
51
+ [CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
52
+ [CommonHeaders.ACCEPT]: JSON_TYPE,
53
+ [CommonHeaders.AUTHORIZATION]: `Bearer ${this.getAccessToken(applicationInstall)}`,
54
+ });
55
+
56
+ if (data) {
57
+ request.setJsonBody(data);
58
+ }
59
+
60
+ return request;
61
+ }
62
+
63
+ public getFormStack(): FormStack {
64
+ const form = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM))
65
+ .addField(new Field(FieldType.TEXT, CLIENT_ID, 'Client Id', null, true))
66
+ .addField(new Field(FieldType.TEXT, CLIENT_SECRET, 'Client Secret', null, true));
67
+
68
+ return new FormStack().addForm(form);
69
+ }
70
+
71
+ public isAuthorized(applicationInstall: ApplicationInstall): boolean {
72
+ const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
73
+ return super.isAuthorized(applicationInstall)
74
+ && authorizationForm?.[CLIENT_ID]
75
+ && authorizationForm?.[CLIENT_SECRET];
76
+ }
77
+
78
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
+ public getScopes(applicationInstall: ApplicationInstall): string[] {
80
+ return [];
81
+ }
82
+
83
+ }
@@ -0,0 +1,45 @@
1
+ import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
+
5
+ export const NAME = 'calendly-get-user-connector';
6
+
7
+ export default class CalendlyGetUserConnector extends AConnector {
8
+
9
+ public getName(): string {
10
+ return NAME;
11
+ }
12
+
13
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
14
+ const { uuid } = dto.getJsonData();
15
+
16
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
17
+ const url = `users/${uuid}`;
18
+ const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods.GET, url);
19
+ const resp = await this.getSender().send<IOutput>(req, [200]);
20
+
21
+ return dto.setNewJsonData(resp.getJsonBody());
22
+ }
23
+
24
+ }
25
+
26
+ /* eslint-disable @typescript-eslint/naming-convention */
27
+
28
+ export interface IInput {
29
+ uuid: string;
30
+ }
31
+
32
+ export interface IOutput {
33
+ resource: {
34
+ uri: string;
35
+ name: string;
36
+ slug: string;
37
+ email: string;
38
+ scheduling_url: string;
39
+ timezone: string;
40
+ avatar_url: string;
41
+ created_at: Date;
42
+ updated_at: Date;
43
+ current_organization: string;
44
+ };
45
+ }
@@ -0,0 +1,45 @@
1
+ import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
+
5
+ export const NAME = 'calendly-invite-user-connector';
6
+
7
+ export default class CalendlyInviteUserConnector extends AConnector {
8
+
9
+ public getName(): string {
10
+ return NAME;
11
+ }
12
+
13
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
14
+ const { uuid, ...body } = dto.getJsonData();
15
+
16
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
17
+ const url = `organizations/${uuid}/invitations`;
18
+ const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods.POST, url, body);
19
+ const resp = await this.getSender().send<IOutput>(req, [201]);
20
+
21
+ return dto.setNewJsonData(resp.getJsonBody());
22
+ }
23
+
24
+ }
25
+
26
+ /* eslint-disable @typescript-eslint/naming-convention */
27
+
28
+ export interface IInput {
29
+ uuid: string;
30
+ email: string;
31
+ }
32
+
33
+ export interface IOutput {
34
+ resource: {
35
+ created_at: Date;
36
+ email: string;
37
+ last_sent_at: Date;
38
+ organization: string;
39
+ status: 'accepted' | 'declined' | 'pending';
40
+ updated_at: Date;
41
+ uri: string;
42
+ };
43
+ }
44
+
45
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,17 @@
1
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
+ import init from '../../../test/dataProvider';
4
+ import { NAME as CALENDLY_GET_USER_CONNECTOR } from '../CalendlyGetUserConnector';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for CalendlyGetUserConnector', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename, true);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testConnector(CALENDLY_GET_USER_CONNECTOR);
16
+ });
17
+ });
@@ -0,0 +1,17 @@
1
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
+ import init from '../../../test/dataProvider';
4
+ import { NAME as CALENDLY_INVITE_USER_CONNECTOR } from '../CalendlyInviteUserConnector';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for CalendlyInviteUserConnector', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename, true);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testConnector(CALENDLY_INVITE_USER_CONNECTOR);
16
+ });
17
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "uuid": "123"
7
+ }
8
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "http": "GET https://api.calendly.com/users/123",
3
+ "code": 200,
4
+ "body": {
5
+ "resource": {
6
+ "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
7
+ "name": "John Doe",
8
+ "slug": "acmesales",
9
+ "email": "test@example.com",
10
+ "scheduling_url": "https://calendly.com/acmesales",
11
+ "timezone": "America/New York",
12
+ "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png",
13
+ "created_at": "2019-01-02T03:04:05.678123Z",
14
+ "updated_at": "2019-08-07T06:05:04.321123Z",
15
+ "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA"
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "resource": {
7
+ "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
8
+ "name": "John Doe",
9
+ "slug": "acmesales",
10
+ "email": "test@example.com",
11
+ "scheduling_url": "https://calendly.com/acmesales",
12
+ "timezone": "America/New York",
13
+ "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png",
14
+ "created_at": "2019-01-02T03:04:05.678123Z",
15
+ "updated_at": "2019-08-07T06:05:04.321123Z",
16
+ "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "uuid": "123",
7
+ "email": "alice@example.com"
8
+ }
9
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "http": "POST https://api.calendly.com/organizations/123/invitations",
3
+ "code": 201,
4
+ "body": {
5
+ "resource": {
6
+ "created_at": "2020-01-01T20:30:00.000000Z",
7
+ "email": "email@example.com",
8
+ "last_sent_at": "2020-01-01T20:30:00.123456Z",
9
+ "organization": "https://api.calendly.com/organizations/ABCDABCDABCDABCD",
10
+ "status": "pending",
11
+ "updated_at": "2020-01-01T20:30:00.000000Z",
12
+ "uri": "https://api.calendly.com/organizations/ABCDABCDABCDABCD/invitations/DCBADCBADCBADCBA"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "resource": {
7
+ "created_at": "2020-01-01T20:30:00.000000Z",
8
+ "email": "email@example.com",
9
+ "last_sent_at": "2020-01-01T20:30:00.123456Z",
10
+ "organization": "https://api.calendly.com/organizations/ABCDABCDABCDABCD",
11
+ "status": "pending",
12
+ "updated_at": "2020-01-01T20:30:00.000000Z",
13
+ "uri": "https://api.calendly.com/organizations/ABCDABCDABCDABCD/invitations/DCBADCBADCBADCBA"
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ appInstall,
3
+ DEFAULT_ACCESS_TOKEN,
4
+ DEFAULT_CLIENT_ID,
5
+ DEFAULT_CLIENT_SECRET,
6
+ DEFAULT_USER,
7
+ } from '@orchesty/nodejs-connectors/test/DataProvider';
8
+ import { container, oauth2Provider } from '@orchesty/nodejs-connectors/test/TestAbstract';
9
+ import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
10
+ import { ACCESS_TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Provider/OAuth2/OAuth2Provider';
11
+ import { TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
12
+ import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
13
+ import CalendlyListEventsBatch from '../src/Batch/CalendlyListEventsBatch';
14
+ import CalendlyApplication, { NAME as CALENDLY_APP } from '../src/CalendlyApplication';
15
+ import CalendlyGetUserConnector from '../src/Connector/CalendlyGetUserConnector';
16
+ import CalendlyInviteUserConnector from '../src/Connector/CalendlyInviteUserConnector';
17
+
18
+ export default function init(): void {
19
+ appInstall(CALENDLY_APP, DEFAULT_USER, {
20
+ [CoreFormsEnum.AUTHORIZATION_FORM]: {
21
+ [CLIENT_ID]: DEFAULT_CLIENT_ID,
22
+ [CLIENT_SECRET]: DEFAULT_CLIENT_SECRET,
23
+ [TOKEN]: {
24
+ [ACCESS_TOKEN]: DEFAULT_ACCESS_TOKEN,
25
+ },
26
+ },
27
+ });
28
+
29
+ const app = new CalendlyApplication(oauth2Provider);
30
+ container.setApplication(app);
31
+
32
+ container.setNode(new CalendlyGetUserConnector(), app);
33
+ container.setNode(new CalendlyListEventsBatch(), app);
34
+ container.setNode(new CalendlyInviteUserConnector(), app);
35
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "composite": true
6
+ },
7
+ "include": ["src", "test", "../../test"]
8
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ },
6
+ "include": [
7
+ "src",
8
+ ],
9
+ "exclude": [
10
+ "node_modules",
11
+ "src/**/__tests__",
12
+ ]
13
+ }