@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.
Files changed (93) hide show
  1. package/dist/Client.cjs +28 -28
  2. package/dist/Client.d.ts +2 -1
  3. package/dist/Client.js +29 -29
  4. package/dist/api/ApiClient.cjs +36 -34
  5. package/dist/api/ApiClient.d.ts +8 -12
  6. package/dist/api/ApiClient.js +34 -31
  7. package/dist/api/DeferredJobsApiClient.cjs +20 -18
  8. package/dist/api/DeferredJobsApiClient.d.ts +8 -10
  9. package/dist/api/DeferredJobsApiClient.js +18 -15
  10. package/dist/api/constants.cjs +1 -1
  11. package/dist/api/constants.js +1 -1
  12. package/dist/api/index.cjs +4 -4
  13. package/dist/api/index.d.ts +2 -2
  14. package/dist/api/index.js +2 -2
  15. package/dist/endpoints/Accounts/Client.cjs +14 -13
  16. package/dist/endpoints/Accounts/Client.d.ts +6 -7
  17. package/dist/endpoints/Accounts/Client.js +12 -10
  18. package/dist/endpoints/Billing/Client.cjs +11 -11
  19. package/dist/endpoints/Billing/Client.d.ts +5 -6
  20. package/dist/endpoints/Billing/Client.js +9 -8
  21. package/dist/endpoints/CampaignRecipients/Client.cjs +26 -21
  22. package/dist/endpoints/CampaignRecipients/Client.d.ts +13 -14
  23. package/dist/endpoints/CampaignRecipients/Client.js +24 -18
  24. package/dist/endpoints/Campaigns/Client.cjs +38 -29
  25. package/dist/endpoints/Campaigns/Client.d.ts +14 -15
  26. package/dist/endpoints/Campaigns/Client.js +36 -26
  27. package/dist/endpoints/Contacts/Client.cjs +41 -32
  28. package/dist/endpoints/Contacts/Client.d.ts +15 -22
  29. package/dist/endpoints/Contacts/Client.js +39 -29
  30. package/dist/endpoints/ContactsExports/Client.cjs +20 -18
  31. package/dist/endpoints/ContactsExports/Client.d.ts +8 -31
  32. package/dist/endpoints/ContactsExports/Client.js +18 -15
  33. package/dist/endpoints/Coverage/Client.cjs +29 -23
  34. package/dist/endpoints/Coverage/Client.d.ts +12 -13
  35. package/dist/endpoints/Coverage/Client.js +27 -20
  36. package/dist/endpoints/Jobs/Client.cjs +8 -9
  37. package/dist/endpoints/Jobs/Client.d.ts +4 -5
  38. package/dist/endpoints/Jobs/Client.js +6 -6
  39. package/dist/endpoints/Licenses/Client.cjs +8 -9
  40. package/dist/endpoints/Licenses/Client.d.ts +4 -5
  41. package/dist/endpoints/Licenses/Client.js +6 -6
  42. package/dist/endpoints/NewsroomCategories/Client.cjs +20 -17
  43. package/dist/endpoints/NewsroomCategories/Client.d.ts +8 -9
  44. package/dist/endpoints/NewsroomCategories/Client.js +18 -14
  45. package/dist/endpoints/NewsroomContacts/Client.cjs +23 -19
  46. package/dist/endpoints/NewsroomContacts/Client.d.ts +9 -10
  47. package/dist/endpoints/NewsroomContacts/Client.js +21 -16
  48. package/dist/endpoints/NewsroomDomains/Client.cjs +23 -19
  49. package/dist/endpoints/NewsroomDomains/Client.d.ts +9 -10
  50. package/dist/endpoints/NewsroomDomains/Client.js +21 -16
  51. package/dist/endpoints/NewsroomGalleries/Client.cjs +26 -21
  52. package/dist/endpoints/NewsroomGalleries/Client.d.ts +10 -11
  53. package/dist/endpoints/NewsroomGalleries/Client.js +24 -18
  54. package/dist/endpoints/NewsroomHub/Client.cjs +26 -23
  55. package/dist/endpoints/NewsroomHub/Client.d.ts +8 -9
  56. package/dist/endpoints/NewsroomHub/Client.js +25 -21
  57. package/dist/endpoints/NewsroomLanguages/Client.cjs +26 -21
  58. package/dist/endpoints/NewsroomLanguages/Client.d.ts +16 -24
  59. package/dist/endpoints/NewsroomLanguages/Client.js +24 -18
  60. package/dist/endpoints/NewsroomPrivacyRequests/Client.cjs +11 -11
  61. package/dist/endpoints/NewsroomPrivacyRequests/Client.d.ts +5 -6
  62. package/dist/endpoints/NewsroomPrivacyRequests/Client.js +9 -8
  63. package/dist/endpoints/NewsroomSubscriptions/Client.cjs +24 -13
  64. package/dist/endpoints/NewsroomSubscriptions/Client.d.ts +8 -9
  65. package/dist/endpoints/NewsroomSubscriptions/Client.js +23 -11
  66. package/dist/endpoints/NewsroomThemes/Client.cjs +17 -15
  67. package/dist/endpoints/NewsroomThemes/Client.d.ts +7 -8
  68. package/dist/endpoints/NewsroomThemes/Client.js +15 -12
  69. package/dist/endpoints/NewsroomWebhooks/Client.cjs +20 -17
  70. package/dist/endpoints/NewsroomWebhooks/Client.d.ts +8 -9
  71. package/dist/endpoints/NewsroomWebhooks/Client.js +18 -14
  72. package/dist/endpoints/Newsrooms/Client.cjs +35 -27
  73. package/dist/endpoints/Newsrooms/Client.d.ts +13 -14
  74. package/dist/endpoints/Newsrooms/Client.js +33 -24
  75. package/dist/endpoints/NotificationSubscriptions/Client.cjs +11 -11
  76. package/dist/endpoints/NotificationSubscriptions/Client.d.ts +5 -6
  77. package/dist/endpoints/NotificationSubscriptions/Client.js +9 -8
  78. package/dist/endpoints/PricingTables/Client.cjs +11 -11
  79. package/dist/endpoints/PricingTables/Client.d.ts +5 -6
  80. package/dist/endpoints/PricingTables/Client.js +9 -8
  81. package/dist/endpoints/SenderAddresses/Client.cjs +20 -17
  82. package/dist/endpoints/SenderAddresses/Client.d.ts +8 -9
  83. package/dist/endpoints/SenderAddresses/Client.js +18 -14
  84. package/dist/endpoints/Snippets/Client.cjs +20 -17
  85. package/dist/endpoints/Snippets/Client.d.ts +8 -9
  86. package/dist/endpoints/Snippets/Client.js +18 -14
  87. package/dist/endpoints/Stories/Client.cjs +63 -46
  88. package/dist/endpoints/Stories/Client.d.ts +109 -128
  89. package/dist/endpoints/Stories/Client.js +62 -44
  90. package/dist/endpoints/Subscriptions/Client.cjs +20 -17
  91. package/dist/endpoints/Subscriptions/Client.d.ts +8 -9
  92. package/dist/endpoints/Subscriptions/Client.js +18 -14
  93. package/package.json +1 -1
@@ -3,41 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Client = void 0;
6
+ exports.createClient = createClient;
7
7
  var _routing = require("../../routing.cjs");
8
8
  var _index = require("../../types/index.cjs");
9
- class Client {
10
- constructor(apiClient) {
11
- this.apiClient = apiClient;
12
- }
13
- async list(newsroomId, {
9
+ function createClient(api) {
10
+ async function list(newsroomId, {
14
11
  search
15
12
  } = {}) {
16
13
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
17
14
  const {
18
15
  contacts
19
- } = await this.apiClient.get(url, {
16
+ } = await api.get(url, {
20
17
  query: {
21
18
  search
22
19
  }
23
20
  });
24
21
  return contacts;
25
22
  }
26
- async get(newsroomId, contactId) {
23
+ async function get(newsroomId, contactId) {
27
24
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
28
25
  const {
29
26
  contact
30
- } = await this.apiClient.get(`${url}/${contactId}`);
27
+ } = await api.get(`${url}/${contactId}`);
31
28
  return contact;
32
29
  }
33
- async search(newsroomId, {
30
+ async function search(newsroomId, {
34
31
  search,
35
32
  query
36
33
  } = {}) {
37
34
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
38
35
  const {
39
36
  contacts
40
- } = await this.apiClient.get(url, {
37
+ } = await api.get(url, {
41
38
  query: {
42
39
  search,
43
40
  query: _index.Query.stringify(query)
@@ -45,32 +42,39 @@ class Client {
45
42
  });
46
43
  return contacts;
47
44
  }
48
- async create(newsroomId, payload) {
45
+ async function create(newsroomId, payload) {
49
46
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
50
47
  const {
51
48
  contact
52
- } = await this.apiClient.post(url, {
49
+ } = await api.post(url, {
53
50
  payload
54
51
  });
55
52
  return contact;
56
53
  }
57
- async update(newsroomId, contactId, payload) {
54
+ async function update(newsroomId, contactId, payload) {
58
55
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
59
56
  const {
60
57
  contact
61
- } = await this.apiClient.patch(`${url}/${contactId}`, {
58
+ } = await api.patch(`${url}/${contactId}`, {
62
59
  payload
63
60
  });
64
61
  return contact;
65
62
  }
66
- async remove(newsroomId, contactId, force = false) {
63
+ async function doDelete(newsroomId, contactId, force = false) {
67
64
  const url = _routing.routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
68
65
  const query = force ? {
69
66
  force: true
70
67
  } : {};
71
- return this.apiClient.delete(`${url}/${contactId}`, {
68
+ return api.delete(`${url}/${contactId}`, {
72
69
  query
73
70
  });
74
71
  }
75
- }
76
- exports.Client = Client;
72
+ return {
73
+ list,
74
+ get,
75
+ search,
76
+ create,
77
+ update,
78
+ delete: doDelete
79
+ };
80
+ }
@@ -3,14 +3,13 @@ import type { Newsroom, NewsroomContact } from '../../types';
3
3
  import type { ListOptions, SearchOptions, CreateRequest, UpdateRequest } from './types';
4
4
  type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
5
5
  type NewsroomContactId = NewsroomContact['uuid'] | NewsroomContact['id'];
6
- export declare class Client {
7
- private readonly apiClient;
8
- constructor(apiClient: DeferredJobsApiClient);
9
- list(newsroomId: NewsroomId, { search }?: ListOptions): Promise<NewsroomContact[]>;
10
- get(newsroomId: NewsroomId, contactId: NewsroomContactId): Promise<NewsroomContact>;
11
- search(newsroomId: NewsroomId, { search, query }?: SearchOptions): Promise<NewsroomContact[]>;
12
- create(newsroomId: NewsroomId, payload: CreateRequest): Promise<NewsroomContact>;
13
- update(newsroomId: NewsroomId, contactId: NewsroomContactId, payload: UpdateRequest): Promise<NewsroomContact>;
14
- remove(newsroomId: NewsroomId, contactId: NewsroomContactId, force?: boolean): Promise<void>;
15
- }
6
+ export type Client = ReturnType<typeof createClient>;
7
+ export declare function createClient(api: DeferredJobsApiClient): {
8
+ list: (newsroomId: NewsroomId, { search }?: ListOptions) => Promise<NewsroomContact[]>;
9
+ get: (newsroomId: NewsroomId, contactId: NewsroomContactId) => Promise<NewsroomContact>;
10
+ search: (newsroomId: NewsroomId, { search, query }?: SearchOptions) => Promise<NewsroomContact[]>;
11
+ create: (newsroomId: NewsroomId, payload: CreateRequest) => Promise<NewsroomContact>;
12
+ update: (newsroomId: NewsroomId, contactId: NewsroomContactId, payload: UpdateRequest) => Promise<NewsroomContact>;
13
+ delete: (newsroomId: NewsroomId, contactId: NewsroomContactId, force?: boolean) => Promise<void>;
14
+ };
16
15
  export {};
@@ -1,37 +1,34 @@
1
1
  import { routing } from "../../routing.js";
2
2
  import { Query } from "../../types/index.js";
3
- export class Client {
4
- constructor(apiClient) {
5
- this.apiClient = apiClient;
6
- }
7
- async list(newsroomId, {
3
+ export function createClient(api) {
4
+ async function list(newsroomId, {
8
5
  search
9
6
  } = {}) {
10
7
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
11
8
  const {
12
9
  contacts
13
- } = await this.apiClient.get(url, {
10
+ } = await api.get(url, {
14
11
  query: {
15
12
  search
16
13
  }
17
14
  });
18
15
  return contacts;
19
16
  }
20
- async get(newsroomId, contactId) {
17
+ async function get(newsroomId, contactId) {
21
18
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
22
19
  const {
23
20
  contact
24
- } = await this.apiClient.get(`${url}/${contactId}`);
21
+ } = await api.get(`${url}/${contactId}`);
25
22
  return contact;
26
23
  }
27
- async search(newsroomId, {
24
+ async function search(newsroomId, {
28
25
  search,
29
26
  query
30
27
  } = {}) {
31
28
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
32
29
  const {
33
30
  contacts
34
- } = await this.apiClient.get(url, {
31
+ } = await api.get(url, {
35
32
  query: {
36
33
  search,
37
34
  query: Query.stringify(query)
@@ -39,31 +36,39 @@ export class Client {
39
36
  });
40
37
  return contacts;
41
38
  }
42
- async create(newsroomId, payload) {
39
+ async function create(newsroomId, payload) {
43
40
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
44
41
  const {
45
42
  contact
46
- } = await this.apiClient.post(url, {
43
+ } = await api.post(url, {
47
44
  payload
48
45
  });
49
46
  return contact;
50
47
  }
51
- async update(newsroomId, contactId, payload) {
48
+ async function update(newsroomId, contactId, payload) {
52
49
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
53
50
  const {
54
51
  contact
55
- } = await this.apiClient.patch(`${url}/${contactId}`, {
52
+ } = await api.patch(`${url}/${contactId}`, {
56
53
  payload
57
54
  });
58
55
  return contact;
59
56
  }
60
- async remove(newsroomId, contactId, force = false) {
57
+ async function doDelete(newsroomId, contactId, force = false) {
61
58
  const url = routing.newsroomContactsUrl.replace(':newsroom_id', String(newsroomId));
62
59
  const query = force ? {
63
60
  force: true
64
61
  } : {};
65
- return this.apiClient.delete(`${url}/${contactId}`, {
62
+ return api.delete(`${url}/${contactId}`, {
66
63
  query
67
64
  });
68
65
  }
66
+ return {
67
+ list,
68
+ get,
69
+ search,
70
+ create,
71
+ update,
72
+ delete: doDelete
73
+ };
69
74
  }
@@ -3,46 +3,50 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Client = void 0;
6
+ exports.createClient = createClient;
7
7
  var _routing = require("../../routing.cjs");
8
- class Client {
9
- constructor(apiClient) {
10
- this.apiClient = apiClient;
11
- }
12
- async get(newsroomId, domain) {
8
+ function createClient(api) {
9
+ async function get(newsroomId, domain) {
13
10
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
14
- const response = await this.apiClient.get(`${url}/${domain}`);
11
+ const response = await api.get(`${url}/${domain}`);
15
12
  return response.domain;
16
13
  }
17
- async list(newsroomId) {
14
+ async function list(newsroomId) {
18
15
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
19
16
  const {
20
17
  domains
21
- } = await this.apiClient.get(url);
18
+ } = await api.get(url);
22
19
  return domains;
23
20
  }
24
- async link(newsroomId, payload) {
21
+ async function link(newsroomId, payload) {
25
22
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
26
23
  const {
27
24
  domain
28
- } = await this.apiClient.post(url, {
25
+ } = await api.post(url, {
29
26
  payload
30
27
  });
31
28
  return domain;
32
29
  }
33
- async unlink(newsroomId, domain) {
30
+ async function unlink(newsroomId, domain) {
34
31
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
35
- return this.apiClient.delete(`${url}/${domain}`);
32
+ return api.delete(`${url}/${domain}`);
36
33
  }
37
- async check(newsroomId, domain) {
34
+ async function check(newsroomId, domain) {
38
35
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
39
- const response = await this.apiClient.post(`${url}/${domain}/check`);
36
+ const response = await api.post(`${url}/${domain}/check`);
40
37
  return response.domain;
41
38
  }
42
- async shareDnsInstructions(newsroomId, domain) {
39
+ async function shareDnsInstructions(newsroomId, domain) {
43
40
  const url = _routing.routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
44
- const response = await this.apiClient.post(`${url}/${domain}/share`);
41
+ const response = await api.post(`${url}/${domain}/share`);
45
42
  return response.sharable_dns_instructions;
46
43
  }
47
- }
48
- exports.Client = Client;
44
+ return {
45
+ get,
46
+ list,
47
+ link,
48
+ unlink,
49
+ check,
50
+ shareDnsInstructions
51
+ };
52
+ }
@@ -2,14 +2,13 @@ import type { DeferredJobsApiClient } from '../../api';
2
2
  import type { NewsroomDomain, Newsroom } from '../../types';
3
3
  import type { LinkRequest } from './types';
4
4
  type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
5
- export declare class Client {
6
- private readonly apiClient;
7
- constructor(apiClient: DeferredJobsApiClient);
8
- get(newsroomId: NewsroomId, domain: string): Promise<NewsroomDomain>;
9
- list(newsroomId: NewsroomId): Promise<NewsroomDomain[]>;
10
- link(newsroomId: NewsroomId, payload: LinkRequest): Promise<NewsroomDomain>;
11
- unlink(newsroomId: NewsroomId, domain: string): Promise<void>;
12
- check(newsroomId: NewsroomId, domain: string): Promise<NewsroomDomain>;
13
- shareDnsInstructions(newsroomId: NewsroomId, domain: string): Promise<NewsroomDomain.ShareInstructions>;
14
- }
5
+ export type Client = ReturnType<typeof createClient>;
6
+ export declare function createClient(api: DeferredJobsApiClient): {
7
+ get: (newsroomId: NewsroomId, domain: string) => Promise<NewsroomDomain>;
8
+ list: (newsroomId: NewsroomId) => Promise<NewsroomDomain[]>;
9
+ link: (newsroomId: NewsroomId, payload: LinkRequest) => Promise<NewsroomDomain>;
10
+ unlink: (newsroomId: NewsroomId, domain: string) => Promise<void>;
11
+ check: (newsroomId: NewsroomId, domain: string) => Promise<NewsroomDomain>;
12
+ shareDnsInstructions: (newsroomId: NewsroomId, domain: string) => Promise<NewsroomDomain.ShareInstructions>;
13
+ };
15
14
  export {};
@@ -1,41 +1,46 @@
1
1
  import { routing } from "../../routing.js";
2
- export class Client {
3
- constructor(apiClient) {
4
- this.apiClient = apiClient;
5
- }
6
- async get(newsroomId, domain) {
2
+ export function createClient(api) {
3
+ async function get(newsroomId, domain) {
7
4
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
8
- const response = await this.apiClient.get(`${url}/${domain}`);
5
+ const response = await api.get(`${url}/${domain}`);
9
6
  return response.domain;
10
7
  }
11
- async list(newsroomId) {
8
+ async function list(newsroomId) {
12
9
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
13
10
  const {
14
11
  domains
15
- } = await this.apiClient.get(url);
12
+ } = await api.get(url);
16
13
  return domains;
17
14
  }
18
- async link(newsroomId, payload) {
15
+ async function link(newsroomId, payload) {
19
16
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
20
17
  const {
21
18
  domain
22
- } = await this.apiClient.post(url, {
19
+ } = await api.post(url, {
23
20
  payload
24
21
  });
25
22
  return domain;
26
23
  }
27
- async unlink(newsroomId, domain) {
24
+ async function unlink(newsroomId, domain) {
28
25
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
29
- return this.apiClient.delete(`${url}/${domain}`);
26
+ return api.delete(`${url}/${domain}`);
30
27
  }
31
- async check(newsroomId, domain) {
28
+ async function check(newsroomId, domain) {
32
29
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
33
- const response = await this.apiClient.post(`${url}/${domain}/check`);
30
+ const response = await api.post(`${url}/${domain}/check`);
34
31
  return response.domain;
35
32
  }
36
- async shareDnsInstructions(newsroomId, domain) {
33
+ async function shareDnsInstructions(newsroomId, domain) {
37
34
  const url = routing.newsroomDomainsUrl.replace(':newsroom_id', String(newsroomId));
38
- const response = await this.apiClient.post(`${url}/${domain}/share`);
35
+ const response = await api.post(`${url}/${domain}/share`);
39
36
  return response.sharable_dns_instructions;
40
37
  }
38
+ return {
39
+ get,
40
+ list,
41
+ link,
42
+ unlink,
43
+ check,
44
+ shareDnsInstructions
45
+ };
41
46
  }
@@ -3,26 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Client = void 0;
6
+ exports.createClient = createClient;
7
7
  var _routing = require("../../routing.cjs");
8
8
  var _index = require("../../types/index.cjs");
9
- class Client {
10
- constructor(apiClient) {
11
- this.apiClient = apiClient;
12
- }
13
- async get(newsroomId, id) {
9
+ function createClient(api) {
10
+ async function get(newsroomId, id) {
14
11
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
15
- const response = await this.apiClient.get(`${url}/${id}`);
12
+ const response = await api.get(`${url}/${id}`);
16
13
  return response.gallery;
17
14
  }
18
- async list(newsroomId, options = {}) {
15
+ async function list(newsroomId, options = {}) {
19
16
  const {
20
17
  sortOrder,
21
18
  limit,
22
19
  offset
23
20
  } = options;
24
21
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
25
- return this.apiClient.get(url, {
22
+ return api.get(url, {
26
23
  query: {
27
24
  sort: _index.SortOrder.stringify(sortOrder),
28
25
  limit: limit,
@@ -30,7 +27,7 @@ class Client {
30
27
  }
31
28
  });
32
29
  }
33
- async search(newsroomId, options = {}) {
30
+ async function search(newsroomId, options = {}) {
34
31
  const {
35
32
  scope,
36
33
  query,
@@ -40,7 +37,7 @@ class Client {
40
37
  } = options;
41
38
  // TODO: Introduce dedicated Search POST API
42
39
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
43
- return this.apiClient.get(url, {
40
+ return api.get(url, {
44
41
  query: {
45
42
  scope: _index.Query.stringify(scope),
46
43
  query: _index.Query.stringify(query),
@@ -50,33 +47,41 @@ class Client {
50
47
  }
51
48
  });
52
49
  }
53
- async order(newsroomId, payload) {
50
+ async function order(newsroomId, payload) {
54
51
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
55
- this.apiClient.post(`${url}/order`, {
52
+ api.post(`${url}/order`, {
56
53
  payload
57
54
  });
58
55
  }
59
- async create(newsroomId, payload) {
56
+ async function create(newsroomId, payload) {
60
57
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
61
58
  const {
62
59
  gallery
63
- } = await this.apiClient.post(url, {
60
+ } = await api.post(url, {
64
61
  payload
65
62
  });
66
63
  return gallery;
67
64
  }
68
- async update(newsroomId, galleryId, payload) {
65
+ async function update(newsroomId, galleryId, payload) {
69
66
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
70
67
  const {
71
68
  gallery
72
- } = await this.apiClient.patch(`${url}/${galleryId}`, {
69
+ } = await api.patch(`${url}/${galleryId}`, {
73
70
  payload
74
71
  });
75
72
  return gallery;
76
73
  }
77
- async remove(newsroomId, galleryId) {
74
+ async function doDelete(newsroomId, galleryId) {
78
75
  const url = _routing.routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
79
- return this.apiClient.delete(`${url}/${galleryId}`);
76
+ return api.delete(`${url}/${galleryId}`);
80
77
  }
81
- }
82
- exports.Client = Client;
78
+ return {
79
+ get,
80
+ list,
81
+ search,
82
+ order,
83
+ create,
84
+ update,
85
+ delete: doDelete
86
+ };
87
+ }
@@ -3,15 +3,14 @@ import type { Newsroom, NewsroomGallery } from '../../types';
3
3
  import type { ListOptions, ListResponse, ReorderRequest, CreateRequest, UpdateRequest, SearchOptions } from './types';
4
4
  type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
5
5
  type GalleryId = NewsroomGallery['uuid'] | NewsroomGallery['id'];
6
- export declare class Client {
7
- private readonly apiClient;
8
- constructor(apiClient: DeferredJobsApiClient);
9
- get(newsroomId: NewsroomId, id: NewsroomGallery['uuid']): Promise<NewsroomGallery>;
10
- list(newsroomId: NewsroomId, options?: ListOptions): Promise<ListResponse>;
11
- search(newsroomId: NewsroomId, options?: SearchOptions): Promise<ListResponse>;
12
- order(newsroomId: NewsroomId, payload: ReorderRequest): Promise<void>;
13
- create(newsroomId: NewsroomId, payload: CreateRequest): Promise<NewsroomGallery>;
14
- update(newsroomId: NewsroomId, galleryId: GalleryId, payload: UpdateRequest): Promise<NewsroomGallery>;
15
- remove(newsroomId: NewsroomId, galleryId: GalleryId): Promise<void>;
16
- }
6
+ export type Client = ReturnType<typeof createClient>;
7
+ export declare function createClient(api: DeferredJobsApiClient): {
8
+ get: (newsroomId: NewsroomId, id: NewsroomGallery['uuid']) => Promise<NewsroomGallery>;
9
+ list: (newsroomId: NewsroomId, options?: ListOptions) => Promise<ListResponse>;
10
+ search: (newsroomId: NewsroomId, options?: SearchOptions) => Promise<ListResponse>;
11
+ order: (newsroomId: NewsroomId, payload: ReorderRequest) => Promise<void>;
12
+ create: (newsroomId: NewsroomId, payload: CreateRequest) => Promise<NewsroomGallery>;
13
+ update: (newsroomId: NewsroomId, galleryId: GalleryId, payload: UpdateRequest) => Promise<NewsroomGallery>;
14
+ delete: (newsroomId: NewsroomId, galleryId: GalleryId) => Promise<void>;
15
+ };
17
16
  export {};
@@ -1,22 +1,19 @@
1
1
  import { routing } from "../../routing.js";
2
2
  import { Query, SortOrder } from "../../types/index.js";
3
- export class Client {
4
- constructor(apiClient) {
5
- this.apiClient = apiClient;
6
- }
7
- async get(newsroomId, id) {
3
+ export function createClient(api) {
4
+ async function get(newsroomId, id) {
8
5
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
9
- const response = await this.apiClient.get(`${url}/${id}`);
6
+ const response = await api.get(`${url}/${id}`);
10
7
  return response.gallery;
11
8
  }
12
- async list(newsroomId, options = {}) {
9
+ async function list(newsroomId, options = {}) {
13
10
  const {
14
11
  sortOrder,
15
12
  limit,
16
13
  offset
17
14
  } = options;
18
15
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
19
- return this.apiClient.get(url, {
16
+ return api.get(url, {
20
17
  query: {
21
18
  sort: SortOrder.stringify(sortOrder),
22
19
  limit: limit,
@@ -24,7 +21,7 @@ export class Client {
24
21
  }
25
22
  });
26
23
  }
27
- async search(newsroomId, options = {}) {
24
+ async function search(newsroomId, options = {}) {
28
25
  const {
29
26
  scope,
30
27
  query,
@@ -34,7 +31,7 @@ export class Client {
34
31
  } = options;
35
32
  // TODO: Introduce dedicated Search POST API
36
33
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
37
- return this.apiClient.get(url, {
34
+ return api.get(url, {
38
35
  query: {
39
36
  scope: Query.stringify(scope),
40
37
  query: Query.stringify(query),
@@ -44,32 +41,41 @@ export class Client {
44
41
  }
45
42
  });
46
43
  }
47
- async order(newsroomId, payload) {
44
+ async function order(newsroomId, payload) {
48
45
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
49
- this.apiClient.post(`${url}/order`, {
46
+ api.post(`${url}/order`, {
50
47
  payload
51
48
  });
52
49
  }
53
- async create(newsroomId, payload) {
50
+ async function create(newsroomId, payload) {
54
51
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
55
52
  const {
56
53
  gallery
57
- } = await this.apiClient.post(url, {
54
+ } = await api.post(url, {
58
55
  payload
59
56
  });
60
57
  return gallery;
61
58
  }
62
- async update(newsroomId, galleryId, payload) {
59
+ async function update(newsroomId, galleryId, payload) {
63
60
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
64
61
  const {
65
62
  gallery
66
- } = await this.apiClient.patch(`${url}/${galleryId}`, {
63
+ } = await api.patch(`${url}/${galleryId}`, {
67
64
  payload
68
65
  });
69
66
  return gallery;
70
67
  }
71
- async remove(newsroomId, galleryId) {
68
+ async function doDelete(newsroomId, galleryId) {
72
69
  const url = routing.newsroomGalleriesUrl.replace(':newsroom_id', String(newsroomId));
73
- return this.apiClient.delete(`${url}/${galleryId}`);
70
+ return api.delete(`${url}/${galleryId}`);
74
71
  }
72
+ return {
73
+ get,
74
+ list,
75
+ search,
76
+ order,
77
+ create,
78
+ update,
79
+ delete: doDelete
80
+ };
75
81
  }