@comicrelief/lambda-wrapper 1.10.1 → 2.0.0-beta.2
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 +172 -47
- package/dist/core/DependencyAwareClass.d.ts +15 -0
- package/dist/core/DependencyAwareClass.d.ts.map +1 -0
- package/dist/core/DependencyAwareClass.js +20 -0
- package/dist/core/DependencyAwareClass.js.map +1 -0
- package/dist/core/DependencyInjection.d.ts +62 -0
- package/dist/core/DependencyInjection.d.ts.map +1 -0
- package/dist/core/DependencyInjection.js +83 -0
- package/dist/core/DependencyInjection.js.map +1 -0
- package/dist/core/LambdaWrapper.d.ts +61 -0
- package/dist/core/LambdaWrapper.d.ts.map +1 -0
- package/dist/core/LambdaWrapper.js +126 -0
- package/dist/core/LambdaWrapper.js.map +1 -0
- package/dist/core/config.d.ts +20 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +21 -0
- package/dist/core/config.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -162
- package/dist/index.js.map +1 -0
- package/dist/models/ResponseModel.d.ts +91 -0
- package/dist/models/ResponseModel.d.ts.map +1 -0
- package/dist/models/ResponseModel.js +100 -0
- package/dist/models/ResponseModel.js.map +1 -0
- package/dist/models/SQSMessageModel.d.ts +46 -0
- package/dist/models/SQSMessageModel.d.ts.map +1 -0
- package/dist/models/SQSMessageModel.js +65 -0
- package/dist/models/SQSMessageModel.js.map +1 -0
- package/dist/models/StatusModel.d.ts +40 -0
- package/dist/models/StatusModel.d.ts.map +1 -0
- package/dist/models/StatusModel.js +50 -0
- package/dist/models/StatusModel.js.map +1 -0
- package/dist/services/BaseConfigService.d.ts +101 -0
- package/dist/services/BaseConfigService.d.ts.map +1 -0
- package/dist/services/BaseConfigService.js +180 -0
- package/dist/services/BaseConfigService.js.map +1 -0
- package/dist/services/HTTPService.d.ts +29 -0
- package/dist/services/HTTPService.d.ts.map +1 -0
- package/dist/services/HTTPService.js +55 -0
- package/dist/services/HTTPService.js.map +1 -0
- package/dist/services/LoggerService.d.ts +102 -0
- package/dist/services/LoggerService.d.ts.map +1 -0
- package/dist/services/LoggerService.js +258 -0
- package/dist/services/LoggerService.js.map +1 -0
- package/dist/services/RequestService.d.ts +119 -0
- package/dist/services/RequestService.d.ts.map +1 -0
- package/dist/services/RequestService.js +293 -0
- package/dist/services/RequestService.js.map +1 -0
- package/dist/services/SQSService.d.ts +181 -0
- package/dist/services/SQSService.d.ts.map +1 -0
- package/dist/services/SQSService.js +366 -0
- package/dist/services/SQSService.js.map +1 -0
- package/dist/services/TimerService.d.ts +22 -0
- package/dist/services/TimerService.d.ts.map +1 -0
- package/dist/services/TimerService.js +40 -0
- package/dist/services/TimerService.js.map +1 -0
- package/dist/utils/LambdaTermination.d.ts +14 -0
- package/dist/utils/LambdaTermination.d.ts.map +1 -0
- package/dist/utils/LambdaTermination.js +23 -0
- package/dist/utils/LambdaTermination.js.map +1 -0
- package/dist/utils/PromisifiedDelay.d.ts +17 -0
- package/dist/utils/PromisifiedDelay.d.ts.map +1 -0
- package/dist/utils/PromisifiedDelay.js +48 -0
- package/dist/utils/PromisifiedDelay.js.map +1 -0
- package/package.json +29 -19
- package/.eslintrc.yml +0 -16
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/main.yml +0 -74
- package/babel.config.js +0 -13
- package/dist/Config/Dependencies.js +0 -40
- package/dist/DependencyInjection/DependencyAware.class.js +0 -47
- package/dist/DependencyInjection/DependencyInjection.class.js +0 -131
- package/dist/Model/CloudEvent.model.js +0 -156
- package/dist/Model/Model.model.js +0 -45
- package/dist/Model/Response.model.js +0 -150
- package/dist/Model/SQS/MarketingPreference.constraints.json +0 -28
- package/dist/Model/SQS/MarketingPreference.model.js +0 -641
- package/dist/Model/SQS/Message.model.js +0 -104
- package/dist/Model/Status.model.js +0 -82
- package/dist/Service/BaseConfig.service.js +0 -225
- package/dist/Service/HTTP.service.js +0 -70
- package/dist/Service/Logger.service.js +0 -293
- package/dist/Service/Request.service.js +0 -341
- package/dist/Service/SQS.service.js +0 -420
- package/dist/Service/Timer.service.js +0 -55
- package/dist/Wrapper/LambdaTermination.js +0 -39
- package/dist/Wrapper/LambdaWrapper.js +0 -164
- package/dist/Wrapper/PromisifiedDelay.js +0 -59
|
@@ -1,641 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.ERROR_TYPES = void 0;
|
|
7
|
-
|
|
8
|
-
var _validate = _interopRequireDefault(require("validate.js"));
|
|
9
|
-
|
|
10
|
-
var _Model = _interopRequireDefault(require("../Model.model"));
|
|
11
|
-
|
|
12
|
-
var _Response = _interopRequireDefault(require("../Response.model"));
|
|
13
|
-
|
|
14
|
-
var _MarketingPreferenceConstraints = _interopRequireDefault(require("./MarketingPreference.constraints.json"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
/* eslint-disable sonarjs/cognitive-complexity */
|
|
19
|
-
// Define action specific error types
|
|
20
|
-
const ERROR_TYPES = {
|
|
21
|
-
VALIDATION_ERROR: new _Response.default({}, 400, 'required fields are missing')
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Marketing Preference
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
exports.ERROR_TYPES = ERROR_TYPES;
|
|
28
|
-
|
|
29
|
-
class MarketingPreference extends _Model.default {
|
|
30
|
-
/**
|
|
31
|
-
* Message constructor
|
|
32
|
-
*
|
|
33
|
-
* @param data object
|
|
34
|
-
*/
|
|
35
|
-
constructor(data = {}) {
|
|
36
|
-
super();
|
|
37
|
-
this.firstname = null;
|
|
38
|
-
this.lastname = null;
|
|
39
|
-
this.phone = null;
|
|
40
|
-
this.mobile = null;
|
|
41
|
-
this.address1 = null;
|
|
42
|
-
this.address2 = null;
|
|
43
|
-
this.address3 = null;
|
|
44
|
-
this.town = null;
|
|
45
|
-
this.postcode = null;
|
|
46
|
-
this.country = null;
|
|
47
|
-
this.campaign = '';
|
|
48
|
-
this.transactionId = null;
|
|
49
|
-
this.transSource = '';
|
|
50
|
-
this.transSourceUrl = '';
|
|
51
|
-
this.transType = 'prefs';
|
|
52
|
-
this.email = null;
|
|
53
|
-
this.permissionPost = null;
|
|
54
|
-
this.permissionEmail = null;
|
|
55
|
-
this.permissionPhone = null;
|
|
56
|
-
this.permissionSMS = null;
|
|
57
|
-
this.timestamp = null;
|
|
58
|
-
this.instantiateFunctionWithDefinedValue('setFirstName', data.firstName);
|
|
59
|
-
this.instantiateFunctionWithDefinedValue('setFirstName', data.firstname);
|
|
60
|
-
this.instantiateFunctionWithDefinedValue('setLastName', data.lastName);
|
|
61
|
-
this.instantiateFunctionWithDefinedValue('setLastName', data.lastname);
|
|
62
|
-
this.instantiateFunctionWithDefinedValue('setPhone', data.phone);
|
|
63
|
-
this.instantiateFunctionWithDefinedValue('setMobile', data.mobile);
|
|
64
|
-
this.instantiateFunctionWithDefinedValue('setAddress1', data.address1);
|
|
65
|
-
this.instantiateFunctionWithDefinedValue('setAddress2', data.address2);
|
|
66
|
-
this.instantiateFunctionWithDefinedValue('setAddress3', data.address3);
|
|
67
|
-
this.instantiateFunctionWithDefinedValue('setTown', data.town);
|
|
68
|
-
this.instantiateFunctionWithDefinedValue('setPostcode', data.postcode);
|
|
69
|
-
this.instantiateFunctionWithDefinedValue('setCountry', data.country);
|
|
70
|
-
this.instantiateFunctionWithDefinedValue('setCampaign', data.campaign);
|
|
71
|
-
this.instantiateFunctionWithDefinedValue('setTransactionId', data.transactionId);
|
|
72
|
-
this.instantiateFunctionWithDefinedValue('setTransSource', data.transSource);
|
|
73
|
-
this.instantiateFunctionWithDefinedValue('setTransSourceUrl', data.transSourceUrl);
|
|
74
|
-
this.instantiateFunctionWithDefinedValue('setEmail', data.email);
|
|
75
|
-
this.instantiateFunctionWithDefinedValue('setPermissionPost', data.permissionPost);
|
|
76
|
-
this.instantiateFunctionWithDefinedValue('setPermissionEmail', data.permissionEmail);
|
|
77
|
-
this.instantiateFunctionWithDefinedValue('setPermissionPhone', data.permissionPhone);
|
|
78
|
-
this.instantiateFunctionWithDefinedValue('setPermissionSMS', data.permissionSMS);
|
|
79
|
-
|
|
80
|
-
if (typeof data.timestamp !== 'undefined' && data.timestamp !== '' && data.timestamp !== null) {
|
|
81
|
-
this.instantiateFunctionWithDefinedValue('setTimestamp', data.timestamp);
|
|
82
|
-
} else {
|
|
83
|
-
this.generateTimestamp();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get First Name
|
|
88
|
-
*
|
|
89
|
-
* @returns {string|*}
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
getFirstName() {
|
|
94
|
-
return this.firstname;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Set First Name
|
|
98
|
-
*
|
|
99
|
-
* @param value string
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
setFirstName(value) {
|
|
104
|
-
this.firstname = value;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get Last Name
|
|
108
|
-
*
|
|
109
|
-
* @returns {string|*}
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
getLastName() {
|
|
114
|
-
return this.lastname;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Set Last Name
|
|
118
|
-
*
|
|
119
|
-
* @param value string
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
setLastName(value) {
|
|
124
|
-
this.lastname = value;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get phone
|
|
128
|
-
*
|
|
129
|
-
* @returns {string|*}
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
getPhone() {
|
|
134
|
-
return this.phone;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Set phone
|
|
138
|
-
*
|
|
139
|
-
* @param value string
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
setPhone(value) {
|
|
144
|
-
this.phone = value;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get Mobile
|
|
148
|
-
*
|
|
149
|
-
* @returns {string|*}
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
getMobile() {
|
|
154
|
-
return this.mobile;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Set Mobile
|
|
158
|
-
*
|
|
159
|
-
* @param value string
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
setMobile(value) {
|
|
164
|
-
this.mobile = value;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Get Address Line 1
|
|
168
|
-
*
|
|
169
|
-
* @returns {string|*}
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
getAddress1() {
|
|
174
|
-
return this.address1;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Set Address Line 1
|
|
178
|
-
*
|
|
179
|
-
* @param value string
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
setAddress1(value) {
|
|
184
|
-
this.address1 = value;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Get Address Line 2
|
|
188
|
-
*
|
|
189
|
-
* @returns {string|*}
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
getAddress2() {
|
|
194
|
-
return this.address2;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Set Address Line 2
|
|
198
|
-
*
|
|
199
|
-
* @param value string
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
setAddress2(value) {
|
|
204
|
-
this.address2 = typeof value === 'undefined' || value === '' ? null : value;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Get Address Line 3
|
|
208
|
-
*
|
|
209
|
-
* @returns {string|*}
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
getAddress3() {
|
|
214
|
-
return this.address3;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Set Address Line 3
|
|
218
|
-
*
|
|
219
|
-
* @param value string
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
setAddress3(value) {
|
|
224
|
-
this.address3 = typeof value === 'undefined' || value === '' ? null : value;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Get Town
|
|
228
|
-
*
|
|
229
|
-
* @returns {string|*}
|
|
230
|
-
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
getTown() {
|
|
234
|
-
return this.town;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Set Town
|
|
238
|
-
*
|
|
239
|
-
* @param value string
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
setTown(value) {
|
|
244
|
-
this.town = value;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Get Postcode
|
|
248
|
-
*
|
|
249
|
-
* @returns {string|*}
|
|
250
|
-
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
getPostcode() {
|
|
254
|
-
return this.postcode;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Set Postcode
|
|
258
|
-
*
|
|
259
|
-
* @param value string
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
setPostcode(value) {
|
|
264
|
-
this.postcode = value;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Get Country
|
|
268
|
-
*
|
|
269
|
-
* @returns {string|*}
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
getCountry() {
|
|
274
|
-
return this.country;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Set Country
|
|
278
|
-
*
|
|
279
|
-
* @param value string
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
setCountry(value) {
|
|
284
|
-
this.country = value;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Get Campaign
|
|
288
|
-
*
|
|
289
|
-
* @returns {string|*}
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
getCampaign() {
|
|
294
|
-
return this.campaign;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Set Campaign
|
|
298
|
-
*
|
|
299
|
-
* @param value string
|
|
300
|
-
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
setCampaign(value) {
|
|
304
|
-
this.campaign = value;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Get Transaction Id
|
|
308
|
-
*
|
|
309
|
-
* @returns {string|*}
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
getTransactionId() {
|
|
314
|
-
return this.transactionId;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Set Transaction Id
|
|
318
|
-
*
|
|
319
|
-
* @param value string
|
|
320
|
-
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
setTransactionId(value) {
|
|
324
|
-
this.transactionId = value;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Get Transaction Source
|
|
328
|
-
*
|
|
329
|
-
* @returns {string|*}
|
|
330
|
-
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
getTransSource() {
|
|
334
|
-
return this.transSource;
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Set Transaction Source
|
|
338
|
-
*
|
|
339
|
-
* @param value string
|
|
340
|
-
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
setTransSource(value) {
|
|
344
|
-
this.transSource = value;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Get Transaction Source URL
|
|
348
|
-
*
|
|
349
|
-
* @returns {string|*}
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
getTransSourceUrl() {
|
|
354
|
-
return this.transSourceUrl;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Set Transaction Source URL
|
|
358
|
-
*
|
|
359
|
-
* @param value string
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
setTransSourceUrl(value) {
|
|
364
|
-
this.transSourceUrl = value;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Get Transaction Type
|
|
368
|
-
*
|
|
369
|
-
* @returns {string|*}
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
getTransType() {
|
|
374
|
-
return this.transType;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Set Transaction Type
|
|
378
|
-
*
|
|
379
|
-
* @param value string
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
setTransType(value) {
|
|
384
|
-
this.transType = value;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Get Email
|
|
388
|
-
*
|
|
389
|
-
* @returns {string|*}
|
|
390
|
-
*/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
getEmail() {
|
|
394
|
-
return this.email;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Set Email
|
|
398
|
-
*
|
|
399
|
-
* @param value string
|
|
400
|
-
*/
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
setEmail(value) {
|
|
404
|
-
this.email = value;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Get Email Permission
|
|
408
|
-
*
|
|
409
|
-
* @returns {string|*}
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
getPermissionEmail() {
|
|
414
|
-
return this.permissionEmail;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Set Email Permission
|
|
418
|
-
*
|
|
419
|
-
* @param value string
|
|
420
|
-
*/
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
setPermissionEmail(value) {
|
|
424
|
-
this.permissionEmail = typeof value === 'undefined' || value === '' ? null : value;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Get Post Permission
|
|
428
|
-
*
|
|
429
|
-
* @returns {string|*}
|
|
430
|
-
*/
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
getPermissionPost() {
|
|
434
|
-
return this.permissionPost;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Set Post Permission
|
|
438
|
-
*
|
|
439
|
-
* @param value string
|
|
440
|
-
*/
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
setPermissionPost(value) {
|
|
444
|
-
this.permissionPost = typeof value === 'undefined' || value === '' ? null : value;
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Get Phone Permission
|
|
448
|
-
*
|
|
449
|
-
* @returns {string|*}
|
|
450
|
-
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
getPermissionPhone() {
|
|
454
|
-
return this.permissionPhone;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Set Phone Permission
|
|
458
|
-
*
|
|
459
|
-
* @param value string
|
|
460
|
-
*/
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
setPermissionPhone(value) {
|
|
464
|
-
this.permissionPhone = typeof value === 'undefined' || value === '' ? null : value;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Get SMS Permission
|
|
468
|
-
*
|
|
469
|
-
* @returns {string|*}
|
|
470
|
-
*/
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
getPermissionSMS() {
|
|
474
|
-
return this.permissionSMS;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Set SMS Permission
|
|
478
|
-
*
|
|
479
|
-
* @param value string
|
|
480
|
-
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
setPermissionSMS(value) {
|
|
484
|
-
this.permissionSMS = typeof value === 'undefined' || value === '' ? null : value;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Get Timestamp
|
|
488
|
-
*
|
|
489
|
-
* @returns {string|*}
|
|
490
|
-
*/
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
getTimestamp() {
|
|
494
|
-
return this.timestamp;
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Set Timestamp
|
|
498
|
-
*
|
|
499
|
-
* @param value string
|
|
500
|
-
*/
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
setTimestamp(value) {
|
|
504
|
-
this.timestamp = value;
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Generate Timestamp
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
generateTimestamp() {
|
|
512
|
-
this.timestamp = Math.floor(Date.now() / 1000);
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Get Base entity mappings
|
|
516
|
-
*
|
|
517
|
-
* @returns {object}
|
|
518
|
-
*/
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
getEntityMappings() {
|
|
522
|
-
return {
|
|
523
|
-
firstname: this.getFirstName(),
|
|
524
|
-
lastname: this.getLastName(),
|
|
525
|
-
phone: this.getPhone(),
|
|
526
|
-
mobile: this.getMobile(),
|
|
527
|
-
address1: this.getAddress1(),
|
|
528
|
-
address2: this.getAddress2(),
|
|
529
|
-
address3: this.getAddress3(),
|
|
530
|
-
town: this.getTown(),
|
|
531
|
-
postcode: this.getPostcode(),
|
|
532
|
-
country: this.getCountry(),
|
|
533
|
-
campaign: this.getCampaign(),
|
|
534
|
-
transactionId: this.getTransactionId(),
|
|
535
|
-
transSource: this.getTransSource(),
|
|
536
|
-
transSourceUrl: this.getTransSourceUrl(),
|
|
537
|
-
transType: this.getTransType(),
|
|
538
|
-
email: this.getEmail(),
|
|
539
|
-
permissionEmail: this.getPermissionEmail(),
|
|
540
|
-
permissionPost: this.getPermissionPost(),
|
|
541
|
-
permissionPhone: this.getPermissionPhone(),
|
|
542
|
-
permissionSMS: this.getPermissionSMS(),
|
|
543
|
-
timestamp: this.getTimestamp()
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Check if any permission is set
|
|
548
|
-
*
|
|
549
|
-
* @returns {boolean}
|
|
550
|
-
*/
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
isPermissionSet() {
|
|
554
|
-
return this.getPermissionEmail() !== null && this.getPermissionEmail() !== '' || this.getPermissionPost() !== null && this.getPermissionPost() !== '' || this.getPermissionPhone() !== null && this.getPermissionPhone() !== '' || this.getPermissionSMS() !== null && this.getPermissionSMS() !== '';
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Validate the model
|
|
558
|
-
*
|
|
559
|
-
* @returns {Promise<any>}
|
|
560
|
-
*/
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
validate() {
|
|
564
|
-
return new Promise((resolve, reject) => {
|
|
565
|
-
const requestConstraintsClone = { ..._MarketingPreferenceConstraints.default
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
if (this.getPermissionEmail() !== null && this.getPermissionEmail() !== '' && this.getPermissionEmail() !== '0' && this.getPermissionEmail() !== 0 || this.getEmail()) {
|
|
569
|
-
if (this.getEmail()) {
|
|
570
|
-
requestConstraintsClone.email = {
|
|
571
|
-
email: true
|
|
572
|
-
};
|
|
573
|
-
} else {
|
|
574
|
-
requestConstraintsClone.email = {
|
|
575
|
-
presence: {
|
|
576
|
-
allowEmpty: false
|
|
577
|
-
},
|
|
578
|
-
email: true
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
} // Update constraints if fields are not empty
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
requestConstraintsClone.firstname = this.getFirstName() !== null && this.getFirstName() !== '' ? {
|
|
585
|
-
format: {
|
|
586
|
-
pattern: "[a-zA-Z.'-_ ]+",
|
|
587
|
-
flags: 'i',
|
|
588
|
-
message: 'can only contain alphabetical characters'
|
|
589
|
-
}
|
|
590
|
-
} : '';
|
|
591
|
-
requestConstraintsClone.lastname = this.getLastName() !== null && this.getLastName() !== '' ? {
|
|
592
|
-
format: {
|
|
593
|
-
pattern: "[a-zA-Z.'-_ ]+",
|
|
594
|
-
flags: 'i',
|
|
595
|
-
message: 'can only contain alphabetical characters'
|
|
596
|
-
}
|
|
597
|
-
} : '';
|
|
598
|
-
requestConstraintsClone.phone = this.getPhone() !== null && this.getPhone() !== '' ? {
|
|
599
|
-
format: {
|
|
600
|
-
pattern: '[0-9 ]+',
|
|
601
|
-
flags: 'i',
|
|
602
|
-
message: 'can only contain numerical characters'
|
|
603
|
-
}
|
|
604
|
-
} : '';
|
|
605
|
-
requestConstraintsClone.mobile = this.getMobile() !== null && this.getMobile() !== '' ? {
|
|
606
|
-
format: {
|
|
607
|
-
pattern: '[0-9 ]+',
|
|
608
|
-
flags: 'i',
|
|
609
|
-
message: 'can only contain numerical characters'
|
|
610
|
-
}
|
|
611
|
-
} : '';
|
|
612
|
-
requestConstraintsClone.address1 = this.getAddress1() !== null && this.getAddress1() !== '' ? {
|
|
613
|
-
format: {
|
|
614
|
-
pattern: "[a-zA-Z.'-_& ]+",
|
|
615
|
-
flags: 'i',
|
|
616
|
-
message: "can only contain alphanumeric characters and . ' - _ &"
|
|
617
|
-
}
|
|
618
|
-
} : '';
|
|
619
|
-
requestConstraintsClone.country = this.getCountry() !== null && this.getCountry() !== '' ? {
|
|
620
|
-
format: {
|
|
621
|
-
pattern: "[a-zA-Z.'-_& ]+",
|
|
622
|
-
flags: 'i',
|
|
623
|
-
message: "can only contain alphabetical characters and . ' - _ &"
|
|
624
|
-
}
|
|
625
|
-
} : '';
|
|
626
|
-
const validation = (0, _validate.default)(this.getEntityMappings(), requestConstraintsClone);
|
|
627
|
-
|
|
628
|
-
if (typeof validation === 'undefined') {
|
|
629
|
-
resolve();
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
const validationErrorResponse = ERROR_TYPES.VALIDATION_ERROR;
|
|
634
|
-
validationErrorResponse.setBodyVariable('validation_errors', validation);
|
|
635
|
-
reject(validationErrorResponse);
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
exports.default = MarketingPreference;
|