@prezly/sdk 11.7.1 → 11.8.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Client.cjs +45 -0
- package/dist/api/ApiClient.cjs +95 -0
- package/dist/api/DeferredJobsApiClient.cjs +99 -0
- package/dist/api/constants.cjs +10 -0
- package/dist/api/constants.js +1 -1
- package/dist/api/index.cjs +19 -0
- package/dist/endpoints/Accounts/Client.cjs +29 -0
- package/dist/endpoints/Accounts/index.cjs +25 -0
- package/dist/endpoints/Accounts/types.cjs +1 -0
- package/dist/endpoints/Billing/Client.cjs +19 -0
- package/dist/endpoints/Billing/index.cjs +25 -0
- package/dist/endpoints/Billing/types.cjs +25 -0
- package/dist/endpoints/CampaignRecipients/Client.cjs +85 -0
- package/dist/endpoints/CampaignRecipients/index.cjs +37 -0
- package/dist/endpoints/CampaignRecipients/types.cjs +1 -0
- package/dist/endpoints/Campaigns/Client.cjs +92 -0
- package/dist/endpoints/Campaigns/index.cjs +25 -0
- package/dist/endpoints/Campaigns/types.cjs +1 -0
- package/dist/endpoints/ContactsExports/Client.cjs +98 -0
- package/dist/endpoints/ContactsExports/index.cjs +37 -0
- package/dist/endpoints/ContactsExports/types.cjs +1 -0
- package/dist/endpoints/Coverage/Client.cjs +109 -0
- package/dist/endpoints/Coverage/index.cjs +25 -0
- package/dist/endpoints/Coverage/types.cjs +1 -0
- package/dist/endpoints/Jobs/Client.cjs +19 -0
- package/dist/endpoints/Jobs/index.cjs +25 -0
- package/dist/endpoints/Jobs/types.cjs +1 -0
- package/dist/endpoints/Licenses/Client.cjs +20 -0
- package/dist/endpoints/Licenses/index.cjs +15 -0
- package/dist/endpoints/NewsroomCategories/Client.cjs +55 -0
- package/dist/endpoints/NewsroomCategories/index.cjs +25 -0
- package/dist/endpoints/NewsroomCategories/types.cjs +1 -0
- package/dist/endpoints/NewsroomContacts/Client.cjs +76 -0
- package/dist/endpoints/NewsroomContacts/index.cjs +25 -0
- package/dist/endpoints/NewsroomContacts/types.cjs +1 -0
- package/dist/endpoints/NewsroomDomains/Client.cjs +48 -0
- package/dist/endpoints/NewsroomDomains/index.cjs +25 -0
- package/dist/endpoints/NewsroomDomains/types.cjs +1 -0
- package/dist/endpoints/NewsroomGalleries/Client.cjs +82 -0
- package/dist/endpoints/NewsroomGalleries/index.cjs +25 -0
- package/dist/endpoints/NewsroomGalleries/types.cjs +1 -0
- package/dist/endpoints/NewsroomLanguages/Client.cjs +100 -0
- package/dist/endpoints/NewsroomLanguages/index.cjs +25 -0
- package/dist/endpoints/NewsroomLanguages/lib.cjs +9 -0
- package/dist/endpoints/NewsroomLanguages/types.cjs +1 -0
- package/dist/endpoints/NewsroomPrivacyRequests/Client.cjs +29 -0
- package/dist/endpoints/NewsroomPrivacyRequests/index.cjs +25 -0
- package/dist/endpoints/NewsroomPrivacyRequests/types.cjs +1 -0
- package/dist/endpoints/NewsroomSubscriptions/Client.cjs +22 -0
- package/dist/endpoints/NewsroomSubscriptions/index.cjs +25 -0
- package/dist/endpoints/NewsroomSubscriptions/types.cjs +1 -0
- package/dist/endpoints/NewsroomThemes/Client.cjs +43 -0
- package/dist/endpoints/NewsroomThemes/index.cjs +15 -0
- package/dist/endpoints/NewsroomWebhooks/Client.cjs +49 -0
- package/dist/endpoints/NewsroomWebhooks/index.cjs +25 -0
- package/dist/endpoints/NewsroomWebhooks/types.cjs +1 -0
- package/dist/endpoints/Newsrooms/Client.cjs +97 -0
- package/dist/endpoints/Newsrooms/index.cjs +25 -0
- package/dist/endpoints/Newsrooms/types.cjs +1 -0
- package/dist/endpoints/NotificationSubscriptions/Client.cjs +29 -0
- package/dist/endpoints/NotificationSubscriptions/index.cjs +25 -0
- package/dist/endpoints/NotificationSubscriptions/types.cjs +1 -0
- package/dist/endpoints/SenderAddresses/Client.cjs +44 -0
- package/dist/endpoints/SenderAddresses/index.cjs +25 -0
- package/dist/endpoints/SenderAddresses/types.cjs +1 -0
- package/dist/endpoints/Signup/Client.cjs +21 -0
- package/dist/endpoints/Signup/index.cjs +25 -0
- package/dist/endpoints/Signup/types.cjs +12 -0
- package/dist/endpoints/Snippets/Client.cjs +49 -0
- package/dist/endpoints/Snippets/index.cjs +25 -0
- package/dist/endpoints/Snippets/types.cjs +1 -0
- package/dist/endpoints/Stories/Client.cjs +291 -0
- package/dist/endpoints/Stories/index.cjs +35 -0
- package/dist/endpoints/Stories/scopes.cjs +15 -0
- package/dist/endpoints/Stories/types.cjs +51 -0
- package/dist/endpoints/Stories/types.d.ts +5 -0
- package/dist/endpoints/Subscriptions/Client.cjs +58 -0
- package/dist/endpoints/Subscriptions/index.cjs +25 -0
- package/dist/endpoints/Subscriptions/types.cjs +15 -0
- package/dist/endpoints/index.cjs +56 -0
- package/dist/http/ApiError.cjs +21 -0
- package/dist/http/Http.cjs +69 -0
- package/dist/http/constants.cjs +12 -0
- package/dist/http/createRequest.cjs +106 -0
- package/dist/http/index.cjs +39 -0
- package/dist/http/lib.cjs +39 -0
- package/dist/http/types.cjs +25 -0
- package/dist/index.cjs +56 -0
- package/dist/routing.cjs +38 -0
- package/dist/types/Campaign.cjs +69 -0
- package/dist/types/Category.cjs +1 -0
- package/dist/types/Contact.cjs +82 -0
- package/dist/types/ContactDuplicateSuggestion.cjs +17 -0
- package/dist/types/ContactsExport.cjs +17 -0
- package/dist/types/ContactsScope.cjs +19 -0
- package/dist/types/Country.cjs +1 -0
- package/dist/types/CoverageEntry.cjs +32 -0
- package/dist/types/Culture.cjs +16 -0
- package/dist/types/Currency.cjs +13 -0
- package/dist/types/DnsConfigurationInstruction.cjs +1 -0
- package/dist/types/EmailRecipient.cjs +18 -0
- package/dist/types/EmailSubscription.cjs +1 -0
- package/dist/types/JobState.cjs +13 -0
- package/dist/types/License.cjs +31 -0
- package/dist/types/Newsroom.cjs +30 -0
- package/dist/types/NewsroomCompanyInformation.cjs +1 -0
- package/dist/types/NewsroomContact.cjs +1 -0
- package/dist/types/NewsroomDomain.cjs +24 -0
- package/dist/types/NewsroomGallery.cjs +16 -0
- package/dist/types/NewsroomLanguageSettings.cjs +1 -0
- package/dist/types/NewsroomTheme.cjs +38 -0
- package/dist/types/NewsroomWebhook.cjs +20 -0
- package/dist/types/NotificationSubscription.cjs +17 -0
- package/dist/types/Permissions.cjs +18 -0
- package/dist/types/Plan.cjs +18 -0
- package/dist/types/PrivacyRequest.cjs +24 -0
- package/dist/types/SEOSettings.cjs +1 -0
- package/dist/types/SEOSettings.d.ts +7 -0
- package/dist/types/SEOSettings.js +1 -0
- package/dist/types/SenderAddress.cjs +16 -0
- package/dist/types/SenderDomain.cjs +18 -0
- package/dist/types/Snippet.cjs +1 -0
- package/dist/types/Story.cjs +89 -0
- package/dist/types/Story.d.ts +2 -0
- package/dist/types/User.cjs +28 -0
- package/dist/types/UserAccount.cjs +1 -0
- package/dist/types/common/Notification.cjs +18 -0
- package/dist/types/common/OEmbedInfo.cjs +18 -0
- package/dist/types/common/Pagination.cjs +15 -0
- package/dist/types/common/Query.cjs +21 -0
- package/dist/types/common/Utm.cjs +1 -0
- package/dist/types/common/Warning.cjs +1 -0
- package/dist/types/common/index.cjs +65 -0
- package/dist/types/index.cjs +325 -0
- package/dist/utils.cjs +30 -0
- package/package.json +14 -3
package/dist/Client.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createClient = createClient;
|
|
7
|
+
var _index = require("./api/index.cjs");
|
|
8
|
+
var _index2 = require("./endpoints/index.cjs");
|
|
9
|
+
const DEFAULT_BASE_URL = 'https://api.prezly.com';
|
|
10
|
+
function createClient({
|
|
11
|
+
accessToken,
|
|
12
|
+
baseUrl = DEFAULT_BASE_URL,
|
|
13
|
+
headers = {}
|
|
14
|
+
}) {
|
|
15
|
+
const apiClient = new _index.DeferredJobsApiClient(new _index.ApiClient({
|
|
16
|
+
accessToken,
|
|
17
|
+
baseUrl,
|
|
18
|
+
headers
|
|
19
|
+
}));
|
|
20
|
+
return {
|
|
21
|
+
accounts: new _index2.Accounts.Client(apiClient),
|
|
22
|
+
billing: new _index2.Billing.Client(apiClient),
|
|
23
|
+
campaigns: new _index2.Campaigns.Client(apiClient),
|
|
24
|
+
campaignRecipients: new _index2.CampaignRecipients.Client(apiClient),
|
|
25
|
+
contactsExports: new _index2.ContactsExports.Client(apiClient),
|
|
26
|
+
coverage: new _index2.Coverage.Client(apiClient),
|
|
27
|
+
jobs: new _index2.Jobs.Client(apiClient),
|
|
28
|
+
licenses: new _index2.Licenses.Client(apiClient),
|
|
29
|
+
newsrooms: new _index2.Newsrooms.Client(apiClient),
|
|
30
|
+
newsroomCategories: new _index2.NewsroomCategories.Client(apiClient),
|
|
31
|
+
newsroomContacts: new _index2.NewsroomContacts.Client(apiClient),
|
|
32
|
+
newsroomLanguages: new _index2.NewsroomLanguages.Client(apiClient),
|
|
33
|
+
newsroomThemes: new _index2.NewsroomThemes.Client(apiClient),
|
|
34
|
+
newsroomWebhooks: new _index2.NewsroomWebhooks.Client(apiClient),
|
|
35
|
+
newsroomPrivacyRequests: new _index2.NewsroomPrivacyRequests.Client(apiClient),
|
|
36
|
+
newsroomDomains: new _index2.NewsroomDomains.Client(apiClient),
|
|
37
|
+
newsroomGalleries: new _index2.NewsroomGalleries.Client(apiClient),
|
|
38
|
+
senderAddresses: new _index2.SenderAddresses.Client(apiClient),
|
|
39
|
+
signup: new _index2.Signup.Client(apiClient),
|
|
40
|
+
stories: new _index2.Stories.Client(apiClient),
|
|
41
|
+
snippets: new _index2.Snippets.Client(apiClient),
|
|
42
|
+
subscriptions: new _index2.Subscriptions.Client(apiClient),
|
|
43
|
+
notificationSubscriptions: new _index2.NotificationSubscriptions.Client(apiClient)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ApiClient = void 0;
|
|
7
|
+
var _index = require("../http/index.cjs");
|
|
8
|
+
var _utils = require("../utils.cjs");
|
|
9
|
+
var _constants = require("./constants.cjs");
|
|
10
|
+
class ApiClient {
|
|
11
|
+
constructor({
|
|
12
|
+
accessToken,
|
|
13
|
+
baseUrl,
|
|
14
|
+
headers
|
|
15
|
+
}) {
|
|
16
|
+
this.baseUrl = baseUrl;
|
|
17
|
+
this.headers = {
|
|
18
|
+
authorization: `Bearer ${accessToken}`,
|
|
19
|
+
'User-Agent': _constants.DEFAULT_USER_AGENT,
|
|
20
|
+
...headers
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
get(endpointUri, {
|
|
24
|
+
headers,
|
|
25
|
+
query
|
|
26
|
+
} = {}) {
|
|
27
|
+
return _index.Http.get(this.buildEndpointUrl(endpointUri), {
|
|
28
|
+
headers: {
|
|
29
|
+
...this.headers,
|
|
30
|
+
...headers
|
|
31
|
+
},
|
|
32
|
+
query
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
post(endpointUri, {
|
|
36
|
+
headers,
|
|
37
|
+
payload,
|
|
38
|
+
query
|
|
39
|
+
} = {}) {
|
|
40
|
+
return _index.Http.post(this.buildEndpointUrl(endpointUri), {
|
|
41
|
+
headers: {
|
|
42
|
+
...this.headers,
|
|
43
|
+
...headers
|
|
44
|
+
},
|
|
45
|
+
payload,
|
|
46
|
+
query
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
put(endpointUri, {
|
|
50
|
+
headers,
|
|
51
|
+
payload,
|
|
52
|
+
query
|
|
53
|
+
} = {}) {
|
|
54
|
+
return _index.Http.put(this.buildEndpointUrl(endpointUri), {
|
|
55
|
+
headers: {
|
|
56
|
+
...this.headers,
|
|
57
|
+
...headers
|
|
58
|
+
},
|
|
59
|
+
payload,
|
|
60
|
+
query
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
patch(endpointUri, {
|
|
64
|
+
headers,
|
|
65
|
+
payload,
|
|
66
|
+
query
|
|
67
|
+
} = {}) {
|
|
68
|
+
return _index.Http.patch(this.buildEndpointUrl(endpointUri), {
|
|
69
|
+
headers: {
|
|
70
|
+
...this.headers,
|
|
71
|
+
...headers
|
|
72
|
+
},
|
|
73
|
+
payload,
|
|
74
|
+
query
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
delete(endpointUri, {
|
|
78
|
+
headers,
|
|
79
|
+
payload,
|
|
80
|
+
query
|
|
81
|
+
} = {}) {
|
|
82
|
+
return _index.Http.delete(this.buildEndpointUrl(endpointUri), {
|
|
83
|
+
headers: {
|
|
84
|
+
...this.headers,
|
|
85
|
+
...headers
|
|
86
|
+
},
|
|
87
|
+
payload,
|
|
88
|
+
query
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
buildEndpointUrl(endpointUri) {
|
|
92
|
+
return `${(0, _utils.stripSlashes)(this.baseUrl)}/${(0, _utils.stripSlashes)(endpointUri)}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.ApiClient = ApiClient;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DeferredJobsApiClient = void 0;
|
|
7
|
+
var _progressPromise = require("@prezly/progress-promise");
|
|
8
|
+
var _index = require("../http/index.cjs");
|
|
9
|
+
var _routing = require("../routing.cjs");
|
|
10
|
+
var _index2 = require("../types/index.cjs");
|
|
11
|
+
const JOB_STATUS_POLLING_INTERVAL = 2000; // ms
|
|
12
|
+
|
|
13
|
+
async function sleep(milliseconds) {
|
|
14
|
+
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
15
|
+
}
|
|
16
|
+
async function handleDeferredJob(request) {
|
|
17
|
+
const response = await request;
|
|
18
|
+
if (response.status === _index.HttpCodes.ACCEPTED && (0, _index.isDeferredJobResponse)(response.payload)) {
|
|
19
|
+
return new _progressPromise.ProgressPromise(async function (resolve, reject, progress) {
|
|
20
|
+
do {
|
|
21
|
+
const response = await _index.Http.get(_routing.routing.jobsUrl);
|
|
22
|
+
const {
|
|
23
|
+
job
|
|
24
|
+
} = response.payload;
|
|
25
|
+
if (job.status === _index2.JobStatus.RESOLVED) {
|
|
26
|
+
resolve(job.value);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (job.status === _index2.JobStatus.REJECTED) {
|
|
30
|
+
reject(job.value);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
progress(job.progress, job.value);
|
|
34
|
+
await sleep(JOB_STATUS_POLLING_INTERVAL);
|
|
35
|
+
} while (true); // eslint-disable-line no-constant-condition
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return _progressPromise.ProgressPromise.resolve(response.payload);
|
|
40
|
+
}
|
|
41
|
+
class DeferredJobsApiClient {
|
|
42
|
+
constructor(apiClient) {
|
|
43
|
+
this.apiClient = apiClient;
|
|
44
|
+
}
|
|
45
|
+
get(endpointUri, {
|
|
46
|
+
headers,
|
|
47
|
+
query
|
|
48
|
+
} = {}) {
|
|
49
|
+
return handleDeferredJob(this.apiClient.get(endpointUri, {
|
|
50
|
+
headers,
|
|
51
|
+
query
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
post(endpointUri, {
|
|
55
|
+
headers,
|
|
56
|
+
payload,
|
|
57
|
+
query
|
|
58
|
+
} = {}) {
|
|
59
|
+
return handleDeferredJob(this.apiClient.post(endpointUri, {
|
|
60
|
+
headers,
|
|
61
|
+
payload,
|
|
62
|
+
query
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
put(endpointUri, {
|
|
66
|
+
headers,
|
|
67
|
+
payload,
|
|
68
|
+
query
|
|
69
|
+
} = {}) {
|
|
70
|
+
return handleDeferredJob(this.apiClient.put(endpointUri, {
|
|
71
|
+
headers,
|
|
72
|
+
payload,
|
|
73
|
+
query
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
patch(endpointUri, {
|
|
77
|
+
headers,
|
|
78
|
+
payload,
|
|
79
|
+
query
|
|
80
|
+
} = {}) {
|
|
81
|
+
return handleDeferredJob(this.apiClient.patch(endpointUri, {
|
|
82
|
+
headers,
|
|
83
|
+
payload,
|
|
84
|
+
query
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
delete(endpointUri, {
|
|
88
|
+
headers,
|
|
89
|
+
payload,
|
|
90
|
+
query
|
|
91
|
+
} = {}) {
|
|
92
|
+
return handleDeferredJob(this.apiClient.delete(endpointUri, {
|
|
93
|
+
headers,
|
|
94
|
+
payload,
|
|
95
|
+
query
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.DeferredJobsApiClient = DeferredJobsApiClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_USER_AGENT = void 0;
|
|
7
|
+
const VERSION = "11.8.0";
|
|
8
|
+
const URL = 'https://github.com/prezly/javascript-sdk';
|
|
9
|
+
const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
|
|
10
|
+
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
package/dist/api/constants.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ApiClient", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ApiClient.ApiClient;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "DeferredJobsApiClient", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _DeferredJobsApiClient.DeferredJobsApiClient;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ApiClient = require("./ApiClient.cjs");
|
|
19
|
+
var _DeferredJobsApiClient = require("./DeferredJobsApiClient.cjs");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
var _routing = require("../../routing.cjs");
|
|
8
|
+
class Client {
|
|
9
|
+
constructor(apiClient) {
|
|
10
|
+
this.apiClient = apiClient;
|
|
11
|
+
}
|
|
12
|
+
async list() {
|
|
13
|
+
const url = _routing.routing.accounts;
|
|
14
|
+
return this.apiClient.get(url);
|
|
15
|
+
}
|
|
16
|
+
async create(payload) {
|
|
17
|
+
const url = _routing.routing.accounts;
|
|
18
|
+
return this.apiClient.post(url, {
|
|
19
|
+
payload
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async update(id, payload) {
|
|
23
|
+
const url = `${_routing.routing.accounts}/${id}`;
|
|
24
|
+
return this.apiClient.patch(url, {
|
|
25
|
+
payload
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Client = require("./Client.cjs");
|
|
7
|
+
Object.keys(_Client).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
Object.defineProperty(exports, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _Client[key];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
var _types = require("./types.cjs");
|
|
17
|
+
Object.keys(_types).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _types[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
var _routing = require("../../routing.cjs");
|
|
8
|
+
class Client {
|
|
9
|
+
constructor(apiClient) {
|
|
10
|
+
this.apiClient = apiClient;
|
|
11
|
+
}
|
|
12
|
+
async signup(payload) {
|
|
13
|
+
const url = `${_routing.routing.billing}/signup`;
|
|
14
|
+
return this.apiClient.post(url, {
|
|
15
|
+
payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Client = require("./Client.cjs");
|
|
7
|
+
Object.keys(_Client).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
Object.defineProperty(exports, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _Client[key];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
var _types = require("./types.cjs");
|
|
17
|
+
Object.keys(_types).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _types[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SignupBillingCycle = exports.SignupCurrency = exports.SignupPlan = void 0;
|
|
7
|
+
let SignupPlan;
|
|
8
|
+
exports.SignupPlan = SignupPlan;
|
|
9
|
+
(function (SignupPlan) {
|
|
10
|
+
SignupPlan["STARTER"] = "starter";
|
|
11
|
+
SignupPlan["CORE"] = "core";
|
|
12
|
+
SignupPlan["PREMIUM"] = "premium";
|
|
13
|
+
})(SignupPlan || (exports.SignupPlan = SignupPlan = {}));
|
|
14
|
+
let SignupCurrency;
|
|
15
|
+
exports.SignupCurrency = SignupCurrency;
|
|
16
|
+
(function (SignupCurrency) {
|
|
17
|
+
SignupCurrency["EUR"] = "eur";
|
|
18
|
+
SignupCurrency["USD"] = "usd";
|
|
19
|
+
})(SignupCurrency || (exports.SignupCurrency = SignupCurrency = {}));
|
|
20
|
+
let SignupBillingCycle;
|
|
21
|
+
exports.SignupBillingCycle = SignupBillingCycle;
|
|
22
|
+
(function (SignupBillingCycle) {
|
|
23
|
+
SignupBillingCycle["YEAR"] = "year";
|
|
24
|
+
SignupBillingCycle["MONTH"] = "month";
|
|
25
|
+
})(SignupBillingCycle || (exports.SignupBillingCycle = SignupBillingCycle = {}));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
var _routing = require("../../routing.cjs");
|
|
8
|
+
var _index = require("../../types/index.cjs");
|
|
9
|
+
class Client {
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this.apiClient = apiClient;
|
|
12
|
+
}
|
|
13
|
+
async list(campaignId, options) {
|
|
14
|
+
const {
|
|
15
|
+
limit,
|
|
16
|
+
offset,
|
|
17
|
+
sortOrder
|
|
18
|
+
} = options;
|
|
19
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
20
|
+
return this.apiClient.get(url, {
|
|
21
|
+
query: {
|
|
22
|
+
limit,
|
|
23
|
+
offset,
|
|
24
|
+
sort: sortOrder
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async search(campaignId, options) {
|
|
29
|
+
const {
|
|
30
|
+
limit,
|
|
31
|
+
offset,
|
|
32
|
+
sortOrder,
|
|
33
|
+
query
|
|
34
|
+
} = options;
|
|
35
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
36
|
+
// TODO: Introduce dedicated Search POST API
|
|
37
|
+
return this.apiClient.get(url, {
|
|
38
|
+
query: {
|
|
39
|
+
query: _index.Query.stringify(query),
|
|
40
|
+
sort: sortOrder,
|
|
41
|
+
limit,
|
|
42
|
+
offset
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async get(campaignId, recipientId) {
|
|
47
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
48
|
+
const {
|
|
49
|
+
recipient
|
|
50
|
+
} = await this.apiClient.get(`${url}/${recipientId}`);
|
|
51
|
+
return recipient;
|
|
52
|
+
}
|
|
53
|
+
async addContact(campaignId, contact) {
|
|
54
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
55
|
+
return this.apiClient.post(url, {
|
|
56
|
+
payload: {
|
|
57
|
+
contact
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async addContacts(campaignId, contacts) {
|
|
62
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
63
|
+
return this.apiClient.post(url, {
|
|
64
|
+
payload: {
|
|
65
|
+
contacts
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async removeRecipient(campaignId, recipientId) {
|
|
70
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
71
|
+
return this.apiClient.delete(`${url}/${recipientId}`);
|
|
72
|
+
}
|
|
73
|
+
async removeRecipients(campaignId, params) {
|
|
74
|
+
const {
|
|
75
|
+
query
|
|
76
|
+
} = params || {};
|
|
77
|
+
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
78
|
+
return this.apiClient.delete(url, {
|
|
79
|
+
payload: {
|
|
80
|
+
query
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
ContactsScope: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "ContactsScope", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _index.ContactsScope;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _Client = require("./Client.cjs");
|
|
16
|
+
Object.keys(_Client).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _Client[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
var _types = require("./types.cjs");
|
|
27
|
+
Object.keys(_types).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _types[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
var _index = require("../../types/index.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
var _routing = require("../../routing.cjs");
|
|
8
|
+
var _index = require("../../types/index.cjs");
|
|
9
|
+
var _utils = require("../../utils.cjs");
|
|
10
|
+
class Client {
|
|
11
|
+
constructor(apiClient) {
|
|
12
|
+
this.apiClient = apiClient;
|
|
13
|
+
}
|
|
14
|
+
async list(options) {
|
|
15
|
+
const {
|
|
16
|
+
query,
|
|
17
|
+
limit,
|
|
18
|
+
offset,
|
|
19
|
+
sortOrder
|
|
20
|
+
} = options;
|
|
21
|
+
return this.apiClient.get(_routing.routing.campaignsUrl, {
|
|
22
|
+
query: {
|
|
23
|
+
limit,
|
|
24
|
+
offset,
|
|
25
|
+
query: _index.Query.stringify(query),
|
|
26
|
+
sort: sortOrder
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async search(options) {
|
|
31
|
+
const {
|
|
32
|
+
query,
|
|
33
|
+
limit,
|
|
34
|
+
offset,
|
|
35
|
+
sortOrder
|
|
36
|
+
} = options;
|
|
37
|
+
return this.apiClient.post(_routing.routing.campaignsUrl, {
|
|
38
|
+
payload: {
|
|
39
|
+
limit,
|
|
40
|
+
offset,
|
|
41
|
+
query,
|
|
42
|
+
sort: sortOrder
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async get(id) {
|
|
47
|
+
return this.apiClient.get(`${_routing.routing.campaignsUrl}/${id}`);
|
|
48
|
+
}
|
|
49
|
+
async duplicate(id) {
|
|
50
|
+
return this.apiClient.post(`${_routing.routing.campaignsUrl}/${id}/duplicate`);
|
|
51
|
+
}
|
|
52
|
+
async delete(id) {
|
|
53
|
+
return this.apiClient.delete(`${_routing.routing.campaignsUrl}/${id}`);
|
|
54
|
+
}
|
|
55
|
+
async test(id, emails) {
|
|
56
|
+
return this.apiClient.post(`${_routing.routing.campaignsUrl}/${id}/test`, {
|
|
57
|
+
payload: {
|
|
58
|
+
emails
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async send(id) {
|
|
63
|
+
return this.apiClient.post(`${_routing.routing.campaignsUrl}/${id}/send`);
|
|
64
|
+
}
|
|
65
|
+
async schedule(id, sendAt) {
|
|
66
|
+
const {
|
|
67
|
+
campaign
|
|
68
|
+
} = await this.apiClient.post(`${_routing.routing.campaignsUrl}/${id}/schedule`, {
|
|
69
|
+
payload: {
|
|
70
|
+
schedule_at: (0, _utils.toIso8601)(sendAt)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return campaign;
|
|
74
|
+
}
|
|
75
|
+
async unschedule(id) {
|
|
76
|
+
const {
|
|
77
|
+
campaign
|
|
78
|
+
} = await this.apiClient.post(`${_routing.routing.campaignsUrl}/${id}/unschedule`);
|
|
79
|
+
return campaign;
|
|
80
|
+
}
|
|
81
|
+
async create(payload) {
|
|
82
|
+
return this.apiClient.post(_routing.routing.campaignsUrl, {
|
|
83
|
+
payload
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async update(id, payload) {
|
|
87
|
+
return this.apiClient.patch(`${_routing.routing.campaignsUrl}/${id}`, {
|
|
88
|
+
payload
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Client = Client;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Client = require("./Client.cjs");
|
|
7
|
+
Object.keys(_Client).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
Object.defineProperty(exports, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _Client[key];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
var _types = require("./types.cjs");
|
|
17
|
+
Object.keys(_types).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _types[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|