@segment/action-destinations 3.390.0 → 3.392.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/dist/destinations/dotdigital/addContactToList/generated-types.d.ts +9 -0
- package/dist/destinations/dotdigital/addContactToList/generated-types.js +3 -0
- package/dist/destinations/dotdigital/addContactToList/generated-types.js.map +1 -0
- package/dist/destinations/dotdigital/addContactToList/index.d.ts +5 -0
- package/dist/destinations/dotdigital/addContactToList/index.js +49 -0
- package/dist/destinations/dotdigital/addContactToList/index.js.map +1 -0
- package/dist/destinations/dotdigital/api/dd-api.d.ts +12 -0
- package/dist/destinations/dotdigital/api/dd-api.js +38 -0
- package/dist/destinations/dotdigital/api/dd-api.js.map +1 -0
- package/dist/destinations/dotdigital/api/index.d.ts +4 -0
- package/dist/destinations/dotdigital/api/index.js +15 -0
- package/dist/destinations/dotdigital/api/index.js.map +1 -0
- package/dist/destinations/dotdigital/api/resources/dd-contact-api.d.ts +12 -0
- package/dist/destinations/dotdigital/api/resources/dd-contact-api.js +50 -0
- package/dist/destinations/dotdigital/api/resources/dd-contact-api.js.map +1 -0
- package/dist/destinations/dotdigital/api/resources/dd-datafields-api.d.ts +15 -0
- package/dist/destinations/dotdigital/api/resources/dd-datafields-api.js +110 -0
- package/dist/destinations/dotdigital/api/resources/dd-datafields-api.js.map +1 -0
- package/dist/destinations/dotdigital/api/resources/dd-enrolment-api.d.ts +10 -0
- package/dist/destinations/dotdigital/api/resources/dd-enrolment-api.js +45 -0
- package/dist/destinations/dotdigital/api/resources/dd-enrolment-api.js.map +1 -0
- package/dist/destinations/dotdigital/api/resources/dd-lists-api.d.ts +11 -0
- package/dist/destinations/dotdigital/api/resources/dd-lists-api.js +53 -0
- package/dist/destinations/dotdigital/api/resources/dd-lists-api.js.map +1 -0
- package/dist/destinations/dotdigital/api/types.d.ts +83 -0
- package/dist/destinations/dotdigital/api/types.js +10 -0
- package/dist/destinations/dotdigital/api/types.js.map +1 -0
- package/dist/destinations/dotdigital/enrolContact/generated-types.d.ts +6 -0
- package/dist/destinations/dotdigital/enrolContact/generated-types.js +3 -0
- package/dist/destinations/dotdigital/enrolContact/generated-types.js.map +1 -0
- package/dist/destinations/dotdigital/enrolContact/index.d.ts +5 -0
- package/dist/destinations/dotdigital/enrolContact/index.js +48 -0
- package/dist/destinations/dotdigital/enrolContact/index.js.map +1 -0
- package/dist/destinations/dotdigital/generated-types.d.ts +5 -0
- package/dist/destinations/dotdigital/generated-types.js +3 -0
- package/dist/destinations/dotdigital/generated-types.js.map +1 -0
- package/dist/destinations/dotdigital/index.d.ts +4 -0
- package/dist/destinations/dotdigital/index.js +59 -0
- package/dist/destinations/dotdigital/index.js.map +1 -0
- package/dist/destinations/dotdigital/input-fields/contact-identifier.d.ts +2 -0
- package/dist/destinations/dotdigital/input-fields/contact-identifier.js +57 -0
- package/dist/destinations/dotdigital/input-fields/contact-identifier.js.map +1 -0
- package/dist/destinations/dotdigital/input-fields/index.d.ts +1 -0
- package/dist/destinations/dotdigital/input-fields/index.js +6 -0
- package/dist/destinations/dotdigital/input-fields/index.js.map +1 -0
- package/dist/destinations/dotdigital/input-fields/types.d.ts +6 -0
- package/dist/destinations/dotdigital/input-fields/types.js +3 -0
- package/dist/destinations/dotdigital/input-fields/types.js.map +1 -0
- package/dist/destinations/dotdigital/removeContactFromList/generated-types.d.ts +6 -0
- package/dist/destinations/dotdigital/removeContactFromList/generated-types.js +3 -0
- package/dist/destinations/dotdigital/removeContactFromList/generated-types.js.map +1 -0
- package/dist/destinations/dotdigital/removeContactFromList/index.d.ts +5 -0
- package/dist/destinations/dotdigital/removeContactFromList/index.js +34 -0
- package/dist/destinations/dotdigital/removeContactFromList/index.js.map +1 -0
- package/dist/destinations/drip/identify/generated-types.d.ts +1 -0
- package/dist/destinations/drip/identify/index.js +13 -2
- package/dist/destinations/drip/identify/index.js.map +1 -1
- package/dist/destinations/dub/index.js +9 -0
- package/dist/destinations/dub/index.js.map +1 -1
- package/dist/destinations/dub/trackLead/index.js +4 -1
- package/dist/destinations/dub/trackLead/index.js.map +1 -1
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/ortto/common-fields.js +7 -55
- package/dist/destinations/ortto/common-fields.js.map +1 -1
- package/dist/destinations/ortto/index.js +7 -0
- package/dist/destinations/ortto/index.js.map +1 -1
- package/dist/destinations/ortto/trackActivity/generated-types.d.ts +5 -8
- package/dist/destinations/ortto/trackActivity/index.js +7 -4
- package/dist/destinations/ortto/trackActivity/index.js.map +1 -1
- package/dist/destinations/ortto/upsertContactProfile/generated-types.d.ts +5 -8
- package/dist/destinations/ortto/upsertContactProfile/index.js +3 -3
- package/dist/destinations/ortto/upsertContactProfile/index.js.map +1 -1
- package/dist/destinations/podscribe/track/index.js +10 -8
- package/dist/destinations/podscribe/track/index.js.map +1 -1
- package/dist/destinations/recombee/addBookmark/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/addCartAddition/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/addCartAddition/index.js +4 -10
- package/dist/destinations/recombee/addCartAddition/index.js.map +1 -1
- package/dist/destinations/recombee/addDetailView/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/addPurchase/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/addPurchase/index.js +4 -10
- package/dist/destinations/recombee/addPurchase/index.js.map +1 -1
- package/dist/destinations/recombee/addRating/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/commonFields.js +21 -1
- package/dist/destinations/recombee/commonFields.js.map +1 -1
- package/dist/destinations/recombee/recombeeApiClient.d.ts +17 -43
- package/dist/destinations/recombee/recombeeApiClient.js +17 -6
- package/dist/destinations/recombee/recombeeApiClient.js.map +1 -1
- package/dist/destinations/recombee/setViewPortion/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/setViewPortion/index.d.ts +1 -1
- package/dist/destinations/recombee/setViewPortion/index.js +3 -1
- package/dist/destinations/recombee/setViewPortion/index.js.map +1 -1
- package/dist/destinations/recombee/setViewPortionFromWatchTime/generated-types.d.ts +3 -0
- package/dist/destinations/recombee/setViewPortionFromWatchTime/index.js +7 -9
- package/dist/destinations/recombee/setViewPortionFromWatchTime/index.js.map +1 -1
- package/dist/destinations/reddit-conversions-api/customEvent/generated-types.d.ts +1 -0
- package/dist/destinations/reddit-conversions-api/fields.js +12 -0
- package/dist/destinations/reddit-conversions-api/fields.js.map +1 -1
- package/dist/destinations/reddit-conversions-api/standardEvent/generated-types.d.ts +1 -0
- package/dist/destinations/reddit-conversions-api/types.d.ts +1 -0
- package/dist/destinations/reddit-conversions-api/utils.js +22 -1
- package/dist/destinations/reddit-conversions-api/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/addContactToList/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("../api");
|
|
4
|
+
const input_fields_1 = require("../input-fields");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Add Contact to List',
|
|
7
|
+
description: 'Adds a Contact to a list.',
|
|
8
|
+
defaultSubscription: 'type = "track" and event = "Add Contact to List"',
|
|
9
|
+
fields: {
|
|
10
|
+
...input_fields_1.contactIdentifier,
|
|
11
|
+
listId: {
|
|
12
|
+
label: 'List',
|
|
13
|
+
description: `The list to add the contact to.`,
|
|
14
|
+
type: 'number',
|
|
15
|
+
required: true,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
|
|
18
|
+
dynamic: true
|
|
19
|
+
},
|
|
20
|
+
dataFields: {
|
|
21
|
+
label: 'Data Fields',
|
|
22
|
+
description: `An object containing key/value pairs for data fields assigned to this Contact. Custom Data Fields must already be defined in Dotdigital.`,
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: false,
|
|
25
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
|
|
26
|
+
defaultObjectUI: 'keyvalue:only',
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
dynamic: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
dynamicFields: {
|
|
32
|
+
listId: async (request, { settings }) => {
|
|
33
|
+
return new api_1.DDListsApi(settings, request).getLists();
|
|
34
|
+
},
|
|
35
|
+
dataFields: {
|
|
36
|
+
__keys__: async (request, { settings }) => {
|
|
37
|
+
return new api_1.DDDataFieldsApi(settings, request).getDataFields();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
perform: async (request, { settings, payload }) => {
|
|
42
|
+
const fieldsAPI = new api_1.DDDataFieldsApi(settings, request);
|
|
43
|
+
await fieldsAPI.validateDataFields(payload);
|
|
44
|
+
const contactApi = new api_1.DDContactApi(settings, request);
|
|
45
|
+
return contactApi.upsertContact(payload);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.default = action;
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/addContactToList/index.ts"],"names":[],"mappings":";;AAGA,gCAAkE;AAClE,kDAAmD;AAEnD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,2BAA2B;IACxC,mBAAmB,EAAE,kDAAkD;IACvE,MAAM,EAAE;QACN,GAAG,gCAAiB;QACpB,MAAM,EAAE;YACN,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,iCAAiC;YAC9C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK;YAChB,oBAAoB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;YACnF,OAAO,EAAE,IAAI;SACd;QACD,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,0IAA0I;YACvJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,oBAAoB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;YACnF,eAAe,EAAE,eAAe;YAChC,oBAAoB,EAAE,KAAK;YAC3B,OAAO,EAAE,IAAI;SACd;KACF;IACD,aAAa,EAAE;QACb,MAAM,EAAE,KAAK,EAAE,OAAsB,EAAE,EAAE,QAAQ,EAAE,EAAiC,EAAE;YACpF,OAAO,IAAI,gBAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QACrD,CAAC;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBACxC,OAAO,IAAI,qBAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,aAAa,EAAE,CAAA;YAC/D,CAAC;SACF;KACF;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,MAAM,SAAS,GAAG,IAAI,qBAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACxD,MAAM,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;QAE3C,MAAM,UAAU,GAAG,IAAI,kBAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACtD,OAAO,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
declare abstract class DDApi {
|
|
4
|
+
private readonly apiUrl;
|
|
5
|
+
private readonly request;
|
|
6
|
+
protected constructor(settings: Settings, request: RequestClient);
|
|
7
|
+
protected get<TResponse>(endpoint: string, params?: Record<string, unknown>): Promise<import("@segment/actions-core/src").ModifiedResponse<TResponse>>;
|
|
8
|
+
protected post<ResponseType, RequestJSON>(endpoint: string, data: RequestJSON): Promise<import("@segment/actions-core/src").ModifiedResponse<ResponseType>>;
|
|
9
|
+
protected delete(endpoint: string): Promise<import("@segment/actions-core/src").ModifiedResponse<unknown>>;
|
|
10
|
+
protected patch<ResponseType, RequestJSON>(endpoint: string, data: RequestJSON): Promise<import("@segment/actions-core/src").ModifiedResponse<ResponseType>>;
|
|
11
|
+
}
|
|
12
|
+
export default DDApi;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class DDApi {
|
|
4
|
+
constructor(settings, request) {
|
|
5
|
+
this.apiUrl = settings.api_host;
|
|
6
|
+
this.request = request;
|
|
7
|
+
}
|
|
8
|
+
async get(endpoint, params) {
|
|
9
|
+
const url = new URL(`${this.apiUrl}${endpoint}`);
|
|
10
|
+
if (params) {
|
|
11
|
+
url.search = new URLSearchParams(Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)]))).toString();
|
|
12
|
+
}
|
|
13
|
+
return await this.request(`${url}`, {
|
|
14
|
+
method: 'GET'
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async post(endpoint, data) {
|
|
18
|
+
return await this.request(`${this.apiUrl}${endpoint}`, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
json: data,
|
|
21
|
+
headers: { 'Content-Type': 'application/json' }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async delete(endpoint) {
|
|
25
|
+
return await this.request(`${this.apiUrl}${endpoint}`, {
|
|
26
|
+
method: 'DELETE'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async patch(endpoint, data) {
|
|
30
|
+
return await this.request(`${this.apiUrl}${endpoint}`, {
|
|
31
|
+
method: 'PATCH',
|
|
32
|
+
json: data,
|
|
33
|
+
headers: { 'Content-Type': 'application/json' }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = DDApi;
|
|
38
|
+
//# sourceMappingURL=dd-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-api.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/api/dd-api.ts"],"names":[],"mappings":";;AAGA,MAAe,KAAK;IAIlB,YAAsB,QAAkB,EAAE,OAAsB;QAC9D,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IASS,KAAK,CAAC,GAAG,CAAY,QAAgB,EAAE,MAAgC;QAC/E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC,CAAA;QAChD,IAAI,MAAM,EAAE;YACV,GAAG,CAAC,MAAM,GAAG,IAAI,eAAe,CAC9B,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC,QAAQ,EAAE,CAAA;SACb;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAY,GAAG,GAAG,EAAE,EAAE;YAC7C,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;IASS,KAAK,CAAC,IAAI,CAA4B,QAAgB,EAAE,IAAiB;QACjF,OAAO,MAAM,IAAI,CAAC,OAAO,CAAe,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAA;IACJ,CAAC;IAMS,KAAK,CAAC,MAAM,CAAC,QAAgB;QACrC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,EAAE;YACrD,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAA;IACJ,CAAC;IASS,KAAK,CAAC,KAAK,CAA4B,QAAgB,EAAE,IAAiB;QAClF,OAAO,MAAM,IAAI,CAAC,OAAO,CAAe,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,EAAE,EAAE;YACnE,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAA;IACJ,CAAC;CACF;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as DDContactApi } from './resources/dd-contact-api';
|
|
2
|
+
export { default as DDListsApi } from './resources/dd-lists-api';
|
|
3
|
+
export { default as DDEnrolmentApi } from './resources/dd-enrolment-api';
|
|
4
|
+
export { default as DDDataFieldsApi } from './resources/dd-datafields-api';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DDDataFieldsApi = exports.DDEnrolmentApi = exports.DDListsApi = exports.DDContactApi = void 0;
|
|
7
|
+
var dd_contact_api_1 = require("./resources/dd-contact-api");
|
|
8
|
+
Object.defineProperty(exports, "DDContactApi", { enumerable: true, get: function () { return __importDefault(dd_contact_api_1).default; } });
|
|
9
|
+
var dd_lists_api_1 = require("./resources/dd-lists-api");
|
|
10
|
+
Object.defineProperty(exports, "DDListsApi", { enumerable: true, get: function () { return __importDefault(dd_lists_api_1).default; } });
|
|
11
|
+
var dd_enrolment_api_1 = require("./resources/dd-enrolment-api");
|
|
12
|
+
Object.defineProperty(exports, "DDEnrolmentApi", { enumerable: true, get: function () { return __importDefault(dd_enrolment_api_1).default; } });
|
|
13
|
+
var dd_datafields_api_1 = require("./resources/dd-datafields-api");
|
|
14
|
+
Object.defineProperty(exports, "DDDataFieldsApi", { enumerable: true, get: function () { return __importDefault(dd_datafields_api_1).default; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAoE;AAA3D,+HAAA,OAAO,OAAgB;AAChC,yDAAgE;AAAvD,2HAAA,OAAO,OAAc;AAC9B,iEAAwE;AAA/D,mIAAA,OAAO,OAAkB;AAClC,mEAA0E;AAAjE,qIAAA,OAAO,OAAmB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../../generated-types';
|
|
3
|
+
import DDApi from '../dd-api';
|
|
4
|
+
import { Contact, ChannelIdentifier } from '../types';
|
|
5
|
+
import type { Payload } from '../../addContactToList/generated-types';
|
|
6
|
+
declare class DDContactApi extends DDApi {
|
|
7
|
+
constructor(settings: Settings, client: RequestClient);
|
|
8
|
+
getContact(idType: string, idValue: string | undefined): Promise<Contact>;
|
|
9
|
+
fetchOrCreateContact<T>(channelIdentifier: ChannelIdentifier, data: T): Promise<Contact>;
|
|
10
|
+
upsertContact(payload: Payload): Promise<Contact>;
|
|
11
|
+
}
|
|
12
|
+
export default DDContactApi;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dd_api_1 = __importDefault(require("../dd-api"));
|
|
7
|
+
class DDContactApi extends dd_api_1.default {
|
|
8
|
+
constructor(settings, client) {
|
|
9
|
+
super(settings, client);
|
|
10
|
+
}
|
|
11
|
+
async getContact(idType, idValue) {
|
|
12
|
+
const response = await this.get(`/contacts/v3/${idType}/${idValue}`);
|
|
13
|
+
return response.data;
|
|
14
|
+
}
|
|
15
|
+
async fetchOrCreateContact(channelIdentifier, data) {
|
|
16
|
+
const [[idType, idValue]] = Object.entries(channelIdentifier);
|
|
17
|
+
const response = await this.patch(`/contacts/v3/${idType}/${idValue}`, data);
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
20
|
+
async upsertContact(payload) {
|
|
21
|
+
const { channelIdentifier, emailIdentifier, mobileNumberIdentifier, listId, dataFields } = payload;
|
|
22
|
+
const idValue = channelIdentifier === 'email' ? emailIdentifier : mobileNumberIdentifier;
|
|
23
|
+
const identifiers = {
|
|
24
|
+
...(emailIdentifier && { email: emailIdentifier }),
|
|
25
|
+
...(mobileNumberIdentifier && { mobileNumber: mobileNumberIdentifier })
|
|
26
|
+
};
|
|
27
|
+
const channelProperties = {
|
|
28
|
+
...(emailIdentifier && {
|
|
29
|
+
email: {
|
|
30
|
+
status: 'subscribed',
|
|
31
|
+
emailType: 'html',
|
|
32
|
+
optInType: 'single'
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
...(mobileNumberIdentifier && {
|
|
36
|
+
sms: { status: 'subscribed' }
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
const data = {
|
|
40
|
+
identifiers,
|
|
41
|
+
channelProperties,
|
|
42
|
+
lists: [listId],
|
|
43
|
+
dataFields: dataFields
|
|
44
|
+
};
|
|
45
|
+
const response = await this.patch(`/contacts/v3/${channelIdentifier}/${idValue}?merge-option=overwrite`, data);
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = DDContactApi;
|
|
50
|
+
//# sourceMappingURL=dd-contact-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-contact-api.js","sourceRoot":"","sources":["../../../../../src/destinations/dotdigital/api/resources/dd-contact-api.ts"],"names":[],"mappings":";;;;;AAEA,uDAA6B;AAI7B,MAAM,YAAa,SAAQ,gBAAK;IAC9B,YAAY,QAAkB,EAAE,MAAqB;QACnD,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACzB,CAAC;IAUD,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,OAA2B;QAC1D,MAAM,QAAQ,GAA8B,MAAM,IAAI,CAAC,GAAG,CAAU,gBAAgB,MAAM,IAAI,OAAO,EAAE,CAAC,CAAA;QACxG,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;IAUD,KAAK,CAAC,oBAAoB,CAAI,iBAAoC,EAAE,IAAO;QACzE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QAC7D,MAAM,QAAQ,GAA8B,MAAM,IAAI,CAAC,KAAK,CAAa,gBAAgB,MAAM,IAAI,OAAO,EAAE,EAAE,IAAI,CAAC,CAAA;QACnH,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;IAOM,KAAK,CAAC,aAAa,CAAC,OAAgB;QACzC,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAA;QAElG,MAAM,OAAO,GAAG,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,sBAAsB,CAAA;QAExF,MAAM,WAAW,GAAgB;YAC/B,GAAG,CAAC,eAAe,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;YAClD,GAAG,CAAC,sBAAsB,IAAI,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC;SACxE,CAAA;QAED,MAAM,iBAAiB,GAAsB;YAC3C,GAAG,CAAC,eAAe,IAAI;gBACrB,KAAK,EAAE;oBACL,MAAM,EAAE,YAAY;oBACpB,SAAS,EAAE,MAAM;oBACjB,SAAS,EAAE,QAAQ;iBACpB;aACF,CAAC;YACF,GAAG,CAAC,sBAAsB,IAAI;gBAC5B,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;aAC9B,CAAC;SACH,CAAA;QAED,MAAM,IAAI,GAAsB;YAC9B,WAAW;YACX,iBAAiB;YACjB,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,UAAU,EAAE,UAAwB;SACrC,CAAA;QAED,MAAM,QAAQ,GAA8B,MAAM,IAAI,CAAC,KAAK,CAC1D,gBAAgB,iBAAiB,IAAI,OAAO,yBAAyB,EACrE,IAAI,CACL,CAAA;QAED,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CACF;AAED,kBAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RequestClient, DynamicFieldResponse } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../../generated-types';
|
|
3
|
+
import DDApi from '../dd-api';
|
|
4
|
+
import type { Payload } from '../../addContactToList/generated-types';
|
|
5
|
+
import type { FieldTypeName } from '@segment/actions-core/destination-kittypes';
|
|
6
|
+
declare class DDDataFieldsApi extends DDApi {
|
|
7
|
+
constructor(settings: Settings, client: RequestClient);
|
|
8
|
+
getDataFields(): Promise<DynamicFieldResponse>;
|
|
9
|
+
mapDataFieldType(fieldType: string): FieldTypeName;
|
|
10
|
+
isNumeric(value: unknown): boolean;
|
|
11
|
+
validateDataFields(payload: Payload): Promise<{
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
} | undefined>;
|
|
14
|
+
}
|
|
15
|
+
export default DDDataFieldsApi;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
+
const dd_api_1 = __importDefault(require("../dd-api"));
|
|
8
|
+
class DDDataFieldsApi extends dd_api_1.default {
|
|
9
|
+
constructor(settings, client) {
|
|
10
|
+
super(settings, client);
|
|
11
|
+
}
|
|
12
|
+
async getDataFields() {
|
|
13
|
+
try {
|
|
14
|
+
const choices = [];
|
|
15
|
+
const response = await this.get('/v2/data-fields/');
|
|
16
|
+
const dataFields = response.data;
|
|
17
|
+
choices.push(...dataFields.map((dataField) => ({
|
|
18
|
+
value: dataField.name,
|
|
19
|
+
label: dataField.name,
|
|
20
|
+
type: this.mapDataFieldType(dataField.type)
|
|
21
|
+
})));
|
|
22
|
+
return { choices };
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return {
|
|
26
|
+
choices: [],
|
|
27
|
+
nextPage: '',
|
|
28
|
+
error: {
|
|
29
|
+
message: 'Failed to fetch data fields',
|
|
30
|
+
code: 'DATA_FIELDS_FETCH_ERROR'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
mapDataFieldType(fieldType) {
|
|
36
|
+
switch (fieldType) {
|
|
37
|
+
case 'String':
|
|
38
|
+
return 'string';
|
|
39
|
+
case 'Numeric':
|
|
40
|
+
return 'number';
|
|
41
|
+
case 'Date':
|
|
42
|
+
return 'datetime';
|
|
43
|
+
case 'Boolean':
|
|
44
|
+
return 'boolean';
|
|
45
|
+
default:
|
|
46
|
+
throw new actions_core_1.PayloadValidationError(`Invalid data field type: ${fieldType}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
isNumeric(value) {
|
|
50
|
+
const type = typeof value;
|
|
51
|
+
return (type === 'number' || type === 'string') && !isNaN(Number(value));
|
|
52
|
+
}
|
|
53
|
+
async validateDataFields(payload) {
|
|
54
|
+
if (!payload.dataFields) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const response = await this.get('/v2/data-fields/');
|
|
58
|
+
const ddDataFields = response.data;
|
|
59
|
+
for (const [key, value] of Object.entries(payload.dataFields)) {
|
|
60
|
+
let validatedValue = value;
|
|
61
|
+
const ddDataField = ddDataFields.find((obj) => obj.name === key);
|
|
62
|
+
if (!ddDataField) {
|
|
63
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} not found in Dotdigital`);
|
|
64
|
+
}
|
|
65
|
+
switch (ddDataField.type) {
|
|
66
|
+
case 'Date':
|
|
67
|
+
if (typeof value !== 'string') {
|
|
68
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} value ${value} is not a valid date`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const date = new Date(value).toISOString();
|
|
72
|
+
if (date === undefined) {
|
|
73
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} value ${value} is not a valid date`);
|
|
74
|
+
}
|
|
75
|
+
validatedValue = date;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case 'Numeric':
|
|
79
|
+
if (typeof value === 'string') {
|
|
80
|
+
if (!this.isNumeric(value)) {
|
|
81
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} value ${value} is not a valid number`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (typeof value !== 'number') {
|
|
85
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} value ${value} is not a valid number`);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case 'Boolean':
|
|
89
|
+
if (typeof value === 'string' && value.trim().toLocaleLowerCase() === 'true') {
|
|
90
|
+
validatedValue = true;
|
|
91
|
+
}
|
|
92
|
+
else if (typeof value === 'string' && value.trim().toLocaleLowerCase() === 'false') {
|
|
93
|
+
validatedValue = false;
|
|
94
|
+
}
|
|
95
|
+
validatedValue = Boolean(validatedValue);
|
|
96
|
+
break;
|
|
97
|
+
case 'String':
|
|
98
|
+
if (typeof value !== 'string') {
|
|
99
|
+
throw new actions_core_1.PayloadValidationError(`Data field ${key} value ${value} is not a valid string`);
|
|
100
|
+
}
|
|
101
|
+
validatedValue = String(value).trim();
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
payload.dataFields[key] = validatedValue;
|
|
105
|
+
}
|
|
106
|
+
return payload.dataFields;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.default = DDDataFieldsApi;
|
|
110
|
+
//# sourceMappingURL=dd-datafields-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-datafields-api.js","sourceRoot":"","sources":["../../../../../src/destinations/dotdigital/api/resources/dd-datafields-api.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestClient, DynamicFieldResponse } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../../generated-types';
|
|
3
|
+
import DDApi from '../dd-api';
|
|
4
|
+
import { Contact, ProgramEnrolment } from '../types';
|
|
5
|
+
declare class DDEnrolmentApi extends DDApi {
|
|
6
|
+
constructor(settings: Settings, client: RequestClient);
|
|
7
|
+
getPrograms(): Promise<DynamicFieldResponse>;
|
|
8
|
+
enrolContact(programId: string, contact: Contact): Promise<ProgramEnrolment>;
|
|
9
|
+
}
|
|
10
|
+
export default DDEnrolmentApi;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dd_api_1 = __importDefault(require("../dd-api"));
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
class DDEnrolmentApi extends dd_api_1.default {
|
|
9
|
+
constructor(settings, client) {
|
|
10
|
+
super(settings, client);
|
|
11
|
+
}
|
|
12
|
+
async getPrograms() {
|
|
13
|
+
try {
|
|
14
|
+
const response = await this.get('/v2/programs');
|
|
15
|
+
const programs = response.data;
|
|
16
|
+
const choices = programs
|
|
17
|
+
.filter((program) => program.status === types_1.ProgramStatus.Active)
|
|
18
|
+
.map((program) => ({
|
|
19
|
+
value: program.id.toString(),
|
|
20
|
+
label: program.name
|
|
21
|
+
}));
|
|
22
|
+
return { choices };
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return {
|
|
26
|
+
choices: [],
|
|
27
|
+
nextPage: '',
|
|
28
|
+
error: {
|
|
29
|
+
message: 'Failed to fetch Programs',
|
|
30
|
+
code: 'PROGRAM_FETCH_ERROR'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async enrolContact(programId, contact) {
|
|
36
|
+
const json = {
|
|
37
|
+
contacts: [contact.contactId],
|
|
38
|
+
programId
|
|
39
|
+
};
|
|
40
|
+
const response = await this.post('/v2/programs/enrolments', json);
|
|
41
|
+
return response.data;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = DDEnrolmentApi;
|
|
45
|
+
//# sourceMappingURL=dd-enrolment-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-enrolment-api.js","sourceRoot":"","sources":["../../../../../src/destinations/dotdigital/api/resources/dd-enrolment-api.ts"],"names":[],"mappings":";;;;;AAEA,uDAA6B;AAC7B,oCAAmG;AAMnG,MAAM,cAAe,SAAQ,gBAAK;IAChC,YAAY,QAAkB,EAAE,MAAqB;QACnD,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACzB,CAAC;IAMM,KAAK,CAAC,WAAW;QACtB,IAAI;YACF,MAAM,QAAQ,GAAgC,MAAM,IAAI,CAAC,GAAG,CAAY,cAAc,CAAC,CAAA;YACvF,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAA;YAC9B,MAAM,OAAO,GAAG,QAAQ;iBACrB,MAAM,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,qBAAa,CAAC,MAAM,CAAC;iBACrE,GAAG,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC;gBAC1B,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE;gBAC5B,KAAK,EAAE,OAAO,CAAC,IAAI;aACpB,CAAC,CAAC,CAAA;YACL,OAAO,EAAE,OAAO,EAAE,CAAA;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;gBACZ,KAAK,EAAE;oBACL,OAAO,EAAE,0BAA0B;oBACnC,IAAI,EAAE,qBAAqB;iBAC5B;aACF,CAAA;SACF;IACH,CAAC;IAQM,KAAK,CAAC,YAAY,CAAC,SAAiB,EAAE,OAAgB;QAC3D,MAAM,IAAI,GAA0B;YAClC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;YAC7B,SAAS;SACV,CAAA;QACD,MAAM,QAAQ,GAAuC,MAAM,IAAI,CAAC,IAAI,CAClE,yBAAyB,EACzB,IAAI,CACL,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CACF;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModifiedResponse, RequestClient, DynamicFieldResponse } from '@segment/actions-core';
|
|
2
|
+
import type { Settings } from '../../generated-types';
|
|
3
|
+
import DDApi from '../dd-api';
|
|
4
|
+
import { List } from '../types';
|
|
5
|
+
declare class DDListsApi extends DDApi {
|
|
6
|
+
constructor(settings: Settings, request: RequestClient);
|
|
7
|
+
getListsPaging(select?: number, skip?: number): Promise<ModifiedResponse<List[]>>;
|
|
8
|
+
getLists(): Promise<DynamicFieldResponse>;
|
|
9
|
+
deleteContactFromList(listId: number, contactId: number): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default DDListsApi;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dd_api_1 = __importDefault(require("../dd-api"));
|
|
7
|
+
class DDListsApi extends dd_api_1.default {
|
|
8
|
+
constructor(settings, request) {
|
|
9
|
+
super(settings, request);
|
|
10
|
+
}
|
|
11
|
+
async getListsPaging(select = 1000, skip = 0) {
|
|
12
|
+
return await this.get('/v2/address-books', { select, skip });
|
|
13
|
+
}
|
|
14
|
+
async getLists() {
|
|
15
|
+
const choices = [];
|
|
16
|
+
const select = 200;
|
|
17
|
+
let skip = 0;
|
|
18
|
+
let hasMoreData = true;
|
|
19
|
+
while (hasMoreData) {
|
|
20
|
+
try {
|
|
21
|
+
const response = await this.getListsPaging(select, skip);
|
|
22
|
+
const content = response.data;
|
|
23
|
+
if (content.length === 0) {
|
|
24
|
+
hasMoreData = false;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
choices.push(...content.map((list) => ({
|
|
29
|
+
value: list.id.toString(),
|
|
30
|
+
label: list.name
|
|
31
|
+
})));
|
|
32
|
+
skip += select;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return {
|
|
37
|
+
choices: [],
|
|
38
|
+
nextPage: '',
|
|
39
|
+
error: {
|
|
40
|
+
message: 'Failed to fetch lists',
|
|
41
|
+
code: 'LIST_FETCH_ERROR'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { choices: choices };
|
|
47
|
+
}
|
|
48
|
+
async deleteContactFromList(listId, contactId) {
|
|
49
|
+
await this.delete(`/v2/address-books/${listId}/contacts/${contactId}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = DDListsApi;
|
|
53
|
+
//# sourceMappingURL=dd-lists-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-lists-api.js","sourceRoot":"","sources":["../../../../../src/destinations/dotdigital/api/resources/dd-lists-api.ts"],"names":[],"mappings":";;;;;AAEA,uDAA6B;AAG7B,MAAM,UAAW,SAAQ,gBAAK;IAC5B,YAAY,QAAkB,EAAE,OAAsB;QACpD,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;IAQD,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,EAAE,IAAI,GAAG,CAAC;QAC1C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAS,mBAAmB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACtE,CAAC;IAOD,KAAK,CAAC,QAAQ;QACZ,MAAM,OAAO,GAAG,EAAE,CAAA;QAClB,MAAM,MAAM,GAAG,GAAG,CAAA;QAClB,IAAI,IAAI,GAAG,CAAC,CAAA;QAEZ,IAAI,WAAW,GAAG,IAAI,CAAA;QACtB,OAAO,WAAW,EAAE;YAClB,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;gBACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAA;gBAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;oBACxB,WAAW,GAAG,KAAK,CAAA;oBACnB,MAAK;iBACN;qBAAM;oBACL,OAAO,CAAC,IAAI,CACV,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,CAAC;wBAC9B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;wBACzB,KAAK,EAAE,IAAI,CAAC,IAAI;qBACjB,CAAC,CAAC,CACJ,CAAA;oBACD,IAAI,IAAI,MAAM,CAAA;iBACf;aACF;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO;oBACL,OAAO,EAAE,EAAE;oBACX,QAAQ,EAAE,EAAE;oBACZ,KAAK,EAAE;wBACL,OAAO,EAAE,uBAAuB;wBAChC,IAAI,EAAE,kBAAkB;qBACzB;iBACF,CAAA;aACF;SACF;QACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IAC7B,CAAC;IAUD,KAAK,CAAC,qBAAqB,CAAC,MAAc,EAAE,SAAiB;QAC3D,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,MAAM,aAAa,SAAS,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAED,kBAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface List {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
status: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DataField {
|
|
7
|
+
name: string;
|
|
8
|
+
type: 'String' | 'Numeric' | 'Date' | 'Boolean';
|
|
9
|
+
visibility: string;
|
|
10
|
+
defaultValue: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface Identifiers {
|
|
13
|
+
email?: string;
|
|
14
|
+
mobileNumber?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DataFields {
|
|
17
|
+
[key: string]: string | number | boolean | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ChannelProperties {
|
|
20
|
+
email?: {
|
|
21
|
+
status: string;
|
|
22
|
+
emailType: string;
|
|
23
|
+
optInType: string;
|
|
24
|
+
};
|
|
25
|
+
sms?: {
|
|
26
|
+
status: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ConsentRecord {
|
|
30
|
+
text: string;
|
|
31
|
+
dateTimeConsented: string;
|
|
32
|
+
url: string;
|
|
33
|
+
ipAddress: string;
|
|
34
|
+
userAgent: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Contact {
|
|
37
|
+
contactId: number;
|
|
38
|
+
status: string;
|
|
39
|
+
created: string;
|
|
40
|
+
updated: string;
|
|
41
|
+
identifiers: Identifiers;
|
|
42
|
+
dataFields: DataFields;
|
|
43
|
+
channelProperties: ChannelProperties;
|
|
44
|
+
lists: List[];
|
|
45
|
+
consentRecords: ConsentRecord[];
|
|
46
|
+
}
|
|
47
|
+
export declare enum ProgramStatus {
|
|
48
|
+
Active = "Active",
|
|
49
|
+
Draft = "Draft",
|
|
50
|
+
Deactivated = "Deactivated"
|
|
51
|
+
}
|
|
52
|
+
export interface Program {
|
|
53
|
+
id: number;
|
|
54
|
+
name: string;
|
|
55
|
+
status: ProgramStatus;
|
|
56
|
+
dateCreated: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ProgramEnrolment {
|
|
59
|
+
id: string;
|
|
60
|
+
programId: number;
|
|
61
|
+
status: string;
|
|
62
|
+
dateCreated: string;
|
|
63
|
+
contacts: null | unknown;
|
|
64
|
+
addressBooks: null | unknown;
|
|
65
|
+
}
|
|
66
|
+
export interface ProgramEnrolementJSON {
|
|
67
|
+
contacts: number[];
|
|
68
|
+
programId: string;
|
|
69
|
+
}
|
|
70
|
+
export type ChannelIdentifier = {
|
|
71
|
+
email: string;
|
|
72
|
+
'mobile-number'?: never;
|
|
73
|
+
} | {
|
|
74
|
+
'mobile-number': string;
|
|
75
|
+
email?: never;
|
|
76
|
+
};
|
|
77
|
+
export interface UpsertContactJSON {
|
|
78
|
+
identifiers: Identifiers;
|
|
79
|
+
channelProperties: ChannelProperties;
|
|
80
|
+
lists: number[];
|
|
81
|
+
dataFields?: DataFields;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProgramStatus = void 0;
|
|
4
|
+
var ProgramStatus;
|
|
5
|
+
(function (ProgramStatus) {
|
|
6
|
+
ProgramStatus["Active"] = "Active";
|
|
7
|
+
ProgramStatus["Draft"] = "Draft";
|
|
8
|
+
ProgramStatus["Deactivated"] = "Deactivated";
|
|
9
|
+
})(ProgramStatus = exports.ProgramStatus || (exports.ProgramStatus = {}));
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/api/types.ts"],"names":[],"mappings":";;;AAoDA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,gCAAe,CAAA;IACf,4CAA2B,CAAA;AAC7B,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/dotdigital/enrolContact/generated-types.ts"],"names":[],"mappings":""}
|