@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
|
@@ -3,54 +3,57 @@
|
|
|
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(newsroomId) {
|
|
13
|
-
const url = generateUrl(newsroomId);
|
|
14
|
-
const {
|
|
15
|
-
members
|
|
16
|
-
} = await this.apiClient.get(url);
|
|
17
|
-
return members;
|
|
18
|
-
}
|
|
19
|
-
async linkMany(newsroomId, payload) {
|
|
8
|
+
function createClient(api) {
|
|
9
|
+
async function list(newsroomId) {
|
|
20
10
|
const url = generateUrl(newsroomId);
|
|
21
11
|
const {
|
|
22
12
|
members
|
|
23
|
-
} = await
|
|
24
|
-
payload
|
|
25
|
-
});
|
|
13
|
+
} = await api.get(url);
|
|
26
14
|
return members;
|
|
27
15
|
}
|
|
28
|
-
async member(newsroomId, memberId) {
|
|
16
|
+
async function member(newsroomId, memberId) {
|
|
29
17
|
const url = generateUrl(newsroomId, memberId);
|
|
30
18
|
const {
|
|
31
19
|
member
|
|
32
|
-
} = await
|
|
20
|
+
} = await api.get(url);
|
|
33
21
|
return member;
|
|
34
22
|
}
|
|
35
|
-
async link(newsroomId, memberId, options = {}) {
|
|
23
|
+
async function link(newsroomId, memberId, options = {}) {
|
|
36
24
|
const {
|
|
37
25
|
is_displaying_stories_in_hub
|
|
38
26
|
} = options;
|
|
39
27
|
const url = generateUrl(newsroomId, memberId);
|
|
40
28
|
const {
|
|
41
29
|
member
|
|
42
|
-
} = await
|
|
30
|
+
} = await api.post(url, {
|
|
43
31
|
payload: {
|
|
44
32
|
is_displaying_stories_in_hub
|
|
45
33
|
}
|
|
46
34
|
});
|
|
47
35
|
return member;
|
|
48
36
|
}
|
|
49
|
-
async
|
|
50
|
-
|
|
37
|
+
async function linkMany(newsroomId, payload) {
|
|
38
|
+
const url = generateUrl(newsroomId);
|
|
39
|
+
const {
|
|
40
|
+
members
|
|
41
|
+
} = await api.post(url, {
|
|
42
|
+
payload
|
|
43
|
+
});
|
|
44
|
+
return members;
|
|
45
|
+
}
|
|
46
|
+
async function unlink(newsroomId, memberId) {
|
|
47
|
+
await api.delete(generateUrl(newsroomId, memberId));
|
|
51
48
|
}
|
|
49
|
+
return {
|
|
50
|
+
list,
|
|
51
|
+
member,
|
|
52
|
+
link,
|
|
53
|
+
linkMany,
|
|
54
|
+
unlink
|
|
55
|
+
};
|
|
52
56
|
}
|
|
53
|
-
exports.Client = Client;
|
|
54
57
|
function generateUrl(newsroomId, memberId) {
|
|
55
58
|
const url = _routing.routing.newsroomHubUrl.replace(':newsroom_id', String(newsroomId));
|
|
56
59
|
if (typeof memberId === 'undefined') {
|
|
@@ -2,13 +2,12 @@ import type { DeferredJobsApiClient } from '../../api';
|
|
|
2
2
|
import type { NewsroomRef } from '../../types';
|
|
3
3
|
import type { LinkOptions, HubMember, LinkManyRequest } from './types';
|
|
4
4
|
type NewsroomId = NewsroomRef['uuid'] | NewsroomRef['id'];
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
export type Client = ReturnType<typeof createClient>;
|
|
6
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
7
|
+
list: (newsroomId: NewsroomId) => Promise<HubMember[]>;
|
|
8
|
+
member: (newsroomId: NewsroomId, memberId: NewsroomId) => Promise<HubMember>;
|
|
9
|
+
link: (newsroomId: NewsroomId, memberId: NewsroomId, options?: LinkOptions) => Promise<HubMember>;
|
|
10
|
+
linkMany: (newsroomId: NewsroomId, payload: LinkManyRequest) => Promise<HubMember[]>;
|
|
11
|
+
unlink: (newsroomId: NewsroomId, memberId: NewsroomId) => Promise<void>;
|
|
12
|
+
};
|
|
14
13
|
export {};
|
|
@@ -1,48 +1,52 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
this.apiClient = apiClient;
|
|
5
|
-
}
|
|
6
|
-
async list(newsroomId) {
|
|
7
|
-
const url = generateUrl(newsroomId);
|
|
8
|
-
const {
|
|
9
|
-
members
|
|
10
|
-
} = await this.apiClient.get(url);
|
|
11
|
-
return members;
|
|
12
|
-
}
|
|
13
|
-
async linkMany(newsroomId, payload) {
|
|
2
|
+
export function createClient(api) {
|
|
3
|
+
async function list(newsroomId) {
|
|
14
4
|
const url = generateUrl(newsroomId);
|
|
15
5
|
const {
|
|
16
6
|
members
|
|
17
|
-
} = await
|
|
18
|
-
payload
|
|
19
|
-
});
|
|
7
|
+
} = await api.get(url);
|
|
20
8
|
return members;
|
|
21
9
|
}
|
|
22
|
-
async member(newsroomId, memberId) {
|
|
10
|
+
async function member(newsroomId, memberId) {
|
|
23
11
|
const url = generateUrl(newsroomId, memberId);
|
|
24
12
|
const {
|
|
25
13
|
member
|
|
26
|
-
} = await
|
|
14
|
+
} = await api.get(url);
|
|
27
15
|
return member;
|
|
28
16
|
}
|
|
29
|
-
async link(newsroomId, memberId, options = {}) {
|
|
17
|
+
async function link(newsroomId, memberId, options = {}) {
|
|
30
18
|
const {
|
|
31
19
|
is_displaying_stories_in_hub
|
|
32
20
|
} = options;
|
|
33
21
|
const url = generateUrl(newsroomId, memberId);
|
|
34
22
|
const {
|
|
35
23
|
member
|
|
36
|
-
} = await
|
|
24
|
+
} = await api.post(url, {
|
|
37
25
|
payload: {
|
|
38
26
|
is_displaying_stories_in_hub
|
|
39
27
|
}
|
|
40
28
|
});
|
|
41
29
|
return member;
|
|
42
30
|
}
|
|
43
|
-
async
|
|
44
|
-
|
|
31
|
+
async function linkMany(newsroomId, payload) {
|
|
32
|
+
const url = generateUrl(newsroomId);
|
|
33
|
+
const {
|
|
34
|
+
members
|
|
35
|
+
} = await api.post(url, {
|
|
36
|
+
payload
|
|
37
|
+
});
|
|
38
|
+
return members;
|
|
39
|
+
}
|
|
40
|
+
async function unlink(newsroomId, memberId) {
|
|
41
|
+
await api.delete(generateUrl(newsroomId, memberId));
|
|
45
42
|
}
|
|
43
|
+
return {
|
|
44
|
+
list,
|
|
45
|
+
member,
|
|
46
|
+
link,
|
|
47
|
+
linkMany,
|
|
48
|
+
unlink
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
51
|
function generateUrl(newsroomId, memberId) {
|
|
48
52
|
const url = routing.newsroomHubUrl.replace(':newsroom_id', String(newsroomId));
|
|
@@ -3,62 +3,59 @@
|
|
|
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 _lib = require("./lib.cjs");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.apiClient = apiClient;
|
|
13
|
-
}
|
|
14
|
-
async list(newsroomId, {
|
|
10
|
+
function createClient(api) {
|
|
11
|
+
async function list(newsroomId, {
|
|
15
12
|
sortOrder
|
|
16
13
|
} = {}) {
|
|
17
14
|
const url = _routing.routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
18
|
-
return
|
|
15
|
+
return api.get(url, {
|
|
19
16
|
query: {
|
|
20
17
|
sort: _index.SortOrder.stringify(sortOrder)
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
|
-
async get(newsroomId, localeCode, {
|
|
21
|
+
async function get(newsroomId, localeCode, {
|
|
25
22
|
fallback
|
|
26
23
|
} = {}) {
|
|
27
24
|
const url = _routing.routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
28
25
|
const {
|
|
29
26
|
language
|
|
30
|
-
} = await
|
|
27
|
+
} = await api.get(`${url}/${localeCode}`, {
|
|
31
28
|
query: {
|
|
32
29
|
fallback: fallback || undefined
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
32
|
return language;
|
|
36
33
|
}
|
|
37
|
-
async enable(newsroomId, localeCode, payload = {}) {
|
|
34
|
+
async function enable(newsroomId, localeCode, payload = {}) {
|
|
38
35
|
const url = _routing.routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
39
36
|
const {
|
|
40
37
|
language
|
|
41
|
-
} = await
|
|
38
|
+
} = await api.put(`${url}/${localeCode}`, {
|
|
42
39
|
payload
|
|
43
40
|
});
|
|
44
41
|
return language;
|
|
45
42
|
}
|
|
46
|
-
async disable(newsroomId, localeCode, {
|
|
43
|
+
async function disable(newsroomId, localeCode, {
|
|
47
44
|
replacement
|
|
48
45
|
}) {
|
|
49
46
|
const url = _routing.routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
50
|
-
return
|
|
47
|
+
return api.delete(`${url}/${localeCode}`, {
|
|
51
48
|
payload: {
|
|
52
49
|
replacement
|
|
53
50
|
}
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
|
-
async update(newsroomId, localeCode, payload, options = {}) {
|
|
53
|
+
async function update(newsroomId, localeCode, payload, options = {}) {
|
|
57
54
|
const url = _routing.routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
58
55
|
const force = Boolean(options.force);
|
|
59
56
|
const {
|
|
60
57
|
language
|
|
61
|
-
} = await
|
|
58
|
+
} = await api.patch(`${url}/${localeCode}`, {
|
|
62
59
|
query: {
|
|
63
60
|
force: force ? true : undefined
|
|
64
61
|
},
|
|
@@ -66,8 +63,8 @@ class Client {
|
|
|
66
63
|
});
|
|
67
64
|
return language;
|
|
68
65
|
}
|
|
69
|
-
async makeDefault(newsroomId, localeCode) {
|
|
70
|
-
return
|
|
66
|
+
async function makeDefault(newsroomId, localeCode) {
|
|
67
|
+
return update(newsroomId, localeCode, {
|
|
71
68
|
is_default: true
|
|
72
69
|
});
|
|
73
70
|
}
|
|
@@ -79,9 +76,9 @@ class Client {
|
|
|
79
76
|
* This will also move all linked stories, if any, to the new language code,
|
|
80
77
|
* but will require a confirmation.
|
|
81
78
|
*/
|
|
82
|
-
async switchDefaultLanguage(newsroomId, localeCode, newLocaleCode, forceUnsafeOperation = false) {
|
|
79
|
+
async function switchDefaultLanguage(newsroomId, localeCode, newLocaleCode, forceUnsafeOperation = false) {
|
|
83
80
|
try {
|
|
84
|
-
const language = await
|
|
81
|
+
const language = await update(newsroomId, localeCode, {
|
|
85
82
|
code: newLocaleCode
|
|
86
83
|
}, {
|
|
87
84
|
force: forceUnsafeOperation
|
|
@@ -97,5 +94,13 @@ class Client {
|
|
|
97
94
|
throw error;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
return {
|
|
98
|
+
list,
|
|
99
|
+
get,
|
|
100
|
+
enable,
|
|
101
|
+
disable,
|
|
102
|
+
update,
|
|
103
|
+
makeDefault,
|
|
104
|
+
switchDefaultLanguage
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -2,31 +2,23 @@ import type { DeferredJobsApiClient } from '../../api';
|
|
|
2
2
|
import type { CultureRef, Newsroom, NewsroomLanguageSettings } from '../../types';
|
|
3
3
|
import type { SettingsUpdateRequest, ListOptions, ListResponse, UnsafeUpdateErrorResponse } from './types';
|
|
4
4
|
type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This operation should be used for single-language newsrooms
|
|
22
|
-
* to switch default language to another code.
|
|
23
|
-
*
|
|
24
|
-
* This will also move all linked stories, if any, to the new language code,
|
|
25
|
-
* but will require a confirmation.
|
|
26
|
-
*/
|
|
27
|
-
switchDefaultLanguage(newsroomId: NewsroomId, localeCode: CultureRef['code'], newLocaleCode: CultureRef['code'], forceUnsafeOperation?: boolean): Promise<{
|
|
5
|
+
export type Client = ReturnType<typeof createClient>;
|
|
6
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
7
|
+
list: (newsroomId: NewsroomId, { sortOrder }?: ListOptions) => Promise<ListResponse>;
|
|
8
|
+
get: (newsroomId: NewsroomId, localeCode: CultureRef['code'], { fallback }?: {
|
|
9
|
+
fallback?: boolean | undefined;
|
|
10
|
+
}) => Promise<NewsroomLanguageSettings>;
|
|
11
|
+
enable: (newsroomId: NewsroomId, localeCode: CultureRef['code'], payload?: SettingsUpdateRequest) => Promise<NewsroomLanguageSettings>;
|
|
12
|
+
disable: (newsroomId: NewsroomId, localeCode: CultureRef['code'], { replacement }: {
|
|
13
|
+
replacement?: import("../../types").Culture.Code | undefined;
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
update: (newsroomId: NewsroomId, localeCode: CultureRef['code'], payload: SettingsUpdateRequest, options?: {
|
|
16
|
+
force?: boolean | undefined;
|
|
17
|
+
}) => Promise<NewsroomLanguageSettings>;
|
|
18
|
+
makeDefault: (newsroomId: NewsroomId, localeCode: CultureRef['code']) => Promise<NewsroomLanguageSettings>;
|
|
19
|
+
switchDefaultLanguage: (newsroomId: NewsroomId, localeCode: CultureRef['code'], newLocaleCode: CultureRef['code'], forceUnsafeOperation?: boolean) => Promise<{
|
|
28
20
|
status: 'success';
|
|
29
21
|
language: NewsroomLanguageSettings;
|
|
30
22
|
} | UnsafeUpdateErrorResponse>;
|
|
31
|
-
}
|
|
23
|
+
};
|
|
32
24
|
export {};
|
|
@@ -1,58 +1,55 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
2
|
import { SortOrder } from "../../types/index.js";
|
|
3
3
|
import { isUnsafeNewsroomUpdateErrorResponse } from "./lib.js";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
this.apiClient = apiClient;
|
|
7
|
-
}
|
|
8
|
-
async list(newsroomId, {
|
|
4
|
+
export function createClient(api) {
|
|
5
|
+
async function list(newsroomId, {
|
|
9
6
|
sortOrder
|
|
10
7
|
} = {}) {
|
|
11
8
|
const url = routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
12
|
-
return
|
|
9
|
+
return api.get(url, {
|
|
13
10
|
query: {
|
|
14
11
|
sort: SortOrder.stringify(sortOrder)
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
|
-
async get(newsroomId, localeCode, {
|
|
15
|
+
async function get(newsroomId, localeCode, {
|
|
19
16
|
fallback
|
|
20
17
|
} = {}) {
|
|
21
18
|
const url = routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
22
19
|
const {
|
|
23
20
|
language
|
|
24
|
-
} = await
|
|
21
|
+
} = await api.get(`${url}/${localeCode}`, {
|
|
25
22
|
query: {
|
|
26
23
|
fallback: fallback || undefined
|
|
27
24
|
}
|
|
28
25
|
});
|
|
29
26
|
return language;
|
|
30
27
|
}
|
|
31
|
-
async enable(newsroomId, localeCode, payload = {}) {
|
|
28
|
+
async function enable(newsroomId, localeCode, payload = {}) {
|
|
32
29
|
const url = routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
33
30
|
const {
|
|
34
31
|
language
|
|
35
|
-
} = await
|
|
32
|
+
} = await api.put(`${url}/${localeCode}`, {
|
|
36
33
|
payload
|
|
37
34
|
});
|
|
38
35
|
return language;
|
|
39
36
|
}
|
|
40
|
-
async disable(newsroomId, localeCode, {
|
|
37
|
+
async function disable(newsroomId, localeCode, {
|
|
41
38
|
replacement
|
|
42
39
|
}) {
|
|
43
40
|
const url = routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
44
|
-
return
|
|
41
|
+
return api.delete(`${url}/${localeCode}`, {
|
|
45
42
|
payload: {
|
|
46
43
|
replacement
|
|
47
44
|
}
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
|
-
async update(newsroomId, localeCode, payload, options = {}) {
|
|
47
|
+
async function update(newsroomId, localeCode, payload, options = {}) {
|
|
51
48
|
const url = routing.newsroomLanguagesUrl.replace(':newsroom_id', String(newsroomId));
|
|
52
49
|
const force = Boolean(options.force);
|
|
53
50
|
const {
|
|
54
51
|
language
|
|
55
|
-
} = await
|
|
52
|
+
} = await api.patch(`${url}/${localeCode}`, {
|
|
56
53
|
query: {
|
|
57
54
|
force: force ? true : undefined
|
|
58
55
|
},
|
|
@@ -60,8 +57,8 @@ export class Client {
|
|
|
60
57
|
});
|
|
61
58
|
return language;
|
|
62
59
|
}
|
|
63
|
-
async makeDefault(newsroomId, localeCode) {
|
|
64
|
-
return
|
|
60
|
+
async function makeDefault(newsroomId, localeCode) {
|
|
61
|
+
return update(newsroomId, localeCode, {
|
|
65
62
|
is_default: true
|
|
66
63
|
});
|
|
67
64
|
}
|
|
@@ -73,9 +70,9 @@ export class Client {
|
|
|
73
70
|
* This will also move all linked stories, if any, to the new language code,
|
|
74
71
|
* but will require a confirmation.
|
|
75
72
|
*/
|
|
76
|
-
async switchDefaultLanguage(newsroomId, localeCode, newLocaleCode, forceUnsafeOperation = false) {
|
|
73
|
+
async function switchDefaultLanguage(newsroomId, localeCode, newLocaleCode, forceUnsafeOperation = false) {
|
|
77
74
|
try {
|
|
78
|
-
const language = await
|
|
75
|
+
const language = await update(newsroomId, localeCode, {
|
|
79
76
|
code: newLocaleCode
|
|
80
77
|
}, {
|
|
81
78
|
force: forceUnsafeOperation
|
|
@@ -91,4 +88,13 @@ export class Client {
|
|
|
91
88
|
throw error;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
91
|
+
return {
|
|
92
|
+
list,
|
|
93
|
+
get,
|
|
94
|
+
enable,
|
|
95
|
+
disable,
|
|
96
|
+
update,
|
|
97
|
+
makeDefault,
|
|
98
|
+
switchDefaultLanguage
|
|
99
|
+
};
|
|
94
100
|
}
|
|
@@ -3,27 +3,27 @@
|
|
|
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 create(newsroomId, payload) {
|
|
8
|
+
function createClient(api) {
|
|
9
|
+
async function create(newsroomId, payload) {
|
|
13
10
|
const url = _routing.routing.newsroomPrivacyRequestsUrl.replace(':newsroom_id', String(newsroomId));
|
|
14
11
|
const {
|
|
15
12
|
privacy_request
|
|
16
|
-
} = await
|
|
13
|
+
} = await api.post(url, {
|
|
17
14
|
payload
|
|
18
15
|
});
|
|
19
16
|
return privacy_request;
|
|
20
17
|
}
|
|
21
|
-
async confirm(newsroomId, privacyRequestId) {
|
|
18
|
+
async function confirm(newsroomId, privacyRequestId) {
|
|
22
19
|
const url = _routing.routing.newsroomPrivacyRequestsUrl.replace(':newsroom_id', String(newsroomId));
|
|
23
20
|
const {
|
|
24
21
|
privacy_request
|
|
25
|
-
} = await
|
|
22
|
+
} = await api.post(`${url}/${privacyRequestId}/confirm`);
|
|
26
23
|
return privacy_request;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
return {
|
|
26
|
+
create,
|
|
27
|
+
confirm
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from '../../api';
|
|
2
2
|
import type { Newsroom, PrivacyRequest } from '../../types';
|
|
3
3
|
import type { DeletePrivacyRequestCreateRequest, ExportPrivacyRequestCreateRequest, CorrectPrivacyRequestCreateRequest, OtherPrivacyRequestCreateRequest } from './types';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
export type Client = ReturnType<typeof createClient>;
|
|
5
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
6
|
+
create: (newsroomId: Newsroom['uuid'], payload: DeletePrivacyRequestCreateRequest | ExportPrivacyRequestCreateRequest | CorrectPrivacyRequestCreateRequest | OtherPrivacyRequestCreateRequest) => Promise<PrivacyRequest>;
|
|
7
|
+
confirm: (newsroomId: Newsroom['uuid'], privacyRequestId: PrivacyRequest['id']) => Promise<PrivacyRequest>;
|
|
8
|
+
};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
this.apiClient = apiClient;
|
|
5
|
-
}
|
|
6
|
-
async create(newsroomId, payload) {
|
|
2
|
+
export function createClient(api) {
|
|
3
|
+
async function create(newsroomId, payload) {
|
|
7
4
|
const url = routing.newsroomPrivacyRequestsUrl.replace(':newsroom_id', String(newsroomId));
|
|
8
5
|
const {
|
|
9
6
|
privacy_request
|
|
10
|
-
} = await
|
|
7
|
+
} = await api.post(url, {
|
|
11
8
|
payload
|
|
12
9
|
});
|
|
13
10
|
return privacy_request;
|
|
14
11
|
}
|
|
15
|
-
async confirm(newsroomId, privacyRequestId) {
|
|
12
|
+
async function confirm(newsroomId, privacyRequestId) {
|
|
16
13
|
const url = routing.newsroomPrivacyRequestsUrl.replace(':newsroom_id', String(newsroomId));
|
|
17
14
|
const {
|
|
18
15
|
privacy_request
|
|
19
|
-
} = await
|
|
16
|
+
} = await api.post(`${url}/${privacyRequestId}/confirm`);
|
|
20
17
|
return privacy_request;
|
|
21
18
|
}
|
|
19
|
+
return {
|
|
20
|
+
create,
|
|
21
|
+
confirm
|
|
22
|
+
};
|
|
22
23
|
}
|
|
@@ -3,31 +3,27 @@
|
|
|
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
|
-
constructor(apiClient) {
|
|
11
|
-
this.apiClient = apiClient;
|
|
12
|
-
}
|
|
13
|
-
|
|
9
|
+
function createClient(api) {
|
|
14
10
|
/**
|
|
15
11
|
* @deprecated Use `subscribeToNewsroom` from `Subscriptions` instead
|
|
16
12
|
*/
|
|
17
|
-
async subscribe(newsroomId, payload) {
|
|
18
|
-
const url =
|
|
19
|
-
return
|
|
13
|
+
async function subscribe(newsroomId, payload) {
|
|
14
|
+
const url = generateUrl(newsroomId);
|
|
15
|
+
return api.post(url, {
|
|
20
16
|
payload
|
|
21
17
|
});
|
|
22
18
|
}
|
|
23
|
-
async list(newsroomId, {
|
|
19
|
+
async function list(newsroomId, {
|
|
24
20
|
limit,
|
|
25
21
|
offset,
|
|
26
22
|
search,
|
|
27
23
|
sortOrder
|
|
28
24
|
} = {}) {
|
|
29
|
-
const url =
|
|
30
|
-
return
|
|
25
|
+
const url = generateUrl(newsroomId);
|
|
26
|
+
return api.get(url, {
|
|
31
27
|
query: {
|
|
32
28
|
limit,
|
|
33
29
|
offset,
|
|
@@ -36,5 +32,20 @@ class Client {
|
|
|
36
32
|
}
|
|
37
33
|
});
|
|
38
34
|
}
|
|
35
|
+
async function doExport(newsroomId) {
|
|
36
|
+
const url = generateUrl(newsroomId, '/export');
|
|
37
|
+
const response = await api.post(url);
|
|
38
|
+
return {
|
|
39
|
+
downloadUrl: response.download_url
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
subscribe,
|
|
44
|
+
list,
|
|
45
|
+
export: doExport
|
|
46
|
+
};
|
|
39
47
|
}
|
|
40
|
-
|
|
48
|
+
function generateUrl(newsroomId, suffix = '') {
|
|
49
|
+
const url = _routing.routing.newsroomSubscriptionsUrl.replace(':newsroom_id', String(newsroomId));
|
|
50
|
+
return url + suffix;
|
|
51
|
+
}
|
|
@@ -2,13 +2,12 @@ import type { DeferredJobsApiClient } from '../../api';
|
|
|
2
2
|
import type { Newsroom } from '../../types';
|
|
3
3
|
import type { CreateRequest, ListOptions, ListResponse } from './types';
|
|
4
4
|
type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
export type Client = ReturnType<typeof createClient>;
|
|
6
|
+
export declare function createClient(api: DeferredJobsApiClient): {
|
|
7
|
+
subscribe: (newsroomId: NewsroomId, payload: CreateRequest) => Promise<void>;
|
|
8
|
+
list: (newsroomId: NewsroomId, { limit, offset, search, sortOrder }?: ListOptions) => Promise<ListResponse>;
|
|
9
|
+
export: (newsroomId: NewsroomId) => Promise<{
|
|
10
|
+
downloadUrl: string;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
14
13
|
export {};
|