@salespark/mailerlite-api 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/README.md +208 -0
- package/dist/@types/debug.log +2 -0
- package/dist/@types/index.d.ts +275 -0
- package/dist/api/account.d.ts +7 -0
- package/dist/api/account.js +76 -0
- package/dist/api/batch.d.ts +5 -0
- package/dist/api/batch.js +55 -0
- package/dist/api/campaigns.d.ts +10 -0
- package/dist/api/campaigns.js +120 -0
- package/dist/api/fields.d.ts +8 -0
- package/dist/api/fields.js +83 -0
- package/dist/api/groups.d.ts +37 -0
- package/dist/api/groups.js +214 -0
- package/dist/api/segments.d.ts +7 -0
- package/dist/api/segments.js +82 -0
- package/dist/api/settings.d.ts +9 -0
- package/dist/api/settings.js +98 -0
- package/dist/api/stats.d.ts +5 -0
- package/dist/api/stats.js +53 -0
- package/dist/api/subscribers.d.ts +13 -0
- package/dist/api/subscribers.js +141 -0
- package/dist/api/timezones.d.ts +6 -0
- package/dist/api/timezones.js +67 -0
- package/dist/api/webhooks.d.ts +11 -0
- package/dist/api/webhooks.js +119 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +88 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +34 -0
- package/package.json +61 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = default_1;
|
|
40
|
+
function default_1(client) {
|
|
41
|
+
return {
|
|
42
|
+
actOnCampaign: function (campaignId_1, action_1) {
|
|
43
|
+
return __awaiter(this, arguments, void 0, function (campaignId, action, data) {
|
|
44
|
+
if (data === void 0) { data = {}; }
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, client.post("/campaigns/".concat(campaignId, "/actions/").concat(action), data)];
|
|
48
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
getCampaigns: function () {
|
|
54
|
+
return __awaiter(this, arguments, void 0, function (status, params) {
|
|
55
|
+
if (status === void 0) { status = 'sent'; }
|
|
56
|
+
if (params === void 0) { params = {}; }
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, client.get("campaigns/".concat(status), { params: params })];
|
|
60
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
getCampaignCount: function () {
|
|
66
|
+
return __awaiter(this, arguments, void 0, function (status) {
|
|
67
|
+
var count;
|
|
68
|
+
if (status === void 0) { status = 'sent'; }
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0: return [4 /*yield*/, client.get("campaigns/".concat(status, "/count"))];
|
|
72
|
+
case 1:
|
|
73
|
+
count = (_a.sent()).count;
|
|
74
|
+
return [2 /*return*/, count];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
createCampaign: function (campaign) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!campaign.groups && !campaign.segments) {
|
|
85
|
+
throw new Error('Groups or segments have to be specified');
|
|
86
|
+
}
|
|
87
|
+
if (campaign.type === 'regular' && !campaign.subject) {
|
|
88
|
+
throw new Error('Mail subject is required if campaign type is regular.');
|
|
89
|
+
}
|
|
90
|
+
if (campaign.type === 'ab' && !campaign.abSettings && typeof campaign.abSettings !== 'object') {
|
|
91
|
+
throw new Error('AbSettings are required if campaign type is ab.');
|
|
92
|
+
}
|
|
93
|
+
return [4 /*yield*/, client.post('campaigns', campaign)];
|
|
94
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
removeCampaign: function (campaignId) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0: return [4 /*yield*/, client.delete("campaigns/".concat(campaignId))];
|
|
104
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
setCampaignContent: function (campaignId, content) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0: return [4 /*yield*/, client.put("campaigns/".concat(campaignId, "/content"), content)];
|
|
114
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { FieldData, FieldUpdate } from '../@types';
|
|
3
|
+
export default function (client: AxiosInstance): {
|
|
4
|
+
getFields(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
createField(field: FieldData): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
updateField(fieldId: number, fieldUpdate: FieldUpdate): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
removeField(fieldId: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = default_1;
|
|
40
|
+
function default_1(client) {
|
|
41
|
+
return {
|
|
42
|
+
getFields: function () {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0: return [4 /*yield*/, client.get('fields')];
|
|
47
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
createField: function (field) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, client.post('fields', field)];
|
|
57
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
updateField: function (fieldId, fieldUpdate) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, client.put("fields/".concat(fieldId), fieldUpdate)];
|
|
67
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
removeField: function (fieldId) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, client.delete("fields/".concat(fieldId))];
|
|
77
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { GroupData, GroupQuery, GroupSearchQuery, GroupSubscriberData, GroupSubscriberFlags, SubscriberGroupQuery, SubscriberType } from '../@types';
|
|
3
|
+
export interface MailerLiteGroup {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
total: number;
|
|
7
|
+
active: number;
|
|
8
|
+
unsubscribed: number;
|
|
9
|
+
bounced: number;
|
|
10
|
+
unconfirmed: number;
|
|
11
|
+
junk: number;
|
|
12
|
+
sent: number;
|
|
13
|
+
opened: number;
|
|
14
|
+
clicked: number;
|
|
15
|
+
parentId: number;
|
|
16
|
+
dateCreated: string;
|
|
17
|
+
dateUpdated: string;
|
|
18
|
+
}
|
|
19
|
+
export default function (client: AxiosInstance): {
|
|
20
|
+
getGroups(params?: GroupQuery): Promise<MailerLiteGroup[]>;
|
|
21
|
+
searchGroups(groupName: GroupSearchQuery["group_name"]): Promise<MailerLiteGroup[]>;
|
|
22
|
+
getGroup(groupId: number): Promise<MailerLiteGroup>;
|
|
23
|
+
createGroup(group: GroupData): Promise<MailerLiteGroup>;
|
|
24
|
+
updateGroup(groupId: number, groupUpdate: GroupData): Promise<import("axios").AxiosResponse<any, any>>;
|
|
25
|
+
removeGroup(groupId: number): Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
addSubscriberToGroup(groupId: number, subscriber: GroupSubscriberData): Promise<import("axios").AxiosResponse<any, any>>;
|
|
29
|
+
addSubscribersToGroup(groupId: number, subscribers: GroupSubscriberData[], importOptions?: GroupSubscriberFlags): Promise<import("axios").AxiosResponse<any, any>>;
|
|
30
|
+
getSubscribersGroupImport(groupId: number, importId: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
31
|
+
getGroupSubscriber(groupId: number, subscriberId: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
32
|
+
getGroupSubscribers(groupId: number, params?: SubscriberGroupQuery): Promise<import("axios").AxiosResponse<any, any>>;
|
|
33
|
+
getGroupSubscriberCount(groupId: number): Promise<number>;
|
|
34
|
+
getGroupSubscribersByType(groupId: number, subscriberType: SubscriberType, params?: GroupQuery): Promise<import("axios").AxiosResponse<any, any>>;
|
|
35
|
+
getGroupSubscribersCountByType(groupId: number, subscriberType: SubscriberType): Promise<number>;
|
|
36
|
+
removeGroupSubscriber(groupId: number, subscriberIdentifier: number | string): Promise<string>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.default = default_1;
|
|
51
|
+
function default_1(client) {
|
|
52
|
+
return {
|
|
53
|
+
getGroups: function () {
|
|
54
|
+
return __awaiter(this, arguments, void 0, function (params) {
|
|
55
|
+
if (params === void 0) { params = {}; }
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0: return [4 /*yield*/, client.get('groups', { params: params })];
|
|
59
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
searchGroups: function (groupName) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0: return [4 /*yield*/, client.post('groups/search', { group_name: groupName })];
|
|
69
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
getGroup: function (groupId) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId))];
|
|
79
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
createGroup: function (group) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0: return [4 /*yield*/, client.post('groups', group)];
|
|
89
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
updateGroup: function (groupId, groupUpdate) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0: return [4 /*yield*/, client.put("groups/".concat(groupId), groupUpdate)];
|
|
99
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
removeGroup: function (groupId) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
switch (_a.label) {
|
|
108
|
+
case 0: return [4 /*yield*/, client.delete("groups/".concat(groupId))];
|
|
109
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
addSubscriberToGroup: function (groupId, subscriber) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0: return [4 /*yield*/, client.post("groups/".concat(groupId, "/subscribers"), subscriber)];
|
|
119
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
addSubscribersToGroup: function (groupId_1, subscribers_1) {
|
|
125
|
+
return __awaiter(this, arguments, void 0, function (groupId, subscribers, importOptions) {
|
|
126
|
+
if (importOptions === void 0) { importOptions = {}; }
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0: return [4 /*yield*/, client.post("groups/".concat(groupId, "/subscribers/import"), __assign({ subscribers: subscribers }, importOptions))];
|
|
130
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
getSubscribersGroupImport: function (groupId, importId) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers/import/").concat(importId))];
|
|
140
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
getGroupSubscriber: function (groupId, subscriberId) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers/").concat(subscriberId))];
|
|
150
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
getGroupSubscribers: function (groupId_1) {
|
|
156
|
+
return __awaiter(this, arguments, void 0, function (groupId, params) {
|
|
157
|
+
if (params === void 0) { params = {}; }
|
|
158
|
+
return __generator(this, function (_a) {
|
|
159
|
+
switch (_a.label) {
|
|
160
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers"), { params: params })];
|
|
161
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
getGroupSubscriberCount: function (groupId) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var count;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers/count"))];
|
|
172
|
+
case 1:
|
|
173
|
+
count = (_a.sent()).count;
|
|
174
|
+
return [2 /*return*/, count];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
getGroupSubscribersByType: function (groupId_1, subscriberType_1) {
|
|
180
|
+
return __awaiter(this, arguments, void 0, function (groupId, subscriberType, params) {
|
|
181
|
+
if (params === void 0) { params = {}; }
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
switch (_a.label) {
|
|
184
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers/").concat(subscriberType), { params: params })];
|
|
185
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
getGroupSubscribersCountByType: function (groupId, subscriberType) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
var count;
|
|
193
|
+
return __generator(this, function (_a) {
|
|
194
|
+
switch (_a.label) {
|
|
195
|
+
case 0: return [4 /*yield*/, client.get("groups/".concat(groupId, "/subscribers/").concat(subscriberType, "/count"))];
|
|
196
|
+
case 1:
|
|
197
|
+
count = (_a.sent()).count;
|
|
198
|
+
return [2 /*return*/, count];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
removeGroupSubscriber: function (groupId, subscriberIdentifier) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0: return [4 /*yield*/, client.delete("groups/".concat(groupId, "/subscribers/").concat(subscriberIdentifier))];
|
|
208
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { SegmentQuery, SegmentsResponse } from '../@types';
|
|
3
|
+
export default function (client: AxiosInstance): {
|
|
4
|
+
getSegments(params?: SegmentQuery): Promise<any[]>;
|
|
5
|
+
getSegmentsCount(params?: SegmentQuery): Promise<number>;
|
|
6
|
+
getSegmentsRaw(params?: SegmentQuery): Promise<SegmentsResponse>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = default_1;
|
|
40
|
+
function default_1(client) {
|
|
41
|
+
return {
|
|
42
|
+
getSegments: function () {
|
|
43
|
+
return __awaiter(this, arguments, void 0, function (params) {
|
|
44
|
+
var data;
|
|
45
|
+
if (params === void 0) { params = {}; }
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, this.getSegmentsRaw(params)];
|
|
49
|
+
case 1:
|
|
50
|
+
data = (_a.sent()).data;
|
|
51
|
+
return [2 /*return*/, data];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
getSegmentsCount: function () {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function (params) {
|
|
58
|
+
var meta;
|
|
59
|
+
if (params === void 0) { params = {}; }
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0: return [4 /*yield*/, this.getSegmentsRaw(params)];
|
|
63
|
+
case 1:
|
|
64
|
+
meta = (_a.sent()).meta;
|
|
65
|
+
return [2 /*return*/, meta.pagination.count];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
getSegmentsRaw: function () {
|
|
71
|
+
return __awaiter(this, arguments, void 0, function (params) {
|
|
72
|
+
if (params === void 0) { params = {}; }
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, client.get('segments', { params: params })];
|
|
76
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { DoubleOptinStatus } from '../@types';
|
|
3
|
+
export default function (client: AxiosInstance): {
|
|
4
|
+
getDoubleOptinStatus(): Promise<DoubleOptinStatus>;
|
|
5
|
+
hasEnabledDoubleOptin(): Promise<boolean>;
|
|
6
|
+
setDoubleOptin(isEnabled: boolean): Promise<DoubleOptinStatus>;
|
|
7
|
+
enableDoubleOptin(): Promise<DoubleOptinStatus>;
|
|
8
|
+
disableDoubleOptin(): Promise<DoubleOptinStatus>;
|
|
9
|
+
};
|