@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
@@ -9,11 +9,8 @@ import { EXTENDED_STORY_INCLUDED_EXTRA_FIELDS } from "./types.js";
9
9
  * Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
10
10
  * @see https://stackoverflow.com/a/69666350
11
11
  */
12
- export class Client {
13
- constructor(apiClient) {
14
- this.apiClient = apiClient;
15
- }
16
- async list(options) {
12
+ export function createClient(api) {
13
+ async function list(options) {
17
14
  const {
18
15
  search,
19
16
  limit,
@@ -22,7 +19,7 @@ export class Client {
22
19
  include,
23
20
  formats
24
21
  } = options ?? {};
25
- return this.apiClient.get(routing.storiesUrl, {
22
+ return api.get(routing.storiesUrl, {
26
23
  headers: acceptedFormatsHeader(formats),
27
24
  query: {
28
25
  search,
@@ -33,7 +30,7 @@ export class Client {
33
30
  }
34
31
  });
35
32
  }
36
- async search(options) {
33
+ async function search(options) {
37
34
  const {
38
35
  search,
39
36
  limit,
@@ -43,7 +40,7 @@ export class Client {
43
40
  query,
44
41
  formats
45
42
  } = options ?? {};
46
- return this.apiClient.post(routing.storiesSearchUrl, {
43
+ return api.post(routing.storiesSearchUrl, {
47
44
  headers: acceptedFormatsHeader(formats),
48
45
  payload: {
49
46
  search,
@@ -77,7 +74,7 @@ export class Client {
77
74
  /**
78
75
  * Implementation
79
76
  */
80
- async get(arg, options) {
77
+ async function get(arg, options) {
81
78
  const {
82
79
  include,
83
80
  formats
@@ -90,7 +87,7 @@ export class Client {
90
87
  if (isArray && typeof arg[0] === 'number') {
91
88
  const {
92
89
  stories
93
- } = await this.search({
90
+ } = await search({
94
91
  limit: arg.length,
95
92
  query: {
96
93
  id: {
@@ -105,7 +102,7 @@ export class Client {
105
102
  if (isArray && typeof arg[0] === 'string') {
106
103
  const {
107
104
  stories
108
- } = await this.search({
105
+ } = await search({
109
106
  limit: arg.length,
110
107
  query: {
111
108
  uuid: {
@@ -119,7 +116,7 @@ export class Client {
119
116
  }
120
117
  const {
121
118
  story
122
- } = await this.apiClient.get(`${routing.storiesUrl}/${arg}`, {
119
+ } = await api.get(`${routing.storiesUrl}/${arg}`, {
123
120
  headers: acceptedFormatsHeader(formats),
124
121
  query: {
125
122
  include
@@ -127,7 +124,7 @@ export class Client {
127
124
  });
128
125
  return story;
129
126
  }
130
- async getBySlug(slug, options) {
127
+ async function getBySlug(slug, options) {
131
128
  if (slug.includes('/') || slug.includes('\\')) {
132
129
  throw new Error('Story slugs cannot contain slashes.');
133
130
  }
@@ -138,7 +135,7 @@ export class Client {
138
135
  } = options ?? {};
139
136
  const {
140
137
  story
141
- } = await this.apiClient.post(`${routing.storiesUrl}/by-slug/${slug}`, {
138
+ } = await api.post(`${routing.storiesUrl}/by-slug/${slug}`, {
142
139
  headers: acceptedFormatsHeader(formats),
143
140
  query: {
144
141
  include
@@ -149,7 +146,7 @@ export class Client {
149
146
  });
150
147
  return story;
151
148
  }
152
- async create(payload, options) {
149
+ async function create(payload, options) {
153
150
  const {
154
151
  include,
155
152
  formats,
@@ -157,7 +154,7 @@ export class Client {
157
154
  } = options ?? {};
158
155
  const {
159
156
  story
160
- } = await this.apiClient.post(routing.storiesUrl, {
157
+ } = await api.post(routing.storiesUrl, {
161
158
  headers: acceptedFormatsHeader(formats),
162
159
  query: {
163
160
  include,
@@ -167,7 +164,7 @@ export class Client {
167
164
  });
168
165
  return story;
169
166
  }
170
- async duplicate(id, options) {
167
+ async function duplicate(id, options) {
171
168
  const {
172
169
  include,
173
170
  formats
@@ -175,7 +172,7 @@ export class Client {
175
172
  const url = `${routing.storiesUrl}/${id}/duplicate`;
176
173
  const {
177
174
  story
178
- } = await this.apiClient.post(url, {
175
+ } = await api.post(url, {
179
176
  headers: acceptedFormatsHeader(formats),
180
177
  query: {
181
178
  include
@@ -183,7 +180,7 @@ export class Client {
183
180
  });
184
181
  return story;
185
182
  }
186
- async translate(id, payload = {}, options) {
183
+ async function translate(id, payload = {}, options) {
187
184
  const {
188
185
  culture
189
186
  } = payload ?? {};
@@ -194,7 +191,7 @@ export class Client {
194
191
  const url = `${routing.storiesUrl}/${id}/translate`;
195
192
  const {
196
193
  story
197
- } = await this.apiClient.post(url, {
194
+ } = await api.post(url, {
198
195
  headers: acceptedFormatsHeader(formats),
199
196
  query: {
200
197
  include
@@ -205,7 +202,7 @@ export class Client {
205
202
  });
206
203
  return story;
207
204
  }
208
- async move(id, payload, options) {
205
+ async function move(id, payload, options) {
209
206
  const {
210
207
  include,
211
208
  formats,
@@ -215,7 +212,7 @@ export class Client {
215
212
  try {
216
213
  const {
217
214
  story
218
- } = await this.apiClient.post(url, {
215
+ } = await api.post(url, {
219
216
  headers: acceptedFormatsHeader(formats),
220
217
  query: {
221
218
  include,
@@ -234,7 +231,7 @@ export class Client {
234
231
  throw error;
235
232
  }
236
233
  }
237
- async update(id, payload, options) {
234
+ async function update(id, payload, options) {
238
235
  const url = `${routing.storiesUrl}/${id}`;
239
236
  const {
240
237
  include,
@@ -243,7 +240,7 @@ export class Client {
243
240
  } = options ?? {};
244
241
  const {
245
242
  story
246
- } = await this.apiClient.patch(url, {
243
+ } = await api.patch(url, {
247
244
  headers: acceptedFormatsHeader(formats),
248
245
  query: {
249
246
  include,
@@ -257,7 +254,7 @@ export class Client {
257
254
  /**
258
255
  * This operation is only allowed for V3 stories
259
256
  */
260
- async autosave(id, payload, options) {
257
+ async function autosave(id, payload, options) {
261
258
  const url = `${routing.storiesUrl}/${id}/autosave`;
262
259
  const {
263
260
  include,
@@ -265,7 +262,7 @@ export class Client {
265
262
  } = options ?? {};
266
263
  const {
267
264
  story
268
- } = await this.apiClient.patch(url, {
265
+ } = await api.patch(url, {
269
266
  headers: acceptedFormatsHeader(formats),
270
267
  payload,
271
268
  query: {
@@ -278,7 +275,7 @@ export class Client {
278
275
  /**
279
276
  * This operation is only allowed for V3 stories
280
277
  */
281
- async revert(id, payload, options) {
278
+ async function revert(id, payload, options) {
282
279
  const url = `${routing.storiesUrl}/${id}/revert`;
283
280
  const {
284
281
  include,
@@ -286,7 +283,7 @@ export class Client {
286
283
  } = options ?? {};
287
284
  const {
288
285
  story
289
- } = await this.apiClient.post(url, {
286
+ } = await api.post(url, {
290
287
  headers: acceptedFormatsHeader(formats),
291
288
  payload,
292
289
  query: {
@@ -295,7 +292,7 @@ export class Client {
295
292
  });
296
293
  return story;
297
294
  }
298
- async publish(id, payload, options) {
295
+ async function publish(id, payload, options) {
299
296
  const url = `${routing.storiesUrl}/${id}/publish`;
300
297
  const {
301
298
  include,
@@ -303,7 +300,7 @@ export class Client {
303
300
  } = options ?? {};
304
301
  const {
305
302
  story
306
- } = await this.apiClient.post(url, {
303
+ } = await api.post(url, {
307
304
  headers: acceptedFormatsHeader(formats),
308
305
  payload,
309
306
  query: {
@@ -312,7 +309,7 @@ export class Client {
312
309
  });
313
310
  return story;
314
311
  }
315
- async unpublish(id, payload, options) {
312
+ async function unpublish(id, payload, options) {
316
313
  const url = `${routing.storiesUrl}/${id}/unpublish`;
317
314
  const {
318
315
  include,
@@ -320,7 +317,7 @@ export class Client {
320
317
  } = options ?? {};
321
318
  const {
322
319
  story
323
- } = await this.apiClient.post(url, {
320
+ } = await api.post(url, {
324
321
  headers: acceptedFormatsHeader(formats),
325
322
  payload,
326
323
  query: {
@@ -329,7 +326,7 @@ export class Client {
329
326
  });
330
327
  return story;
331
328
  }
332
- async schedule(id, payload, options) {
329
+ async function schedule(id, payload, options) {
333
330
  const url = `${routing.storiesUrl}/${id}/schedule`;
334
331
  const {
335
332
  include,
@@ -337,7 +334,7 @@ export class Client {
337
334
  } = options ?? {};
338
335
  const {
339
336
  story
340
- } = await this.apiClient.post(url, {
337
+ } = await api.post(url, {
341
338
  headers: acceptedFormatsHeader(formats),
342
339
  payload,
343
340
  query: {
@@ -346,7 +343,7 @@ export class Client {
346
343
  });
347
344
  return story;
348
345
  }
349
- async unschedule(id, payload, options) {
346
+ async function unschedule(id, payload, options) {
350
347
  const url = `${routing.storiesUrl}/${id}/unpublish`;
351
348
  const {
352
349
  include,
@@ -354,7 +351,7 @@ export class Client {
354
351
  } = options ?? {};
355
352
  const {
356
353
  story
357
- } = await this.apiClient.post(url, {
354
+ } = await api.post(url, {
358
355
  headers: acceptedFormatsHeader(formats),
359
356
  payload,
360
357
  query: {
@@ -363,7 +360,7 @@ export class Client {
363
360
  });
364
361
  return story;
365
362
  }
366
- async pin(id, options) {
363
+ async function pin(id, options) {
367
364
  const url = `${routing.storiesUrl}/${id}/pin`;
368
365
  const {
369
366
  include,
@@ -372,7 +369,7 @@ export class Client {
372
369
  } = options ?? {};
373
370
  const {
374
371
  story
375
- } = await this.apiClient.post(url, {
372
+ } = await api.post(url, {
376
373
  headers: acceptedFormatsHeader(formats),
377
374
  query: {
378
375
  include: include,
@@ -381,7 +378,7 @@ export class Client {
381
378
  });
382
379
  return story;
383
380
  }
384
- async unpin(id, options) {
381
+ async function unpin(id, options) {
385
382
  const url = `${routing.storiesUrl}/${id}/unpin`;
386
383
  const {
387
384
  include,
@@ -389,7 +386,7 @@ export class Client {
389
386
  } = options ?? {};
390
387
  const {
391
388
  story
392
- } = await this.apiClient.post(url, {
389
+ } = await api.post(url, {
393
390
  headers: acceptedFormatsHeader(formats),
394
391
  query: {
395
392
  include: include
@@ -397,15 +394,15 @@ export class Client {
397
394
  });
398
395
  return story;
399
396
  }
400
- async delete(id) {
397
+ async function doDelete(id) {
401
398
  const url = `${routing.storiesUrl}/${id}`;
402
- await this.apiClient.delete(url);
399
+ await api.delete(url);
403
400
  }
404
- async preview(id, options) {
401
+ async function preview(id, options) {
405
402
  const url = `${routing.storiesUrl}/${id}/preview`;
406
403
  const {
407
404
  preview
408
- } = await this.apiClient.get(url, {
405
+ } = await api.get(url, {
409
406
  query: {
410
407
  alignment: options?.alignment,
411
408
  appearance: options?.appearance,
@@ -414,6 +411,27 @@ export class Client {
414
411
  });
415
412
  return preview;
416
413
  }
414
+ return {
415
+ list,
416
+ search,
417
+ get,
418
+ getBySlug,
419
+ create,
420
+ duplicate,
421
+ translate,
422
+ move,
423
+ update,
424
+ autosave,
425
+ revert,
426
+ publish,
427
+ unpublish,
428
+ schedule,
429
+ unschedule,
430
+ pin,
431
+ unpin,
432
+ delete: doDelete,
433
+ preview
434
+ };
417
435
  }
418
436
  function acceptedFormatsHeader(formats = []) {
419
437
  if (formats.length === 0) {
@@ -3,56 +3,59 @@
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 subscribeToNewsroom(newsroomId, payload) {
8
+ function createClient(api) {
9
+ async function subscribeToNewsroom(newsroomId, payload) {
13
10
  const url = _routing.routing.newsroomSubscribeUrl.replace(':newsroom_id', String(newsroomId));
14
11
  const {
15
12
  subscription
16
- } = await this.apiClient.post(url, {
13
+ } = await api.post(url, {
17
14
  payload
18
15
  });
19
16
  return subscription;
20
17
  }
21
- async unsubscribeFromNewsroom(newsroomId, payload) {
18
+ async function unsubscribeFromNewsroom(newsroomId, payload) {
22
19
  const url = _routing.routing.newsroomUnsubscribeUrl.replace(':newsroom_id', String(newsroomId));
23
20
  const {
24
21
  subscription
25
- } = await this.apiClient.post(url, {
22
+ } = await api.post(url, {
26
23
  payload
27
24
  });
28
25
  return subscription;
29
26
  }
30
- async updateNewsroomUnsubscribeDetails(newsroomId, subscriptionId, payload) {
27
+ async function updateNewsroomUnsubscribeDetails(newsroomId, subscriptionId, payload) {
31
28
  const url = _routing.routing.newsroomUnsubscribeUrl.replace(':newsroom_id', String(newsroomId));
32
29
  const {
33
30
  subscription
34
- } = await this.apiClient.patch(`${url}/${subscriptionId}`, {
31
+ } = await api.patch(`${url}/${subscriptionId}`, {
35
32
  payload
36
33
  });
37
34
  return subscription;
38
35
  }
39
- async unsubscribeFromLicense(payload) {
36
+ async function unsubscribeFromLicense(payload) {
40
37
  const url = _routing.routing.licenseUnsubscribeUrl;
41
38
  const {
42
39
  subscription
43
- } = await this.apiClient.post(url, {
40
+ } = await api.post(url, {
44
41
  payload
45
42
  });
46
43
  return subscription;
47
44
  }
48
- async updateLicenseUnsubscribeDetails(subscriptionId, payload) {
45
+ async function updateLicenseUnsubscribeDetails(subscriptionId, payload) {
49
46
  const url = _routing.routing.licenseUnsubscribeUrl;
50
47
  const {
51
48
  subscription
52
- } = await this.apiClient.patch(`${url}/${subscriptionId}`, {
49
+ } = await api.patch(`${url}/${subscriptionId}`, {
53
50
  payload
54
51
  });
55
52
  return subscription;
56
53
  }
57
- }
58
- exports.Client = Client;
54
+ return {
55
+ subscribeToNewsroom,
56
+ unsubscribeFromNewsroom,
57
+ unsubscribeFromLicense,
58
+ updateNewsroomUnsubscribeDetails,
59
+ updateLicenseUnsubscribeDetails
60
+ };
61
+ }
@@ -2,13 +2,12 @@ import type { DeferredJobsApiClient } from '../../api';
2
2
  import type { Contact, EmailSubscription, Newsroom } from '../../types';
3
3
  import type { SubscribeRequest, UnsubscribeRequest, UpdateUnsubscribeDetailsRequest } from './types';
4
4
  type NewsroomId = Newsroom['uuid'] | Newsroom['id'];
5
- export declare class Client {
6
- private readonly apiClient;
7
- constructor(apiClient: DeferredJobsApiClient);
8
- subscribeToNewsroom<Type extends Contact.Type>(newsroomId: NewsroomId, payload: SubscribeRequest<Type>): Promise<EmailSubscription>;
9
- unsubscribeFromNewsroom(newsroomId: NewsroomId, payload: UnsubscribeRequest): Promise<EmailSubscription>;
10
- updateNewsroomUnsubscribeDetails(newsroomId: NewsroomId, subscriptionId: EmailSubscription['id'], payload: UpdateUnsubscribeDetailsRequest): Promise<EmailSubscription>;
11
- unsubscribeFromLicense(payload: UnsubscribeRequest): Promise<EmailSubscription>;
12
- updateLicenseUnsubscribeDetails(subscriptionId: EmailSubscription['id'], payload: UpdateUnsubscribeDetailsRequest): Promise<EmailSubscription>;
13
- }
5
+ export type Client = ReturnType<typeof createClient>;
6
+ export declare function createClient(api: DeferredJobsApiClient): {
7
+ subscribeToNewsroom: <Type extends Contact.Type>(newsroomId: NewsroomId, payload: SubscribeRequest<Type>) => Promise<EmailSubscription>;
8
+ unsubscribeFromNewsroom: (newsroomId: NewsroomId, payload: UnsubscribeRequest) => Promise<EmailSubscription>;
9
+ unsubscribeFromLicense: (payload: UnsubscribeRequest) => Promise<EmailSubscription>;
10
+ updateNewsroomUnsubscribeDetails: (newsroomId: NewsroomId, subscriptionId: EmailSubscription['id'], payload: UpdateUnsubscribeDetailsRequest) => Promise<EmailSubscription>;
11
+ updateLicenseUnsubscribeDetails: (subscriptionId: EmailSubscription['id'], payload: UpdateUnsubscribeDetailsRequest) => Promise<EmailSubscription>;
12
+ };
14
13
  export {};
@@ -1,51 +1,55 @@
1
1
  import { routing } from "../../routing.js";
2
- export class Client {
3
- constructor(apiClient) {
4
- this.apiClient = apiClient;
5
- }
6
- async subscribeToNewsroom(newsroomId, payload) {
2
+ export function createClient(api) {
3
+ async function subscribeToNewsroom(newsroomId, payload) {
7
4
  const url = routing.newsroomSubscribeUrl.replace(':newsroom_id', String(newsroomId));
8
5
  const {
9
6
  subscription
10
- } = await this.apiClient.post(url, {
7
+ } = await api.post(url, {
11
8
  payload
12
9
  });
13
10
  return subscription;
14
11
  }
15
- async unsubscribeFromNewsroom(newsroomId, payload) {
12
+ async function unsubscribeFromNewsroom(newsroomId, payload) {
16
13
  const url = routing.newsroomUnsubscribeUrl.replace(':newsroom_id', String(newsroomId));
17
14
  const {
18
15
  subscription
19
- } = await this.apiClient.post(url, {
16
+ } = await api.post(url, {
20
17
  payload
21
18
  });
22
19
  return subscription;
23
20
  }
24
- async updateNewsroomUnsubscribeDetails(newsroomId, subscriptionId, payload) {
21
+ async function updateNewsroomUnsubscribeDetails(newsroomId, subscriptionId, payload) {
25
22
  const url = routing.newsroomUnsubscribeUrl.replace(':newsroom_id', String(newsroomId));
26
23
  const {
27
24
  subscription
28
- } = await this.apiClient.patch(`${url}/${subscriptionId}`, {
25
+ } = await api.patch(`${url}/${subscriptionId}`, {
29
26
  payload
30
27
  });
31
28
  return subscription;
32
29
  }
33
- async unsubscribeFromLicense(payload) {
30
+ async function unsubscribeFromLicense(payload) {
34
31
  const url = routing.licenseUnsubscribeUrl;
35
32
  const {
36
33
  subscription
37
- } = await this.apiClient.post(url, {
34
+ } = await api.post(url, {
38
35
  payload
39
36
  });
40
37
  return subscription;
41
38
  }
42
- async updateLicenseUnsubscribeDetails(subscriptionId, payload) {
39
+ async function updateLicenseUnsubscribeDetails(subscriptionId, payload) {
43
40
  const url = routing.licenseUnsubscribeUrl;
44
41
  const {
45
42
  subscription
46
- } = await this.apiClient.patch(`${url}/${subscriptionId}`, {
43
+ } = await api.patch(`${url}/${subscriptionId}`, {
47
44
  payload
48
45
  });
49
46
  return subscription;
50
47
  }
48
+ return {
49
+ subscribeToNewsroom,
50
+ unsubscribeFromNewsroom,
51
+ unsubscribeFromLicense,
52
+ updateNewsroomUnsubscribeDetails,
53
+ updateLicenseUnsubscribeDetails
54
+ };
51
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "19.9.0",
3
+ "version": "20.0.0",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",