@segment/action-destinations 3.134.0 → 3.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/destinations/blackbaud-raisers-edge-nxt/api/index.d.ts +17 -12
  2. package/dist/destinations/blackbaud-raisers-edge-nxt/api/index.js +299 -32
  3. package/dist/destinations/blackbaud-raisers-edge-nxt/api/index.js.map +1 -1
  4. package/dist/destinations/blackbaud-raisers-edge-nxt/constants/index.d.ts +3 -1
  5. package/dist/destinations/blackbaud-raisers-edge-nxt/constants/index.js +4 -2
  6. package/dist/destinations/blackbaud-raisers-edge-nxt/constants/index.js.map +1 -1
  7. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/fixtures.d.ts +27 -0
  8. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/fixtures.js +60 -0
  9. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/fixtures.js.map +1 -0
  10. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/generated-types.d.ts +63 -0
  11. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/generated-types.js +3 -0
  12. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/generated-types.js.map +1 -0
  13. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/index.d.ts +5 -0
  14. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/index.js +242 -0
  15. package/dist/destinations/blackbaud-raisers-edge-nxt/createGift/index.js.map +1 -0
  16. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/fixtures.js +1 -1
  17. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/fixtures.js.map +1 -1
  18. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/generated-types.d.ts +1 -0
  19. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/index.d.ts +3 -1
  20. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/index.js +277 -550
  21. package/dist/destinations/blackbaud-raisers-edge-nxt/createOrUpdateIndividualConstituent/index.js.map +1 -1
  22. package/dist/destinations/blackbaud-raisers-edge-nxt/index.js +2 -0
  23. package/dist/destinations/blackbaud-raisers-edge-nxt/index.js.map +1 -1
  24. package/dist/destinations/blackbaud-raisers-edge-nxt/types/index.d.ts +61 -8
  25. package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.d.ts +6 -1
  26. package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.js +149 -5
  27. package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.js.map +1 -1
  28. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +1 -1
  29. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +5 -2
  30. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -1
  31. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +1 -1
  32. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +0 -1
  33. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
  34. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +4 -1
  35. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +1 -1
  36. package/dist/destinations/google-analytics-4/index.js +1 -1
  37. package/dist/destinations/google-analytics-4/index.js.map +1 -1
  38. package/dist/destinations/index.js +1 -0
  39. package/dist/destinations/index.js.map +1 -1
  40. package/dist/destinations/ironclad/recordAction.types.d.ts +12 -0
  41. package/dist/destinations/ironclad/recordAction.types.js +3 -0
  42. package/dist/destinations/ironclad/recordAction.types.js.map +1 -0
  43. package/dist/destinations/mixpanel/mixpanel-properties.js +0 -8
  44. package/dist/destinations/mixpanel/mixpanel-properties.js.map +1 -1
  45. package/dist/destinations/mixpanel/trackEvent/generated-types.d.ts +0 -3
  46. package/dist/destinations/mixpanel/trackPurchase/generated-types.d.ts +0 -3
  47. package/dist/destinations/outfunnel/forwardGroupEvent/generated-types.d.ts +14 -0
  48. package/dist/destinations/outfunnel/forwardGroupEvent/generated-types.js +3 -0
  49. package/dist/destinations/outfunnel/forwardGroupEvent/generated-types.js.map +1 -0
  50. package/dist/destinations/outfunnel/forwardGroupEvent/index.d.ts +5 -0
  51. package/dist/destinations/outfunnel/forwardGroupEvent/index.js +83 -0
  52. package/dist/destinations/outfunnel/forwardGroupEvent/index.js.map +1 -0
  53. package/dist/destinations/outfunnel/forwardIdentifyEvent/generated-types.d.ts +13 -0
  54. package/dist/destinations/outfunnel/forwardIdentifyEvent/generated-types.js +3 -0
  55. package/dist/destinations/outfunnel/forwardIdentifyEvent/generated-types.js.map +1 -0
  56. package/dist/destinations/outfunnel/forwardIdentifyEvent/index.d.ts +5 -0
  57. package/dist/destinations/outfunnel/forwardIdentifyEvent/index.js +76 -0
  58. package/dist/destinations/outfunnel/forwardIdentifyEvent/index.js.map +1 -0
  59. package/dist/destinations/outfunnel/forwardTrackEvent/generated-types.d.ts +15 -0
  60. package/dist/destinations/outfunnel/forwardTrackEvent/generated-types.js +3 -0
  61. package/dist/destinations/outfunnel/forwardTrackEvent/generated-types.js.map +1 -0
  62. package/dist/destinations/outfunnel/forwardTrackEvent/index.d.ts +5 -0
  63. package/dist/destinations/outfunnel/forwardTrackEvent/index.js +97 -0
  64. package/dist/destinations/outfunnel/forwardTrackEvent/index.js.map +1 -0
  65. package/dist/destinations/outfunnel/generated-types.d.ts +4 -0
  66. package/dist/destinations/outfunnel/generated-types.js +3 -0
  67. package/dist/destinations/outfunnel/generated-types.js.map +1 -0
  68. package/dist/destinations/outfunnel/index.d.ts +4 -0
  69. package/dist/destinations/outfunnel/index.js +54 -0
  70. package/dist/destinations/outfunnel/index.js.map +1 -0
  71. package/dist/destinations/outfunnel/presets.d.ts +2 -0
  72. package/dist/destinations/outfunnel/presets.js +31 -0
  73. package/dist/destinations/outfunnel/presets.js.map +1 -0
  74. package/dist/destinations/outfunnel/utils.d.ts +1 -0
  75. package/dist/destinations/outfunnel/utils.js +7 -0
  76. package/dist/destinations/outfunnel/utils.js.map +1 -0
  77. package/dist/destinations/qualtrics/qualtricsApiClient.js +3 -1
  78. package/dist/destinations/qualtrics/qualtricsApiClient.js.map +1 -1
  79. package/dist/destinations/ripe/group/index.js +0 -1
  80. package/dist/destinations/ripe/group/index.js.map +1 -1
  81. package/dist/destinations/ripe/identify/index.js +0 -1
  82. package/dist/destinations/ripe/identify/index.js.map +1 -1
  83. package/dist/destinations/ripe/page/index.js +0 -1
  84. package/dist/destinations/ripe/page/index.js.map +1 -1
  85. package/dist/destinations/ripe/track/index.js +0 -1
  86. package/dist/destinations/ripe/track/index.js.map +1 -1
  87. package/dist/destinations/segment-profiles/segment-properties.js +1 -1
  88. package/dist/destinations/twilio/sendSMS.types.d.ts +1 -0
  89. package/dist/destinations/voucherify/index.js +1 -1
  90. package/dist/destinations/voucherify/index.js.map +1 -1
  91. package/package.json +2 -2
@@ -1,619 +1,346 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const actions_core_1 = require("@segment/actions-core");
3
+ exports.perform = exports.fields = void 0;
4
4
  const api_1 = require("../api");
5
5
  const utils_1 = require("../utils");
6
- const action = {
7
- title: 'Create or Update Individual Constituent',
8
- description: "Create or update an Individual Constituent record in Raiser's Edge NXT.",
9
- defaultSubscription: 'type = "identify"',
10
- fields: {
11
- address: {
12
- label: 'Address',
13
- description: "The constituent's address.",
14
- type: 'object',
15
- properties: {
16
- address_lines: {
17
- label: 'Address Lines',
18
- type: 'string'
19
- },
20
- city: {
21
- label: 'City',
22
- type: 'string'
23
- },
24
- country: {
25
- label: 'Country',
26
- type: 'string'
27
- },
28
- do_not_mail: {
29
- label: 'Do Not Mail',
30
- type: 'boolean'
31
- },
32
- postal_code: {
33
- label: 'ZIP/Postal Code',
34
- type: 'string'
35
- },
36
- primary: {
37
- label: 'Is Primary',
38
- type: 'boolean'
39
- },
40
- state: {
41
- label: 'State/Province',
42
- type: 'string'
43
- },
44
- type: {
45
- label: 'Address Type',
46
- type: 'string'
47
- }
6
+ exports.fields = {
7
+ address: {
8
+ label: 'Address',
9
+ description: "The constituent's address.",
10
+ type: 'object',
11
+ properties: {
12
+ address_lines: {
13
+ label: 'Address Lines',
14
+ type: 'string'
48
15
  },
49
- default: {
50
- address_lines: {
51
- '@if': {
52
- exists: {
53
- '@path': '$.traits.address.street'
54
- },
55
- then: {
56
- '@path': '$.traits.address.street'
57
- },
58
- else: {
59
- '@path': '$.properties.address.street'
60
- }
61
- }
62
- },
63
- city: {
64
- '@if': {
65
- exists: {
66
- '@path': '$.traits.address.city'
67
- },
68
- then: {
69
- '@path': '$.traits.address.city'
70
- },
71
- else: {
72
- '@path': '$.properties.address.city'
73
- }
74
- }
75
- },
76
- country: {
77
- '@if': {
78
- exists: {
79
- '@path': '$.traits.address.country'
80
- },
81
- then: {
82
- '@path': '$.traits.address.country'
83
- },
84
- else: {
85
- '@path': '$.properties.address.country'
86
- }
87
- }
88
- },
89
- do_not_mail: '',
90
- postal_code: {
91
- '@if': {
92
- exists: {
93
- '@path': '$.traits.address.postalCode'
94
- },
95
- then: {
96
- '@path': '$.traits.address.postalCode'
97
- },
98
- else: {
99
- '@path': '$.properties.address.postalCode'
100
- }
101
- }
102
- },
103
- primary: '',
104
- state: {
105
- '@if': {
106
- exists: {
107
- '@path': '$.traits.address.state'
108
- },
109
- then: {
110
- '@path': '$.traits.address.state'
111
- },
112
- else: {
113
- '@path': '$.properties.address.state'
114
- }
115
- }
116
- },
117
- type: ''
16
+ city: {
17
+ label: 'City',
18
+ type: 'string'
19
+ },
20
+ country: {
21
+ label: 'Country',
22
+ type: 'string'
23
+ },
24
+ do_not_mail: {
25
+ label: 'Do Not Mail',
26
+ type: 'boolean'
27
+ },
28
+ postal_code: {
29
+ label: 'ZIP/Postal Code',
30
+ type: 'string'
31
+ },
32
+ primary: {
33
+ label: 'Is Primary',
34
+ type: 'boolean'
35
+ },
36
+ state: {
37
+ label: 'State/Province',
38
+ type: 'string'
39
+ },
40
+ type: {
41
+ label: 'Address Type',
42
+ type: 'string'
118
43
  }
119
44
  },
120
- birthdate: {
121
- label: 'Birthdate',
122
- description: "The constituent's birthdate.",
123
- type: 'datetime',
124
- default: {
45
+ default: {
46
+ address_lines: {
125
47
  '@if': {
126
48
  exists: {
127
- '@path': '$.traits.birthday'
49
+ '@path': '$.traits.address.street'
128
50
  },
129
51
  then: {
130
- '@path': '$.traits.birthday'
52
+ '@path': '$.traits.address.street'
131
53
  },
132
54
  else: {
133
- '@path': '$.properties.birthday'
55
+ '@path': '$.properties.address.street'
134
56
  }
135
57
  }
136
- }
137
- },
138
- email: {
139
- label: 'Email',
140
- description: "The constituent's email address.",
141
- type: 'object',
142
- properties: {
143
- address: {
144
- label: 'Email Address',
145
- type: 'string'
146
- },
147
- do_not_email: {
148
- label: 'Do Not Email',
149
- type: 'boolean'
150
- },
151
- primary: {
152
- label: 'Is Primary',
153
- type: 'boolean'
154
- },
155
- type: {
156
- label: 'Email Type',
157
- type: 'string'
158
- }
159
58
  },
160
- default: {
161
- address: {
162
- '@if': {
163
- exists: {
164
- '@path': '$.traits.email'
165
- },
166
- then: {
167
- '@path': '$.traits.email'
168
- },
169
- else: {
170
- '@path': '$.properties.email'
171
- }
59
+ city: {
60
+ '@if': {
61
+ exists: {
62
+ '@path': '$.traits.address.city'
63
+ },
64
+ then: {
65
+ '@path': '$.traits.address.city'
66
+ },
67
+ else: {
68
+ '@path': '$.properties.address.city'
172
69
  }
173
- },
174
- do_not_email: '',
175
- primary: '',
176
- type: ''
177
- }
178
- },
179
- first: {
180
- label: 'First Name',
181
- description: "The constituent's first name up to 50 characters.",
182
- type: 'string',
183
- default: {
70
+ }
71
+ },
72
+ country: {
184
73
  '@if': {
185
74
  exists: {
186
- '@path': '$.traits.firstName'
75
+ '@path': '$.traits.address.country'
187
76
  },
188
77
  then: {
189
- '@path': '$.traits.firstName'
78
+ '@path': '$.traits.address.country'
190
79
  },
191
80
  else: {
192
- '@path': '$.properties.firstName'
81
+ '@path': '$.properties.address.country'
193
82
  }
194
83
  }
195
- }
196
- },
197
- gender: {
198
- label: 'Gender',
199
- description: "The constituent's gender.",
200
- type: 'string',
201
- default: {
84
+ },
85
+ do_not_mail: '',
86
+ postal_code: {
202
87
  '@if': {
203
88
  exists: {
204
- '@path': '$.traits.gender'
89
+ '@path': '$.traits.address.postalCode'
205
90
  },
206
91
  then: {
207
- '@path': '$.traits.gender'
92
+ '@path': '$.traits.address.postalCode'
208
93
  },
209
94
  else: {
210
- '@path': '$.properties.gender'
95
+ '@path': '$.properties.address.postalCode'
211
96
  }
212
97
  }
213
- }
214
- },
215
- income: {
216
- label: 'Income',
217
- description: "The constituent's income.",
218
- type: 'string'
219
- },
220
- last: {
221
- label: 'Last Name',
222
- description: "The constituent's last name up to 100 characters. This is required to create a constituent.",
223
- type: 'string',
224
- default: {
98
+ },
99
+ primary: '',
100
+ state: {
225
101
  '@if': {
226
102
  exists: {
227
- '@path': '$.traits.lastName'
103
+ '@path': '$.traits.address.state'
228
104
  },
229
105
  then: {
230
- '@path': '$.traits.lastName'
106
+ '@path': '$.traits.address.state'
231
107
  },
232
108
  else: {
233
- '@path': '$.properties.lastName'
109
+ '@path': '$.properties.address.state'
234
110
  }
235
111
  }
236
- }
237
- },
238
- lookup_id: {
239
- label: 'Lookup ID',
240
- description: 'The organization-defined identifier for the constituent.',
241
- type: 'string',
242
- default: ''
243
- },
244
- online_presence: {
245
- label: 'Online Presence',
246
- description: "The constituent's online presence.",
247
- type: 'object',
248
- properties: {
249
- address: {
250
- label: 'Web Address',
251
- type: 'string'
112
+ },
113
+ type: ''
114
+ }
115
+ },
116
+ birthdate: {
117
+ label: 'Birthdate',
118
+ description: "The constituent's birthdate.",
119
+ type: 'datetime',
120
+ default: {
121
+ '@if': {
122
+ exists: {
123
+ '@path': '$.traits.birthday'
252
124
  },
253
- primary: {
254
- label: 'Is Primary',
255
- type: 'boolean'
125
+ then: {
126
+ '@path': '$.traits.birthday'
256
127
  },
257
- type: {
258
- label: 'Online Presence Type',
259
- type: 'string'
128
+ else: {
129
+ '@path': '$.properties.birthday'
260
130
  }
131
+ }
132
+ }
133
+ },
134
+ constituent_id: {
135
+ label: 'Constituent ID',
136
+ description: 'The ID of the constituent.',
137
+ type: 'string'
138
+ },
139
+ email: {
140
+ label: 'Email',
141
+ description: "The constituent's email address.",
142
+ type: 'object',
143
+ properties: {
144
+ address: {
145
+ label: 'Email Address',
146
+ type: 'string'
261
147
  },
262
- default: {
263
- address: {
264
- '@if': {
265
- exists: {
266
- '@path': '$.traits.website'
267
- },
268
- then: {
269
- '@path': '$.traits.website'
270
- },
271
- else: {
272
- '@path': '$.properties.website'
273
- }
274
- }
275
- },
276
- primary: '',
277
- type: ''
148
+ do_not_email: {
149
+ label: 'Do Not Email',
150
+ type: 'boolean'
151
+ },
152
+ primary: {
153
+ label: 'Is Primary',
154
+ type: 'boolean'
155
+ },
156
+ type: {
157
+ label: 'Email Type',
158
+ type: 'string'
278
159
  }
279
160
  },
280
- phone: {
281
- label: 'Phone',
282
- description: "The constituent's phone number.",
283
- type: 'object',
284
- properties: {
285
- do_not_call: {
286
- label: 'Do Not Call',
287
- type: 'boolean'
288
- },
289
- number: {
290
- label: 'Phone Number',
291
- type: 'string'
292
- },
293
- primary: {
294
- label: 'Is Primary',
295
- type: 'boolean'
296
- },
297
- type: {
298
- label: 'Phone Type',
299
- type: 'string'
161
+ default: {
162
+ address: {
163
+ '@if': {
164
+ exists: {
165
+ '@path': '$.traits.email'
166
+ },
167
+ then: {
168
+ '@path': '$.traits.email'
169
+ },
170
+ else: {
171
+ '@path': '$.properties.email'
172
+ }
300
173
  }
301
174
  },
302
- default: {
303
- do_not_call: '',
304
- number: {
305
- '@if': {
306
- exists: {
307
- '@path': '$.traits.phone'
308
- },
309
- then: {
310
- '@path': '$.traits.phone'
311
- },
312
- else: {
313
- '@path': '$.properties.phone'
314
- }
315
- }
316
- },
317
- primary: '',
318
- type: ''
319
- }
175
+ do_not_email: '',
176
+ primary: '',
177
+ type: ''
320
178
  }
321
179
  },
322
- perform: async (request, { payload }) => {
323
- const blackbaudSkyApiClient = new api_1.BlackbaudSkyApi(request);
324
- let constituentId = undefined;
325
- if (payload.email?.address || payload.lookup_id) {
326
- let searchField = 'email_address';
327
- let searchText = payload.email?.address || '';
328
- if (payload.lookup_id) {
329
- searchField = 'lookup_id';
330
- searchText = payload.lookup_id;
331
- }
332
- const constituentSearchResponse = await blackbaudSkyApiClient.getExistingConstituents(searchField, searchText);
333
- const constituentSearchResults = await constituentSearchResponse.json();
334
- if (constituentSearchResults.count > 1) {
335
- throw new actions_core_1.IntegrationError('Multiple records returned for given traits', 'MULTIPLE_EXISTING_RECORDS', 400);
336
- }
337
- else if (constituentSearchResults.count === 1) {
338
- constituentId = constituentSearchResults.value[0].id;
339
- }
340
- }
341
- const constituentData = {
342
- first: payload.first,
343
- gender: payload.gender,
344
- income: payload.income,
345
- last: payload.last,
346
- lookup_id: payload.lookup_id
347
- };
348
- Object.keys(constituentData).forEach((key) => {
349
- if (!constituentData[key]) {
350
- delete constituentData[key];
351
- }
352
- });
353
- if (payload.birthdate) {
354
- const birthdateFuzzyDate = utils_1.dateStringToFuzzyDate(payload.birthdate);
355
- if (birthdateFuzzyDate) {
356
- constituentData.birthdate = birthdateFuzzyDate;
357
- }
358
- }
359
- let constituentAddressData = {};
360
- if (payload.address &&
361
- (payload.address.address_lines ||
362
- payload.address.city ||
363
- payload.address.country ||
364
- payload.address.postal_code ||
365
- payload.address.state) &&
366
- payload.address.type) {
367
- constituentAddressData = payload.address;
368
- }
369
- let constituentEmailData = {};
370
- if (payload.email && payload.email.address && payload.email.type) {
371
- constituentEmailData = payload.email;
372
- }
373
- let constituentOnlinePresenceData = {};
374
- if (payload.online_presence && payload.online_presence.address && payload.online_presence.type) {
375
- constituentOnlinePresenceData = payload.online_presence;
376
- }
377
- let constituentPhoneData = {};
378
- if (payload.phone && payload.phone.number && payload.phone.type) {
379
- constituentPhoneData = payload.phone;
380
- }
381
- if (!constituentId) {
382
- constituentData.type = 'Individual';
383
- if (!constituentData.last) {
384
- throw new actions_core_1.IntegrationError('Missing last name value', 'MISSING_REQUIRED_FIELD', 400);
385
- }
386
- else {
387
- if (Object.keys(constituentAddressData).length > 0) {
388
- constituentData.address = constituentAddressData;
389
- }
390
- if (Object.keys(constituentEmailData).length > 0) {
391
- constituentData.email = constituentEmailData;
392
- }
393
- if (Object.keys(constituentOnlinePresenceData).length > 0) {
394
- constituentData.online_presence = constituentOnlinePresenceData;
395
- }
396
- if (Object.keys(constituentPhoneData).length > 0) {
397
- constituentData.phone = constituentPhoneData;
180
+ first: {
181
+ label: 'First Name',
182
+ description: "The constituent's first name up to 50 characters.",
183
+ type: 'string',
184
+ default: {
185
+ '@if': {
186
+ exists: {
187
+ '@path': '$.traits.firstName'
188
+ },
189
+ then: {
190
+ '@path': '$.traits.firstName'
191
+ },
192
+ else: {
193
+ '@path': '$.properties.firstName'
398
194
  }
399
- await blackbaudSkyApiClient.createConstituent(constituentData);
400
195
  }
401
- return;
402
196
  }
403
- else {
404
- const integrationErrors = [];
405
- if (Object.keys(constituentData).length > 0) {
406
- const updateConstituentResponse = await blackbaudSkyApiClient.updateConstituent(constituentId, constituentData);
407
- if (updateConstituentResponse.status !== 200) {
408
- const statusCode = updateConstituentResponse.status;
409
- const errorMessage = statusCode
410
- ? `${statusCode} error occurred when updating constituent`
411
- : 'Error occurred when updating constituent';
412
- if (utils_1.isRequestErrorRetryable(statusCode)) {
413
- throw new actions_core_1.RetryableError(errorMessage);
414
- }
415
- else {
416
- integrationErrors.push(errorMessage);
417
- }
197
+ },
198
+ gender: {
199
+ label: 'Gender',
200
+ description: "The constituent's gender.",
201
+ type: 'string',
202
+ default: {
203
+ '@if': {
204
+ exists: {
205
+ '@path': '$.traits.gender'
206
+ },
207
+ then: {
208
+ '@path': '$.traits.gender'
209
+ },
210
+ else: {
211
+ '@path': '$.properties.gender'
418
212
  }
419
213
  }
420
- if (Object.keys(constituentAddressData).length > 0) {
421
- const getConstituentAddressListResponse = await blackbaudSkyApiClient.getConstituentAddressList(constituentId);
422
- let updateAddressErrorCode = undefined;
423
- if (getConstituentAddressListResponse.status !== 200) {
424
- updateAddressErrorCode = getConstituentAddressListResponse.status;
425
- }
426
- else {
427
- const constituentAddressListResults = await getConstituentAddressListResponse.json();
428
- let existingAddress = undefined;
429
- if (constituentAddressListResults.count > 0) {
430
- existingAddress = utils_1.filterObjectListByMatchFields(constituentAddressListResults.value, constituentAddressData, ['address_lines', 'city', 'postal_code', 'state']);
431
- }
432
- if (!existingAddress) {
433
- if (constituentAddressData.primary !== false && constituentAddressListResults.count === 0) {
434
- constituentAddressData.primary = true;
435
- }
436
- const createConstituentAddressResponse = await blackbaudSkyApiClient.createConstituentAddress(constituentId, constituentAddressData);
437
- if (createConstituentAddressResponse.status !== 200) {
438
- updateAddressErrorCode = createConstituentAddressResponse.status;
439
- }
440
- }
441
- else {
442
- if (existingAddress.inactive ||
443
- (constituentAddressData.do_not_mail !== undefined &&
444
- constituentAddressData.do_not_mail !== existingAddress.do_not_mail) ||
445
- (constituentAddressData.primary !== undefined &&
446
- constituentAddressData.primary &&
447
- constituentAddressData.primary !== existingAddress.primary) ||
448
- constituentAddressData.type !== existingAddress.type) {
449
- const updateConstituentAddressByIdResponse = await blackbaudSkyApiClient.updateConstituentAddressById(existingAddress.id, constituentAddressData);
450
- if (updateConstituentAddressByIdResponse.status !== 200) {
451
- updateAddressErrorCode = updateConstituentAddressByIdResponse.status;
452
- }
453
- }
454
- }
455
- }
456
- if (updateAddressErrorCode) {
457
- const errorMessage = updateAddressErrorCode
458
- ? `${updateAddressErrorCode} error occurred when updating constituent address`
459
- : 'Error occurred when updating constituent address';
460
- if (utils_1.isRequestErrorRetryable(updateAddressErrorCode)) {
461
- throw new actions_core_1.RetryableError(errorMessage);
462
- }
463
- else {
464
- integrationErrors.push(errorMessage);
465
- }
214
+ }
215
+ },
216
+ income: {
217
+ label: 'Income',
218
+ description: "The constituent's income.",
219
+ type: 'string'
220
+ },
221
+ last: {
222
+ label: 'Last Name',
223
+ description: "The constituent's last name up to 100 characters. This is required to create a constituent.",
224
+ type: 'string',
225
+ default: {
226
+ '@if': {
227
+ exists: {
228
+ '@path': '$.traits.lastName'
229
+ },
230
+ then: {
231
+ '@path': '$.traits.lastName'
232
+ },
233
+ else: {
234
+ '@path': '$.properties.lastName'
466
235
  }
467
236
  }
468
- if (Object.keys(constituentEmailData).length > 0) {
469
- const getConstituentEmailListResponse = await blackbaudSkyApiClient.getConstituentEmailList(constituentId);
470
- let updateEmailErrorCode = undefined;
471
- if (getConstituentEmailListResponse.status !== 200) {
472
- updateEmailErrorCode = getConstituentEmailListResponse.status;
473
- }
474
- else {
475
- const constituentEmailListResults = await getConstituentEmailListResponse.json();
476
- let existingEmail = undefined;
477
- if (constituentEmailListResults.count > 0) {
478
- existingEmail = utils_1.filterObjectListByMatchFields(constituentEmailListResults.value, constituentEmailData, [
479
- 'address'
480
- ]);
481
- }
482
- if (!existingEmail) {
483
- if (constituentEmailData.primary !== false && constituentEmailListResults.count === 0) {
484
- constituentEmailData.primary = true;
485
- }
486
- const createConstituentEmailResponse = await blackbaudSkyApiClient.createConstituentEmail(constituentId, constituentEmailData);
487
- if (createConstituentEmailResponse.status !== 200) {
488
- updateEmailErrorCode = createConstituentEmailResponse.status;
489
- }
490
- }
491
- else {
492
- if (existingEmail.inactive ||
493
- (constituentEmailData.do_not_email !== undefined &&
494
- constituentEmailData.do_not_email !== existingEmail.do_not_email) ||
495
- (constituentEmailData.primary !== undefined &&
496
- constituentEmailData.primary &&
497
- constituentEmailData.primary !== existingEmail.primary) ||
498
- constituentEmailData.type !== existingEmail.type) {
499
- const updateConstituentEmailByIdResponse = await blackbaudSkyApiClient.updateConstituentEmailById(existingEmail.id, constituentEmailData);
500
- if (updateConstituentEmailByIdResponse.status !== 200) {
501
- updateEmailErrorCode = updateConstituentEmailByIdResponse.status;
502
- }
503
- }
504
- }
505
- }
506
- if (updateEmailErrorCode) {
507
- const errorMessage = updateEmailErrorCode
508
- ? `${updateEmailErrorCode} error occurred when updating constituent email`
509
- : 'Error occurred when updating constituent email';
510
- if (utils_1.isRequestErrorRetryable(updateEmailErrorCode)) {
511
- throw new actions_core_1.RetryableError(errorMessage);
512
- }
513
- else {
514
- integrationErrors.push(errorMessage);
515
- }
516
- }
237
+ }
238
+ },
239
+ lookup_id: {
240
+ label: 'Lookup ID',
241
+ description: 'The organization-defined identifier for the constituent.',
242
+ type: 'string'
243
+ },
244
+ online_presence: {
245
+ label: 'Online Presence',
246
+ description: "The constituent's online presence.",
247
+ type: 'object',
248
+ properties: {
249
+ address: {
250
+ label: 'Web Address',
251
+ type: 'string'
252
+ },
253
+ primary: {
254
+ label: 'Is Primary',
255
+ type: 'boolean'
256
+ },
257
+ type: {
258
+ label: 'Online Presence Type',
259
+ type: 'string'
517
260
  }
518
- if (Object.keys(constituentOnlinePresenceData).length > 0) {
519
- const getConstituentOnlinePresenceListResponse = await blackbaudSkyApiClient.getConstituentOnlinePresenceList(constituentId);
520
- let updateOnlinePresenceErrorCode = undefined;
521
- if (getConstituentOnlinePresenceListResponse.status !== 200) {
522
- updateOnlinePresenceErrorCode = getConstituentOnlinePresenceListResponse.status;
523
- }
524
- else {
525
- const constituentOnlinePresenceListResults = await getConstituentOnlinePresenceListResponse.json();
526
- let existingOnlinePresence = undefined;
527
- if (constituentOnlinePresenceListResults.count > 0) {
528
- existingOnlinePresence = utils_1.filterObjectListByMatchFields(constituentOnlinePresenceListResults.value, constituentOnlinePresenceData, ['address']);
529
- }
530
- if (!existingOnlinePresence) {
531
- if (constituentOnlinePresenceData.primary !== false && constituentOnlinePresenceListResults.count === 0) {
532
- constituentOnlinePresenceData.primary = true;
533
- }
534
- const createConstituentOnlinePresenceResponse = await blackbaudSkyApiClient.createConstituentOnlinePresence(constituentId, constituentOnlinePresenceData);
535
- if (createConstituentOnlinePresenceResponse.status !== 200) {
536
- updateOnlinePresenceErrorCode = createConstituentOnlinePresenceResponse.status;
537
- }
538
- }
539
- else {
540
- if (existingOnlinePresence.inactive ||
541
- (constituentOnlinePresenceData.primary !== undefined &&
542
- constituentOnlinePresenceData.primary !== existingOnlinePresence.primary) ||
543
- constituentOnlinePresenceData.type !== existingOnlinePresence.type) {
544
- const updateConstituentOnlinePresenceByIdResponse = await blackbaudSkyApiClient.updateConstituentOnlinePresenceById(existingOnlinePresence.id, constituentOnlinePresenceData);
545
- if (updateConstituentOnlinePresenceByIdResponse.status !== 200) {
546
- updateOnlinePresenceErrorCode = updateConstituentOnlinePresenceByIdResponse.status;
547
- }
548
- }
549
- }
550
- }
551
- if (updateOnlinePresenceErrorCode) {
552
- const errorMessage = updateOnlinePresenceErrorCode
553
- ? `${updateOnlinePresenceErrorCode} error occurred when updating constituent online presence`
554
- : 'Error occurred when updating constituent online presence';
555
- if (utils_1.isRequestErrorRetryable(updateOnlinePresenceErrorCode)) {
556
- throw new actions_core_1.RetryableError(errorMessage);
557
- }
558
- else {
559
- integrationErrors.push(errorMessage);
261
+ },
262
+ default: {
263
+ address: {
264
+ '@if': {
265
+ exists: {
266
+ '@path': '$.traits.website'
267
+ },
268
+ then: {
269
+ '@path': '$.traits.website'
270
+ },
271
+ else: {
272
+ '@path': '$.properties.website'
560
273
  }
561
274
  }
275
+ },
276
+ primary: '',
277
+ type: ''
278
+ }
279
+ },
280
+ phone: {
281
+ label: 'Phone',
282
+ description: "The constituent's phone number.",
283
+ type: 'object',
284
+ properties: {
285
+ do_not_call: {
286
+ label: 'Do Not Call',
287
+ type: 'boolean'
288
+ },
289
+ number: {
290
+ label: 'Phone Number',
291
+ type: 'string'
292
+ },
293
+ primary: {
294
+ label: 'Is Primary',
295
+ type: 'boolean'
296
+ },
297
+ type: {
298
+ label: 'Phone Type',
299
+ type: 'string'
562
300
  }
563
- if (Object.keys(constituentPhoneData).length > 0) {
564
- const getConstituentPhoneListResponse = await blackbaudSkyApiClient.getConstituentPhoneList(constituentId);
565
- let updatePhoneErrorCode = undefined;
566
- if (getConstituentPhoneListResponse.status !== 200) {
567
- updatePhoneErrorCode = getConstituentPhoneListResponse.status;
568
- }
569
- else {
570
- const constituentPhoneListResults = await getConstituentPhoneListResponse.json();
571
- let existingPhone = undefined;
572
- if (constituentPhoneListResults.count > 0) {
573
- existingPhone = utils_1.filterObjectListByMatchFields(constituentPhoneListResults.value, constituentPhoneData, [
574
- 'int:number'
575
- ]);
576
- }
577
- if (!existingPhone) {
578
- if (constituentPhoneData.primary !== false && constituentPhoneListResults.count === 0) {
579
- constituentPhoneData.primary = true;
580
- }
581
- const createConstituentPhoneResponse = await blackbaudSkyApiClient.createConstituentPhone(constituentId, constituentPhoneData);
582
- if (createConstituentPhoneResponse.status !== 200) {
583
- updatePhoneErrorCode = createConstituentPhoneResponse.status;
584
- }
585
- }
586
- else {
587
- if (existingPhone.inactive ||
588
- (constituentPhoneData.do_not_call !== undefined &&
589
- constituentPhoneData.do_not_call !== existingPhone.do_not_call) ||
590
- (constituentPhoneData.primary !== undefined && constituentPhoneData.primary !== existingPhone.primary) ||
591
- constituentPhoneData.type !== existingPhone.type) {
592
- const updateConstituentPhoneByIdResponse = await blackbaudSkyApiClient.updateConstituentPhoneById(existingPhone.id, constituentPhoneData);
593
- if (updateConstituentPhoneByIdResponse.status !== 200) {
594
- updatePhoneErrorCode = updateConstituentPhoneByIdResponse.status;
595
- }
596
- }
597
- }
598
- }
599
- if (updatePhoneErrorCode) {
600
- const errorMessage = updatePhoneErrorCode
601
- ? `${updatePhoneErrorCode} error occurred when updating constituent online presence`
602
- : 'Error occurred when updating constituent online presence';
603
- if (utils_1.isRequestErrorRetryable(updatePhoneErrorCode)) {
604
- throw new actions_core_1.RetryableError(errorMessage);
605
- }
606
- else {
607
- integrationErrors.push(errorMessage);
301
+ },
302
+ default: {
303
+ do_not_call: '',
304
+ number: {
305
+ '@if': {
306
+ exists: {
307
+ '@path': '$.traits.phone'
308
+ },
309
+ then: {
310
+ '@path': '$.traits.phone'
311
+ },
312
+ else: {
313
+ '@path': '$.properties.phone'
608
314
  }
609
315
  }
610
- }
611
- if (integrationErrors.length > 0) {
612
- throw new actions_core_1.IntegrationError('One or more errors occurred when updating existing constituent: ' + integrationErrors.join(', '), 'UPDATE_CONSTITUENT_ERROR', 500);
613
- }
614
- return;
316
+ },
317
+ primary: '',
318
+ type: ''
615
319
  }
616
320
  }
617
321
  };
322
+ const perform = async (request, { payload }) => {
323
+ const blackbaudSkyApiClient = new api_1.BlackbaudSkyApi(request);
324
+ let constituentId = payload.constituent_id;
325
+ if (!constituentId && (payload.email?.address || payload.lookup_id)) {
326
+ const getExistingConstituentResponse = await blackbaudSkyApiClient.getExistingConstituent(payload.email, payload.lookup_id);
327
+ constituentId = getExistingConstituentResponse.id;
328
+ }
329
+ const [constituentData, addressData, emailData, onlinePresenceData, phoneData] = utils_1.splitConstituentPayload(payload);
330
+ if (!constituentId) {
331
+ return blackbaudSkyApiClient.createConstituentWithRelatedObjects(constituentData, addressData, emailData, onlinePresenceData, phoneData);
332
+ }
333
+ else {
334
+ return blackbaudSkyApiClient.updateConstituentWithRelatedObjects(constituentId, constituentData, addressData, emailData, onlinePresenceData, phoneData);
335
+ }
336
+ };
337
+ exports.perform = perform;
338
+ const action = {
339
+ title: 'Create or Update Individual Constituent',
340
+ description: "Create or update an Individual Constituent record in Raiser's Edge NXT.",
341
+ defaultSubscription: 'type = "identify"',
342
+ fields: exports.fields,
343
+ perform: exports.perform
344
+ };
618
345
  exports.default = action;
619
346
  //# sourceMappingURL=index.js.map