@orchesty/connector-raynet-crm 1.0.0 → 2.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.
- package/README.md +101 -0
- package/dist/Batch/RaynetCRMSubscribeWebhook.js +1 -0
- package/dist/Batch/RaynetCRMUnregisterWebhook.js +5 -1
- package/dist/package.json +5 -2
- package/package.json +5 -2
- package/CHANGELOG.md +0 -7
- package/coverage/clover.xml +0 -283
- package/coverage/coverage-final.json +0 -13
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/Batch/RaynetCRMGetActivities.ts.html +0 -385
- package/coverage/lcov-report/src/Batch/RaynetCRMGetClients.ts.html +0 -679
- package/coverage/lcov-report/src/Batch/RaynetCRMGetContactPersons.ts.html +0 -553
- package/coverage/lcov-report/src/Batch/RaynetCRMSubscribeWebhook.ts.html +0 -355
- package/coverage/lcov-report/src/Batch/RaynetCRMUnregisterWebhook.ts.html +0 -241
- package/coverage/lcov-report/src/Batch/index.html +0 -176
- package/coverage/lcov-report/src/Connector/RaynetCRMGetVoipByTel.ts.html +0 -856
- package/coverage/lcov-report/src/Connector/RaynetCRMUniversalActivityDetail.ts.html +0 -448
- package/coverage/lcov-report/src/Connector/RaynetCRMUniversalCreateActivity.ts.html +0 -223
- package/coverage/lcov-report/src/Connector/RaynetCRMUniversalDeleteActivity.ts.html +0 -184
- package/coverage/lcov-report/src/Connector/RaynetCRMUniversalUpdateActivity.ts.html +0 -205
- package/coverage/lcov-report/src/Connector/index.html +0 -176
- package/coverage/lcov-report/src/RaynetCRMApplication.ts.html +0 -331
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/test/dataProvider.ts.html +0 -205
- package/coverage/lcov-report/test/index.html +0 -116
- package/coverage/lcov.info +0 -465
- package/jest.config.js +0 -13
- package/src/Batch/RaynetCRMGetActivities.ts +0 -100
- package/src/Batch/RaynetCRMGetClients.ts +0 -198
- package/src/Batch/RaynetCRMGetContactPersons.ts +0 -156
- package/src/Batch/RaynetCRMSubscribeWebhook.ts +0 -90
- package/src/Batch/RaynetCRMUnregisterWebhook.ts +0 -52
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/from-input.json +0 -8
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/from-mock.json +0 -64
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/from-output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/input.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/mock.json +0 -64
- package/src/Batch/__tests__/Data/RaynetCRMGetActivities/output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/email-input.json +0 -8
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/email-mock.json +0 -157
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/email-output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/input.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/mock.json +0 -157
- package/src/Batch/__tests__/Data/RaynetCRMGetClients/output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/email-input.json +0 -8
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/email-mock.json +0 -157
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/email-output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/input.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/mock.json +0 -112
- package/src/Batch/__tests__/Data/RaynetCRMGetContactPersons/output.json +0 -11
- package/src/Batch/__tests__/Data/RaynetCRMSubscribeWebhook/input.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMSubscribeWebhook/mock.json +0 -10
- package/src/Batch/__tests__/Data/RaynetCRMSubscribeWebhook/output.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMUnregisterWebhook/input.json +0 -6
- package/src/Batch/__tests__/Data/RaynetCRMUnregisterWebhook/mock.json +0 -7
- package/src/Batch/__tests__/Data/RaynetCRMUnregisterWebhook/output.json +0 -6
- package/src/Batch/__tests__/RaynetCRMGetActivities.ts +0 -23
- package/src/Batch/__tests__/RaynetCRMGetClients.ts +0 -23
- package/src/Batch/__tests__/RaynetCRMGetContactPersons.ts +0 -23
- package/src/Batch/__tests__/RaynetCRMSubscribeWebhook.ts +0 -18
- package/src/Batch/__tests__/RaynetCRMUnregisterWebhook.ts +0 -42
- package/src/Connector/RaynetCRMGetVoipByTel.ts +0 -257
- package/src/Connector/RaynetCRMUniversalActivityDetail.ts +0 -121
- package/src/Connector/RaynetCRMUniversalCreateActivity.ts +0 -46
- package/src/Connector/RaynetCRMUniversalDeleteActivity.ts +0 -33
- package/src/Connector/RaynetCRMUniversalUpdateActivity.ts +0 -40
- package/src/Connector/__tests__/Data/RaynetCRMGetVoipByTel/input.json +0 -8
- package/src/Connector/__tests__/Data/RaynetCRMGetVoipByTel/mock.json +0 -216
- package/src/Connector/__tests__/Data/RaynetCRMGetVoipByTel/output.json +0 -217
- package/src/Connector/__tests__/Data/RaynetCRMUniversalActivityDetail/input.json +0 -22
- package/src/Connector/__tests__/Data/RaynetCRMUniversalActivityDetail/mock.json +0 -84
- package/src/Connector/__tests__/Data/RaynetCRMUniversalActivityDetail/output.json +0 -83
- package/src/Connector/__tests__/Data/RaynetCRMUniversalCreateActivity/input.json +0 -83
- package/src/Connector/__tests__/Data/RaynetCRMUniversalCreateActivity/mock.json +0 -10
- package/src/Connector/__tests__/Data/RaynetCRMUniversalCreateActivity/output.json +0 -11
- package/src/Connector/__tests__/Data/RaynetCRMUniversalDeleteActivity/input.json +0 -9
- package/src/Connector/__tests__/Data/RaynetCRMUniversalDeleteActivity/mock.json +0 -7
- package/src/Connector/__tests__/Data/RaynetCRMUniversalDeleteActivity/output.json +0 -8
- package/src/Connector/__tests__/Data/RaynetCRMUniversalUpdateActivity/input.json +0 -83
- package/src/Connector/__tests__/Data/RaynetCRMUniversalUpdateActivity/mock.json +0 -7
- package/src/Connector/__tests__/Data/RaynetCRMUniversalUpdateActivity/output.json +0 -8
- package/src/Connector/__tests__/RaynetCRMGetVoipByTel.ts +0 -18
- package/src/Connector/__tests__/RaynetCRMUniversalActivityDetail.ts +0 -18
- package/src/Connector/__tests__/RaynetCRMUniversalCreateActivity.ts +0 -18
- package/src/Connector/__tests__/RaynetCRMUniversalDeleteActivity.ts +0 -18
- package/src/Connector/__tests__/RaynetCRMUniversalUpdateActivity.ts +0 -18
- package/src/RaynetCRMApplication.ts +0 -82
- package/test/dataProvider.ts +0 -40
- package/tsconfig.json +0 -8
- package/tsconfig.prod.json +0 -13
- package/tsconfig.prod.tsbuildinfo +0 -1
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
2
|
-
import ResponseDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/ResponseDto';
|
|
3
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
4
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
5
|
-
|
|
6
|
-
export const NAME = 'raynet-crm-get-clients';
|
|
7
|
-
export const LIMIT = 1000;
|
|
8
|
-
|
|
9
|
-
export default class RaynetCRMGetClients extends ABatchNode {
|
|
10
|
-
|
|
11
|
-
protected limit = LIMIT;
|
|
12
|
-
|
|
13
|
-
public getName(): string {
|
|
14
|
-
return NAME;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async processAction(dto: BatchProcessDto<IInput>): Promise<BatchProcessDto> {
|
|
18
|
-
const email = this.getData(dto);
|
|
19
|
-
const page = Number(dto.getBatchCursor('0'));
|
|
20
|
-
|
|
21
|
-
const req = await this.getApplication().getRequestDto(
|
|
22
|
-
dto,
|
|
23
|
-
await this.getApplicationInstallFromProcess(dto),
|
|
24
|
-
HttpMethods.GET,
|
|
25
|
-
`company?offset=${page}&limit=${this.limit}${email ? `&primaryAddress-contactInfo.email=${email}` : ''}`,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return this.processResponse(dto, await this.getSender().send<IResponse>(req, [200]), page);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected getData(dto: BatchProcessDto<IInput>): string {
|
|
32
|
-
return dto.getJsonData().email ?? '';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
protected processResponse(dto: BatchProcessDto, resp: ResponseDto<IResponse>, page: number): BatchProcessDto {
|
|
36
|
-
const { totalCount } = resp.getJsonBody();
|
|
37
|
-
|
|
38
|
-
if (totalCount && totalCount > this.limit * (page + 1)) {
|
|
39
|
-
dto.setBatchCursor(String(page + 1));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return dto.setItemList(resp.getJsonBody().data);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface IInput {
|
|
48
|
-
email?: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
52
|
-
export interface IResponse {
|
|
53
|
-
success: string;
|
|
54
|
-
totalCount: number;
|
|
55
|
-
data: {
|
|
56
|
-
id: number;
|
|
57
|
-
name: string;
|
|
58
|
-
titleBefore?: unknown;
|
|
59
|
-
firstName?: unknown;
|
|
60
|
-
lastName?: unknown;
|
|
61
|
-
titleAfter?: unknown;
|
|
62
|
-
person: boolean;
|
|
63
|
-
role: string;
|
|
64
|
-
state: string;
|
|
65
|
-
rating: string;
|
|
66
|
-
owner: {
|
|
67
|
-
id: number;
|
|
68
|
-
fullName: string;
|
|
69
|
-
};
|
|
70
|
-
regNumber: string;
|
|
71
|
-
taxNumber: string;
|
|
72
|
-
taxNumber2?: unknown;
|
|
73
|
-
taxPayer: string;
|
|
74
|
-
bankAccount?: unknown;
|
|
75
|
-
databox?: unknown;
|
|
76
|
-
court?: unknown;
|
|
77
|
-
primaryAddress: {
|
|
78
|
-
id: number;
|
|
79
|
-
primary: boolean;
|
|
80
|
-
contactAddress: boolean;
|
|
81
|
-
address: {
|
|
82
|
-
id: number;
|
|
83
|
-
city: string;
|
|
84
|
-
country: string;
|
|
85
|
-
name: string;
|
|
86
|
-
province: string;
|
|
87
|
-
street: string;
|
|
88
|
-
zipCode: string;
|
|
89
|
-
lat: number;
|
|
90
|
-
lng: number;
|
|
91
|
-
};
|
|
92
|
-
territory: {
|
|
93
|
-
id: number;
|
|
94
|
-
value: string;
|
|
95
|
-
};
|
|
96
|
-
contactInfo: {
|
|
97
|
-
email: string;
|
|
98
|
-
email2: string;
|
|
99
|
-
primary: boolean;
|
|
100
|
-
tel1: string;
|
|
101
|
-
tel1Type: string;
|
|
102
|
-
tel2: string;
|
|
103
|
-
tel2Type: string;
|
|
104
|
-
www: string;
|
|
105
|
-
otherContact?: unknown;
|
|
106
|
-
};
|
|
107
|
-
extIds?: unknown;
|
|
108
|
-
};
|
|
109
|
-
contactAddress: {
|
|
110
|
-
id: number;
|
|
111
|
-
primary: boolean;
|
|
112
|
-
contactAddress: boolean;
|
|
113
|
-
address: {
|
|
114
|
-
id: number;
|
|
115
|
-
city: string;
|
|
116
|
-
country: string;
|
|
117
|
-
name: string;
|
|
118
|
-
province: string;
|
|
119
|
-
street: string;
|
|
120
|
-
zipCode: string;
|
|
121
|
-
lat?: unknown;
|
|
122
|
-
lng?: unknown;
|
|
123
|
-
};
|
|
124
|
-
territory: {
|
|
125
|
-
id: number;
|
|
126
|
-
value: string;
|
|
127
|
-
};
|
|
128
|
-
contactInfo: {
|
|
129
|
-
email: string;
|
|
130
|
-
email2?: unknown;
|
|
131
|
-
primary: boolean;
|
|
132
|
-
tel1: string;
|
|
133
|
-
tel1Type: string;
|
|
134
|
-
tel2: string;
|
|
135
|
-
tel2Type: string;
|
|
136
|
-
www?: unknown;
|
|
137
|
-
otherContact?: unknown;
|
|
138
|
-
};
|
|
139
|
-
extIds?: unknown;
|
|
140
|
-
};
|
|
141
|
-
category: {
|
|
142
|
-
id: number;
|
|
143
|
-
value: string;
|
|
144
|
-
};
|
|
145
|
-
turnover: {
|
|
146
|
-
id: number;
|
|
147
|
-
value: string;
|
|
148
|
-
};
|
|
149
|
-
economyActivity: {
|
|
150
|
-
id: number;
|
|
151
|
-
value: string;
|
|
152
|
-
};
|
|
153
|
-
companyClassification1: {
|
|
154
|
-
id: number;
|
|
155
|
-
value: string;
|
|
156
|
-
};
|
|
157
|
-
companyClassification2: {
|
|
158
|
-
id: number;
|
|
159
|
-
value: string;
|
|
160
|
-
};
|
|
161
|
-
companyClassification3: {
|
|
162
|
-
id: number;
|
|
163
|
-
value: string;
|
|
164
|
-
};
|
|
165
|
-
paymentTerm: {
|
|
166
|
-
id: number;
|
|
167
|
-
value: string;
|
|
168
|
-
};
|
|
169
|
-
contactSource: {
|
|
170
|
-
id: number;
|
|
171
|
-
value: string;
|
|
172
|
-
};
|
|
173
|
-
birthday?: unknown;
|
|
174
|
-
notice: string;
|
|
175
|
-
tags: string[];
|
|
176
|
-
customFields?: unknown;
|
|
177
|
-
'rowInfo.createdAt': string;
|
|
178
|
-
'rowInfo.createdBy': string;
|
|
179
|
-
'rowInfo.updatedAt': string;
|
|
180
|
-
'rowInfo.updatedBy': string;
|
|
181
|
-
'rowInfo.rowAccess'?: unknown;
|
|
182
|
-
'rowInfo.rowState'?: unknown;
|
|
183
|
-
securityLevel: {
|
|
184
|
-
id: number;
|
|
185
|
-
name: string;
|
|
186
|
-
};
|
|
187
|
-
inlineGdpr: {
|
|
188
|
-
id: number;
|
|
189
|
-
validFrom: string;
|
|
190
|
-
validTill: string;
|
|
191
|
-
legalTitle: string;
|
|
192
|
-
templateName: string;
|
|
193
|
-
gdprTemplate: number;
|
|
194
|
-
}[];
|
|
195
|
-
_version: number;
|
|
196
|
-
}[];
|
|
197
|
-
}
|
|
198
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
2
|
-
import ResponseDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/ResponseDto';
|
|
3
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
4
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
5
|
-
|
|
6
|
-
export const NAME = 'raynet-crm-get-contact-persons';
|
|
7
|
-
export const LIMIT = 1000;
|
|
8
|
-
|
|
9
|
-
export default class RaynetCRMGetContactPersons extends ABatchNode {
|
|
10
|
-
|
|
11
|
-
protected limit = LIMIT;
|
|
12
|
-
|
|
13
|
-
public getName(): string {
|
|
14
|
-
return NAME;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async processAction(dto: BatchProcessDto<IInput>): Promise<BatchProcessDto> {
|
|
18
|
-
const email = this.getData(dto);
|
|
19
|
-
const page = Number(dto.getBatchCursor('0'));
|
|
20
|
-
|
|
21
|
-
const req = await this.getApplication().getRequestDto(
|
|
22
|
-
dto,
|
|
23
|
-
await this.getApplicationInstallFromProcess(dto),
|
|
24
|
-
HttpMethods.GET,
|
|
25
|
-
`person?offset=${page}&limit=${this.limit}${email ? `&contactInfo.email=${email}` : ''}`,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return this.processResponse(dto, await this.getSender().send<IResponse>(req, [200]), page);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected getData(dto: BatchProcessDto<IInput>): string {
|
|
32
|
-
return dto.getJsonData().email ?? '';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
protected processResponse(dto: BatchProcessDto, resp: ResponseDto<IResponse>, page: number): BatchProcessDto {
|
|
36
|
-
const { totalCount } = resp.getJsonBody();
|
|
37
|
-
|
|
38
|
-
if (totalCount && totalCount > this.limit * (page + 1)) {
|
|
39
|
-
dto.setBatchCursor(String(page + 1));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return dto.setItemList(resp.getJsonBody().data);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface IInput {
|
|
48
|
-
email?: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
52
|
-
export interface IResponse {
|
|
53
|
-
success: string;
|
|
54
|
-
totalCount: number;
|
|
55
|
-
data: {
|
|
56
|
-
id: number;
|
|
57
|
-
titleBefore: string;
|
|
58
|
-
firstName: string;
|
|
59
|
-
lastName: string;
|
|
60
|
-
titleAfter: string;
|
|
61
|
-
primaryRelationship: {
|
|
62
|
-
id: number;
|
|
63
|
-
type: string;
|
|
64
|
-
company: {
|
|
65
|
-
id: number;
|
|
66
|
-
name: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
owner: {
|
|
70
|
-
id: number;
|
|
71
|
-
fullName: string;
|
|
72
|
-
};
|
|
73
|
-
contactInfo: {
|
|
74
|
-
email: string;
|
|
75
|
-
email2: string;
|
|
76
|
-
tel1: string;
|
|
77
|
-
tel1Type: string;
|
|
78
|
-
tel2?: unknown;
|
|
79
|
-
tel2Type?: unknown;
|
|
80
|
-
www?: unknown;
|
|
81
|
-
otherContact?: unknown;
|
|
82
|
-
};
|
|
83
|
-
privateAddress: {
|
|
84
|
-
city: string;
|
|
85
|
-
country: string;
|
|
86
|
-
countryCode: string;
|
|
87
|
-
province?: unknown;
|
|
88
|
-
street: string;
|
|
89
|
-
zipCode: string;
|
|
90
|
-
};
|
|
91
|
-
category: {
|
|
92
|
-
id: number;
|
|
93
|
-
value: string;
|
|
94
|
-
};
|
|
95
|
-
personClassification1: {
|
|
96
|
-
id: number;
|
|
97
|
-
value: string;
|
|
98
|
-
};
|
|
99
|
-
personClassification2: {
|
|
100
|
-
id: number;
|
|
101
|
-
value: string;
|
|
102
|
-
};
|
|
103
|
-
personClassification3: {
|
|
104
|
-
id: number;
|
|
105
|
-
value: string;
|
|
106
|
-
};
|
|
107
|
-
salutation: string;
|
|
108
|
-
birthday: string;
|
|
109
|
-
language: {
|
|
110
|
-
id: number;
|
|
111
|
-
value: string;
|
|
112
|
-
};
|
|
113
|
-
maritalStatus: {
|
|
114
|
-
id: number;
|
|
115
|
-
value: string;
|
|
116
|
-
};
|
|
117
|
-
gender: string;
|
|
118
|
-
companyAddress: {
|
|
119
|
-
address: {
|
|
120
|
-
id: number;
|
|
121
|
-
city: string;
|
|
122
|
-
country: string;
|
|
123
|
-
countryCode: string;
|
|
124
|
-
province?: unknown;
|
|
125
|
-
street: string;
|
|
126
|
-
zipCode: string;
|
|
127
|
-
};
|
|
128
|
-
territory?: unknown;
|
|
129
|
-
};
|
|
130
|
-
customFields?: unknown;
|
|
131
|
-
'rowInfo.createdAt': string;
|
|
132
|
-
'rowInfo.createdBy': string;
|
|
133
|
-
'rowInfo.updatedAt': string;
|
|
134
|
-
'rowInfo.updatedBy': string;
|
|
135
|
-
'rowInfo.rowAccess'?: unknown;
|
|
136
|
-
'rowInfo.rowState'?: unknown;
|
|
137
|
-
securityLevel: {
|
|
138
|
-
id: number;
|
|
139
|
-
name: string;
|
|
140
|
-
};
|
|
141
|
-
notice: string;
|
|
142
|
-
activeUserAccount: boolean;
|
|
143
|
-
keyman: boolean;
|
|
144
|
-
tags: unknown[];
|
|
145
|
-
_version: number;
|
|
146
|
-
inlineGdpr: {
|
|
147
|
-
id: number;
|
|
148
|
-
validFrom: string;
|
|
149
|
-
validTill: string;
|
|
150
|
-
legalTitle: string;
|
|
151
|
-
templateName: string;
|
|
152
|
-
gdprTemplate: number;
|
|
153
|
-
}[];
|
|
154
|
-
}[];
|
|
155
|
-
}
|
|
156
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
2
|
-
import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
|
|
3
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
4
|
-
import TopologyRunner from '@orchesty/nodejs-sdk/dist/lib/Topology/TopologyRunner';
|
|
5
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
6
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
7
|
-
import ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
|
|
8
|
-
import crypto from 'crypto';
|
|
9
|
-
import RaynetCRMApplication from '../RaynetCRMApplication';
|
|
10
|
-
|
|
11
|
-
export const NAME = 'raynet-crm-subscribe-webhook';
|
|
12
|
-
|
|
13
|
-
export function getEntities(): string[] {
|
|
14
|
-
return ['Task', 'Email', 'Meeting', 'Letter', 'PhoneCall', 'Event'];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default class RaynetCRMSubscribeWebhook extends ABatchNode {
|
|
18
|
-
|
|
19
|
-
public getName(): string {
|
|
20
|
-
return NAME;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
|
|
24
|
-
const app = this.getApplication<RaynetCRMApplication>();
|
|
25
|
-
|
|
26
|
-
const webhookIndex = Number(dto.getBatchCursor('0'));
|
|
27
|
-
const webhooks = app.getWebhookSubscriptions();
|
|
28
|
-
|
|
29
|
-
if (webhooks.length > 0) {
|
|
30
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
31
|
-
const repo = this.getDbClient().getRepository(Webhook);
|
|
32
|
-
|
|
33
|
-
const token = this.getRandomToken();
|
|
34
|
-
const requestDto = app.getRequestDto(
|
|
35
|
-
dto,
|
|
36
|
-
appInstall,
|
|
37
|
-
HttpMethods.PUT,
|
|
38
|
-
'webhook',
|
|
39
|
-
{
|
|
40
|
-
url: TopologyRunner.getWebhookUrl(
|
|
41
|
-
webhooks[webhookIndex].getTopology(),
|
|
42
|
-
webhooks[webhookIndex].getNode(),
|
|
43
|
-
token,
|
|
44
|
-
),
|
|
45
|
-
events: webhooks[webhookIndex].getName().split(','),
|
|
46
|
-
entityFilter: getEntities(),
|
|
47
|
-
},
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
let res;
|
|
51
|
-
try {
|
|
52
|
-
res = await this.getSender().send<IResponseJson>(requestDto, [201]);
|
|
53
|
-
const respBody = res.getJsonBody();
|
|
54
|
-
|
|
55
|
-
await repo.insert(new Webhook()
|
|
56
|
-
.setWebhookId(respBody.data.uuid)
|
|
57
|
-
.setUser(appInstall.getUser())
|
|
58
|
-
.setNode(webhooks[webhookIndex].getNode())
|
|
59
|
-
.setToken(token)
|
|
60
|
-
.setApplication(app.getName())
|
|
61
|
-
.setTopology(webhooks[webhookIndex].getTopology())
|
|
62
|
-
.setName(webhooks[webhookIndex].getName()));
|
|
63
|
-
|
|
64
|
-
if (webhooks.length - 1 > webhookIndex) {
|
|
65
|
-
dto.setBatchCursor((webhookIndex + 1).toString());
|
|
66
|
-
}
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
-
} catch (e) {
|
|
69
|
-
appInstall.setEnabled(false);
|
|
70
|
-
await this.getDbClient().getRepository(ApplicationInstall).update(appInstall);
|
|
71
|
-
|
|
72
|
-
dto.setStopProcess(ResultCode.STOP_AND_FAILED, res?.getBody() ?? 'Webhook could not be registered!');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return dto;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private getRandomToken(): string {
|
|
80
|
-
return crypto.randomBytes(64).toString('hex');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface IResponseJson {
|
|
86
|
-
success: boolean;
|
|
87
|
-
data: {
|
|
88
|
-
uuid: string;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
|
|
2
|
-
import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
|
|
3
|
-
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
|
|
4
|
-
import OnRepeatException from '@orchesty/nodejs-sdk/dist/lib/Exception/OnRepeatException';
|
|
5
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
6
|
-
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
|
|
7
|
-
import { StatusCodes } from 'http-status-codes';
|
|
8
|
-
import RaynetCRMApplication from '../RaynetCRMApplication';
|
|
9
|
-
|
|
10
|
-
export const NAME = 'raynet-crm-unregister-webhook';
|
|
11
|
-
|
|
12
|
-
export default class RaynetCRMUnregisterWebhook extends ABatchNode {
|
|
13
|
-
|
|
14
|
-
public getName(): string {
|
|
15
|
-
return NAME;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
|
|
19
|
-
const app = this.getApplication<RaynetCRMApplication>();
|
|
20
|
-
|
|
21
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto, null, true);
|
|
22
|
-
|
|
23
|
-
const repo = this.getDbClient().getRepository(Webhook) as WebhookRepository;
|
|
24
|
-
const webhooks = await repo.findMany({ users: [appInstall.getUser()], apps: [app.getName()] });
|
|
25
|
-
|
|
26
|
-
if (webhooks && webhooks.length > 0) {
|
|
27
|
-
const webhookId = webhooks[0].getWebhookId();
|
|
28
|
-
const requestDto = app.getRequestDto(
|
|
29
|
-
dto,
|
|
30
|
-
appInstall,
|
|
31
|
-
HttpMethods.DELETE,
|
|
32
|
-
`webhook/${webhookId}`,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const res = await this.getSender().send(requestDto);
|
|
36
|
-
if (res.getResponseCode() !== StatusCodes.OK && res.getResponseCode() !== StatusCodes.NOT_FOUND) {
|
|
37
|
-
webhooks[0].setUnsubscribeFailed(true);
|
|
38
|
-
await repo.update(webhooks[0]);
|
|
39
|
-
throw new OnRepeatException(60, 10, res.getBody());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await repo.remove(webhooks[0]);
|
|
43
|
-
|
|
44
|
-
if (webhooks.length > 1) {
|
|
45
|
-
dto.setBatchCursor('next');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return dto;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"http": "GET https://app.raynet.cz/api/v2/activity?offset=0&limit=1000&rowInfo.lastModifiedAt[GE]=1970-1-1%200:0&dateFormat=ISO8601&scheduledFrom=2017-04-15T03:00:50.7579581Z",
|
|
3
|
-
"code": 200,
|
|
4
|
-
"body": {
|
|
5
|
-
"success": true,
|
|
6
|
-
"totalCount": 1,
|
|
7
|
-
"data": [
|
|
8
|
-
{
|
|
9
|
-
"_entityName": "Meeting",
|
|
10
|
-
"id": 2,
|
|
11
|
-
"title": "ZRDZ-Meeting-",
|
|
12
|
-
"personal": true,
|
|
13
|
-
"status": "SCHEDULED",
|
|
14
|
-
"priority": "DEFAULT",
|
|
15
|
-
"category": null,
|
|
16
|
-
"activity": null,
|
|
17
|
-
"company": null,
|
|
18
|
-
"person": null,
|
|
19
|
-
"lead": null,
|
|
20
|
-
"project": null,
|
|
21
|
-
"businessCase": null,
|
|
22
|
-
"offer": null,
|
|
23
|
-
"salesOrder": null,
|
|
24
|
-
"scheduledFrom": "2024-02-08T15:00:00.000+01:00",
|
|
25
|
-
"scheduledTill": "2024-02-08T15:30:00.000+01:00",
|
|
26
|
-
"completed": null,
|
|
27
|
-
"description": "<p>ZTSR</p>",
|
|
28
|
-
"solution": null,
|
|
29
|
-
"tags": [],
|
|
30
|
-
"rowInfo.createdAt": "2024-02-05T09:33:13.833+01:00",
|
|
31
|
-
"rowInfo.createdBy": "fila.r@hanaboso.com",
|
|
32
|
-
"rowInfo.updatedAt": "2024-02-07T12:42:24.900+01:00",
|
|
33
|
-
"rowInfo.updatedBy": "fila.r@hanaboso.com",
|
|
34
|
-
"rowInfo.rowAccess": null,
|
|
35
|
-
"rowInfo.rowState": null,
|
|
36
|
-
"securityLevel": {
|
|
37
|
-
"id": 1,
|
|
38
|
-
"name": "Sdílená"
|
|
39
|
-
},
|
|
40
|
-
"_version": 7,
|
|
41
|
-
"customFields": {},
|
|
42
|
-
"participants": [
|
|
43
|
-
{
|
|
44
|
-
"owner": true,
|
|
45
|
-
"role": "FROM",
|
|
46
|
-
"name": "Richard Fíla",
|
|
47
|
-
"person": 2,
|
|
48
|
-
"company": null,
|
|
49
|
-
"lead": null
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"recurrence": null,
|
|
53
|
-
"meetingPlace": null,
|
|
54
|
-
"companyAddress": {
|
|
55
|
-
"city": null,
|
|
56
|
-
"country": null,
|
|
57
|
-
"province": null,
|
|
58
|
-
"street": null,
|
|
59
|
-
"zipCode": null
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"headers": {
|
|
3
|
-
"user": "TestUser"
|
|
4
|
-
},
|
|
5
|
-
"data": [
|
|
6
|
-
{
|
|
7
|
-
"body": "{\"_entityName\":\"Meeting\",\"id\":2,\"title\":\"ZRDZ-Meeting-\",\"personal\":true,\"status\":\"SCHEDULED\",\"priority\":\"DEFAULT\",\"category\":null,\"activity\":null,\"company\":null,\"person\":null,\"lead\":null,\"project\":null,\"businessCase\":null,\"offer\":null,\"salesOrder\":null,\"scheduledFrom\":\"2024-02-08T15:00:00.000+01:00\",\"scheduledTill\":\"2024-02-08T15:30:00.000+01:00\",\"completed\":null,\"description\":\"<p>ZTSR</p>\",\"solution\":null,\"tags\":[],\"rowInfo.createdAt\":\"2024-02-05T09:33:13.833+01:00\",\"rowInfo.createdBy\":\"fila.r@hanaboso.com\",\"rowInfo.updatedAt\":\"2024-02-07T12:42:24.900+01:00\",\"rowInfo.updatedBy\":\"fila.r@hanaboso.com\",\"rowInfo.rowAccess\":null,\"rowInfo.rowState\":null,\"securityLevel\":{\"id\":1,\"name\":\"Sdílená\"},\"_version\":7,\"customFields\":{},\"participants\":[{\"owner\":true,\"role\":\"FROM\",\"name\":\"Richard Fíla\",\"person\":2,\"company\":null,\"lead\":null}],\"recurrence\":null,\"meetingPlace\":null,\"companyAddress\":{\"city\":null,\"country\":null,\"province\":null,\"street\":null,\"zipCode\":null}}",
|
|
8
|
-
"headers": {}
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"http": "GET https://app.raynet.cz/api/v2/activity?offset=0&limit=1000&rowInfo.lastModifiedAt[GE]=1970-1-1%200:0&dateFormat=ISO8601",
|
|
3
|
-
"code": 200,
|
|
4
|
-
"body": {
|
|
5
|
-
"success": true,
|
|
6
|
-
"totalCount": 1,
|
|
7
|
-
"data": [
|
|
8
|
-
{
|
|
9
|
-
"_entityName": "Meeting",
|
|
10
|
-
"id": 2,
|
|
11
|
-
"title": "ZRDZ-Meeting-",
|
|
12
|
-
"personal": true,
|
|
13
|
-
"status": "SCHEDULED",
|
|
14
|
-
"priority": "DEFAULT",
|
|
15
|
-
"category": null,
|
|
16
|
-
"activity": null,
|
|
17
|
-
"company": null,
|
|
18
|
-
"person": null,
|
|
19
|
-
"lead": null,
|
|
20
|
-
"project": null,
|
|
21
|
-
"businessCase": null,
|
|
22
|
-
"offer": null,
|
|
23
|
-
"salesOrder": null,
|
|
24
|
-
"scheduledFrom": "2024-02-08T15:00:00.000+01:00",
|
|
25
|
-
"scheduledTill": "2024-02-08T15:30:00.000+01:00",
|
|
26
|
-
"completed": null,
|
|
27
|
-
"description": "<p>ZTSR</p>",
|
|
28
|
-
"solution": null,
|
|
29
|
-
"tags": [],
|
|
30
|
-
"rowInfo.createdAt": "2024-02-05T09:33:13.833+01:00",
|
|
31
|
-
"rowInfo.createdBy": "fila.r@hanaboso.com",
|
|
32
|
-
"rowInfo.updatedAt": "2024-02-07T12:42:24.900+01:00",
|
|
33
|
-
"rowInfo.updatedBy": "fila.r@hanaboso.com",
|
|
34
|
-
"rowInfo.rowAccess": null,
|
|
35
|
-
"rowInfo.rowState": null,
|
|
36
|
-
"securityLevel": {
|
|
37
|
-
"id": 1,
|
|
38
|
-
"name": "Sdílená"
|
|
39
|
-
},
|
|
40
|
-
"_version": 7,
|
|
41
|
-
"customFields": {},
|
|
42
|
-
"participants": [
|
|
43
|
-
{
|
|
44
|
-
"owner": true,
|
|
45
|
-
"role": "FROM",
|
|
46
|
-
"name": "Richard Fíla",
|
|
47
|
-
"person": 2,
|
|
48
|
-
"company": null,
|
|
49
|
-
"lead": null
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"recurrence": null,
|
|
53
|
-
"meetingPlace": null,
|
|
54
|
-
"companyAddress": {
|
|
55
|
-
"city": null,
|
|
56
|
-
"country": null,
|
|
57
|
-
"province": null,
|
|
58
|
-
"street": null,
|
|
59
|
-
"zipCode": null
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"headers": {
|
|
3
|
-
"user": "TestUser"
|
|
4
|
-
},
|
|
5
|
-
"data": [
|
|
6
|
-
{
|
|
7
|
-
"body": "{\"_entityName\":\"Meeting\",\"id\":2,\"title\":\"ZRDZ-Meeting-\",\"personal\":true,\"status\":\"SCHEDULED\",\"priority\":\"DEFAULT\",\"category\":null,\"activity\":null,\"company\":null,\"person\":null,\"lead\":null,\"project\":null,\"businessCase\":null,\"offer\":null,\"salesOrder\":null,\"scheduledFrom\":\"2024-02-08T15:00:00.000+01:00\",\"scheduledTill\":\"2024-02-08T15:30:00.000+01:00\",\"completed\":null,\"description\":\"<p>ZTSR</p>\",\"solution\":null,\"tags\":[],\"rowInfo.createdAt\":\"2024-02-05T09:33:13.833+01:00\",\"rowInfo.createdBy\":\"fila.r@hanaboso.com\",\"rowInfo.updatedAt\":\"2024-02-07T12:42:24.900+01:00\",\"rowInfo.updatedBy\":\"fila.r@hanaboso.com\",\"rowInfo.rowAccess\":null,\"rowInfo.rowState\":null,\"securityLevel\":{\"id\":1,\"name\":\"Sdílená\"},\"_version\":7,\"customFields\":{},\"participants\":[{\"owner\":true,\"role\":\"FROM\",\"name\":\"Richard Fíla\",\"person\":2,\"company\":null,\"lead\":null}],\"recurrence\":null,\"meetingPlace\":null,\"companyAddress\":{\"city\":null,\"country\":null,\"province\":null,\"street\":null,\"zipCode\":null}}",
|
|
8
|
-
"headers": {}
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|