@prezly/sdk 19.10.0 → 20.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) 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 +13 -13
  64. package/dist/endpoints/NewsroomSubscriptions/Client.d.ts +6 -10
  65. package/dist/endpoints/NewsroomSubscriptions/Client.js +12 -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/dist/types/UserAccount.d.ts +1 -0
  94. package/package.json +1 -1
package/dist/Client.cjs CHANGED
@@ -17,38 +17,38 @@ function createClient({
17
17
  const http = (0, _index3.createHttpClient)({
18
18
  fetch
19
19
  });
20
- const apiClient = new _index.DeferredJobsApiClient(http, new _index.ApiClient(http, {
20
+ const api = (0, _index.createDeferredJobsApiClient)(http, (0, _index.createApiClient)(http, {
21
21
  accessToken,
22
22
  baseUrl,
23
23
  headers
24
24
  }));
25
25
  return {
26
- api: apiClient,
27
- accounts: new _index2.Accounts.Client(apiClient),
28
- billing: new _index2.Billing.Client(apiClient),
29
- campaigns: new _index2.Campaigns.Client(apiClient),
30
- campaignRecipients: new _index2.CampaignRecipients.Client(apiClient),
31
- contacts: new _index2.Contacts.Client(apiClient),
32
- contactsExports: new _index2.ContactsExports.Client(apiClient),
33
- coverage: new _index2.Coverage.Client(apiClient),
34
- jobs: new _index2.Jobs.Client(apiClient),
35
- licenses: new _index2.Licenses.Client(apiClient),
36
- newsrooms: new _index2.Newsrooms.Client(apiClient),
37
- newsroomCategories: new _index2.NewsroomCategories.Client(apiClient),
38
- newsroomContacts: new _index2.NewsroomContacts.Client(apiClient),
39
- newsroomLanguages: new _index2.NewsroomLanguages.Client(apiClient),
40
- newsroomThemes: new _index2.NewsroomThemes.Client(apiClient),
41
- newsroomWebhooks: new _index2.NewsroomWebhooks.Client(apiClient),
42
- newsroomPrivacyRequests: new _index2.NewsroomPrivacyRequests.Client(apiClient),
43
- newsroomDomains: new _index2.NewsroomDomains.Client(apiClient),
44
- newsroomGalleries: new _index2.NewsroomGalleries.Client(apiClient),
45
- newsroomHub: new _index2.NewsroomHub.Client(apiClient),
46
- newsroomSubscriptions: new _index2.NewsroomSubscriptions.Client(apiClient),
47
- pricingTables: new _index2.PricingTables.Client(apiClient),
48
- senderAddresses: new _index2.SenderAddresses.Client(apiClient),
49
- stories: new _index2.Stories.Client(apiClient),
50
- snippets: new _index2.Snippets.Client(apiClient),
51
- subscriptions: new _index2.Subscriptions.Client(apiClient),
52
- notificationSubscriptions: new _index2.NotificationSubscriptions.Client(apiClient)
26
+ api,
27
+ accounts: _index2.Accounts.createClient(api),
28
+ billing: _index2.Billing.createClient(api),
29
+ campaigns: _index2.Campaigns.createClient(api),
30
+ campaignRecipients: _index2.CampaignRecipients.createClient(api),
31
+ contacts: _index2.Contacts.createClient(api),
32
+ contactsExports: _index2.ContactsExports.createClient(api),
33
+ coverage: _index2.Coverage.createClient(api),
34
+ jobs: _index2.Jobs.createClient(api),
35
+ licenses: _index2.Licenses.createClient(api),
36
+ newsrooms: _index2.Newsrooms.createClient(api),
37
+ newsroomCategories: _index2.NewsroomCategories.createClient(api),
38
+ newsroomContacts: _index2.NewsroomContacts.createClient(api),
39
+ newsroomLanguages: _index2.NewsroomLanguages.createClient(api),
40
+ newsroomThemes: _index2.NewsroomThemes.createClient(api),
41
+ newsroomWebhooks: _index2.NewsroomWebhooks.createClient(api),
42
+ newsroomPrivacyRequests: _index2.NewsroomPrivacyRequests.createClient(api),
43
+ newsroomDomains: _index2.NewsroomDomains.createClient(api),
44
+ newsroomGalleries: _index2.NewsroomGalleries.createClient(api),
45
+ newsroomHub: _index2.NewsroomHub.createClient(api),
46
+ newsroomSubscriptions: _index2.NewsroomSubscriptions.createClient(api),
47
+ pricingTables: _index2.PricingTables.createClient(api),
48
+ senderAddresses: _index2.SenderAddresses.createClient(api),
49
+ stories: _index2.Stories.createClient(api),
50
+ snippets: _index2.Snippets.createClient(api),
51
+ subscriptions: _index2.Subscriptions.createClient(api),
52
+ notificationSubscriptions: _index2.NotificationSubscriptions.createClient(api)
53
53
  };
54
54
  }
package/dist/Client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { DeferredJobsApiClient, type Fetch } from './api';
1
+ import type { DeferredJobsApiClient } from './api';
2
+ import { type Fetch } from './api';
2
3
  import { Contacts } from './endpoints';
3
4
  import { Accounts, Billing, NewsroomSubscriptions, Campaigns, CampaignRecipients, ContactsExports, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, NewsroomHub, PricingTables, SenderAddresses, Stories, Snippets, Subscriptions, NotificationSubscriptions } from './endpoints';
4
5
  import type { HeadersMap } from './http';
package/dist/Client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiClient, DeferredJobsApiClient } from "./api/index.js";
1
+ import { createApiClient, createDeferredJobsApiClient } from "./api/index.js";
2
2
  import { Contacts } from "./endpoints/index.js";
3
3
  import { Accounts, Billing, NewsroomSubscriptions, Campaigns, CampaignRecipients, ContactsExports, Coverage, Jobs, Licenses, Newsrooms, NewsroomCategories, NewsroomContacts, NewsroomLanguages, NewsroomThemes, NewsroomWebhooks, NewsroomPrivacyRequests, NewsroomDomains, NewsroomGalleries, NewsroomHub, PricingTables, SenderAddresses, Stories, Snippets, Subscriptions, NotificationSubscriptions } from "./endpoints/index.js";
4
4
  import { createHttpClient } from "./http/index.js";
@@ -12,38 +12,38 @@ export function createClient({
12
12
  const http = createHttpClient({
13
13
  fetch
14
14
  });
15
- const apiClient = new DeferredJobsApiClient(http, new ApiClient(http, {
15
+ const api = createDeferredJobsApiClient(http, createApiClient(http, {
16
16
  accessToken,
17
17
  baseUrl,
18
18
  headers
19
19
  }));
20
20
  return {
21
- api: apiClient,
22
- accounts: new Accounts.Client(apiClient),
23
- billing: new Billing.Client(apiClient),
24
- campaigns: new Campaigns.Client(apiClient),
25
- campaignRecipients: new CampaignRecipients.Client(apiClient),
26
- contacts: new Contacts.Client(apiClient),
27
- contactsExports: new ContactsExports.Client(apiClient),
28
- coverage: new Coverage.Client(apiClient),
29
- jobs: new Jobs.Client(apiClient),
30
- licenses: new Licenses.Client(apiClient),
31
- newsrooms: new Newsrooms.Client(apiClient),
32
- newsroomCategories: new NewsroomCategories.Client(apiClient),
33
- newsroomContacts: new NewsroomContacts.Client(apiClient),
34
- newsroomLanguages: new NewsroomLanguages.Client(apiClient),
35
- newsroomThemes: new NewsroomThemes.Client(apiClient),
36
- newsroomWebhooks: new NewsroomWebhooks.Client(apiClient),
37
- newsroomPrivacyRequests: new NewsroomPrivacyRequests.Client(apiClient),
38
- newsroomDomains: new NewsroomDomains.Client(apiClient),
39
- newsroomGalleries: new NewsroomGalleries.Client(apiClient),
40
- newsroomHub: new NewsroomHub.Client(apiClient),
41
- newsroomSubscriptions: new NewsroomSubscriptions.Client(apiClient),
42
- pricingTables: new PricingTables.Client(apiClient),
43
- senderAddresses: new SenderAddresses.Client(apiClient),
44
- stories: new Stories.Client(apiClient),
45
- snippets: new Snippets.Client(apiClient),
46
- subscriptions: new Subscriptions.Client(apiClient),
47
- notificationSubscriptions: new NotificationSubscriptions.Client(apiClient)
21
+ api,
22
+ accounts: Accounts.createClient(api),
23
+ billing: Billing.createClient(api),
24
+ campaigns: Campaigns.createClient(api),
25
+ campaignRecipients: CampaignRecipients.createClient(api),
26
+ contacts: Contacts.createClient(api),
27
+ contactsExports: ContactsExports.createClient(api),
28
+ coverage: Coverage.createClient(api),
29
+ jobs: Jobs.createClient(api),
30
+ licenses: Licenses.createClient(api),
31
+ newsrooms: Newsrooms.createClient(api),
32
+ newsroomCategories: NewsroomCategories.createClient(api),
33
+ newsroomContacts: NewsroomContacts.createClient(api),
34
+ newsroomLanguages: NewsroomLanguages.createClient(api),
35
+ newsroomThemes: NewsroomThemes.createClient(api),
36
+ newsroomWebhooks: NewsroomWebhooks.createClient(api),
37
+ newsroomPrivacyRequests: NewsroomPrivacyRequests.createClient(api),
38
+ newsroomDomains: NewsroomDomains.createClient(api),
39
+ newsroomGalleries: NewsroomGalleries.createClient(api),
40
+ newsroomHub: NewsroomHub.createClient(api),
41
+ newsroomSubscriptions: NewsroomSubscriptions.createClient(api),
42
+ pricingTables: PricingTables.createClient(api),
43
+ senderAddresses: SenderAddresses.createClient(api),
44
+ stories: Stories.createClient(api),
45
+ snippets: Snippets.createClient(api),
46
+ subscriptions: Subscriptions.createClient(api),
47
+ notificationSubscriptions: NotificationSubscriptions.createClient(api)
48
48
  };
49
49
  }
@@ -3,93 +3,95 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ApiClient = void 0;
6
+ exports.createApiClient = createApiClient;
7
7
  var _utils = require("../utils.cjs");
8
8
  var _constants = require("./constants.cjs");
9
- class ApiClient {
10
- constructor(http, {
11
- accessToken,
12
- baseUrl,
13
- headers
14
- }) {
15
- this.http = http;
16
- this.baseUrl = baseUrl;
17
- this.headers = {
18
- authorization: `Bearer ${accessToken}`,
19
- 'User-Agent': _constants.DEFAULT_USER_AGENT,
20
- ...headers
21
- };
9
+ function createApiClient(http, {
10
+ accessToken,
11
+ baseUrl,
12
+ headers
13
+ }) {
14
+ const defaultHeaders = {
15
+ authorization: `Bearer ${accessToken}`,
16
+ 'User-Agent': _constants.DEFAULT_USER_AGENT,
17
+ ...headers
18
+ };
19
+ function buildEndpointUrl(endpointUri) {
20
+ return `${(0, _utils.stripSlashes)(baseUrl)}/${(0, _utils.stripSlashes)(endpointUri)}`;
22
21
  }
23
- get(endpointUri, {
22
+ function get(endpointUri, {
24
23
  headers,
25
24
  query
26
25
  } = {}) {
27
- return this.http.get(this.buildEndpointUrl(endpointUri), {
26
+ return http.get(buildEndpointUrl(endpointUri), {
28
27
  headers: {
29
- ...this.headers,
28
+ ...defaultHeaders,
30
29
  ...headers
31
30
  },
32
31
  query
33
32
  });
34
33
  }
35
- post(endpointUri, {
34
+ function post(endpointUri, {
36
35
  headers,
37
36
  payload,
38
37
  query
39
38
  } = {}) {
40
- return this.http.post(this.buildEndpointUrl(endpointUri), {
39
+ return http.post(buildEndpointUrl(endpointUri), {
41
40
  headers: {
42
- ...this.headers,
41
+ ...defaultHeaders,
43
42
  ...headers
44
43
  },
45
44
  payload,
46
45
  query
47
46
  });
48
47
  }
49
- put(endpointUri, {
48
+ function put(endpointUri, {
50
49
  headers,
51
50
  payload,
52
51
  query
53
52
  } = {}) {
54
- return this.http.put(this.buildEndpointUrl(endpointUri), {
53
+ return http.put(buildEndpointUrl(endpointUri), {
55
54
  headers: {
56
- ...this.headers,
55
+ ...defaultHeaders,
57
56
  ...headers
58
57
  },
59
58
  payload,
60
59
  query
61
60
  });
62
61
  }
63
- patch(endpointUri, {
62
+ function patch(endpointUri, {
64
63
  headers,
65
64
  payload,
66
65
  query
67
66
  } = {}) {
68
- return this.http.patch(this.buildEndpointUrl(endpointUri), {
67
+ return http.patch(buildEndpointUrl(endpointUri), {
69
68
  headers: {
70
- ...this.headers,
69
+ ...defaultHeaders,
71
70
  ...headers
72
71
  },
73
72
  payload,
74
73
  query
75
74
  });
76
75
  }
77
- delete(endpointUri, {
76
+ function doDelete(endpointUri, {
78
77
  headers,
79
78
  payload,
80
79
  query
81
80
  } = {}) {
82
- return this.http.delete(this.buildEndpointUrl(endpointUri), {
81
+ return http.delete(buildEndpointUrl(endpointUri), {
83
82
  headers: {
84
- ...this.headers,
83
+ ...defaultHeaders,
85
84
  ...headers
86
85
  },
87
86
  payload,
88
87
  query
89
88
  });
90
89
  }
91
- buildEndpointUrl(endpointUri) {
92
- return `${(0, _utils.stripSlashes)(this.baseUrl)}/${(0, _utils.stripSlashes)(endpointUri)}`;
93
- }
94
- }
95
- exports.ApiClient = ApiClient;
90
+ return {
91
+ get,
92
+ post,
93
+ put,
94
+ patch,
95
+ delete: doDelete
96
+ };
97
+ }
@@ -4,15 +4,11 @@ export interface Options {
4
4
  baseUrl: string;
5
5
  headers: HeadersMap;
6
6
  }
7
- export declare class ApiClient {
8
- private readonly http;
9
- private readonly baseUrl;
10
- private readonly headers;
11
- constructor(http: HttpClient, { accessToken, baseUrl, headers }: Options);
12
- get<V = any>(endpointUri: string, { headers, query }?: Params): Promise<ApiResponse<V>>;
13
- post<V = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): Promise<ApiResponse<V>>;
14
- put<V = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): Promise<ApiResponse<V>>;
15
- patch<V = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): Promise<ApiResponse<V>>;
16
- delete<V = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): Promise<ApiResponse<V>>;
17
- private buildEndpointUrl;
18
- }
7
+ export type ApiClient = ReturnType<typeof createApiClient>;
8
+ export declare function createApiClient(http: HttpClient, { accessToken, baseUrl, headers }: Options): {
9
+ get: <V = any>(endpointUri: string, { headers, query }?: Params) => Promise<ApiResponse<V>>;
10
+ post: <V_1 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_1>>;
11
+ put: <V_2 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_2>>;
12
+ patch: <V_3 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_3>>;
13
+ delete: <V_4 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_4>>;
14
+ };
@@ -1,88 +1,91 @@
1
1
  import { stripSlashes } from "../utils.js";
2
2
  import { DEFAULT_USER_AGENT } from "./constants.js";
3
- export class ApiClient {
4
- constructor(http, {
5
- accessToken,
6
- baseUrl,
7
- headers
8
- }) {
9
- this.http = http;
10
- this.baseUrl = baseUrl;
11
- this.headers = {
12
- authorization: `Bearer ${accessToken}`,
13
- 'User-Agent': DEFAULT_USER_AGENT,
14
- ...headers
15
- };
3
+ export function createApiClient(http, {
4
+ accessToken,
5
+ baseUrl,
6
+ headers
7
+ }) {
8
+ const defaultHeaders = {
9
+ authorization: `Bearer ${accessToken}`,
10
+ 'User-Agent': DEFAULT_USER_AGENT,
11
+ ...headers
12
+ };
13
+ function buildEndpointUrl(endpointUri) {
14
+ return `${stripSlashes(baseUrl)}/${stripSlashes(endpointUri)}`;
16
15
  }
17
- get(endpointUri, {
16
+ function get(endpointUri, {
18
17
  headers,
19
18
  query
20
19
  } = {}) {
21
- return this.http.get(this.buildEndpointUrl(endpointUri), {
20
+ return http.get(buildEndpointUrl(endpointUri), {
22
21
  headers: {
23
- ...this.headers,
22
+ ...defaultHeaders,
24
23
  ...headers
25
24
  },
26
25
  query
27
26
  });
28
27
  }
29
- post(endpointUri, {
28
+ function post(endpointUri, {
30
29
  headers,
31
30
  payload,
32
31
  query
33
32
  } = {}) {
34
- return this.http.post(this.buildEndpointUrl(endpointUri), {
33
+ return http.post(buildEndpointUrl(endpointUri), {
35
34
  headers: {
36
- ...this.headers,
35
+ ...defaultHeaders,
37
36
  ...headers
38
37
  },
39
38
  payload,
40
39
  query
41
40
  });
42
41
  }
43
- put(endpointUri, {
42
+ function put(endpointUri, {
44
43
  headers,
45
44
  payload,
46
45
  query
47
46
  } = {}) {
48
- return this.http.put(this.buildEndpointUrl(endpointUri), {
47
+ return http.put(buildEndpointUrl(endpointUri), {
49
48
  headers: {
50
- ...this.headers,
49
+ ...defaultHeaders,
51
50
  ...headers
52
51
  },
53
52
  payload,
54
53
  query
55
54
  });
56
55
  }
57
- patch(endpointUri, {
56
+ function patch(endpointUri, {
58
57
  headers,
59
58
  payload,
60
59
  query
61
60
  } = {}) {
62
- return this.http.patch(this.buildEndpointUrl(endpointUri), {
61
+ return http.patch(buildEndpointUrl(endpointUri), {
63
62
  headers: {
64
- ...this.headers,
63
+ ...defaultHeaders,
65
64
  ...headers
66
65
  },
67
66
  payload,
68
67
  query
69
68
  });
70
69
  }
71
- delete(endpointUri, {
70
+ function doDelete(endpointUri, {
72
71
  headers,
73
72
  payload,
74
73
  query
75
74
  } = {}) {
76
- return this.http.delete(this.buildEndpointUrl(endpointUri), {
75
+ return http.delete(buildEndpointUrl(endpointUri), {
77
76
  headers: {
78
- ...this.headers,
77
+ ...defaultHeaders,
79
78
  ...headers
80
79
  },
81
80
  payload,
82
81
  query
83
82
  });
84
83
  }
85
- buildEndpointUrl(endpointUri) {
86
- return `${stripSlashes(this.baseUrl)}/${stripSlashes(endpointUri)}`;
87
- }
84
+ return {
85
+ get,
86
+ post,
87
+ put,
88
+ patch,
89
+ delete: doDelete
90
+ };
88
91
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DeferredJobsApiClient = void 0;
6
+ exports.createDeferredJobsApiClient = createDeferredJobsApiClient;
7
7
  var _progressPromise = require("@prezly/progress-promise");
8
8
  var _index = require("../http/index.cjs");
9
9
  var _routing = require("../routing.cjs");
@@ -39,63 +39,65 @@ async function handleDeferredJob(http, request) {
39
39
  }
40
40
  return _progressPromise.ProgressPromise.resolve(response.payload);
41
41
  }
42
- class DeferredJobsApiClient {
43
- constructor(httpClient, apiClient) {
44
- this.http = httpClient;
45
- this.api = apiClient;
46
- }
47
- get(endpointUri, {
42
+ function createDeferredJobsApiClient(http, api) {
43
+ function get(endpointUri, {
48
44
  headers,
49
45
  query
50
46
  } = {}) {
51
- return handleDeferredJob(this.http, this.api.get(endpointUri, {
47
+ return handleDeferredJob(http, api.get(endpointUri, {
52
48
  headers,
53
49
  query
54
50
  }));
55
51
  }
56
- post(endpointUri, {
52
+ function post(endpointUri, {
57
53
  headers,
58
54
  payload,
59
55
  query
60
56
  } = {}) {
61
- return handleDeferredJob(this.http, this.api.post(endpointUri, {
57
+ return handleDeferredJob(http, api.post(endpointUri, {
62
58
  headers,
63
59
  payload,
64
60
  query
65
61
  }));
66
62
  }
67
- put(endpointUri, {
63
+ function put(endpointUri, {
68
64
  headers,
69
65
  payload,
70
66
  query
71
67
  } = {}) {
72
- return handleDeferredJob(this.http, this.api.put(endpointUri, {
68
+ return handleDeferredJob(http, api.put(endpointUri, {
73
69
  headers,
74
70
  payload,
75
71
  query
76
72
  }));
77
73
  }
78
- patch(endpointUri, {
74
+ function patch(endpointUri, {
79
75
  headers,
80
76
  payload,
81
77
  query
82
78
  } = {}) {
83
- return handleDeferredJob(this.http, this.api.patch(endpointUri, {
79
+ return handleDeferredJob(http, api.patch(endpointUri, {
84
80
  headers,
85
81
  payload,
86
82
  query
87
83
  }));
88
84
  }
89
- delete(endpointUri, {
85
+ function doDelete(endpointUri, {
90
86
  headers,
91
87
  payload,
92
88
  query
93
89
  } = {}) {
94
- return handleDeferredJob(this.http, this.api.delete(endpointUri, {
90
+ return handleDeferredJob(http, api.delete(endpointUri, {
95
91
  headers,
96
92
  payload,
97
93
  query
98
94
  }));
99
95
  }
100
- }
101
- exports.DeferredJobsApiClient = DeferredJobsApiClient;
96
+ return {
97
+ get,
98
+ post,
99
+ put,
100
+ patch,
101
+ delete: doDelete
102
+ };
103
+ }
@@ -1,13 +1,11 @@
1
1
  import { ProgressPromise } from '@prezly/progress-promise';
2
2
  import type { HttpClient, Params, ParamsWithPayload } from '../http';
3
3
  import type { ApiClient } from './ApiClient';
4
- export declare class DeferredJobsApiClient {
5
- private readonly http;
6
- private readonly api;
7
- constructor(httpClient: HttpClient, apiClient: ApiClient);
8
- get<V = any, P = any>(endpointUri: string, { headers, query }?: Params): ProgressPromise<V, P>;
9
- post<V = any, P = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): ProgressPromise<V, P>;
10
- put<V = any, P = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): ProgressPromise<V, P>;
11
- patch<V = any, P = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): ProgressPromise<V, P>;
12
- delete<V = any, P = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload): ProgressPromise<V, P>;
13
- }
4
+ export type DeferredJobsApiClient = ReturnType<typeof createDeferredJobsApiClient>;
5
+ export declare function createDeferredJobsApiClient(http: HttpClient, api: ApiClient): {
6
+ get: <V = any, P = any>(endpointUri: string, { headers, query }?: Params) => ProgressPromise<V, P>;
7
+ post: <V_1 = any, P_1 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_1, P_1>;
8
+ put: <V_2 = any, P_2 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_2, P_2>;
9
+ patch: <V_3 = any, P_3 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_3, P_3>;
10
+ delete: <V_4 = any, P_4 = any>(endpointUri: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_4, P_4>;
11
+ };
@@ -33,62 +33,65 @@ async function handleDeferredJob(http, request) {
33
33
  }
34
34
  return ProgressPromise.resolve(response.payload);
35
35
  }
36
- export class DeferredJobsApiClient {
37
- constructor(httpClient, apiClient) {
38
- this.http = httpClient;
39
- this.api = apiClient;
40
- }
41
- get(endpointUri, {
36
+ export function createDeferredJobsApiClient(http, api) {
37
+ function get(endpointUri, {
42
38
  headers,
43
39
  query
44
40
  } = {}) {
45
- return handleDeferredJob(this.http, this.api.get(endpointUri, {
41
+ return handleDeferredJob(http, api.get(endpointUri, {
46
42
  headers,
47
43
  query
48
44
  }));
49
45
  }
50
- post(endpointUri, {
46
+ function post(endpointUri, {
51
47
  headers,
52
48
  payload,
53
49
  query
54
50
  } = {}) {
55
- return handleDeferredJob(this.http, this.api.post(endpointUri, {
51
+ return handleDeferredJob(http, api.post(endpointUri, {
56
52
  headers,
57
53
  payload,
58
54
  query
59
55
  }));
60
56
  }
61
- put(endpointUri, {
57
+ function put(endpointUri, {
62
58
  headers,
63
59
  payload,
64
60
  query
65
61
  } = {}) {
66
- return handleDeferredJob(this.http, this.api.put(endpointUri, {
62
+ return handleDeferredJob(http, api.put(endpointUri, {
67
63
  headers,
68
64
  payload,
69
65
  query
70
66
  }));
71
67
  }
72
- patch(endpointUri, {
68
+ function patch(endpointUri, {
73
69
  headers,
74
70
  payload,
75
71
  query
76
72
  } = {}) {
77
- return handleDeferredJob(this.http, this.api.patch(endpointUri, {
73
+ return handleDeferredJob(http, api.patch(endpointUri, {
78
74
  headers,
79
75
  payload,
80
76
  query
81
77
  }));
82
78
  }
83
- delete(endpointUri, {
79
+ function doDelete(endpointUri, {
84
80
  headers,
85
81
  payload,
86
82
  query
87
83
  } = {}) {
88
- return handleDeferredJob(this.http, this.api.delete(endpointUri, {
84
+ return handleDeferredJob(http, api.delete(endpointUri, {
89
85
  headers,
90
86
  payload,
91
87
  query
92
88
  }));
93
89
  }
90
+ return {
91
+ get,
92
+ post,
93
+ put,
94
+ patch,
95
+ delete: doDelete
96
+ };
94
97
  }
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_USER_AGENT = void 0;
7
- const VERSION = "19.9.0";
7
+ const VERSION = "20.0.0";
8
8
  const URL = 'https://github.com/prezly/javascript-sdk';
9
9
  const DEFAULT_USER_AGENT = exports.DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -1,3 +1,3 @@
1
- const VERSION = "19.9.0";
1
+ const VERSION = "20.0.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;