@wix/notifications 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +24 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/src/ping-notifications-v3-notification.http.d.ts +42 -0
- package/build/cjs/src/ping-notifications-v3-notification.http.js +106 -0
- package/build/cjs/src/ping-notifications-v3-notification.http.js.map +1 -0
- package/build/cjs/src/ping-notifications-v3-notification.public.d.ts +5 -0
- package/build/cjs/src/ping-notifications-v3-notification.public.js +13 -0
- package/build/cjs/src/ping-notifications-v3-notification.public.js.map +1 -0
- package/build/cjs/src/ping-notifications-v3-notification.types.d.ts +83 -0
- package/build/cjs/src/ping-notifications-v3-notification.types.js +15 -0
- package/build/cjs/src/ping-notifications-v3-notification.types.js.map +1 -0
- package/build/cjs/src/ping-notifications-v3-notification.universal.d.ts +141 -0
- package/build/cjs/src/ping-notifications-v3-notification.universal.js +157 -0
- package/build/cjs/src/ping-notifications-v3-notification.universal.js.map +1 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +2 -0
- package/build/es/index.js.map +1 -0
- package/build/es/src/ping-notifications-v3-notification.http.d.ts +42 -0
- package/build/es/src/ping-notifications-v3-notification.http.js +102 -0
- package/build/es/src/ping-notifications-v3-notification.http.js.map +1 -0
- package/build/es/src/ping-notifications-v3-notification.public.d.ts +5 -0
- package/build/es/src/ping-notifications-v3-notification.public.js +8 -0
- package/build/es/src/ping-notifications-v3-notification.public.js.map +1 -0
- package/build/es/src/ping-notifications-v3-notification.types.d.ts +83 -0
- package/build/es/src/ping-notifications-v3-notification.types.js +12 -0
- package/build/es/src/ping-notifications-v3-notification.types.js.map +1 -0
- package/build/es/src/ping-notifications-v3-notification.universal.d.ts +141 -0
- package/build/es/src/ping-notifications-v3-notification.universal.js +134 -0
- package/build/es/src/ping-notifications-v3-notification.universal.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as notifications from './src/ping-notifications-v3-notification.public';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.notifications = void 0;
|
|
23
|
+
exports.notifications = __importStar(require("./src/ping-notifications-v3-notification.public"));
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iGAAiF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RequestOptionsFactory } from '@wix/sdk-types';
|
|
2
|
+
import { NotifyRequest, NotifyResponse } from './ping-notifications-v3-notification.types';
|
|
3
|
+
/**
|
|
4
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
5
|
+
*
|
|
6
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
7
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
8
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
9
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
10
|
+
*
|
|
11
|
+
* For example, if your notification template looks like this:
|
|
12
|
+
*
|
|
13
|
+
* > **Title:** New {{roomType}} reservation.
|
|
14
|
+
* >
|
|
15
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
16
|
+
*
|
|
17
|
+
* You can pass the following values:
|
|
18
|
+
*
|
|
19
|
+
* ```json
|
|
20
|
+
* {
|
|
21
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
22
|
+
* "dynamicValues": {
|
|
23
|
+
* "roomType": {
|
|
24
|
+
* "text": "studio"
|
|
25
|
+
* },
|
|
26
|
+
* "customerName": {
|
|
27
|
+
* "text": "Sally Jones"
|
|
28
|
+
* },
|
|
29
|
+
* "dayOfWeek": {
|
|
30
|
+
* "text": "Friday"
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
37
|
+
*
|
|
38
|
+
* > **Title:** New studio reservation.
|
|
39
|
+
* >
|
|
40
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
41
|
+
*/
|
|
42
|
+
export declare function notify(payload: NotifyRequest): RequestOptionsFactory<NotifyResponse>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notify = void 0;
|
|
4
|
+
const ambassador_1 = require("@wix/metro-runtime/ambassador");
|
|
5
|
+
const metro_runtime_1 = require("@wix/metro-runtime");
|
|
6
|
+
const _arrayDynamicValue = { items: '_dynamicValue' };
|
|
7
|
+
const _dynamicValue = { map: '_mapDynamicValue', array: '_arrayDynamicValue' };
|
|
8
|
+
const _mapDynamicValue = { items: 'Map#_dynamicValue' };
|
|
9
|
+
const _notifyRequest = { dynamicValues: 'Map#_dynamicValue' };
|
|
10
|
+
const _notifyResponse = {};
|
|
11
|
+
function resolveComWixpressPingHubApiV3NotificationsServiceV3Url(opts) {
|
|
12
|
+
const domainToMappings = {
|
|
13
|
+
'api._api_base_domain_': [
|
|
14
|
+
{
|
|
15
|
+
srcPath: '/notifications-hub-server',
|
|
16
|
+
destPath: '',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
'www._base_domain_': [
|
|
20
|
+
{
|
|
21
|
+
srcPath: '/_api/ping/hub',
|
|
22
|
+
destPath: '',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
srcPath: '/_api/ping/notifications',
|
|
26
|
+
destPath: '',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
'manage._base_domain_': [
|
|
30
|
+
{
|
|
31
|
+
srcPath: '/_api/ping/hub',
|
|
32
|
+
destPath: '',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
srcPath: '/_api/ping/notifications',
|
|
36
|
+
destPath: '',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
return (0, metro_runtime_1.resolveUrl)(Object.assign(opts, { domainToMappings }));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
44
|
+
*
|
|
45
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
46
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
47
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
48
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
49
|
+
*
|
|
50
|
+
* For example, if your notification template looks like this:
|
|
51
|
+
*
|
|
52
|
+
* > **Title:** New {{roomType}} reservation.
|
|
53
|
+
* >
|
|
54
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
55
|
+
*
|
|
56
|
+
* You can pass the following values:
|
|
57
|
+
*
|
|
58
|
+
* ```json
|
|
59
|
+
* {
|
|
60
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
61
|
+
* "dynamicValues": {
|
|
62
|
+
* "roomType": {
|
|
63
|
+
* "text": "studio"
|
|
64
|
+
* },
|
|
65
|
+
* "customerName": {
|
|
66
|
+
* "text": "Sally Jones"
|
|
67
|
+
* },
|
|
68
|
+
* "dayOfWeek": {
|
|
69
|
+
* "text": "Friday"
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
76
|
+
*
|
|
77
|
+
* > **Title:** New studio reservation.
|
|
78
|
+
* >
|
|
79
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
80
|
+
*/
|
|
81
|
+
function notify(payload) {
|
|
82
|
+
const { toJSON: toReq, fromJSON: fromReq } = (0, ambassador_1.serializer)(_notifyRequest, {
|
|
83
|
+
_arrayDynamicValue,
|
|
84
|
+
_dynamicValue,
|
|
85
|
+
_mapDynamicValue,
|
|
86
|
+
});
|
|
87
|
+
const { fromJSON: fromRes } = (0, ambassador_1.serializer)(_notifyResponse, {});
|
|
88
|
+
function __notify({ host }) {
|
|
89
|
+
const serializedData = toReq(payload);
|
|
90
|
+
const metadata = {
|
|
91
|
+
method: 'POST',
|
|
92
|
+
url: resolveComWixpressPingHubApiV3NotificationsServiceV3Url({
|
|
93
|
+
protoPath: '/v3/notify',
|
|
94
|
+
data: serializedData,
|
|
95
|
+
host,
|
|
96
|
+
}),
|
|
97
|
+
data: serializedData,
|
|
98
|
+
transformResponse: fromRes,
|
|
99
|
+
};
|
|
100
|
+
return metadata;
|
|
101
|
+
}
|
|
102
|
+
__notify.fromReq = fromReq;
|
|
103
|
+
return __notify;
|
|
104
|
+
}
|
|
105
|
+
exports.notify = notify;
|
|
106
|
+
//# sourceMappingURL=ping-notifications-v3-notification.http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.http.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.http.ts"],"names":[],"mappings":";;;AAAA,8DAA2D;AAC3D,sDAAgD;AAQhD,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;AACtD,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;AAC/E,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;AACxD,MAAM,cAAc,GAAG,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC;AAC9D,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,SAAS,uDAAuD,CAC9D,IAA8C;IAE9C,MAAM,gBAAgB,GAAG;QACvB,uBAAuB,EAAE;YACvB;gBACE,OAAO,EAAE,2BAA2B;gBACpC,QAAQ,EAAE,EAAE;aACb;SACF;QACD,mBAAmB,EAAE;YACnB;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,EAAE;aACb;YACD;gBACE,OAAO,EAAE,0BAA0B;gBACnC,QAAQ,EAAE,EAAE;aACb;SACF;QACD,sBAAsB,EAAE;YACtB;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,EAAE;aACb;YACD;gBACE,OAAO,EAAE,0BAA0B;gBACnC,QAAQ,EAAE,EAAE;aACb;SACF;KACF,CAAC;IAEF,OAAO,IAAA,0BAAU,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,MAAM,CACpB,OAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAA,uBAAU,EAAC,cAAc,EAAE;QACtE,kBAAkB;QAClB,aAAa;QACb,gBAAgB;KACjB,CAAC,CAAC;IACH,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAA,uBAAU,EAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAE9D,SAAS,QAAQ,CAAC,EAAE,IAAI,EAAO;QAC7B,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,MAAa;YACrB,GAAG,EAAE,uDAAuD,CAAC;gBAC3D,SAAS,EAAE,YAAY;gBACvB,IAAI,EAAE,cAAc;gBACpB,IAAI;aACL,CAAC;YACF,IAAI,EAAE,cAAc;YACpB,iBAAiB,EAAE,OAAO;SAC3B,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7BD,wBA6BC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HttpClient } from '@wix/sdk-types';
|
|
2
|
+
import { NotifyOptions } from './ping-notifications-v3-notification.universal';
|
|
3
|
+
export declare function notify(httpClient: HttpClient): (notificationTemplateId: string, options?: NotifyOptions | undefined) => Promise<import("./ping-notifications-v3-notification.universal").NotifyResponse>;
|
|
4
|
+
export { TemplateChannel } from './ping-notifications-v3-notification.universal';
|
|
5
|
+
export { Notification, NotifyRequest, DynamicValue, DynamicValueOfTypeOneOf, Money, MapDynamicValue, ArrayDynamicValue, NotifyResponse, NotifyByAppRequest, Overrides, ExcludedAudiences, NotifyByAppResponse, NotifyOptions, } from './ping-notifications-v3-notification.universal';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemplateChannel = exports.notify = void 0;
|
|
4
|
+
const ping_notifications_v3_notification_universal_1 = require("./ping-notifications-v3-notification.universal");
|
|
5
|
+
function notify(httpClient) {
|
|
6
|
+
return (notificationTemplateId, options) => (0, ping_notifications_v3_notification_universal_1.notify)(notificationTemplateId, options,
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
{ httpClient });
|
|
9
|
+
}
|
|
10
|
+
exports.notify = notify;
|
|
11
|
+
var ping_notifications_v3_notification_universal_2 = require("./ping-notifications-v3-notification.universal");
|
|
12
|
+
Object.defineProperty(exports, "TemplateChannel", { enumerable: true, get: function () { return ping_notifications_v3_notification_universal_2.TemplateChannel; } });
|
|
13
|
+
//# sourceMappingURL=ping-notifications-v3-notification.public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.public.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.public.ts"],"names":[],"mappings":";;;AACA,iHAGwD;AAExD,SAAgB,MAAM,CAAC,UAAsB;IAC3C,OAAO,CAAC,sBAA8B,EAAE,OAAuB,EAAE,EAAE,CACjE,IAAA,qDAAe,EACb,sBAAsB,EACtB,OAAO;IACP,aAAa;IACb,EAAE,UAAU,EAAE,CACf,CAAC;AACN,CAAC;AARD,wBAQC;AAED,+GAAiF;AAAxE,+IAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface Notification {
|
|
2
|
+
/** The id of the notification */
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface NotifyRequest {
|
|
6
|
+
/**
|
|
7
|
+
* Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
8
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
9
|
+
*/
|
|
10
|
+
notificationTemplateId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
13
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
14
|
+
*/
|
|
15
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
16
|
+
}
|
|
17
|
+
export interface DynamicValue extends DynamicValueOfTypeOneOf {
|
|
18
|
+
/** Text to be integrated into the notification. */
|
|
19
|
+
text?: string;
|
|
20
|
+
}
|
|
21
|
+
/** @oneof */
|
|
22
|
+
export interface DynamicValueOfTypeOneOf {
|
|
23
|
+
/** Text to be integrated into the notification. */
|
|
24
|
+
text?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Money.
|
|
28
|
+
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
29
|
+
*/
|
|
30
|
+
export interface Money {
|
|
31
|
+
/** Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. */
|
|
32
|
+
value?: string;
|
|
33
|
+
/** Currency code. Must be valid ISO 4217 currency code (e.g., USD). */
|
|
34
|
+
currency?: string;
|
|
35
|
+
/** Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. */
|
|
36
|
+
formattedValue?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface MapDynamicValue {
|
|
39
|
+
/** items */
|
|
40
|
+
items?: Record<string, DynamicValue>;
|
|
41
|
+
}
|
|
42
|
+
export interface ArrayDynamicValue {
|
|
43
|
+
/** items */
|
|
44
|
+
items?: DynamicValue[];
|
|
45
|
+
}
|
|
46
|
+
export interface NotifyResponse {
|
|
47
|
+
/** ID of the batch of notifications triggered by one request. */
|
|
48
|
+
notificationBatchId?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface NotifyByAppRequest {
|
|
51
|
+
/** notification_template_id */
|
|
52
|
+
notificationTemplateId?: string;
|
|
53
|
+
/** app_def_id */
|
|
54
|
+
appDefId?: string;
|
|
55
|
+
/** dynamic_values */
|
|
56
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
57
|
+
/** overrides */
|
|
58
|
+
overrides?: Overrides;
|
|
59
|
+
}
|
|
60
|
+
export interface Overrides {
|
|
61
|
+
/** excluded_channels */
|
|
62
|
+
excludedChannels?: TemplateChannel[];
|
|
63
|
+
/** excluded_audiences */
|
|
64
|
+
excludedAudiences?: ExcludedAudiences;
|
|
65
|
+
}
|
|
66
|
+
export declare enum TemplateChannel {
|
|
67
|
+
WEB_FEED = "WEB_FEED",
|
|
68
|
+
MOBILE_FEED = "MOBILE_FEED",
|
|
69
|
+
MOBILE_PUSH = "MOBILE_PUSH",
|
|
70
|
+
BROWSER = "BROWSER",
|
|
71
|
+
SMS = "SMS",
|
|
72
|
+
EMAIL = "EMAIL",
|
|
73
|
+
KAFKA = "KAFKA",
|
|
74
|
+
VOICE = "VOICE"
|
|
75
|
+
}
|
|
76
|
+
export interface ExcludedAudiences {
|
|
77
|
+
/** audience_key */
|
|
78
|
+
audienceKey?: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface NotifyByAppResponse {
|
|
81
|
+
/** notification_batch_id */
|
|
82
|
+
notificationBatchId?: string;
|
|
83
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemplateChannel = void 0;
|
|
4
|
+
var TemplateChannel;
|
|
5
|
+
(function (TemplateChannel) {
|
|
6
|
+
TemplateChannel["WEB_FEED"] = "WEB_FEED";
|
|
7
|
+
TemplateChannel["MOBILE_FEED"] = "MOBILE_FEED";
|
|
8
|
+
TemplateChannel["MOBILE_PUSH"] = "MOBILE_PUSH";
|
|
9
|
+
TemplateChannel["BROWSER"] = "BROWSER";
|
|
10
|
+
TemplateChannel["SMS"] = "SMS";
|
|
11
|
+
TemplateChannel["EMAIL"] = "EMAIL";
|
|
12
|
+
TemplateChannel["KAFKA"] = "KAFKA";
|
|
13
|
+
TemplateChannel["VOICE"] = "VOICE";
|
|
14
|
+
})(TemplateChannel = exports.TemplateChannel || (exports.TemplateChannel = {}));
|
|
15
|
+
//# sourceMappingURL=ping-notifications-v3-notification.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.types.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.types.ts"],"names":[],"mappings":";;;AA2EA,IAAY,eASX;AATD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,8CAA2B,CAAA;IAC3B,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,8BAAW,CAAA;IACX,kCAAe,CAAA;IACf,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EATW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAS1B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare const __debug: {
|
|
2
|
+
verboseLogging: {
|
|
3
|
+
on: () => boolean;
|
|
4
|
+
off: () => boolean;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export interface Notification {
|
|
8
|
+
/** The id of the notification */
|
|
9
|
+
_id?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NotifyRequest {
|
|
12
|
+
/**
|
|
13
|
+
* Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
14
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
15
|
+
*/
|
|
16
|
+
notificationTemplateId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
19
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
20
|
+
*/
|
|
21
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
22
|
+
}
|
|
23
|
+
export interface DynamicValue extends DynamicValueOfTypeOneOf {
|
|
24
|
+
/** Text to be integrated into the notification. */
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
/** @oneof */
|
|
28
|
+
export interface DynamicValueOfTypeOneOf {
|
|
29
|
+
/** Text to be integrated into the notification. */
|
|
30
|
+
text?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Money.
|
|
34
|
+
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
35
|
+
*/
|
|
36
|
+
export interface Money {
|
|
37
|
+
/** Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. */
|
|
38
|
+
value?: string;
|
|
39
|
+
/** Currency code. Must be valid ISO 4217 currency code (e.g., USD). */
|
|
40
|
+
currency?: string;
|
|
41
|
+
/** Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. */
|
|
42
|
+
formattedValue?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface MapDynamicValue {
|
|
45
|
+
/** items */
|
|
46
|
+
items?: Record<string, DynamicValue>;
|
|
47
|
+
}
|
|
48
|
+
export interface ArrayDynamicValue {
|
|
49
|
+
/** items */
|
|
50
|
+
items?: DynamicValue[];
|
|
51
|
+
}
|
|
52
|
+
export interface NotifyResponse {
|
|
53
|
+
/** ID of the batch of notifications triggered by one request. */
|
|
54
|
+
notificationBatchId?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface NotifyByAppRequest {
|
|
57
|
+
/** notification_template_id */
|
|
58
|
+
notificationTemplateId?: string;
|
|
59
|
+
/** app_def_id */
|
|
60
|
+
appDefId?: string;
|
|
61
|
+
/** dynamic_values */
|
|
62
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
63
|
+
/** overrides */
|
|
64
|
+
overrides?: Overrides;
|
|
65
|
+
}
|
|
66
|
+
export interface Overrides {
|
|
67
|
+
/** excluded_channels */
|
|
68
|
+
excludedChannels?: TemplateChannel[];
|
|
69
|
+
/** excluded_audiences */
|
|
70
|
+
excludedAudiences?: ExcludedAudiences;
|
|
71
|
+
}
|
|
72
|
+
export declare enum TemplateChannel {
|
|
73
|
+
WEB_FEED = "WEB_FEED",
|
|
74
|
+
MOBILE_FEED = "MOBILE_FEED",
|
|
75
|
+
MOBILE_PUSH = "MOBILE_PUSH",
|
|
76
|
+
BROWSER = "BROWSER",
|
|
77
|
+
SMS = "SMS",
|
|
78
|
+
EMAIL = "EMAIL",
|
|
79
|
+
KAFKA = "KAFKA",
|
|
80
|
+
VOICE = "VOICE"
|
|
81
|
+
}
|
|
82
|
+
export interface ExcludedAudiences {
|
|
83
|
+
/** audience_key */
|
|
84
|
+
audienceKey?: string[];
|
|
85
|
+
}
|
|
86
|
+
export interface NotifyByAppResponse {
|
|
87
|
+
/** notification_batch_id */
|
|
88
|
+
notificationBatchId?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
92
|
+
*
|
|
93
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
94
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
95
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
96
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
97
|
+
*
|
|
98
|
+
* For example, if your notification template looks like this:
|
|
99
|
+
*
|
|
100
|
+
* > **Title:** New {{roomType}} reservation.
|
|
101
|
+
* >
|
|
102
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
103
|
+
*
|
|
104
|
+
* You can pass the following values:
|
|
105
|
+
*
|
|
106
|
+
* ```json
|
|
107
|
+
* {
|
|
108
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
109
|
+
* "dynamicValues": {
|
|
110
|
+
* "roomType": {
|
|
111
|
+
* "text": "studio"
|
|
112
|
+
* },
|
|
113
|
+
* "customerName": {
|
|
114
|
+
* "text": "Sally Jones"
|
|
115
|
+
* },
|
|
116
|
+
* "dayOfWeek": {
|
|
117
|
+
* "text": "Friday"
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
124
|
+
*
|
|
125
|
+
* > **Title:** New studio reservation.
|
|
126
|
+
* >
|
|
127
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
128
|
+
* @param notificationTemplateId - Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
129
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
130
|
+
* @public
|
|
131
|
+
* @documentationMaturity preview
|
|
132
|
+
* @requiredField notificationTemplateId
|
|
133
|
+
*/
|
|
134
|
+
export declare function notify(notificationTemplateId: string, options?: NotifyOptions): Promise<NotifyResponse>;
|
|
135
|
+
export interface NotifyOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
138
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
139
|
+
*/
|
|
140
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
141
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.notify = exports.TemplateChannel = exports.__debug = void 0;
|
|
32
|
+
const velo_1 = require("@wix/metro-runtime/velo");
|
|
33
|
+
const ambassadorWixPingNotificationsV3Notification = __importStar(require("./ping-notifications-v3-notification.http"));
|
|
34
|
+
let __verbose = false;
|
|
35
|
+
function __log(...args) {
|
|
36
|
+
__verbose && console.log(...args);
|
|
37
|
+
}
|
|
38
|
+
function __inspect(obj) {
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
exports.__debug = {
|
|
42
|
+
verboseLogging: {
|
|
43
|
+
on: () => (__verbose = true),
|
|
44
|
+
off: () => (__verbose = false),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const _toVeloEntity = '$';
|
|
48
|
+
const _fromVeloEntity = '$';
|
|
49
|
+
var TemplateChannel;
|
|
50
|
+
(function (TemplateChannel) {
|
|
51
|
+
TemplateChannel["WEB_FEED"] = "WEB_FEED";
|
|
52
|
+
TemplateChannel["MOBILE_FEED"] = "MOBILE_FEED";
|
|
53
|
+
TemplateChannel["MOBILE_PUSH"] = "MOBILE_PUSH";
|
|
54
|
+
TemplateChannel["BROWSER"] = "BROWSER";
|
|
55
|
+
TemplateChannel["SMS"] = "SMS";
|
|
56
|
+
TemplateChannel["EMAIL"] = "EMAIL";
|
|
57
|
+
TemplateChannel["KAFKA"] = "KAFKA";
|
|
58
|
+
TemplateChannel["VOICE"] = "VOICE";
|
|
59
|
+
})(TemplateChannel = exports.TemplateChannel || (exports.TemplateChannel = {}));
|
|
60
|
+
const _arrayDynamicValue = { items: '_dynamicValue' };
|
|
61
|
+
const _dynamicValue = { map: '_mapDynamicValue', array: '_arrayDynamicValue' };
|
|
62
|
+
const _mapDynamicValue = { items: 'Map#_dynamicValue' };
|
|
63
|
+
const _notifyRequest = { dynamicValues: 'Map#_dynamicValue' };
|
|
64
|
+
const _notifyResponse = {};
|
|
65
|
+
/**
|
|
66
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
67
|
+
*
|
|
68
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
69
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
70
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
71
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
72
|
+
*
|
|
73
|
+
* For example, if your notification template looks like this:
|
|
74
|
+
*
|
|
75
|
+
* > **Title:** New {{roomType}} reservation.
|
|
76
|
+
* >
|
|
77
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
78
|
+
*
|
|
79
|
+
* You can pass the following values:
|
|
80
|
+
*
|
|
81
|
+
* ```json
|
|
82
|
+
* {
|
|
83
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
84
|
+
* "dynamicValues": {
|
|
85
|
+
* "roomType": {
|
|
86
|
+
* "text": "studio"
|
|
87
|
+
* },
|
|
88
|
+
* "customerName": {
|
|
89
|
+
* "text": "Sally Jones"
|
|
90
|
+
* },
|
|
91
|
+
* "dayOfWeek": {
|
|
92
|
+
* "text": "Friday"
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
99
|
+
*
|
|
100
|
+
* > **Title:** New studio reservation.
|
|
101
|
+
* >
|
|
102
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
103
|
+
* @param notificationTemplateId - Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
104
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
105
|
+
* @public
|
|
106
|
+
* @documentationMaturity preview
|
|
107
|
+
* @requiredField notificationTemplateId
|
|
108
|
+
*/
|
|
109
|
+
function notify(notificationTemplateId, options) {
|
|
110
|
+
var _a, _b, _c;
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
112
|
+
const requestTransformation = {
|
|
113
|
+
notificationTemplateId: '$[0]',
|
|
114
|
+
dynamicValues: '$[1].dynamicValues',
|
|
115
|
+
};
|
|
116
|
+
const responseTransformation = '$';
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
119
|
+
const { toAmbassadorRequest } = (0, velo_1.serializer)({
|
|
120
|
+
rootSchema: _notifyRequest,
|
|
121
|
+
depSchemas: { _arrayDynamicValue, _dynamicValue, _mapDynamicValue },
|
|
122
|
+
fqdnTransformation: {
|
|
123
|
+
paths: [],
|
|
124
|
+
transformation: _fromVeloEntity,
|
|
125
|
+
},
|
|
126
|
+
customTransformation: requestTransformation,
|
|
127
|
+
});
|
|
128
|
+
const { fromJSON } = (0, velo_1.serializer)({
|
|
129
|
+
rootSchema: _notifyResponse,
|
|
130
|
+
depSchemas: {},
|
|
131
|
+
fqdnTransformation: {
|
|
132
|
+
paths: [],
|
|
133
|
+
transformation: _toVeloEntity,
|
|
134
|
+
},
|
|
135
|
+
customTransformation: responseTransformation,
|
|
136
|
+
});
|
|
137
|
+
const payload = toAmbassadorRequest([notificationTemplateId, options]);
|
|
138
|
+
const reqOpts = ambassadorWixPingNotificationsV3Notification.notify(payload);
|
|
139
|
+
__log(`"Notify" sending request with: ${__inspect(reqOpts)}`);
|
|
140
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
141
|
+
try {
|
|
142
|
+
const result = yield httpClient.request(reqOpts);
|
|
143
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
144
|
+
return fromJSON(result.data);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
|
|
148
|
+
'notificationTemplateId',
|
|
149
|
+
'options',
|
|
150
|
+
]);
|
|
151
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
152
|
+
throw transformedError;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
exports.notify = notify;
|
|
157
|
+
//# sourceMappingURL=ping-notifications-v3-notification.universal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.universal.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.universal.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as notifications from './src/ping-notifications-v3-notification.public';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,iDAAiD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RequestOptionsFactory } from '@wix/sdk-types';
|
|
2
|
+
import { NotifyRequest, NotifyResponse } from './ping-notifications-v3-notification.types';
|
|
3
|
+
/**
|
|
4
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
5
|
+
*
|
|
6
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
7
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
8
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
9
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
10
|
+
*
|
|
11
|
+
* For example, if your notification template looks like this:
|
|
12
|
+
*
|
|
13
|
+
* > **Title:** New {{roomType}} reservation.
|
|
14
|
+
* >
|
|
15
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
16
|
+
*
|
|
17
|
+
* You can pass the following values:
|
|
18
|
+
*
|
|
19
|
+
* ```json
|
|
20
|
+
* {
|
|
21
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
22
|
+
* "dynamicValues": {
|
|
23
|
+
* "roomType": {
|
|
24
|
+
* "text": "studio"
|
|
25
|
+
* },
|
|
26
|
+
* "customerName": {
|
|
27
|
+
* "text": "Sally Jones"
|
|
28
|
+
* },
|
|
29
|
+
* "dayOfWeek": {
|
|
30
|
+
* "text": "Friday"
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
37
|
+
*
|
|
38
|
+
* > **Title:** New studio reservation.
|
|
39
|
+
* >
|
|
40
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
41
|
+
*/
|
|
42
|
+
export declare function notify(payload: NotifyRequest): RequestOptionsFactory<NotifyResponse>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { serializer } from '@wix/metro-runtime/ambassador';
|
|
2
|
+
import { resolveUrl } from '@wix/metro-runtime';
|
|
3
|
+
const _arrayDynamicValue = { items: '_dynamicValue' };
|
|
4
|
+
const _dynamicValue = { map: '_mapDynamicValue', array: '_arrayDynamicValue' };
|
|
5
|
+
const _mapDynamicValue = { items: 'Map#_dynamicValue' };
|
|
6
|
+
const _notifyRequest = { dynamicValues: 'Map#_dynamicValue' };
|
|
7
|
+
const _notifyResponse = {};
|
|
8
|
+
function resolveComWixpressPingHubApiV3NotificationsServiceV3Url(opts) {
|
|
9
|
+
const domainToMappings = {
|
|
10
|
+
'api._api_base_domain_': [
|
|
11
|
+
{
|
|
12
|
+
srcPath: '/notifications-hub-server',
|
|
13
|
+
destPath: '',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
'www._base_domain_': [
|
|
17
|
+
{
|
|
18
|
+
srcPath: '/_api/ping/hub',
|
|
19
|
+
destPath: '',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
srcPath: '/_api/ping/notifications',
|
|
23
|
+
destPath: '',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
'manage._base_domain_': [
|
|
27
|
+
{
|
|
28
|
+
srcPath: '/_api/ping/hub',
|
|
29
|
+
destPath: '',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
srcPath: '/_api/ping/notifications',
|
|
33
|
+
destPath: '',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
return resolveUrl(Object.assign(opts, { domainToMappings }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
41
|
+
*
|
|
42
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
43
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
44
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
45
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
46
|
+
*
|
|
47
|
+
* For example, if your notification template looks like this:
|
|
48
|
+
*
|
|
49
|
+
* > **Title:** New {{roomType}} reservation.
|
|
50
|
+
* >
|
|
51
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
52
|
+
*
|
|
53
|
+
* You can pass the following values:
|
|
54
|
+
*
|
|
55
|
+
* ```json
|
|
56
|
+
* {
|
|
57
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
58
|
+
* "dynamicValues": {
|
|
59
|
+
* "roomType": {
|
|
60
|
+
* "text": "studio"
|
|
61
|
+
* },
|
|
62
|
+
* "customerName": {
|
|
63
|
+
* "text": "Sally Jones"
|
|
64
|
+
* },
|
|
65
|
+
* "dayOfWeek": {
|
|
66
|
+
* "text": "Friday"
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
73
|
+
*
|
|
74
|
+
* > **Title:** New studio reservation.
|
|
75
|
+
* >
|
|
76
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
77
|
+
*/
|
|
78
|
+
export function notify(payload) {
|
|
79
|
+
const { toJSON: toReq, fromJSON: fromReq } = serializer(_notifyRequest, {
|
|
80
|
+
_arrayDynamicValue,
|
|
81
|
+
_dynamicValue,
|
|
82
|
+
_mapDynamicValue,
|
|
83
|
+
});
|
|
84
|
+
const { fromJSON: fromRes } = serializer(_notifyResponse, {});
|
|
85
|
+
function __notify({ host }) {
|
|
86
|
+
const serializedData = toReq(payload);
|
|
87
|
+
const metadata = {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
url: resolveComWixpressPingHubApiV3NotificationsServiceV3Url({
|
|
90
|
+
protoPath: '/v3/notify',
|
|
91
|
+
data: serializedData,
|
|
92
|
+
host,
|
|
93
|
+
}),
|
|
94
|
+
data: serializedData,
|
|
95
|
+
transformResponse: fromRes,
|
|
96
|
+
};
|
|
97
|
+
return metadata;
|
|
98
|
+
}
|
|
99
|
+
__notify.fromReq = fromReq;
|
|
100
|
+
return __notify;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=ping-notifications-v3-notification.http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.http.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQhD,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;AACtD,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;AAC/E,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;AACxD,MAAM,cAAc,GAAG,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC;AAC9D,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,SAAS,uDAAuD,CAC9D,IAA8C;IAE9C,MAAM,gBAAgB,GAAG;QACvB,uBAAuB,EAAE;YACvB;gBACE,OAAO,EAAE,2BAA2B;gBACpC,QAAQ,EAAE,EAAE;aACb;SACF;QACD,mBAAmB,EAAE;YACnB;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,EAAE;aACb;YACD;gBACE,OAAO,EAAE,0BAA0B;gBACnC,QAAQ,EAAE,EAAE;aACb;SACF;QACD,sBAAsB,EAAE;YACtB;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,EAAE;aACb;YACD;gBACE,OAAO,EAAE,0BAA0B;gBACnC,QAAQ,EAAE,EAAE;aACb;SACF;KACF,CAAC;IAEF,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,MAAM,CACpB,OAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,cAAc,EAAE;QACtE,kBAAkB;QAClB,aAAa;QACb,gBAAgB;KACjB,CAAC,CAAC;IACH,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAE9D,SAAS,QAAQ,CAAC,EAAE,IAAI,EAAO;QAC7B,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,MAAa;YACrB,GAAG,EAAE,uDAAuD,CAAC;gBAC3D,SAAS,EAAE,YAAY;gBACvB,IAAI,EAAE,cAAc;gBACpB,IAAI;aACL,CAAC;YACF,IAAI,EAAE,cAAc;YACpB,iBAAiB,EAAE,OAAO;SAC3B,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HttpClient } from '@wix/sdk-types';
|
|
2
|
+
import { NotifyOptions } from './ping-notifications-v3-notification.universal';
|
|
3
|
+
export declare function notify(httpClient: HttpClient): (notificationTemplateId: string, options?: NotifyOptions | undefined) => Promise<import("./ping-notifications-v3-notification.universal").NotifyResponse>;
|
|
4
|
+
export { TemplateChannel } from './ping-notifications-v3-notification.universal';
|
|
5
|
+
export { Notification, NotifyRequest, DynamicValue, DynamicValueOfTypeOneOf, Money, MapDynamicValue, ArrayDynamicValue, NotifyResponse, NotifyByAppRequest, Overrides, ExcludedAudiences, NotifyByAppResponse, NotifyOptions, } from './ping-notifications-v3-notification.universal';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { notify as universalNotify, } from './ping-notifications-v3-notification.universal';
|
|
2
|
+
export function notify(httpClient) {
|
|
3
|
+
return (notificationTemplateId, options) => universalNotify(notificationTemplateId, options,
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
{ httpClient });
|
|
6
|
+
}
|
|
7
|
+
export { TemplateChannel } from './ping-notifications-v3-notification.universal';
|
|
8
|
+
//# sourceMappingURL=ping-notifications-v3-notification.public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.public.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.public.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,IAAI,eAAe,GAE1B,MAAM,gDAAgD,CAAC;AAExD,MAAM,UAAU,MAAM,CAAC,UAAsB;IAC3C,OAAO,CAAC,sBAA8B,EAAE,OAAuB,EAAE,EAAE,CACjE,eAAe,CACb,sBAAsB,EACtB,OAAO;IACP,aAAa;IACb,EAAE,UAAU,EAAE,CACf,CAAC;AACN,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface Notification {
|
|
2
|
+
/** The id of the notification */
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface NotifyRequest {
|
|
6
|
+
/**
|
|
7
|
+
* Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
8
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
9
|
+
*/
|
|
10
|
+
notificationTemplateId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
13
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
14
|
+
*/
|
|
15
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
16
|
+
}
|
|
17
|
+
export interface DynamicValue extends DynamicValueOfTypeOneOf {
|
|
18
|
+
/** Text to be integrated into the notification. */
|
|
19
|
+
text?: string;
|
|
20
|
+
}
|
|
21
|
+
/** @oneof */
|
|
22
|
+
export interface DynamicValueOfTypeOneOf {
|
|
23
|
+
/** Text to be integrated into the notification. */
|
|
24
|
+
text?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Money.
|
|
28
|
+
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
29
|
+
*/
|
|
30
|
+
export interface Money {
|
|
31
|
+
/** Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. */
|
|
32
|
+
value?: string;
|
|
33
|
+
/** Currency code. Must be valid ISO 4217 currency code (e.g., USD). */
|
|
34
|
+
currency?: string;
|
|
35
|
+
/** Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. */
|
|
36
|
+
formattedValue?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface MapDynamicValue {
|
|
39
|
+
/** items */
|
|
40
|
+
items?: Record<string, DynamicValue>;
|
|
41
|
+
}
|
|
42
|
+
export interface ArrayDynamicValue {
|
|
43
|
+
/** items */
|
|
44
|
+
items?: DynamicValue[];
|
|
45
|
+
}
|
|
46
|
+
export interface NotifyResponse {
|
|
47
|
+
/** ID of the batch of notifications triggered by one request. */
|
|
48
|
+
notificationBatchId?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface NotifyByAppRequest {
|
|
51
|
+
/** notification_template_id */
|
|
52
|
+
notificationTemplateId?: string;
|
|
53
|
+
/** app_def_id */
|
|
54
|
+
appDefId?: string;
|
|
55
|
+
/** dynamic_values */
|
|
56
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
57
|
+
/** overrides */
|
|
58
|
+
overrides?: Overrides;
|
|
59
|
+
}
|
|
60
|
+
export interface Overrides {
|
|
61
|
+
/** excluded_channels */
|
|
62
|
+
excludedChannels?: TemplateChannel[];
|
|
63
|
+
/** excluded_audiences */
|
|
64
|
+
excludedAudiences?: ExcludedAudiences;
|
|
65
|
+
}
|
|
66
|
+
export declare enum TemplateChannel {
|
|
67
|
+
WEB_FEED = "WEB_FEED",
|
|
68
|
+
MOBILE_FEED = "MOBILE_FEED",
|
|
69
|
+
MOBILE_PUSH = "MOBILE_PUSH",
|
|
70
|
+
BROWSER = "BROWSER",
|
|
71
|
+
SMS = "SMS",
|
|
72
|
+
EMAIL = "EMAIL",
|
|
73
|
+
KAFKA = "KAFKA",
|
|
74
|
+
VOICE = "VOICE"
|
|
75
|
+
}
|
|
76
|
+
export interface ExcludedAudiences {
|
|
77
|
+
/** audience_key */
|
|
78
|
+
audienceKey?: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface NotifyByAppResponse {
|
|
81
|
+
/** notification_batch_id */
|
|
82
|
+
notificationBatchId?: string;
|
|
83
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var TemplateChannel;
|
|
2
|
+
(function (TemplateChannel) {
|
|
3
|
+
TemplateChannel["WEB_FEED"] = "WEB_FEED";
|
|
4
|
+
TemplateChannel["MOBILE_FEED"] = "MOBILE_FEED";
|
|
5
|
+
TemplateChannel["MOBILE_PUSH"] = "MOBILE_PUSH";
|
|
6
|
+
TemplateChannel["BROWSER"] = "BROWSER";
|
|
7
|
+
TemplateChannel["SMS"] = "SMS";
|
|
8
|
+
TemplateChannel["EMAIL"] = "EMAIL";
|
|
9
|
+
TemplateChannel["KAFKA"] = "KAFKA";
|
|
10
|
+
TemplateChannel["VOICE"] = "VOICE";
|
|
11
|
+
})(TemplateChannel || (TemplateChannel = {}));
|
|
12
|
+
//# sourceMappingURL=ping-notifications-v3-notification.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.types.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.types.ts"],"names":[],"mappings":"AA2EA,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,8CAA2B,CAAA;IAC3B,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,8BAAW,CAAA;IACX,kCAAe,CAAA;IACf,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare const __debug: {
|
|
2
|
+
verboseLogging: {
|
|
3
|
+
on: () => boolean;
|
|
4
|
+
off: () => boolean;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export interface Notification {
|
|
8
|
+
/** The id of the notification */
|
|
9
|
+
_id?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NotifyRequest {
|
|
12
|
+
/**
|
|
13
|
+
* Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
14
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
15
|
+
*/
|
|
16
|
+
notificationTemplateId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
19
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
20
|
+
*/
|
|
21
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
22
|
+
}
|
|
23
|
+
export interface DynamicValue extends DynamicValueOfTypeOneOf {
|
|
24
|
+
/** Text to be integrated into the notification. */
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
/** @oneof */
|
|
28
|
+
export interface DynamicValueOfTypeOneOf {
|
|
29
|
+
/** Text to be integrated into the notification. */
|
|
30
|
+
text?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Money.
|
|
34
|
+
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
35
|
+
*/
|
|
36
|
+
export interface Money {
|
|
37
|
+
/** Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. */
|
|
38
|
+
value?: string;
|
|
39
|
+
/** Currency code. Must be valid ISO 4217 currency code (e.g., USD). */
|
|
40
|
+
currency?: string;
|
|
41
|
+
/** Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. */
|
|
42
|
+
formattedValue?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface MapDynamicValue {
|
|
45
|
+
/** items */
|
|
46
|
+
items?: Record<string, DynamicValue>;
|
|
47
|
+
}
|
|
48
|
+
export interface ArrayDynamicValue {
|
|
49
|
+
/** items */
|
|
50
|
+
items?: DynamicValue[];
|
|
51
|
+
}
|
|
52
|
+
export interface NotifyResponse {
|
|
53
|
+
/** ID of the batch of notifications triggered by one request. */
|
|
54
|
+
notificationBatchId?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface NotifyByAppRequest {
|
|
57
|
+
/** notification_template_id */
|
|
58
|
+
notificationTemplateId?: string;
|
|
59
|
+
/** app_def_id */
|
|
60
|
+
appDefId?: string;
|
|
61
|
+
/** dynamic_values */
|
|
62
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
63
|
+
/** overrides */
|
|
64
|
+
overrides?: Overrides;
|
|
65
|
+
}
|
|
66
|
+
export interface Overrides {
|
|
67
|
+
/** excluded_channels */
|
|
68
|
+
excludedChannels?: TemplateChannel[];
|
|
69
|
+
/** excluded_audiences */
|
|
70
|
+
excludedAudiences?: ExcludedAudiences;
|
|
71
|
+
}
|
|
72
|
+
export declare enum TemplateChannel {
|
|
73
|
+
WEB_FEED = "WEB_FEED",
|
|
74
|
+
MOBILE_FEED = "MOBILE_FEED",
|
|
75
|
+
MOBILE_PUSH = "MOBILE_PUSH",
|
|
76
|
+
BROWSER = "BROWSER",
|
|
77
|
+
SMS = "SMS",
|
|
78
|
+
EMAIL = "EMAIL",
|
|
79
|
+
KAFKA = "KAFKA",
|
|
80
|
+
VOICE = "VOICE"
|
|
81
|
+
}
|
|
82
|
+
export interface ExcludedAudiences {
|
|
83
|
+
/** audience_key */
|
|
84
|
+
audienceKey?: string[];
|
|
85
|
+
}
|
|
86
|
+
export interface NotifyByAppResponse {
|
|
87
|
+
/** notification_batch_id */
|
|
88
|
+
notificationBatchId?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
92
|
+
*
|
|
93
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
94
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
95
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
96
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
97
|
+
*
|
|
98
|
+
* For example, if your notification template looks like this:
|
|
99
|
+
*
|
|
100
|
+
* > **Title:** New {{roomType}} reservation.
|
|
101
|
+
* >
|
|
102
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
103
|
+
*
|
|
104
|
+
* You can pass the following values:
|
|
105
|
+
*
|
|
106
|
+
* ```json
|
|
107
|
+
* {
|
|
108
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
109
|
+
* "dynamicValues": {
|
|
110
|
+
* "roomType": {
|
|
111
|
+
* "text": "studio"
|
|
112
|
+
* },
|
|
113
|
+
* "customerName": {
|
|
114
|
+
* "text": "Sally Jones"
|
|
115
|
+
* },
|
|
116
|
+
* "dayOfWeek": {
|
|
117
|
+
* "text": "Friday"
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
124
|
+
*
|
|
125
|
+
* > **Title:** New studio reservation.
|
|
126
|
+
* >
|
|
127
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
128
|
+
* @param notificationTemplateId - Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
129
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
130
|
+
* @public
|
|
131
|
+
* @documentationMaturity preview
|
|
132
|
+
* @requiredField notificationTemplateId
|
|
133
|
+
*/
|
|
134
|
+
export declare function notify(notificationTemplateId: string, options?: NotifyOptions): Promise<NotifyResponse>;
|
|
135
|
+
export interface NotifyOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Each key is a placeholder name you specify when [creating a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template).
|
|
138
|
+
* The value is an object containing the text to replace the placeholder in the notifications.
|
|
139
|
+
*/
|
|
140
|
+
dynamicValues?: Record<string, DynamicValue>;
|
|
141
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { serializer, transformError } from '@wix/metro-runtime/velo';
|
|
11
|
+
import * as ambassadorWixPingNotificationsV3Notification from './ping-notifications-v3-notification.http';
|
|
12
|
+
let __verbose = false;
|
|
13
|
+
function __log(...args) {
|
|
14
|
+
__verbose && console.log(...args);
|
|
15
|
+
}
|
|
16
|
+
function __inspect(obj) {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
export const __debug = {
|
|
20
|
+
verboseLogging: {
|
|
21
|
+
on: () => (__verbose = true),
|
|
22
|
+
off: () => (__verbose = false),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const _toVeloEntity = '$';
|
|
26
|
+
const _fromVeloEntity = '$';
|
|
27
|
+
export var TemplateChannel;
|
|
28
|
+
(function (TemplateChannel) {
|
|
29
|
+
TemplateChannel["WEB_FEED"] = "WEB_FEED";
|
|
30
|
+
TemplateChannel["MOBILE_FEED"] = "MOBILE_FEED";
|
|
31
|
+
TemplateChannel["MOBILE_PUSH"] = "MOBILE_PUSH";
|
|
32
|
+
TemplateChannel["BROWSER"] = "BROWSER";
|
|
33
|
+
TemplateChannel["SMS"] = "SMS";
|
|
34
|
+
TemplateChannel["EMAIL"] = "EMAIL";
|
|
35
|
+
TemplateChannel["KAFKA"] = "KAFKA";
|
|
36
|
+
TemplateChannel["VOICE"] = "VOICE";
|
|
37
|
+
})(TemplateChannel || (TemplateChannel = {}));
|
|
38
|
+
const _arrayDynamicValue = { items: '_dynamicValue' };
|
|
39
|
+
const _dynamicValue = { map: '_mapDynamicValue', array: '_arrayDynamicValue' };
|
|
40
|
+
const _mapDynamicValue = { items: 'Map#_dynamicValue' };
|
|
41
|
+
const _notifyRequest = { dynamicValues: 'Map#_dynamicValue' };
|
|
42
|
+
const _notifyResponse = {};
|
|
43
|
+
/**
|
|
44
|
+
* Sends notifications based on the template and dynamic values provided.
|
|
45
|
+
*
|
|
46
|
+
* When you [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center, you are given a notification template ID.
|
|
47
|
+
* Call the Notify endpoint with this ID as `notificationTemplateID` to trigger notifications based on the notification template.
|
|
48
|
+
* If the notification template contains placeholders for dynamic values, provide those values as key-value pairs in the `dynamicValues` array.
|
|
49
|
+
* The values you specify are incorporated seamlessly in the notifications sent out.
|
|
50
|
+
*
|
|
51
|
+
* For example, if your notification template looks like this:
|
|
52
|
+
*
|
|
53
|
+
* > **Title:** New {{roomType}} reservation.
|
|
54
|
+
* >
|
|
55
|
+
* > **Message:** {{customerName}} just made a new {{roomType}} reservation for {{dayOfWeek}}.
|
|
56
|
+
*
|
|
57
|
+
* You can pass the following values:
|
|
58
|
+
*
|
|
59
|
+
* ```json
|
|
60
|
+
* {
|
|
61
|
+
* "notificationTemplateId": "<YOUR_NOTIFICATION_ID>",
|
|
62
|
+
* "dynamicValues": {
|
|
63
|
+
* "roomType": {
|
|
64
|
+
* "text": "studio"
|
|
65
|
+
* },
|
|
66
|
+
* "customerName": {
|
|
67
|
+
* "text": "Sally Jones"
|
|
68
|
+
* },
|
|
69
|
+
* "dayOfWeek": {
|
|
70
|
+
* "text": "Friday"
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* This will cause the following text to be sent in notifications to the recipients defined in the Wix Dev Center:
|
|
77
|
+
*
|
|
78
|
+
* > **Title:** New studio reservation.
|
|
79
|
+
* >
|
|
80
|
+
* > **Message:** Sally Jones just made a new studio reservation for Friday.
|
|
81
|
+
* @param notificationTemplateId - Notification template ID. A notification template specifies the text and recipients for notifications.
|
|
82
|
+
* To obtain a notification template ID, [create a notification template](https://dev.wix.com/api/rest/notifications/notifications/creating-a-notification-template) in the Wix Dev Center.
|
|
83
|
+
* @public
|
|
84
|
+
* @documentationMaturity preview
|
|
85
|
+
* @requiredField notificationTemplateId
|
|
86
|
+
*/
|
|
87
|
+
export function notify(notificationTemplateId, options) {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
90
|
+
const requestTransformation = {
|
|
91
|
+
notificationTemplateId: '$[0]',
|
|
92
|
+
dynamicValues: '$[1].dynamicValues',
|
|
93
|
+
};
|
|
94
|
+
const responseTransformation = '$';
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
97
|
+
const { toAmbassadorRequest } = serializer({
|
|
98
|
+
rootSchema: _notifyRequest,
|
|
99
|
+
depSchemas: { _arrayDynamicValue, _dynamicValue, _mapDynamicValue },
|
|
100
|
+
fqdnTransformation: {
|
|
101
|
+
paths: [],
|
|
102
|
+
transformation: _fromVeloEntity,
|
|
103
|
+
},
|
|
104
|
+
customTransformation: requestTransformation,
|
|
105
|
+
});
|
|
106
|
+
const { fromJSON } = serializer({
|
|
107
|
+
rootSchema: _notifyResponse,
|
|
108
|
+
depSchemas: {},
|
|
109
|
+
fqdnTransformation: {
|
|
110
|
+
paths: [],
|
|
111
|
+
transformation: _toVeloEntity,
|
|
112
|
+
},
|
|
113
|
+
customTransformation: responseTransformation,
|
|
114
|
+
});
|
|
115
|
+
const payload = toAmbassadorRequest([notificationTemplateId, options]);
|
|
116
|
+
const reqOpts = ambassadorWixPingNotificationsV3Notification.notify(payload);
|
|
117
|
+
__log(`"Notify" sending request with: ${__inspect(reqOpts)}`);
|
|
118
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
|
119
|
+
try {
|
|
120
|
+
const result = yield httpClient.request(reqOpts);
|
|
121
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
122
|
+
return fromJSON(result.data);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
const transformedError = transformError(err, requestTransformation, [
|
|
126
|
+
'notificationTemplateId',
|
|
127
|
+
'options',
|
|
128
|
+
]);
|
|
129
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
130
|
+
throw transformedError;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=ping-notifications-v3-notification.universal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping-notifications-v3-notification.universal.js","sourceRoot":"","sources":["../../../src/ping-notifications-v3-notification.universal.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/notifications",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"registry": "https://registry.npmjs.org/",
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"module": "build/es/index.js",
|
|
10
|
+
"main": "build/cjs/index.js",
|
|
11
|
+
"typings": "./build/cjs/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"build",
|
|
14
|
+
"frontend/package.json"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@wix/metro-runtime": "^1.0.0",
|
|
18
|
+
"@wix/sdk-types": "^1.0.0",
|
|
19
|
+
"@wix/motion-edm-autogen-query-wrapper": "^1.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@wix/typescript-to-service-json": "^1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -b tsconfig.json tsconfig.esm.json",
|
|
26
|
+
"autodocs": "ts-to-sj",
|
|
27
|
+
"posttest": "npm run autodocs",
|
|
28
|
+
"test": ":"
|
|
29
|
+
},
|
|
30
|
+
"wix": {
|
|
31
|
+
"artifact": {
|
|
32
|
+
"artifactId": "notifications-public-sdk-autogen",
|
|
33
|
+
"groupId": "com.wixpress.public-sdk-autogen"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"falconPackageHash": "6a0d3fff85e9f9bc36cce6c63fae243b6ccd94322c2de8b17072a567"
|
|
37
|
+
}
|