@prezly/sdk 19.9.0 → 20.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/dist/Client.cjs +28 -28
- package/dist/Client.d.ts +2 -1
- package/dist/Client.js +29 -29
- package/dist/api/ApiClient.cjs +36 -34
- package/dist/api/ApiClient.d.ts +8 -12
- package/dist/api/ApiClient.js +34 -31
- package/dist/api/DeferredJobsApiClient.cjs +20 -18
- package/dist/api/DeferredJobsApiClient.d.ts +8 -10
- package/dist/api/DeferredJobsApiClient.js +18 -15
- package/dist/api/constants.cjs +1 -1
- package/dist/api/constants.js +1 -1
- package/dist/api/index.cjs +4 -4
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +2 -2
- package/dist/endpoints/Accounts/Client.cjs +14 -13
- package/dist/endpoints/Accounts/Client.d.ts +6 -7
- package/dist/endpoints/Accounts/Client.js +12 -10
- package/dist/endpoints/Billing/Client.cjs +11 -11
- package/dist/endpoints/Billing/Client.d.ts +5 -6
- package/dist/endpoints/Billing/Client.js +9 -8
- package/dist/endpoints/CampaignRecipients/Client.cjs +26 -21
- package/dist/endpoints/CampaignRecipients/Client.d.ts +13 -14
- package/dist/endpoints/CampaignRecipients/Client.js +24 -18
- package/dist/endpoints/Campaigns/Client.cjs +38 -29
- package/dist/endpoints/Campaigns/Client.d.ts +14 -15
- package/dist/endpoints/Campaigns/Client.js +36 -26
- package/dist/endpoints/Contacts/Client.cjs +41 -32
- package/dist/endpoints/Contacts/Client.d.ts +15 -22
- package/dist/endpoints/Contacts/Client.js +39 -29
- package/dist/endpoints/ContactsExports/Client.cjs +20 -18
- package/dist/endpoints/ContactsExports/Client.d.ts +8 -31
- package/dist/endpoints/ContactsExports/Client.js +18 -15
- package/dist/endpoints/Coverage/Client.cjs +29 -23
- package/dist/endpoints/Coverage/Client.d.ts +12 -13
- package/dist/endpoints/Coverage/Client.js +27 -20
- package/dist/endpoints/Jobs/Client.cjs +8 -9
- package/dist/endpoints/Jobs/Client.d.ts +4 -5
- package/dist/endpoints/Jobs/Client.js +6 -6
- package/dist/endpoints/Licenses/Client.cjs +8 -9
- package/dist/endpoints/Licenses/Client.d.ts +4 -5
- package/dist/endpoints/Licenses/Client.js +6 -6
- package/dist/endpoints/NewsroomCategories/Client.cjs +20 -17
- package/dist/endpoints/NewsroomCategories/Client.d.ts +8 -9
- package/dist/endpoints/NewsroomCategories/Client.js +18 -14
- package/dist/endpoints/NewsroomContacts/Client.cjs +23 -19
- package/dist/endpoints/NewsroomContacts/Client.d.ts +9 -10
- package/dist/endpoints/NewsroomContacts/Client.js +21 -16
- package/dist/endpoints/NewsroomDomains/Client.cjs +23 -19
- package/dist/endpoints/NewsroomDomains/Client.d.ts +9 -10
- package/dist/endpoints/NewsroomDomains/Client.js +21 -16
- package/dist/endpoints/NewsroomGalleries/Client.cjs +26 -21
- package/dist/endpoints/NewsroomGalleries/Client.d.ts +10 -11
- package/dist/endpoints/NewsroomGalleries/Client.js +24 -18
- package/dist/endpoints/NewsroomHub/Client.cjs +26 -23
- package/dist/endpoints/NewsroomHub/Client.d.ts +8 -9
- package/dist/endpoints/NewsroomHub/Client.js +25 -21
- package/dist/endpoints/NewsroomLanguages/Client.cjs +26 -21
- package/dist/endpoints/NewsroomLanguages/Client.d.ts +16 -24
- package/dist/endpoints/NewsroomLanguages/Client.js +24 -18
- package/dist/endpoints/NewsroomPrivacyRequests/Client.cjs +11 -11
- package/dist/endpoints/NewsroomPrivacyRequests/Client.d.ts +5 -6
- package/dist/endpoints/NewsroomPrivacyRequests/Client.js +9 -8
- package/dist/endpoints/NewsroomSubscriptions/Client.cjs +24 -13
- package/dist/endpoints/NewsroomSubscriptions/Client.d.ts +8 -9
- package/dist/endpoints/NewsroomSubscriptions/Client.js +23 -11
- package/dist/endpoints/NewsroomThemes/Client.cjs +17 -15
- package/dist/endpoints/NewsroomThemes/Client.d.ts +7 -8
- package/dist/endpoints/NewsroomThemes/Client.js +15 -12
- package/dist/endpoints/NewsroomWebhooks/Client.cjs +20 -17
- package/dist/endpoints/NewsroomWebhooks/Client.d.ts +8 -9
- package/dist/endpoints/NewsroomWebhooks/Client.js +18 -14
- package/dist/endpoints/Newsrooms/Client.cjs +35 -27
- package/dist/endpoints/Newsrooms/Client.d.ts +13 -14
- package/dist/endpoints/Newsrooms/Client.js +33 -24
- package/dist/endpoints/NotificationSubscriptions/Client.cjs +11 -11
- package/dist/endpoints/NotificationSubscriptions/Client.d.ts +5 -6
- package/dist/endpoints/NotificationSubscriptions/Client.js +9 -8
- package/dist/endpoints/PricingTables/Client.cjs +11 -11
- package/dist/endpoints/PricingTables/Client.d.ts +5 -6
- package/dist/endpoints/PricingTables/Client.js +9 -8
- package/dist/endpoints/SenderAddresses/Client.cjs +20 -17
- package/dist/endpoints/SenderAddresses/Client.d.ts +8 -9
- package/dist/endpoints/SenderAddresses/Client.js +18 -14
- package/dist/endpoints/Snippets/Client.cjs +20 -17
- package/dist/endpoints/Snippets/Client.d.ts +8 -9
- package/dist/endpoints/Snippets/Client.js +18 -14
- package/dist/endpoints/Stories/Client.cjs +63 -46
- package/dist/endpoints/Stories/Client.d.ts +109 -128
- package/dist/endpoints/Stories/Client.js +62 -44
- package/dist/endpoints/Subscriptions/Client.cjs +20 -17
- package/dist/endpoints/Subscriptions/Client.d.ts +8 -9
- package/dist/endpoints/Subscriptions/Client.js +18 -14
- package/package.json +1 -1
package/dist/api/index.cjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "createApiClient", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return _ApiClient.
|
|
9
|
+
return _ApiClient.createApiClient;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "createDeferredJobsApiClient", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _DeferredJobsApiClient.
|
|
15
|
+
return _DeferredJobsApiClient.createDeferredJobsApiClient;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
var _ApiClient = require("./ApiClient.cjs");
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiClient } from './ApiClient';
|
|
2
|
-
export { DeferredJobsApiClient } from './DeferredJobsApiClient';
|
|
1
|
+
export { createApiClient, type ApiClient } from './ApiClient';
|
|
2
|
+
export { createDeferredJobsApiClient, type DeferredJobsApiClient } from './DeferredJobsApiClient';
|
|
3
3
|
export type { Fetch } from './types';
|
package/dist/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { createApiClient } from "./ApiClient.js";
|
|
2
|
+
export { createDeferredJobsApiClient } from "./DeferredJobsApiClient.js";
|
|
@@ -3,27 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createClient = createClient;
|
|
7
7
|
var _routing = require("../../routing.cjs");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.apiClient = apiClient;
|
|
11
|
-
}
|
|
12
|
-
async list() {
|
|
8
|
+
function createClient(api) {
|
|
9
|
+
async function list() {
|
|
13
10
|
const url = _routing.routing.accounts;
|
|
14
|
-
return
|
|
11
|
+
return api.get(url);
|
|
15
12
|
}
|
|
16
|
-
async create(payload) {
|
|
13
|
+
async function create(payload) {
|
|
17
14
|
const url = _routing.routing.accounts;
|
|
18
|
-
return
|
|
15
|
+
return api.post(url, {
|
|
19
16
|
payload
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
|
-
async update(id, payload) {
|
|
19
|
+
async function update(id, payload) {
|
|
23
20
|
const url = `${_routing.routing.accounts}/${id}`;
|
|
24
|
-
return
|
|
21
|
+
return api.patch(url, {
|
|
25
22
|
payload
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
return {
|
|
26
|
+
list,
|
|
27
|
+
create,
|
|
28
|
+
update
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from '../../api';
|
|
2
2
|
import type { UserAccount } from '../../types';
|
|
3
3
|
import type { CreateRequest, CreateResponse, ListResponse, UpdateRequest, UpdateResponse } from './types';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
4
|
+
export type Client = ReturnType<typeof createClient>;
|
|
5
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
6
|
+
list: () => Promise<ListResponse>;
|
|
7
|
+
create: (payload: CreateRequest) => Promise<CreateResponse>;
|
|
8
|
+
update: (id: UserAccount['id'], payload: UpdateRequest) => Promise<UpdateResponse>;
|
|
9
|
+
};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
this.apiClient = apiClient;
|
|
5
|
-
}
|
|
6
|
-
async list() {
|
|
2
|
+
export function createClient(api) {
|
|
3
|
+
async function list() {
|
|
7
4
|
const url = routing.accounts;
|
|
8
|
-
return
|
|
5
|
+
return api.get(url);
|
|
9
6
|
}
|
|
10
|
-
async create(payload) {
|
|
7
|
+
async function create(payload) {
|
|
11
8
|
const url = routing.accounts;
|
|
12
|
-
return
|
|
9
|
+
return api.post(url, {
|
|
13
10
|
payload
|
|
14
11
|
});
|
|
15
12
|
}
|
|
16
|
-
async update(id, payload) {
|
|
13
|
+
async function update(id, payload) {
|
|
17
14
|
const url = `${routing.accounts}/${id}`;
|
|
18
|
-
return
|
|
15
|
+
return api.patch(url, {
|
|
19
16
|
payload
|
|
20
17
|
});
|
|
21
18
|
}
|
|
19
|
+
return {
|
|
20
|
+
list,
|
|
21
|
+
create,
|
|
22
|
+
update
|
|
23
|
+
};
|
|
22
24
|
}
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createClient = createClient;
|
|
7
7
|
var _routing = require("../../routing.cjs");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.apiClient = apiClient;
|
|
11
|
-
}
|
|
12
|
-
async signup(payload) {
|
|
8
|
+
function createClient(api) {
|
|
9
|
+
async function signup(payload) {
|
|
13
10
|
const url = `${_routing.routing.billing}/signup`;
|
|
14
|
-
return
|
|
11
|
+
return api.post(url, {
|
|
15
12
|
payload
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
|
-
async getPlan() {
|
|
15
|
+
async function getPlan() {
|
|
19
16
|
const {
|
|
20
17
|
plan
|
|
21
|
-
} = await
|
|
18
|
+
} = await api.get(`${_routing.routing.billing}/plan`);
|
|
22
19
|
return plan;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return {
|
|
22
|
+
signup,
|
|
23
|
+
getPlan
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from '../../api';
|
|
2
2
|
import type { Plan } from '../../types';
|
|
3
3
|
import type { SignupRequest, SignupResponse } from './types';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
export type Client = ReturnType<typeof createClient>;
|
|
5
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
6
|
+
signup: (payload: SignupRequest) => Promise<SignupResponse>;
|
|
7
|
+
getPlan: () => Promise<Plan>;
|
|
8
|
+
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
this.apiClient = apiClient;
|
|
5
|
-
}
|
|
6
|
-
async signup(payload) {
|
|
2
|
+
export function createClient(api) {
|
|
3
|
+
async function signup(payload) {
|
|
7
4
|
const url = `${routing.billing}/signup`;
|
|
8
|
-
return
|
|
5
|
+
return api.post(url, {
|
|
9
6
|
payload
|
|
10
7
|
});
|
|
11
8
|
}
|
|
12
|
-
async getPlan() {
|
|
9
|
+
async function getPlan() {
|
|
13
10
|
const {
|
|
14
11
|
plan
|
|
15
|
-
} = await
|
|
12
|
+
} = await api.get(`${routing.billing}/plan`);
|
|
16
13
|
return plan;
|
|
17
14
|
}
|
|
15
|
+
return {
|
|
16
|
+
signup,
|
|
17
|
+
getPlan
|
|
18
|
+
};
|
|
18
19
|
}
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createClient = createClient;
|
|
7
7
|
var _routing = require("../../routing.cjs");
|
|
8
8
|
var _index = require("../../types/index.cjs");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.apiClient = apiClient;
|
|
12
|
-
}
|
|
13
|
-
async list(campaignId, options) {
|
|
9
|
+
function createClient(api) {
|
|
10
|
+
async function list(campaignId, options) {
|
|
14
11
|
const {
|
|
15
12
|
limit,
|
|
16
13
|
offset,
|
|
17
14
|
sortOrder
|
|
18
15
|
} = options;
|
|
19
16
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
20
|
-
return
|
|
17
|
+
return api.get(url, {
|
|
21
18
|
query: {
|
|
22
19
|
limit,
|
|
23
20
|
offset,
|
|
@@ -25,7 +22,7 @@ class Client {
|
|
|
25
22
|
}
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
|
-
async search(campaignId, options) {
|
|
25
|
+
async function search(campaignId, options) {
|
|
29
26
|
const {
|
|
30
27
|
limit,
|
|
31
28
|
offset,
|
|
@@ -34,7 +31,7 @@ class Client {
|
|
|
34
31
|
} = options;
|
|
35
32
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
36
33
|
// TODO: Introduce dedicated Search POST API
|
|
37
|
-
return
|
|
34
|
+
return api.get(url, {
|
|
38
35
|
query: {
|
|
39
36
|
query: _index.Query.stringify(query),
|
|
40
37
|
sort: _index.SortOrder.stringify(sortOrder),
|
|
@@ -43,43 +40,51 @@ class Client {
|
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
|
-
async get(campaignId, recipientId) {
|
|
43
|
+
async function get(campaignId, recipientId) {
|
|
47
44
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
48
45
|
const {
|
|
49
46
|
recipient
|
|
50
|
-
} = await
|
|
47
|
+
} = await api.get(`${url}/${recipientId}`);
|
|
51
48
|
return recipient;
|
|
52
49
|
}
|
|
53
|
-
async addContact(campaignId, contact) {
|
|
50
|
+
async function addContact(campaignId, contact) {
|
|
54
51
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
55
|
-
return
|
|
52
|
+
return api.post(url, {
|
|
56
53
|
payload: {
|
|
57
54
|
contact
|
|
58
55
|
}
|
|
59
56
|
});
|
|
60
57
|
}
|
|
61
|
-
async addContacts(campaignId, contacts) {
|
|
58
|
+
async function addContacts(campaignId, contacts) {
|
|
62
59
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
63
|
-
return
|
|
60
|
+
return api.post(url, {
|
|
64
61
|
payload: {
|
|
65
62
|
contacts
|
|
66
63
|
}
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
|
-
async removeRecipient(campaignId, recipientId) {
|
|
66
|
+
async function removeRecipient(campaignId, recipientId) {
|
|
70
67
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
71
|
-
return
|
|
68
|
+
return api.delete(`${url}/${recipientId}`);
|
|
72
69
|
}
|
|
73
|
-
async removeRecipients(campaignId, params) {
|
|
70
|
+
async function removeRecipients(campaignId, params) {
|
|
74
71
|
const {
|
|
75
72
|
query
|
|
76
73
|
} = params || {};
|
|
77
74
|
const url = _routing.routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
78
|
-
return
|
|
75
|
+
return api.delete(url, {
|
|
79
76
|
payload: {
|
|
80
77
|
query
|
|
81
78
|
}
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
return {
|
|
82
|
+
list,
|
|
83
|
+
search,
|
|
84
|
+
get,
|
|
85
|
+
addContact,
|
|
86
|
+
addContacts,
|
|
87
|
+
removeRecipient,
|
|
88
|
+
removeRecipients
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -6,23 +6,22 @@ import type { ListOptions, ListResponse, SearchOptions } from './types';
|
|
|
6
6
|
type CampaignId = Campaign['id'];
|
|
7
7
|
type ContactId = Contact['id'];
|
|
8
8
|
type EmailRecipientId = EmailRecipient['id'];
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addContact(campaignId: CampaignId, contact: {
|
|
9
|
+
export type Client = ReturnType<typeof createClient>;
|
|
10
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
11
|
+
list: (campaignId: CampaignId, options: ListOptions) => Promise<ListResponse>;
|
|
12
|
+
search: (campaignId: CampaignId, options: SearchOptions) => Promise<ListResponse>;
|
|
13
|
+
get: (campaignId: CampaignId, recipientId: EmailRecipientId) => Promise<EmailRecipient>;
|
|
14
|
+
addContact: (campaignId: CampaignId, contact: {
|
|
16
15
|
id: ContactId;
|
|
17
16
|
emailAddress?: string;
|
|
18
|
-
})
|
|
19
|
-
addContacts(campaignId: CampaignId, contacts: {
|
|
17
|
+
}) => Promise<RecipientsOperationResponse>;
|
|
18
|
+
addContacts: (campaignId: CampaignId, contacts: {
|
|
20
19
|
query?: Query;
|
|
21
20
|
scope?: ContactsScope;
|
|
22
|
-
})
|
|
23
|
-
removeRecipient(campaignId: CampaignId, recipientId: EmailRecipientId)
|
|
24
|
-
removeRecipients(campaignId: CampaignId, params?: {
|
|
21
|
+
}) => Promise<RecipientsOperationResponse>;
|
|
22
|
+
removeRecipient: (campaignId: CampaignId, recipientId: EmailRecipientId) => Promise<RecipientsOperationResponse>;
|
|
23
|
+
removeRecipients: (campaignId: CampaignId, params?: {
|
|
25
24
|
query: Query;
|
|
26
|
-
})
|
|
27
|
-
}
|
|
25
|
+
} | undefined) => Promise<RecipientsOperationResponse>;
|
|
26
|
+
};
|
|
28
27
|
export {};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
2
|
import { Query, SortOrder } from "../../types/index.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
this.apiClient = apiClient;
|
|
6
|
-
}
|
|
7
|
-
async list(campaignId, options) {
|
|
3
|
+
export function createClient(api) {
|
|
4
|
+
async function list(campaignId, options) {
|
|
8
5
|
const {
|
|
9
6
|
limit,
|
|
10
7
|
offset,
|
|
11
8
|
sortOrder
|
|
12
9
|
} = options;
|
|
13
10
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
14
|
-
return
|
|
11
|
+
return api.get(url, {
|
|
15
12
|
query: {
|
|
16
13
|
limit,
|
|
17
14
|
offset,
|
|
@@ -19,7 +16,7 @@ export class Client {
|
|
|
19
16
|
}
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
|
-
async search(campaignId, options) {
|
|
19
|
+
async function search(campaignId, options) {
|
|
23
20
|
const {
|
|
24
21
|
limit,
|
|
25
22
|
offset,
|
|
@@ -28,7 +25,7 @@ export class Client {
|
|
|
28
25
|
} = options;
|
|
29
26
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
30
27
|
// TODO: Introduce dedicated Search POST API
|
|
31
|
-
return
|
|
28
|
+
return api.get(url, {
|
|
32
29
|
query: {
|
|
33
30
|
query: Query.stringify(query),
|
|
34
31
|
sort: SortOrder.stringify(sortOrder),
|
|
@@ -37,42 +34,51 @@ export class Client {
|
|
|
37
34
|
}
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
|
-
async get(campaignId, recipientId) {
|
|
37
|
+
async function get(campaignId, recipientId) {
|
|
41
38
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
42
39
|
const {
|
|
43
40
|
recipient
|
|
44
|
-
} = await
|
|
41
|
+
} = await api.get(`${url}/${recipientId}`);
|
|
45
42
|
return recipient;
|
|
46
43
|
}
|
|
47
|
-
async addContact(campaignId, contact) {
|
|
44
|
+
async function addContact(campaignId, contact) {
|
|
48
45
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
49
|
-
return
|
|
46
|
+
return api.post(url, {
|
|
50
47
|
payload: {
|
|
51
48
|
contact
|
|
52
49
|
}
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
|
-
async addContacts(campaignId, contacts) {
|
|
52
|
+
async function addContacts(campaignId, contacts) {
|
|
56
53
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
57
|
-
return
|
|
54
|
+
return api.post(url, {
|
|
58
55
|
payload: {
|
|
59
56
|
contacts
|
|
60
57
|
}
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
|
-
async removeRecipient(campaignId, recipientId) {
|
|
60
|
+
async function removeRecipient(campaignId, recipientId) {
|
|
64
61
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
65
|
-
return
|
|
62
|
+
return api.delete(`${url}/${recipientId}`);
|
|
66
63
|
}
|
|
67
|
-
async removeRecipients(campaignId, params) {
|
|
64
|
+
async function removeRecipients(campaignId, params) {
|
|
68
65
|
const {
|
|
69
66
|
query
|
|
70
67
|
} = params || {};
|
|
71
68
|
const url = routing.campaignRecipientsUrl.replace(':campaign_id', String(campaignId));
|
|
72
|
-
return
|
|
69
|
+
return api.delete(url, {
|
|
73
70
|
payload: {
|
|
74
71
|
query
|
|
75
72
|
}
|
|
76
73
|
});
|
|
77
74
|
}
|
|
75
|
+
return {
|
|
76
|
+
list,
|
|
77
|
+
search,
|
|
78
|
+
get,
|
|
79
|
+
addContact,
|
|
80
|
+
addContacts,
|
|
81
|
+
removeRecipient,
|
|
82
|
+
removeRecipients
|
|
83
|
+
};
|
|
78
84
|
}
|
|
@@ -3,22 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createClient = createClient;
|
|
7
7
|
var _routing = require("../../routing.cjs");
|
|
8
8
|
var _index = require("../../types/index.cjs");
|
|
9
9
|
var _utils = require("../../utils.cjs");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.apiClient = apiClient;
|
|
13
|
-
}
|
|
14
|
-
async list(options) {
|
|
10
|
+
function createClient(api) {
|
|
11
|
+
async function list(options) {
|
|
15
12
|
const {
|
|
16
13
|
query,
|
|
17
14
|
limit,
|
|
18
15
|
offset,
|
|
19
16
|
sortOrder
|
|
20
17
|
} = options;
|
|
21
|
-
return
|
|
18
|
+
return api.get(_routing.routing.campaignsUrl, {
|
|
22
19
|
query: {
|
|
23
20
|
limit,
|
|
24
21
|
offset,
|
|
@@ -27,14 +24,14 @@ class Client {
|
|
|
27
24
|
}
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
|
-
async search(options) {
|
|
27
|
+
async function search(options) {
|
|
31
28
|
const {
|
|
32
29
|
query,
|
|
33
30
|
limit,
|
|
34
31
|
offset,
|
|
35
32
|
sortOrder
|
|
36
33
|
} = options;
|
|
37
|
-
return
|
|
34
|
+
return api.post(_routing.routing.campaignsUrl, {
|
|
38
35
|
payload: {
|
|
39
36
|
limit,
|
|
40
37
|
offset,
|
|
@@ -43,50 +40,62 @@ class Client {
|
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
|
-
async get(id) {
|
|
47
|
-
return
|
|
43
|
+
async function get(id) {
|
|
44
|
+
return api.get(`${_routing.routing.campaignsUrl}/${id}`);
|
|
48
45
|
}
|
|
49
|
-
async duplicate(id) {
|
|
50
|
-
return
|
|
46
|
+
async function duplicate(id) {
|
|
47
|
+
return api.post(`${_routing.routing.campaignsUrl}/${id}/duplicate`);
|
|
51
48
|
}
|
|
52
|
-
async
|
|
53
|
-
return
|
|
49
|
+
async function doDelete(id) {
|
|
50
|
+
return api.delete(`${_routing.routing.campaignsUrl}/${id}`);
|
|
54
51
|
}
|
|
55
|
-
async test(id, emails) {
|
|
56
|
-
return
|
|
52
|
+
async function test(id, emails) {
|
|
53
|
+
return api.post(`${_routing.routing.campaignsUrl}/${id}/test`, {
|
|
57
54
|
payload: {
|
|
58
55
|
emails
|
|
59
56
|
}
|
|
60
57
|
});
|
|
61
58
|
}
|
|
62
|
-
async send(id) {
|
|
63
|
-
return
|
|
59
|
+
async function send(id) {
|
|
60
|
+
return api.post(`${_routing.routing.campaignsUrl}/${id}/send`);
|
|
64
61
|
}
|
|
65
|
-
async schedule(id, sendAt) {
|
|
62
|
+
async function schedule(id, sendAt) {
|
|
66
63
|
const {
|
|
67
64
|
campaign
|
|
68
|
-
} = await
|
|
65
|
+
} = await api.post(`${_routing.routing.campaignsUrl}/${id}/schedule`, {
|
|
69
66
|
payload: {
|
|
70
67
|
schedule_at: (0, _utils.toIso8601)(sendAt)
|
|
71
68
|
}
|
|
72
69
|
});
|
|
73
70
|
return campaign;
|
|
74
71
|
}
|
|
75
|
-
async unschedule(id) {
|
|
72
|
+
async function unschedule(id) {
|
|
76
73
|
const {
|
|
77
74
|
campaign
|
|
78
|
-
} = await
|
|
75
|
+
} = await api.post(`${_routing.routing.campaignsUrl}/${id}/unschedule`);
|
|
79
76
|
return campaign;
|
|
80
77
|
}
|
|
81
|
-
async create(payload) {
|
|
82
|
-
return
|
|
78
|
+
async function create(payload) {
|
|
79
|
+
return api.post(_routing.routing.campaignsUrl, {
|
|
83
80
|
payload
|
|
84
81
|
});
|
|
85
82
|
}
|
|
86
|
-
async update(id, payload) {
|
|
87
|
-
return
|
|
83
|
+
async function update(id, payload) {
|
|
84
|
+
return api.patch(`${_routing.routing.campaignsUrl}/${id}`, {
|
|
88
85
|
payload
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
return {
|
|
89
|
+
list,
|
|
90
|
+
search,
|
|
91
|
+
get,
|
|
92
|
+
duplicate,
|
|
93
|
+
test,
|
|
94
|
+
send,
|
|
95
|
+
schedule,
|
|
96
|
+
unschedule,
|
|
97
|
+
create,
|
|
98
|
+
update,
|
|
99
|
+
delete: doDelete
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -2,20 +2,19 @@ import type { ProgressPromise } from '@prezly/progress-promise';
|
|
|
2
2
|
import type { DeferredJobsApiClient } from '../../api';
|
|
3
3
|
import type { Campaign } from '../../types';
|
|
4
4
|
import type { CreateRequest, RecipientsOperationResponse, CampaignResponse, UpdateRequest, ListResponse, SearchOptions } from './types';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unschedule(id: Campaign['id']): Promise<Campaign>;
|
|
17
|
-
create(payload: CreateRequest): ProgressPromise<RecipientsOperationResponse, {
|
|
5
|
+
export type Client = ReturnType<typeof createClient>;
|
|
6
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
7
|
+
list: (options: SearchOptions) => Promise<ListResponse>;
|
|
8
|
+
search: (options: SearchOptions) => Promise<ListResponse>;
|
|
9
|
+
get: (id: Campaign['id']) => Promise<CampaignResponse>;
|
|
10
|
+
duplicate: (id: Campaign['id']) => Promise<CampaignResponse>;
|
|
11
|
+
test: (id: Campaign['id'], emails: string[]) => Promise<void>;
|
|
12
|
+
send: (id: Campaign['id']) => Promise<void>;
|
|
13
|
+
schedule: (id: Campaign['id'], sendAt: Date) => Promise<Campaign>;
|
|
14
|
+
unschedule: (id: Campaign['id']) => Promise<Campaign>;
|
|
15
|
+
create: (payload: CreateRequest) => ProgressPromise<RecipientsOperationResponse, {
|
|
18
16
|
recipients_number: number;
|
|
19
17
|
}>;
|
|
20
|
-
update(id: Campaign['id'], payload: UpdateRequest)
|
|
21
|
-
|
|
18
|
+
update: (id: Campaign['id'], payload: UpdateRequest) => Promise<CampaignResponse>;
|
|
19
|
+
delete: (id: Campaign['id']) => Promise<void>;
|
|
20
|
+
};
|