@23blocks/block-forms 3.3.0 → 5.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/CHANGELOG.md +352 -0
- package/README.md +107 -138
- package/dist/index.esm.js +509 -172
- package/dist/src/lib/forms.block.d.ts +1 -5
- package/dist/src/lib/forms.block.d.ts.map +1 -1
- package/dist/src/lib/mappers/application-form.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/appointment.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/form-instance.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/form-schema.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/form-set.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/form.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/landing.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/mail-template.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/referral.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/subscription.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/survey.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/utils.d.ts +2 -2
- package/dist/src/lib/mappers/utils.d.ts.map +1 -1
- package/dist/src/lib/services/application-forms.service.d.ts +1 -40
- package/dist/src/lib/services/application-forms.service.d.ts.map +1 -1
- package/dist/src/lib/services/appointments.service.d.ts +1 -54
- package/dist/src/lib/services/appointments.service.d.ts.map +1 -1
- package/dist/src/lib/services/crm-sync.service.d.ts +3 -35
- package/dist/src/lib/services/crm-sync.service.d.ts.map +1 -1
- package/dist/src/lib/services/form-instances.service.d.ts +1 -56
- package/dist/src/lib/services/form-instances.service.d.ts.map +1 -1
- package/dist/src/lib/services/form-schema-versions.service.d.ts +1 -45
- package/dist/src/lib/services/form-schema-versions.service.d.ts.map +1 -1
- package/dist/src/lib/services/form-schemas.service.d.ts +1 -32
- package/dist/src/lib/services/form-schemas.service.d.ts.map +1 -1
- package/dist/src/lib/services/form-sets.service.d.ts +1 -37
- package/dist/src/lib/services/form-sets.service.d.ts.map +1 -1
- package/dist/src/lib/services/forms.service.d.ts +1 -27
- package/dist/src/lib/services/forms.service.d.ts.map +1 -1
- package/dist/src/lib/services/landings.service.d.ts +1 -32
- package/dist/src/lib/services/landings.service.d.ts.map +1 -1
- package/dist/src/lib/services/mail-templates.service.d.ts +1 -32
- package/dist/src/lib/services/mail-templates.service.d.ts.map +1 -1
- package/dist/src/lib/services/referrals.service.d.ts +1 -32
- package/dist/src/lib/services/referrals.service.d.ts.map +1 -1
- package/dist/src/lib/services/subscriptions.service.d.ts +1 -32
- package/dist/src/lib/services/subscriptions.service.d.ts.map +1 -1
- package/dist/src/lib/services/surveys.service.d.ts +1 -59
- package/dist/src/lib/services/surveys.service.d.ts.map +1 -1
- package/dist/src/lib/types/application-form.d.ts +0 -21
- package/dist/src/lib/types/application-form.d.ts.map +1 -1
- package/dist/src/lib/types/appointment.d.ts +68 -18
- package/dist/src/lib/types/appointment.d.ts.map +1 -1
- package/dist/src/lib/types/crm-sync.d.ts +5 -4
- package/dist/src/lib/types/crm-sync.d.ts.map +1 -1
- package/dist/src/lib/types/form-instance.d.ts +22 -20
- package/dist/src/lib/types/form-instance.d.ts.map +1 -1
- package/dist/src/lib/types/form-schema-version.d.ts +6 -6
- package/dist/src/lib/types/form-schema-version.d.ts.map +1 -1
- package/dist/src/lib/types/form-schema.d.ts +6 -11
- package/dist/src/lib/types/form-schema.d.ts.map +1 -1
- package/dist/src/lib/types/form-set.d.ts +45 -19
- package/dist/src/lib/types/form-set.d.ts.map +1 -1
- package/dist/src/lib/types/form.d.ts +60 -2
- package/dist/src/lib/types/form.d.ts.map +1 -1
- package/dist/src/lib/types/landing.d.ts +45 -11
- package/dist/src/lib/types/landing.d.ts.map +1 -1
- package/dist/src/lib/types/mail-template.d.ts +45 -21
- package/dist/src/lib/types/mail-template.d.ts.map +1 -1
- package/dist/src/lib/types/referral.d.ts +61 -21
- package/dist/src/lib/types/referral.d.ts.map +1 -1
- package/dist/src/lib/types/subscription.d.ts +39 -8
- package/dist/src/lib/types/subscription.d.ts.map +1 -1
- package/dist/src/lib/types/survey.d.ts +42 -6
- package/dist/src/lib/types/survey.d.ts.map +1 -1
- package/package.json +3 -1
package/dist/index.esm.js
CHANGED
|
@@ -5,25 +5,25 @@ import { _ } from '@swc/helpers/_/_extends';
|
|
|
5
5
|
* Parse a string value, returning undefined for empty/undefined
|
|
6
6
|
*/ function parseString(value) {
|
|
7
7
|
if (value === null || value === undefined) {
|
|
8
|
-
return
|
|
8
|
+
return '';
|
|
9
9
|
}
|
|
10
10
|
const str = String(value);
|
|
11
|
-
return str.length > 0 ? str :
|
|
11
|
+
return str.length > 0 ? str : '';
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Parse a date value
|
|
15
15
|
*/ function parseDate(value) {
|
|
16
16
|
if (value === null || value === undefined) {
|
|
17
|
-
return
|
|
17
|
+
return new Date();
|
|
18
18
|
}
|
|
19
19
|
if (value instanceof Date) {
|
|
20
20
|
return value;
|
|
21
21
|
}
|
|
22
22
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
23
23
|
const date = new Date(value);
|
|
24
|
-
return isNaN(date.getTime()) ?
|
|
24
|
+
return isNaN(date.getTime()) ? new Date() : date;
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return new Date();
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Parse a boolean value
|
|
@@ -76,7 +76,26 @@ const formMapper = {
|
|
|
76
76
|
description: parseString(resource.attributes['description']),
|
|
77
77
|
formType: parseString(resource.attributes['form_type']),
|
|
78
78
|
status: parseStatus(resource.attributes['status']),
|
|
79
|
-
|
|
79
|
+
formUrl: parseString(resource.attributes['form_url']),
|
|
80
|
+
formDomain: parseString(resource.attributes['form_domain']),
|
|
81
|
+
formFields: resource.attributes['form_fields'],
|
|
82
|
+
onlyOnce: resource.attributes['only_once'] !== undefined ? parseBoolean(resource.attributes['only_once']) : undefined,
|
|
83
|
+
backgroundUrl: parseString(resource.attributes['background_url']),
|
|
84
|
+
contentUrl: parseString(resource.attributes['content_url']),
|
|
85
|
+
successUrl: parseString(resource.attributes['success_url']),
|
|
86
|
+
errorUrl: parseString(resource.attributes['error_url']),
|
|
87
|
+
notifySlack: resource.attributes['notify_slack'] !== undefined ? parseBoolean(resource.attributes['notify_slack']) : undefined,
|
|
88
|
+
successNotificationMessage: parseString(resource.attributes['success_notification_message']),
|
|
89
|
+
errorNotificationMessage: parseString(resource.attributes['error_notification_message']),
|
|
90
|
+
sendConfirmationMail: resource.attributes['send_confirmation_mail'] !== undefined ? parseBoolean(resource.attributes['send_confirmation_mail']) : undefined,
|
|
91
|
+
mailTemplate: parseString(resource.attributes['mail_template']),
|
|
92
|
+
sendConfirmationSms: resource.attributes['send_confirmation_sms'] !== undefined ? parseBoolean(resource.attributes['send_confirmation_sms']) : undefined,
|
|
93
|
+
smsTemplate: parseString(resource.attributes['sms_template']),
|
|
94
|
+
sendAdminNotification: resource.attributes['send_admin_notification'] !== undefined ? parseBoolean(resource.attributes['send_admin_notification']) : undefined,
|
|
95
|
+
adminNotificationEmail: parseString(resource.attributes['admin_notification_email']),
|
|
96
|
+
adminNotificationTemplate: parseString(resource.attributes['admin_notification_template']),
|
|
97
|
+
formSchemaUniqueId: parseString(resource.attributes['form_schema_unique_id']),
|
|
98
|
+
requireOtpVerification: resource.attributes['require_otp_verification'] !== undefined ? parseBoolean(resource.attributes['require_otp_verification']) : undefined,
|
|
80
99
|
payload: resource.attributes['payload']
|
|
81
100
|
})
|
|
82
101
|
};
|
|
@@ -107,6 +126,26 @@ function createFormsService(transport, _config) {
|
|
|
107
126
|
name: data.name,
|
|
108
127
|
description: data.description,
|
|
109
128
|
form_type: data.formType,
|
|
129
|
+
form_url: data.formUrl,
|
|
130
|
+
form_domain: data.formDomain,
|
|
131
|
+
form_fields: data.formFields,
|
|
132
|
+
only_once: data.onlyOnce,
|
|
133
|
+
background_url: data.backgroundUrl,
|
|
134
|
+
content_url: data.contentUrl,
|
|
135
|
+
success_url: data.successUrl,
|
|
136
|
+
error_url: data.errorUrl,
|
|
137
|
+
notify_slack: data.notifySlack,
|
|
138
|
+
success_notification_message: data.successNotificationMessage,
|
|
139
|
+
error_notification_message: data.errorNotificationMessage,
|
|
140
|
+
send_confirmation_mail: data.sendConfirmationMail,
|
|
141
|
+
mail_template: data.mailTemplate,
|
|
142
|
+
send_confirmation_sms: data.sendConfirmationSms,
|
|
143
|
+
sms_template: data.smsTemplate,
|
|
144
|
+
send_admin_notification: data.sendAdminNotification,
|
|
145
|
+
admin_notification_email: data.adminNotificationEmail,
|
|
146
|
+
admin_notification_template: data.adminNotificationTemplate,
|
|
147
|
+
form_schema_unique_id: data.formSchemaUniqueId,
|
|
148
|
+
require_otp_verification: data.requireOtpVerification,
|
|
110
149
|
payload: data.payload
|
|
111
150
|
}
|
|
112
151
|
});
|
|
@@ -118,8 +157,27 @@ function createFormsService(transport, _config) {
|
|
|
118
157
|
name: data.name,
|
|
119
158
|
description: data.description,
|
|
120
159
|
form_type: data.formType,
|
|
121
|
-
enabled: data.enabled,
|
|
122
160
|
status: data.status,
|
|
161
|
+
form_url: data.formUrl,
|
|
162
|
+
form_domain: data.formDomain,
|
|
163
|
+
form_fields: data.formFields,
|
|
164
|
+
only_once: data.onlyOnce,
|
|
165
|
+
background_url: data.backgroundUrl,
|
|
166
|
+
content_url: data.contentUrl,
|
|
167
|
+
success_url: data.successUrl,
|
|
168
|
+
error_url: data.errorUrl,
|
|
169
|
+
notify_slack: data.notifySlack,
|
|
170
|
+
success_notification_message: data.successNotificationMessage,
|
|
171
|
+
error_notification_message: data.errorNotificationMessage,
|
|
172
|
+
send_confirmation_mail: data.sendConfirmationMail,
|
|
173
|
+
mail_template: data.mailTemplate,
|
|
174
|
+
send_confirmation_sms: data.sendConfirmationSms,
|
|
175
|
+
sms_template: data.smsTemplate,
|
|
176
|
+
send_admin_notification: data.sendAdminNotification,
|
|
177
|
+
admin_notification_email: data.adminNotificationEmail,
|
|
178
|
+
admin_notification_template: data.adminNotificationTemplate,
|
|
179
|
+
form_schema_unique_id: data.formSchemaUniqueId,
|
|
180
|
+
require_otp_verification: data.requireOtpVerification,
|
|
123
181
|
payload: data.payload
|
|
124
182
|
}
|
|
125
183
|
});
|
|
@@ -139,12 +197,10 @@ const formSchemaMapper = {
|
|
|
139
197
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
140
198
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
141
199
|
formUniqueId: parseString(resource.attributes['form_unique_id']) || '',
|
|
142
|
-
code: parseString(resource.attributes['code']) || '',
|
|
143
200
|
name: parseString(resource.attributes['name']) || '',
|
|
144
201
|
description: parseString(resource.attributes['description']),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
uiSchema: resource.attributes['ui_schema'],
|
|
202
|
+
formFields: resource.attributes['form_fields'],
|
|
203
|
+
datasource: resource.attributes['datasource'],
|
|
148
204
|
status: parseStatus(resource.attributes['status']),
|
|
149
205
|
enabled: parseBoolean(resource.attributes['enabled']),
|
|
150
206
|
payload: resource.attributes['payload']
|
|
@@ -159,7 +215,6 @@ function createFormSchemasService(transport, _config) {
|
|
|
159
215
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
160
216
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
161
217
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
162
|
-
if (params == null ? void 0 : params.version) queryParams['version'] = String(params.version);
|
|
163
218
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
164
219
|
const response = await transport.get(`${basePath(formUniqueId)}/`, {
|
|
165
220
|
params: queryParams
|
|
@@ -173,12 +228,10 @@ function createFormSchemasService(transport, _config) {
|
|
|
173
228
|
async create (formUniqueId, data) {
|
|
174
229
|
const response = await transport.post(`${basePath(formUniqueId)}/`, {
|
|
175
230
|
form_schema: {
|
|
176
|
-
code: data.code,
|
|
177
231
|
name: data.name,
|
|
178
232
|
description: data.description,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
ui_schema: data.uiSchema,
|
|
233
|
+
form_fields: data.formFields,
|
|
234
|
+
datasource: data.datasource,
|
|
182
235
|
payload: data.payload
|
|
183
236
|
}
|
|
184
237
|
});
|
|
@@ -189,8 +242,8 @@ function createFormSchemasService(transport, _config) {
|
|
|
189
242
|
form_schema: {
|
|
190
243
|
name: data.name,
|
|
191
244
|
description: data.description,
|
|
192
|
-
|
|
193
|
-
|
|
245
|
+
form_fields: data.formFields,
|
|
246
|
+
datasource: data.datasource,
|
|
194
247
|
enabled: data.enabled,
|
|
195
248
|
status: data.status,
|
|
196
249
|
payload: data.payload
|
|
@@ -214,8 +267,8 @@ const formSchemaVersionMapper = {
|
|
|
214
267
|
formUniqueId: parseString(resource.attributes['form_unique_id']) || '',
|
|
215
268
|
schemaUniqueId: parseString(resource.attributes['schema_unique_id']) || '',
|
|
216
269
|
version: parseNumber(resource.attributes['version']),
|
|
217
|
-
|
|
218
|
-
|
|
270
|
+
formFields: resource.attributes['form_fields'],
|
|
271
|
+
datasource: resource.attributes['datasource'],
|
|
219
272
|
status: parseStatus(resource.attributes['status']),
|
|
220
273
|
isPublished: parseBoolean(resource.attributes['is_published']),
|
|
221
274
|
publishedAt: parseString(resource.attributes['published_at']),
|
|
@@ -244,8 +297,8 @@ function createFormSchemaVersionsService(transport, _config) {
|
|
|
244
297
|
async create (formUniqueId, schemaUniqueId, data) {
|
|
245
298
|
const response = await transport.post(`${basePath(formUniqueId, schemaUniqueId)}/`, {
|
|
246
299
|
form_schema_version: {
|
|
247
|
-
|
|
248
|
-
|
|
300
|
+
form_fields: data.formFields,
|
|
301
|
+
datasource: data.datasource,
|
|
249
302
|
payload: data.payload
|
|
250
303
|
}
|
|
251
304
|
});
|
|
@@ -254,8 +307,8 @@ function createFormSchemaVersionsService(transport, _config) {
|
|
|
254
307
|
async update (formUniqueId, schemaUniqueId, versionUniqueId, data) {
|
|
255
308
|
const response = await transport.put(`${basePath(formUniqueId, schemaUniqueId)}/${versionUniqueId}`, {
|
|
256
309
|
form_schema_version: {
|
|
257
|
-
|
|
258
|
-
|
|
310
|
+
form_fields: data.formFields,
|
|
311
|
+
datasource: data.datasource,
|
|
259
312
|
status: data.status,
|
|
260
313
|
payload: data.payload
|
|
261
314
|
}
|
|
@@ -279,13 +332,16 @@ const formInstanceMapper = {
|
|
|
279
332
|
uniqueId: parseString(resource.attributes['unique_id']),
|
|
280
333
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
281
334
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
282
|
-
|
|
283
|
-
formSchemaVersion: parseNumber(resource.attributes['form_schema_version']),
|
|
335
|
+
formUniqueId: parseString(resource.attributes['form_unique_id']),
|
|
284
336
|
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
285
|
-
|
|
337
|
+
assignedToUniqueId: parseString(resource.attributes['assigned_to_unique_id']),
|
|
338
|
+
assignedToEmail: parseString(resource.attributes['assigned_to_email']),
|
|
339
|
+
assignedToName: parseString(resource.attributes['assigned_to_name']),
|
|
340
|
+
assignedByName: parseString(resource.attributes['assigned_by_name']),
|
|
341
|
+
expiresAt: parseDate(resource.attributes['expires_at']),
|
|
342
|
+
responses: resource.attributes['responses'],
|
|
343
|
+
metadata: resource.attributes['metadata'],
|
|
286
344
|
status: parseStatus(resource.attributes['status']),
|
|
287
|
-
enabled: parseBoolean(resource.attributes['enabled']),
|
|
288
|
-
submittedAt: parseDate(resource.attributes['submitted_at']),
|
|
289
345
|
payload: resource.attributes['payload']
|
|
290
346
|
})
|
|
291
347
|
};
|
|
@@ -297,7 +353,6 @@ function createFormInstancesService(transport, _config) {
|
|
|
297
353
|
const queryParams = {};
|
|
298
354
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
299
355
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
300
|
-
if (params == null ? void 0 : params.formSchemaUniqueId) queryParams['form_schema_unique_id'] = params.formSchemaUniqueId;
|
|
301
356
|
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
302
357
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
303
358
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
@@ -313,11 +368,13 @@ function createFormInstancesService(transport, _config) {
|
|
|
313
368
|
async create (formUniqueId, data) {
|
|
314
369
|
const response = await transport.post(`${basePath(formUniqueId)}/`, {
|
|
315
370
|
app_form_instance: {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
371
|
+
assigned_to_unique_id: data.assignedToUniqueId,
|
|
372
|
+
assigned_to_email: data.assignedToEmail,
|
|
373
|
+
assigned_to_name: data.assignedToName,
|
|
374
|
+
assigned_by_name: data.assignedByName,
|
|
375
|
+
expires_at: data.expiresAt instanceof Date ? data.expiresAt.toISOString() : data.expiresAt,
|
|
376
|
+
responses: data.responses,
|
|
377
|
+
metadata: data.metadata
|
|
321
378
|
}
|
|
322
379
|
});
|
|
323
380
|
return decodeOne(response, formInstanceMapper);
|
|
@@ -325,10 +382,14 @@ function createFormInstancesService(transport, _config) {
|
|
|
325
382
|
async update (formUniqueId, uniqueId, data) {
|
|
326
383
|
const response = await transport.put(`${basePath(formUniqueId)}/${uniqueId}`, {
|
|
327
384
|
app_form_instance: {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
385
|
+
assigned_to_unique_id: data.assignedToUniqueId,
|
|
386
|
+
assigned_to_email: data.assignedToEmail,
|
|
387
|
+
assigned_to_name: data.assignedToName,
|
|
388
|
+
assigned_by_name: data.assignedByName,
|
|
389
|
+
expires_at: data.expiresAt instanceof Date ? data.expiresAt.toISOString() : data.expiresAt,
|
|
390
|
+
responses: data.responses,
|
|
391
|
+
metadata: data.metadata,
|
|
392
|
+
status: data.status
|
|
332
393
|
}
|
|
333
394
|
});
|
|
334
395
|
return decodeOne(response, formInstanceMapper);
|
|
@@ -364,9 +425,18 @@ const formSetMapper = {
|
|
|
364
425
|
code: parseString(resource.attributes['code']) || '',
|
|
365
426
|
name: parseString(resource.attributes['name']) || '',
|
|
366
427
|
description: parseString(resource.attributes['description']),
|
|
367
|
-
|
|
428
|
+
category: parseString(resource.attributes['category']),
|
|
429
|
+
appliesTo: parseString(resource.attributes['applies_to']),
|
|
430
|
+
isActive: resource.attributes['is_active'] !== undefined ? parseBoolean(resource.attributes['is_active']) : undefined,
|
|
431
|
+
isDefault: resource.attributes['is_default'] !== undefined ? parseBoolean(resource.attributes['is_default']) : undefined,
|
|
432
|
+
sendAllAtOnce: resource.attributes['send_all_at_once'] !== undefined ? parseBoolean(resource.attributes['send_all_at_once']) : undefined,
|
|
433
|
+
allowPartialCompletion: resource.attributes['allow_partial_completion'] !== undefined ? parseBoolean(resource.attributes['allow_partial_completion']) : undefined,
|
|
434
|
+
enforceSequential: resource.attributes['enforce_sequential'] !== undefined ? parseBoolean(resource.attributes['enforce_sequential']) : undefined,
|
|
435
|
+
expirationDays: parseOptionalNumber(resource.attributes['expiration_days']),
|
|
436
|
+
autoAssignRules: resource.attributes['auto_assign_rules'],
|
|
437
|
+
metadata: resource.attributes['metadata'],
|
|
438
|
+
formSetItemsAttributes: resource.attributes['form_set_items_attributes'] || undefined,
|
|
368
439
|
status: parseStatus(resource.attributes['status']),
|
|
369
|
-
enabled: parseBoolean(resource.attributes['enabled']),
|
|
370
440
|
payload: resource.attributes['payload']
|
|
371
441
|
})
|
|
372
442
|
};
|
|
@@ -390,24 +460,53 @@ function createFormSetsService(transport, _config) {
|
|
|
390
460
|
return decodeOne(response, formSetMapper);
|
|
391
461
|
},
|
|
392
462
|
async create (data) {
|
|
463
|
+
var _data_formSetItemsAttributes;
|
|
393
464
|
const response = await transport.post('/form_sets', {
|
|
394
465
|
form_set: {
|
|
395
466
|
code: data.code,
|
|
396
467
|
name: data.name,
|
|
397
468
|
description: data.description,
|
|
398
|
-
|
|
469
|
+
category: data.category,
|
|
470
|
+
applies_to: data.appliesTo,
|
|
471
|
+
is_active: data.isActive,
|
|
472
|
+
is_default: data.isDefault,
|
|
473
|
+
send_all_at_once: data.sendAllAtOnce,
|
|
474
|
+
allow_partial_completion: data.allowPartialCompletion,
|
|
475
|
+
enforce_sequential: data.enforceSequential,
|
|
476
|
+
expiration_days: data.expirationDays,
|
|
477
|
+
auto_assign_rules: data.autoAssignRules,
|
|
478
|
+
metadata: data.metadata,
|
|
479
|
+
form_set_items_attributes: (_data_formSetItemsAttributes = data.formSetItemsAttributes) == null ? void 0 : _data_formSetItemsAttributes.map((item)=>({
|
|
480
|
+
form_schema_unique_id: item.formSchemaUniqueId,
|
|
481
|
+
display_order: item.displayOrder,
|
|
482
|
+
required: item.required
|
|
483
|
+
})),
|
|
399
484
|
payload: data.payload
|
|
400
485
|
}
|
|
401
486
|
});
|
|
402
487
|
return decodeOne(response, formSetMapper);
|
|
403
488
|
},
|
|
404
489
|
async update (uniqueId, data) {
|
|
490
|
+
var _data_formSetItemsAttributes;
|
|
405
491
|
const response = await transport.put(`/form_sets/${uniqueId}`, {
|
|
406
492
|
form_set: {
|
|
407
493
|
name: data.name,
|
|
408
494
|
description: data.description,
|
|
409
|
-
|
|
410
|
-
|
|
495
|
+
category: data.category,
|
|
496
|
+
applies_to: data.appliesTo,
|
|
497
|
+
is_active: data.isActive,
|
|
498
|
+
is_default: data.isDefault,
|
|
499
|
+
send_all_at_once: data.sendAllAtOnce,
|
|
500
|
+
allow_partial_completion: data.allowPartialCompletion,
|
|
501
|
+
enforce_sequential: data.enforceSequential,
|
|
502
|
+
expiration_days: data.expirationDays,
|
|
503
|
+
auto_assign_rules: data.autoAssignRules,
|
|
504
|
+
metadata: data.metadata,
|
|
505
|
+
form_set_items_attributes: (_data_formSetItemsAttributes = data.formSetItemsAttributes) == null ? void 0 : _data_formSetItemsAttributes.map((item)=>({
|
|
506
|
+
form_schema_unique_id: item.formSchemaUniqueId,
|
|
507
|
+
display_order: item.displayOrder,
|
|
508
|
+
required: item.required
|
|
509
|
+
})),
|
|
411
510
|
status: data.status,
|
|
412
511
|
payload: data.payload
|
|
413
512
|
}
|
|
@@ -419,22 +518,30 @@ function createFormSetsService(transport, _config) {
|
|
|
419
518
|
},
|
|
420
519
|
async match (data) {
|
|
421
520
|
const response = await transport.post('/form_sets/match', {
|
|
422
|
-
|
|
423
|
-
|
|
521
|
+
context: {
|
|
522
|
+
user_unique_id: data.userUniqueId,
|
|
523
|
+
form_set_unique_id: data.formSetUniqueId,
|
|
524
|
+
category: data.category,
|
|
525
|
+
applies_to: data.appliesTo,
|
|
526
|
+
metadata: data.metadata
|
|
527
|
+
}
|
|
424
528
|
});
|
|
425
|
-
// Response is an array of match results
|
|
426
529
|
const results = response;
|
|
427
530
|
return (results.data || []).map((item)=>({
|
|
428
|
-
formSet: formSetMapper.map(item.form_set),
|
|
531
|
+
formSet: formSetMapper.map(item.form_set, new Map()),
|
|
429
532
|
score: item.score,
|
|
430
533
|
matchedCriteria: item.matched_criteria || []
|
|
431
534
|
}));
|
|
432
535
|
},
|
|
433
536
|
async autoAssign (data) {
|
|
434
537
|
const response = await transport.post('/form_sets/auto_assign', {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
538
|
+
assignment: {
|
|
539
|
+
user_unique_id: data.userUniqueId,
|
|
540
|
+
form_set_unique_id: data.formSetUniqueId,
|
|
541
|
+
assigned_by_name: data.assignedByName,
|
|
542
|
+
expires_at: data.expiresAt instanceof Date ? data.expiresAt.toISOString() : data.expiresAt,
|
|
543
|
+
metadata: data.metadata
|
|
544
|
+
}
|
|
438
545
|
});
|
|
439
546
|
const result = decodePageResult(response, formInstanceMapper);
|
|
440
547
|
return result.data;
|
|
@@ -445,17 +552,30 @@ function createFormSetsService(transport, _config) {
|
|
|
445
552
|
const landingMapper = {
|
|
446
553
|
type: 'landing_instance',
|
|
447
554
|
map: (resource)=>{
|
|
448
|
-
var _parseString
|
|
555
|
+
var _parseString;
|
|
449
556
|
return {
|
|
557
|
+
id: resource.id,
|
|
450
558
|
uniqueId: resource.id,
|
|
451
559
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
452
560
|
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
453
561
|
email: parseString(resource.attributes['email']),
|
|
454
562
|
firstName: parseString(resource.attributes['first_name']),
|
|
563
|
+
middleName: parseString(resource.attributes['middle_name']),
|
|
455
564
|
lastName: parseString(resource.attributes['last_name']),
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
565
|
+
phoneNumber: parseString(resource.attributes['phone_number']),
|
|
566
|
+
message: parseString(resource.attributes['message']),
|
|
567
|
+
notes: parseString(resource.attributes['notes']),
|
|
568
|
+
selectedOption: parseString(resource.attributes['selected_option']),
|
|
569
|
+
formFields: resource.attributes['form_fields'],
|
|
570
|
+
source: parseString(resource.attributes['source']),
|
|
571
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
572
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
573
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
574
|
+
visitorUniqueId: parseString(resource.attributes['visitor_unique_id']),
|
|
575
|
+
visitorType: parseString(resource.attributes['visitor_type']),
|
|
576
|
+
touchId: parseString(resource.attributes['touch_id']),
|
|
577
|
+
touchReferenceId: parseString(resource.attributes['touch_reference_id']),
|
|
578
|
+
preferredLanguage: parseString(resource.attributes['preferred_language']),
|
|
459
579
|
status: parseStatus(resource.attributes['status']),
|
|
460
580
|
token: parseString(resource.attributes['token']),
|
|
461
581
|
submittedAt: parseDate(resource.attributes['submitted_at']),
|
|
@@ -485,29 +605,51 @@ function createLandingsService(transport, _config) {
|
|
|
485
605
|
},
|
|
486
606
|
async submit (formUniqueId, data) {
|
|
487
607
|
const response = await transport.post(`/landings/${formUniqueId}/instances`, {
|
|
488
|
-
|
|
608
|
+
landing: {
|
|
489
609
|
email: data.email,
|
|
490
610
|
first_name: data.firstName,
|
|
611
|
+
middle_name: data.middleName,
|
|
491
612
|
last_name: data.lastName,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
613
|
+
phone_number: data.phoneNumber,
|
|
614
|
+
message: data.message,
|
|
615
|
+
notes: data.notes,
|
|
616
|
+
selected_option: data.selectedOption,
|
|
617
|
+
form_fields: data.formFields,
|
|
618
|
+
source: data.source,
|
|
619
|
+
source_alias: data.sourceAlias,
|
|
620
|
+
source_id: data.sourceId,
|
|
621
|
+
source_type: data.sourceType,
|
|
622
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
623
|
+
visitor_type: data.visitorType,
|
|
624
|
+
touch_id: data.touchId,
|
|
625
|
+
touch_reference_id: data.touchReferenceId,
|
|
626
|
+
preferred_language: data.preferredLanguage
|
|
496
627
|
}
|
|
497
628
|
});
|
|
498
629
|
return decodeOne(response, landingMapper);
|
|
499
630
|
},
|
|
500
631
|
async update (formUniqueId, uniqueId, data) {
|
|
501
632
|
const response = await transport.put(`/landings/${formUniqueId}/instances/${uniqueId}`, {
|
|
502
|
-
|
|
633
|
+
landing: {
|
|
503
634
|
email: data.email,
|
|
504
635
|
first_name: data.firstName,
|
|
636
|
+
middle_name: data.middleName,
|
|
505
637
|
last_name: data.lastName,
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
638
|
+
phone_number: data.phoneNumber,
|
|
639
|
+
message: data.message,
|
|
640
|
+
notes: data.notes,
|
|
641
|
+
selected_option: data.selectedOption,
|
|
642
|
+
form_fields: data.formFields,
|
|
643
|
+
source: data.source,
|
|
644
|
+
source_alias: data.sourceAlias,
|
|
645
|
+
source_id: data.sourceId,
|
|
646
|
+
source_type: data.sourceType,
|
|
647
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
648
|
+
visitor_type: data.visitorType,
|
|
649
|
+
touch_id: data.touchId,
|
|
650
|
+
touch_reference_id: data.touchReferenceId,
|
|
651
|
+
preferred_language: data.preferredLanguage,
|
|
652
|
+
status: data.status
|
|
511
653
|
}
|
|
512
654
|
});
|
|
513
655
|
return decodeOne(response, landingMapper);
|
|
@@ -521,16 +663,28 @@ function createLandingsService(transport, _config) {
|
|
|
521
663
|
const subscriptionMapper = {
|
|
522
664
|
type: 'subscription',
|
|
523
665
|
map: (resource)=>{
|
|
524
|
-
var _parseString, _parseString1
|
|
666
|
+
var _parseString, _parseString1;
|
|
525
667
|
return {
|
|
668
|
+
id: resource.id,
|
|
526
669
|
uniqueId: resource.id,
|
|
527
670
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
528
671
|
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
529
672
|
email: (_parseString1 = parseString(resource.attributes['email'])) != null ? _parseString1 : '',
|
|
530
673
|
firstName: parseString(resource.attributes['first_name']),
|
|
674
|
+
middleName: parseString(resource.attributes['middle_name']),
|
|
531
675
|
lastName: parseString(resource.attributes['last_name']),
|
|
532
|
-
|
|
533
|
-
|
|
676
|
+
phoneNumber: parseString(resource.attributes['phone_number']),
|
|
677
|
+
notes: parseString(resource.attributes['notes']),
|
|
678
|
+
selectedOption: parseString(resource.attributes['selected_option']),
|
|
679
|
+
formFields: resource.attributes['form_fields'],
|
|
680
|
+
source: parseString(resource.attributes['source']),
|
|
681
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
682
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
683
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
684
|
+
visitorUniqueId: parseString(resource.attributes['visitor_unique_id']),
|
|
685
|
+
visitorType: parseString(resource.attributes['visitor_type']),
|
|
686
|
+
touchId: parseString(resource.attributes['touch_id']),
|
|
687
|
+
touchReferenceId: parseString(resource.attributes['touch_reference_id']),
|
|
534
688
|
status: parseStatus(resource.attributes['status']),
|
|
535
689
|
subscribedAt: parseDate(resource.attributes['subscribed_at']),
|
|
536
690
|
unsubscribedAt: parseDate(resource.attributes['unsubscribed_at']),
|
|
@@ -563,10 +717,20 @@ function createSubscriptionsService(transport, _config) {
|
|
|
563
717
|
subscription: {
|
|
564
718
|
email: data.email,
|
|
565
719
|
first_name: data.firstName,
|
|
720
|
+
middle_name: data.middleName,
|
|
566
721
|
last_name: data.lastName,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
722
|
+
phone_number: data.phoneNumber,
|
|
723
|
+
notes: data.notes,
|
|
724
|
+
selected_option: data.selectedOption,
|
|
725
|
+
form_fields: data.formFields,
|
|
726
|
+
source: data.source,
|
|
727
|
+
source_alias: data.sourceAlias,
|
|
728
|
+
source_id: data.sourceId,
|
|
729
|
+
source_type: data.sourceType,
|
|
730
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
731
|
+
visitor_type: data.visitorType,
|
|
732
|
+
touch_id: data.touchId,
|
|
733
|
+
touch_reference_id: data.touchReferenceId
|
|
570
734
|
}
|
|
571
735
|
});
|
|
572
736
|
return decodeOne(response, subscriptionMapper);
|
|
@@ -576,11 +740,21 @@ function createSubscriptionsService(transport, _config) {
|
|
|
576
740
|
subscription: {
|
|
577
741
|
email: data.email,
|
|
578
742
|
first_name: data.firstName,
|
|
743
|
+
middle_name: data.middleName,
|
|
579
744
|
last_name: data.lastName,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
745
|
+
phone_number: data.phoneNumber,
|
|
746
|
+
notes: data.notes,
|
|
747
|
+
selected_option: data.selectedOption,
|
|
748
|
+
form_fields: data.formFields,
|
|
749
|
+
source: data.source,
|
|
750
|
+
source_alias: data.sourceAlias,
|
|
751
|
+
source_id: data.sourceId,
|
|
752
|
+
source_type: data.sourceType,
|
|
753
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
754
|
+
visitor_type: data.visitorType,
|
|
755
|
+
touch_id: data.touchId,
|
|
756
|
+
touch_reference_id: data.touchReferenceId,
|
|
757
|
+
status: data.status
|
|
584
758
|
}
|
|
585
759
|
});
|
|
586
760
|
return decodeOne(response, subscriptionMapper);
|
|
@@ -594,21 +768,38 @@ function createSubscriptionsService(transport, _config) {
|
|
|
594
768
|
const appointmentMapper = {
|
|
595
769
|
type: 'appointment',
|
|
596
770
|
map: (resource)=>{
|
|
597
|
-
var _parseString, _parseDate
|
|
771
|
+
var _parseString, _parseDate;
|
|
598
772
|
return {
|
|
773
|
+
id: resource.id,
|
|
599
774
|
uniqueId: resource.id,
|
|
600
775
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
601
776
|
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
602
777
|
email: parseString(resource.attributes['email']),
|
|
603
778
|
firstName: parseString(resource.attributes['first_name']),
|
|
779
|
+
middleName: parseString(resource.attributes['middle_name']),
|
|
604
780
|
lastName: parseString(resource.attributes['last_name']),
|
|
605
|
-
|
|
606
|
-
|
|
781
|
+
phoneNumber: parseString(resource.attributes['phone_number']),
|
|
782
|
+
selectedOption: parseString(resource.attributes['selected_option']),
|
|
783
|
+
formFields: resource.attributes['form_fields'],
|
|
784
|
+
startAt: (_parseDate = parseDate(resource.attributes['start_at'])) != null ? _parseDate : new Date(),
|
|
785
|
+
endAt: parseDate(resource.attributes['end_at']),
|
|
607
786
|
duration: parseOptionalNumber(resource.attributes['duration']),
|
|
608
|
-
|
|
609
|
-
|
|
787
|
+
locationUniqueId: parseString(resource.attributes['location_unique_id']),
|
|
788
|
+
locationName: parseString(resource.attributes['location_name']),
|
|
789
|
+
locationAddress: parseString(resource.attributes['location_address']),
|
|
790
|
+
assignedToUniqueId: parseString(resource.attributes['assigned_to_unique_id']),
|
|
791
|
+
assignedToName: parseString(resource.attributes['assigned_to_name']),
|
|
792
|
+
assignedToEmail: parseString(resource.attributes['assigned_to_email']),
|
|
793
|
+
assignedToPhone: parseString(resource.attributes['assigned_to_phone']),
|
|
610
794
|
notes: parseString(resource.attributes['notes']),
|
|
611
|
-
|
|
795
|
+
source: parseString(resource.attributes['source']),
|
|
796
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
797
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
798
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
799
|
+
visitorUniqueId: parseString(resource.attributes['visitor_unique_id']),
|
|
800
|
+
visitorType: parseString(resource.attributes['visitor_type']),
|
|
801
|
+
touchId: parseString(resource.attributes['touch_id']),
|
|
802
|
+
touchReferenceId: parseString(resource.attributes['touch_reference_id']),
|
|
612
803
|
status: parseStatus(resource.attributes['status']),
|
|
613
804
|
confirmedAt: parseDate(resource.attributes['confirmed_at']),
|
|
614
805
|
cancelledAt: parseDate(resource.attributes['cancelled_at']),
|
|
@@ -643,15 +834,30 @@ function createAppointmentsService(transport, _config) {
|
|
|
643
834
|
appointment: {
|
|
644
835
|
email: data.email,
|
|
645
836
|
first_name: data.firstName,
|
|
837
|
+
middle_name: data.middleName,
|
|
646
838
|
last_name: data.lastName,
|
|
647
|
-
|
|
648
|
-
|
|
839
|
+
phone_number: data.phoneNumber,
|
|
840
|
+
selected_option: data.selectedOption,
|
|
841
|
+
form_fields: data.formFields,
|
|
842
|
+
start_at: data.startAt instanceof Date ? data.startAt.toISOString() : data.startAt,
|
|
843
|
+
end_at: data.endAt instanceof Date ? data.endAt.toISOString() : data.endAt,
|
|
649
844
|
duration: data.duration,
|
|
650
|
-
|
|
651
|
-
|
|
845
|
+
location_unique_id: data.locationUniqueId,
|
|
846
|
+
location_name: data.locationName,
|
|
847
|
+
location_address: data.locationAddress,
|
|
848
|
+
assigned_to_unique_id: data.assignedToUniqueId,
|
|
849
|
+
assigned_to_name: data.assignedToName,
|
|
850
|
+
assigned_to_email: data.assignedToEmail,
|
|
851
|
+
assigned_to_phone: data.assignedToPhone,
|
|
652
852
|
notes: data.notes,
|
|
653
|
-
|
|
654
|
-
|
|
853
|
+
source: data.source,
|
|
854
|
+
source_alias: data.sourceAlias,
|
|
855
|
+
source_id: data.sourceId,
|
|
856
|
+
source_type: data.sourceType,
|
|
857
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
858
|
+
visitor_type: data.visitorType,
|
|
859
|
+
touch_id: data.touchId,
|
|
860
|
+
touch_reference_id: data.touchReferenceId
|
|
655
861
|
}
|
|
656
862
|
});
|
|
657
863
|
return decodeOne(response, appointmentMapper);
|
|
@@ -661,16 +867,31 @@ function createAppointmentsService(transport, _config) {
|
|
|
661
867
|
appointment: {
|
|
662
868
|
email: data.email,
|
|
663
869
|
first_name: data.firstName,
|
|
870
|
+
middle_name: data.middleName,
|
|
664
871
|
last_name: data.lastName,
|
|
665
|
-
|
|
666
|
-
|
|
872
|
+
phone_number: data.phoneNumber,
|
|
873
|
+
selected_option: data.selectedOption,
|
|
874
|
+
form_fields: data.formFields,
|
|
875
|
+
start_at: data.startAt instanceof Date ? data.startAt.toISOString() : data.startAt,
|
|
876
|
+
end_at: data.endAt instanceof Date ? data.endAt.toISOString() : data.endAt,
|
|
667
877
|
duration: data.duration,
|
|
668
|
-
|
|
669
|
-
|
|
878
|
+
location_unique_id: data.locationUniqueId,
|
|
879
|
+
location_name: data.locationName,
|
|
880
|
+
location_address: data.locationAddress,
|
|
881
|
+
assigned_to_unique_id: data.assignedToUniqueId,
|
|
882
|
+
assigned_to_name: data.assignedToName,
|
|
883
|
+
assigned_to_email: data.assignedToEmail,
|
|
884
|
+
assigned_to_phone: data.assignedToPhone,
|
|
670
885
|
notes: data.notes,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
886
|
+
source: data.source,
|
|
887
|
+
source_alias: data.sourceAlias,
|
|
888
|
+
source_id: data.sourceId,
|
|
889
|
+
source_type: data.sourceType,
|
|
890
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
891
|
+
visitor_type: data.visitorType,
|
|
892
|
+
touch_id: data.touchId,
|
|
893
|
+
touch_reference_id: data.touchReferenceId,
|
|
894
|
+
status: data.status
|
|
674
895
|
}
|
|
675
896
|
});
|
|
676
897
|
return decodeOne(response, appointmentMapper);
|
|
@@ -688,12 +909,16 @@ function createAppointmentsService(transport, _config) {
|
|
|
688
909
|
},
|
|
689
910
|
async reportList (data) {
|
|
690
911
|
const response = await transport.post('/reports/appointments/list', {
|
|
691
|
-
|
|
912
|
+
query_params: {
|
|
692
913
|
form_unique_id: data.formUniqueId,
|
|
914
|
+
user_unique_id: data.userUniqueId,
|
|
915
|
+
source: data.source,
|
|
916
|
+
date_part: data.datePart,
|
|
693
917
|
from_date: data.fromDate instanceof Date ? data.fromDate.toISOString() : data.fromDate,
|
|
694
918
|
to_date: data.toDate instanceof Date ? data.toDate.toISOString() : data.toDate,
|
|
695
919
|
status: data.status,
|
|
696
|
-
|
|
920
|
+
page: data.page,
|
|
921
|
+
records: data.records
|
|
697
922
|
}
|
|
698
923
|
});
|
|
699
924
|
const result = decodePageResult(response, appointmentMapper);
|
|
@@ -701,12 +926,16 @@ function createAppointmentsService(transport, _config) {
|
|
|
701
926
|
},
|
|
702
927
|
async reportSummary (data) {
|
|
703
928
|
const response = await transport.post('/reports/appointments/summary', {
|
|
704
|
-
|
|
929
|
+
query_params: {
|
|
705
930
|
form_unique_id: data.formUniqueId,
|
|
931
|
+
user_unique_id: data.userUniqueId,
|
|
932
|
+
source: data.source,
|
|
933
|
+
date_part: data.datePart,
|
|
706
934
|
from_date: data.fromDate instanceof Date ? data.fromDate.toISOString() : data.fromDate,
|
|
707
935
|
to_date: data.toDate instanceof Date ? data.toDate.toISOString() : data.toDate,
|
|
708
936
|
status: data.status,
|
|
709
|
-
|
|
937
|
+
page: data.page,
|
|
938
|
+
records: data.records
|
|
710
939
|
}
|
|
711
940
|
});
|
|
712
941
|
return response;
|
|
@@ -717,15 +946,29 @@ function createAppointmentsService(transport, _config) {
|
|
|
717
946
|
const surveyMapper = {
|
|
718
947
|
type: 'survey_instance',
|
|
719
948
|
map: (resource)=>{
|
|
720
|
-
var _parseString
|
|
949
|
+
var _parseString;
|
|
721
950
|
return {
|
|
951
|
+
id: resource.id,
|
|
722
952
|
uniqueId: resource.id,
|
|
723
953
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
724
954
|
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
725
955
|
email: parseString(resource.attributes['email']),
|
|
726
956
|
firstName: parseString(resource.attributes['first_name']),
|
|
957
|
+
middleName: parseString(resource.attributes['middle_name']),
|
|
727
958
|
lastName: parseString(resource.attributes['last_name']),
|
|
728
|
-
|
|
959
|
+
phoneNumber: parseString(resource.attributes['phone_number']),
|
|
960
|
+
message: parseString(resource.attributes['message']),
|
|
961
|
+
notes: parseString(resource.attributes['notes']),
|
|
962
|
+
selectedOption: parseString(resource.attributes['selected_option']),
|
|
963
|
+
formFields: resource.attributes['form_fields'],
|
|
964
|
+
source: parseString(resource.attributes['source']),
|
|
965
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
966
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
967
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
968
|
+
visitorUniqueId: parseString(resource.attributes['visitor_unique_id']),
|
|
969
|
+
visitorType: parseString(resource.attributes['visitor_type']),
|
|
970
|
+
touchId: parseString(resource.attributes['touch_id']),
|
|
971
|
+
touchReferenceId: parseString(resource.attributes['touch_reference_id']),
|
|
729
972
|
status: parseStatus(resource.attributes['status']),
|
|
730
973
|
token: parseString(resource.attributes['token']),
|
|
731
974
|
startedAt: parseDate(resource.attributes['started_at']),
|
|
@@ -768,26 +1011,49 @@ function createSurveysService(transport, _config) {
|
|
|
768
1011
|
},
|
|
769
1012
|
async create (formUniqueId, data) {
|
|
770
1013
|
const response = await transport.post(`/surveys/${formUniqueId}/instances`, {
|
|
771
|
-
|
|
772
|
-
user_unique_id: data.userUniqueId,
|
|
1014
|
+
survey: {
|
|
773
1015
|
email: data.email,
|
|
774
1016
|
first_name: data.firstName,
|
|
1017
|
+
middle_name: data.middleName,
|
|
775
1018
|
last_name: data.lastName,
|
|
776
|
-
|
|
777
|
-
|
|
1019
|
+
phone_number: data.phoneNumber,
|
|
1020
|
+
message: data.message,
|
|
1021
|
+
notes: data.notes,
|
|
1022
|
+
selected_option: data.selectedOption,
|
|
1023
|
+
form_fields: data.formFields,
|
|
1024
|
+
source: data.source,
|
|
1025
|
+
source_alias: data.sourceAlias,
|
|
1026
|
+
source_id: data.sourceId,
|
|
1027
|
+
source_type: data.sourceType,
|
|
1028
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
1029
|
+
visitor_type: data.visitorType,
|
|
1030
|
+
touch_id: data.touchId,
|
|
1031
|
+
touch_reference_id: data.touchReferenceId
|
|
778
1032
|
}
|
|
779
1033
|
});
|
|
780
1034
|
return decodeOne(response, surveyMapper);
|
|
781
1035
|
},
|
|
782
1036
|
async update (formUniqueId, uniqueId, data) {
|
|
783
1037
|
const response = await transport.put(`/surveys/${formUniqueId}/instances/${uniqueId}`, {
|
|
784
|
-
|
|
1038
|
+
survey: {
|
|
785
1039
|
email: data.email,
|
|
786
1040
|
first_name: data.firstName,
|
|
1041
|
+
middle_name: data.middleName,
|
|
787
1042
|
last_name: data.lastName,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
1043
|
+
phone_number: data.phoneNumber,
|
|
1044
|
+
message: data.message,
|
|
1045
|
+
notes: data.notes,
|
|
1046
|
+
selected_option: data.selectedOption,
|
|
1047
|
+
form_fields: data.formFields,
|
|
1048
|
+
source: data.source,
|
|
1049
|
+
source_alias: data.sourceAlias,
|
|
1050
|
+
source_id: data.sourceId,
|
|
1051
|
+
source_type: data.sourceType,
|
|
1052
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
1053
|
+
visitor_type: data.visitorType,
|
|
1054
|
+
touch_id: data.touchId,
|
|
1055
|
+
touch_reference_id: data.touchReferenceId,
|
|
1056
|
+
status: data.status
|
|
791
1057
|
}
|
|
792
1058
|
});
|
|
793
1059
|
return decodeOne(response, surveyMapper);
|
|
@@ -797,7 +1063,7 @@ function createSurveysService(transport, _config) {
|
|
|
797
1063
|
},
|
|
798
1064
|
async updateStatus (formUniqueId, uniqueId, data) {
|
|
799
1065
|
const response = await transport.put(`/surveys/${formUniqueId}/instances/${uniqueId}/status`, {
|
|
800
|
-
|
|
1066
|
+
survey: {
|
|
801
1067
|
status: data.status
|
|
802
1068
|
}
|
|
803
1069
|
});
|
|
@@ -823,17 +1089,32 @@ function createSurveysService(transport, _config) {
|
|
|
823
1089
|
const referralMapper = {
|
|
824
1090
|
type: 'referral',
|
|
825
1091
|
map: (resource)=>{
|
|
826
|
-
var _parseString
|
|
1092
|
+
var _parseString;
|
|
827
1093
|
return {
|
|
1094
|
+
id: resource.id,
|
|
828
1095
|
uniqueId: resource.id,
|
|
829
1096
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
1097
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
1098
|
+
firstName: parseString(resource.attributes['first_name']),
|
|
1099
|
+
middleName: parseString(resource.attributes['middle_name']),
|
|
1100
|
+
lastName: parseString(resource.attributes['last_name']),
|
|
1101
|
+
email: parseString(resource.attributes['email']),
|
|
1102
|
+
phoneNumber: parseString(resource.attributes['phone_number']),
|
|
1103
|
+
message: parseString(resource.attributes['message']),
|
|
1104
|
+
notes: parseString(resource.attributes['notes']),
|
|
1105
|
+
selectedOption: parseString(resource.attributes['selected_option']),
|
|
1106
|
+
formFields: resource.attributes['form_fields'],
|
|
1107
|
+
referredByType: parseString(resource.attributes['referred_by_type']),
|
|
1108
|
+
referredByName: parseString(resource.attributes['referred_by_name']),
|
|
1109
|
+
referredByUniqueId: parseString(resource.attributes['referred_by_unique_id']),
|
|
1110
|
+
source: parseString(resource.attributes['source']),
|
|
1111
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
1112
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
1113
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
1114
|
+
visitorUniqueId: parseString(resource.attributes['visitor_unique_id']),
|
|
1115
|
+
visitorType: parseString(resource.attributes['visitor_type']),
|
|
1116
|
+
touchId: parseString(resource.attributes['touch_id']),
|
|
1117
|
+
touchReferenceId: parseString(resource.attributes['touch_reference_id']),
|
|
837
1118
|
status: parseStatus(resource.attributes['status']),
|
|
838
1119
|
convertedAt: parseDate(resource.attributes['converted_at']),
|
|
839
1120
|
payload: resource.attributes['payload'],
|
|
@@ -850,7 +1131,6 @@ function createReferralsService(transport, _config) {
|
|
|
850
1131
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
851
1132
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
852
1133
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
853
|
-
if (params == null ? void 0 : params.referrerUniqueId) queryParams['referrer_unique_id'] = params.referrerUniqueId;
|
|
854
1134
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
855
1135
|
const response = await transport.get(`/referrals/${formUniqueId}/instances`, {
|
|
856
1136
|
params: queryParams
|
|
@@ -864,14 +1144,26 @@ function createReferralsService(transport, _config) {
|
|
|
864
1144
|
async create (formUniqueId, data) {
|
|
865
1145
|
const response = await transport.post(`/referrals/${formUniqueId}/instances`, {
|
|
866
1146
|
referral: {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1147
|
+
first_name: data.firstName,
|
|
1148
|
+
middle_name: data.middleName,
|
|
1149
|
+
last_name: data.lastName,
|
|
1150
|
+
email: data.email,
|
|
1151
|
+
phone_number: data.phoneNumber,
|
|
1152
|
+
message: data.message,
|
|
1153
|
+
notes: data.notes,
|
|
1154
|
+
selected_option: data.selectedOption,
|
|
1155
|
+
form_fields: data.formFields,
|
|
1156
|
+
referred_by_type: data.referredByType,
|
|
1157
|
+
referred_by_name: data.referredByName,
|
|
1158
|
+
referred_by_unique_id: data.referredByUniqueId,
|
|
1159
|
+
source: data.source,
|
|
1160
|
+
source_alias: data.sourceAlias,
|
|
1161
|
+
source_id: data.sourceId,
|
|
1162
|
+
source_type: data.sourceType,
|
|
1163
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
1164
|
+
visitor_type: data.visitorType,
|
|
1165
|
+
touch_id: data.touchId,
|
|
1166
|
+
touch_reference_id: data.touchReferenceId
|
|
875
1167
|
}
|
|
876
1168
|
});
|
|
877
1169
|
return decodeOne(response, referralMapper);
|
|
@@ -879,12 +1171,27 @@ function createReferralsService(transport, _config) {
|
|
|
879
1171
|
async update (formUniqueId, uniqueId, data) {
|
|
880
1172
|
const response = await transport.put(`/referrals/${formUniqueId}/instances/${uniqueId}`, {
|
|
881
1173
|
referral: {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1174
|
+
first_name: data.firstName,
|
|
1175
|
+
middle_name: data.middleName,
|
|
1176
|
+
last_name: data.lastName,
|
|
1177
|
+
email: data.email,
|
|
1178
|
+
phone_number: data.phoneNumber,
|
|
1179
|
+
message: data.message,
|
|
1180
|
+
notes: data.notes,
|
|
1181
|
+
selected_option: data.selectedOption,
|
|
1182
|
+
form_fields: data.formFields,
|
|
1183
|
+
referred_by_type: data.referredByType,
|
|
1184
|
+
referred_by_name: data.referredByName,
|
|
1185
|
+
referred_by_unique_id: data.referredByUniqueId,
|
|
1186
|
+
source: data.source,
|
|
1187
|
+
source_alias: data.sourceAlias,
|
|
1188
|
+
source_id: data.sourceId,
|
|
1189
|
+
source_type: data.sourceType,
|
|
1190
|
+
visitor_unique_id: data.visitorUniqueId,
|
|
1191
|
+
visitor_type: data.visitorType,
|
|
1192
|
+
touch_id: data.touchId,
|
|
1193
|
+
touch_reference_id: data.touchReferenceId,
|
|
1194
|
+
status: data.status
|
|
888
1195
|
}
|
|
889
1196
|
});
|
|
890
1197
|
return decodeOne(response, referralMapper);
|
|
@@ -898,18 +1205,27 @@ function createReferralsService(transport, _config) {
|
|
|
898
1205
|
const mailTemplateMapper = {
|
|
899
1206
|
type: 'mail_template',
|
|
900
1207
|
map: (resource)=>{
|
|
901
|
-
var _parseString
|
|
1208
|
+
var _parseString;
|
|
902
1209
|
return {
|
|
1210
|
+
id: resource.id,
|
|
903
1211
|
uniqueId: resource.id,
|
|
904
1212
|
name: (_parseString = parseString(resource.attributes['name'])) != null ? _parseString : '',
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1213
|
+
eventName: parseString(resource.attributes['event_name']),
|
|
1214
|
+
fromSubject: parseString(resource.attributes['from_subject']),
|
|
1215
|
+
templateHtml: parseString(resource.attributes['template_html']),
|
|
1216
|
+
templateText: parseString(resource.attributes['template_text']),
|
|
1217
|
+
templateName: parseString(resource.attributes['template_name']),
|
|
1218
|
+
fromAddress: parseString(resource.attributes['from_address']),
|
|
1219
|
+
fromDomain: parseString(resource.attributes['from_domain']),
|
|
911
1220
|
fromName: parseString(resource.attributes['from_name']),
|
|
912
|
-
|
|
1221
|
+
provider: parseString(resource.attributes['provider']),
|
|
1222
|
+
source: parseString(resource.attributes['source']),
|
|
1223
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
1224
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
1225
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
1226
|
+
preferredLanguage: parseString(resource.attributes['preferred_language']),
|
|
1227
|
+
key: parseString(resource.attributes['key']),
|
|
1228
|
+
secret: parseString(resource.attributes['secret']),
|
|
913
1229
|
status: parseStatus(resource.attributes['status']),
|
|
914
1230
|
payload: resource.attributes['payload'],
|
|
915
1231
|
createdAt: parseDate(resource.attributes['created_at']),
|
|
@@ -938,16 +1254,24 @@ function createMailTemplatesService(transport, _config) {
|
|
|
938
1254
|
},
|
|
939
1255
|
async create (data) {
|
|
940
1256
|
const response = await transport.post('/mailtemplates', {
|
|
941
|
-
|
|
1257
|
+
template: {
|
|
942
1258
|
name: data.name,
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1259
|
+
event_name: data.eventName,
|
|
1260
|
+
from_subject: data.fromSubject,
|
|
1261
|
+
template_html: data.templateHtml,
|
|
1262
|
+
template_text: data.templateText,
|
|
1263
|
+
template_name: data.templateName,
|
|
1264
|
+
from_address: data.fromAddress,
|
|
1265
|
+
from_domain: data.fromDomain,
|
|
949
1266
|
from_name: data.fromName,
|
|
950
|
-
|
|
1267
|
+
provider: data.provider,
|
|
1268
|
+
source: data.source,
|
|
1269
|
+
source_alias: data.sourceAlias,
|
|
1270
|
+
source_id: data.sourceId,
|
|
1271
|
+
source_type: data.sourceType,
|
|
1272
|
+
preferred_language: data.preferredLanguage,
|
|
1273
|
+
key: data.key,
|
|
1274
|
+
secret: data.secret,
|
|
951
1275
|
payload: data.payload
|
|
952
1276
|
}
|
|
953
1277
|
});
|
|
@@ -955,16 +1279,24 @@ function createMailTemplatesService(transport, _config) {
|
|
|
955
1279
|
},
|
|
956
1280
|
async update (uniqueId, data) {
|
|
957
1281
|
const response = await transport.put(`/mailtemplates/${uniqueId}`, {
|
|
958
|
-
|
|
1282
|
+
template: {
|
|
959
1283
|
name: data.name,
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1284
|
+
event_name: data.eventName,
|
|
1285
|
+
from_subject: data.fromSubject,
|
|
1286
|
+
template_html: data.templateHtml,
|
|
1287
|
+
template_text: data.templateText,
|
|
1288
|
+
template_name: data.templateName,
|
|
1289
|
+
from_address: data.fromAddress,
|
|
1290
|
+
from_domain: data.fromDomain,
|
|
966
1291
|
from_name: data.fromName,
|
|
967
|
-
|
|
1292
|
+
provider: data.provider,
|
|
1293
|
+
source: data.source,
|
|
1294
|
+
source_alias: data.sourceAlias,
|
|
1295
|
+
source_id: data.sourceId,
|
|
1296
|
+
source_type: data.sourceType,
|
|
1297
|
+
preferred_language: data.preferredLanguage,
|
|
1298
|
+
key: data.key,
|
|
1299
|
+
secret: data.secret,
|
|
968
1300
|
status: data.status,
|
|
969
1301
|
payload: data.payload
|
|
970
1302
|
}
|
|
@@ -995,6 +1327,7 @@ const applicationFormMapper = {
|
|
|
995
1327
|
map: (resource)=>{
|
|
996
1328
|
var _parseString, _resource_attributes_schema;
|
|
997
1329
|
return {
|
|
1330
|
+
id: resource.id,
|
|
998
1331
|
uniqueId: resource.id,
|
|
999
1332
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
1000
1333
|
title: parseString(resource.attributes['title']),
|
|
@@ -1031,6 +1364,7 @@ const applicationFormResponseMapper = {
|
|
|
1031
1364
|
map: (resource)=>{
|
|
1032
1365
|
var _parseString, _resource_attributes_data;
|
|
1033
1366
|
return {
|
|
1367
|
+
id: resource.id,
|
|
1034
1368
|
uniqueId: resource.id,
|
|
1035
1369
|
formUniqueId: (_parseString = parseString(resource.attributes['form_unique_id'])) != null ? _parseString : '',
|
|
1036
1370
|
data: (_resource_attributes_data = resource.attributes['data']) != null ? _resource_attributes_data : {},
|
|
@@ -1051,19 +1385,13 @@ function createApplicationFormsService(transport, _config) {
|
|
|
1051
1385
|
},
|
|
1052
1386
|
async submit (urlId, data) {
|
|
1053
1387
|
const response = await transport.post(`/${urlId}/forms/public`, {
|
|
1054
|
-
|
|
1055
|
-
data: data.data,
|
|
1056
|
-
payload: data.payload
|
|
1057
|
-
}
|
|
1388
|
+
responses: data.data
|
|
1058
1389
|
});
|
|
1059
1390
|
return decodeOne(response, applicationFormResponseMapper);
|
|
1060
1391
|
},
|
|
1061
1392
|
async draft (urlId, data) {
|
|
1062
1393
|
const response = await transport.put(`/${urlId}/forms/public`, {
|
|
1063
|
-
|
|
1064
|
-
data: data.data,
|
|
1065
|
-
payload: data.payload
|
|
1066
|
-
}
|
|
1394
|
+
responses: data.data
|
|
1067
1395
|
});
|
|
1068
1396
|
return decodeOne(response, applicationFormResponseMapper);
|
|
1069
1397
|
},
|
|
@@ -1090,19 +1418,28 @@ function createCrmSyncService(transport, _config) {
|
|
|
1090
1418
|
const response = await transport.post(`/crm/sync/subscription/${uniqueId}`, {});
|
|
1091
1419
|
return mapSyncResult(response);
|
|
1092
1420
|
},
|
|
1093
|
-
async syncAppointment (uniqueId) {
|
|
1094
|
-
const
|
|
1421
|
+
async syncAppointment (uniqueId, asType) {
|
|
1422
|
+
const body = {};
|
|
1423
|
+
if (asType) body['as_type'] = asType;
|
|
1424
|
+
const response = await transport.post(`/crm/sync/appointment/${uniqueId}`, body);
|
|
1095
1425
|
return mapSyncResult(response);
|
|
1096
1426
|
},
|
|
1097
1427
|
async batchSync (data) {
|
|
1098
1428
|
const response = await transport.post('/crm/sync/batch', {
|
|
1099
|
-
|
|
1100
|
-
|
|
1429
|
+
batch: {
|
|
1430
|
+
limit: data.limit,
|
|
1431
|
+
sync_landings: data.syncLandings,
|
|
1432
|
+
sync_subscriptions: data.syncSubscriptions,
|
|
1433
|
+
sync_appointments: data.syncAppointments,
|
|
1434
|
+
appointments_as_type: data.appointmentsAsType
|
|
1435
|
+
}
|
|
1101
1436
|
});
|
|
1102
1437
|
return mapBatchResult(response);
|
|
1103
1438
|
},
|
|
1104
|
-
async retryFailed () {
|
|
1105
|
-
const
|
|
1439
|
+
async retryFailed (limit) {
|
|
1440
|
+
const body = {};
|
|
1441
|
+
if (limit !== undefined) body['limit'] = limit;
|
|
1442
|
+
const response = await transport.post('/crm/sync/retry_failed', body);
|
|
1106
1443
|
return mapBatchResult(response);
|
|
1107
1444
|
},
|
|
1108
1445
|
async testConnection () {
|
|
@@ -1164,7 +1501,7 @@ function mapBatchResult(response) {
|
|
|
1164
1501
|
*
|
|
1165
1502
|
* @example
|
|
1166
1503
|
* ```typescript
|
|
1167
|
-
* const block = createFormsBlock(transport, {
|
|
1504
|
+
* const block = createFormsBlock(transport, { apiKey: 'xxx' });
|
|
1168
1505
|
* const forms = await block.forms.list({ page: 1 });
|
|
1169
1506
|
* ```
|
|
1170
1507
|
*/ function createFormsBlock(transport, config) {
|