@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
@@ -1,18 +1,15 @@
1
1
  import { routing } from "../../routing.js";
2
2
  import { Query, SortOrder } from "../../types/index.js";
3
3
  import { toIso8601 } from "../../utils.js";
4
- export class Client {
5
- constructor(apiClient) {
6
- this.apiClient = apiClient;
7
- }
8
- async list(options) {
4
+ export function createClient(api) {
5
+ async function list(options) {
9
6
  const {
10
7
  query,
11
8
  limit,
12
9
  offset,
13
10
  sortOrder
14
11
  } = options;
15
- return this.apiClient.get(routing.campaignsUrl, {
12
+ return api.get(routing.campaignsUrl, {
16
13
  query: {
17
14
  limit,
18
15
  offset,
@@ -21,14 +18,14 @@ export class Client {
21
18
  }
22
19
  });
23
20
  }
24
- async search(options) {
21
+ async function search(options) {
25
22
  const {
26
23
  query,
27
24
  limit,
28
25
  offset,
29
26
  sortOrder
30
27
  } = options;
31
- return this.apiClient.post(routing.campaignsUrl, {
28
+ return api.post(routing.campaignsUrl, {
32
29
  payload: {
33
30
  limit,
34
31
  offset,
@@ -37,49 +34,62 @@ export class Client {
37
34
  }
38
35
  });
39
36
  }
40
- async get(id) {
41
- return this.apiClient.get(`${routing.campaignsUrl}/${id}`);
37
+ async function get(id) {
38
+ return api.get(`${routing.campaignsUrl}/${id}`);
42
39
  }
43
- async duplicate(id) {
44
- return this.apiClient.post(`${routing.campaignsUrl}/${id}/duplicate`);
40
+ async function duplicate(id) {
41
+ return api.post(`${routing.campaignsUrl}/${id}/duplicate`);
45
42
  }
46
- async delete(id) {
47
- return this.apiClient.delete(`${routing.campaignsUrl}/${id}`);
43
+ async function doDelete(id) {
44
+ return api.delete(`${routing.campaignsUrl}/${id}`);
48
45
  }
49
- async test(id, emails) {
50
- return this.apiClient.post(`${routing.campaignsUrl}/${id}/test`, {
46
+ async function test(id, emails) {
47
+ return api.post(`${routing.campaignsUrl}/${id}/test`, {
51
48
  payload: {
52
49
  emails
53
50
  }
54
51
  });
55
52
  }
56
- async send(id) {
57
- return this.apiClient.post(`${routing.campaignsUrl}/${id}/send`);
53
+ async function send(id) {
54
+ return api.post(`${routing.campaignsUrl}/${id}/send`);
58
55
  }
59
- async schedule(id, sendAt) {
56
+ async function schedule(id, sendAt) {
60
57
  const {
61
58
  campaign
62
- } = await this.apiClient.post(`${routing.campaignsUrl}/${id}/schedule`, {
59
+ } = await api.post(`${routing.campaignsUrl}/${id}/schedule`, {
63
60
  payload: {
64
61
  schedule_at: toIso8601(sendAt)
65
62
  }
66
63
  });
67
64
  return campaign;
68
65
  }
69
- async unschedule(id) {
66
+ async function unschedule(id) {
70
67
  const {
71
68
  campaign
72
- } = await this.apiClient.post(`${routing.campaignsUrl}/${id}/unschedule`);
69
+ } = await api.post(`${routing.campaignsUrl}/${id}/unschedule`);
73
70
  return campaign;
74
71
  }
75
- async create(payload) {
76
- return this.apiClient.post(routing.campaignsUrl, {
72
+ async function create(payload) {
73
+ return api.post(routing.campaignsUrl, {
77
74
  payload
78
75
  });
79
76
  }
80
- async update(id, payload) {
81
- return this.apiClient.patch(`${routing.campaignsUrl}/${id}`, {
77
+ async function update(id, payload) {
78
+ return api.patch(`${routing.campaignsUrl}/${id}`, {
82
79
  payload
83
80
  });
84
81
  }
82
+ return {
83
+ list,
84
+ search,
85
+ get,
86
+ duplicate,
87
+ test,
88
+ send,
89
+ schedule,
90
+ unschedule,
91
+ create,
92
+ update,
93
+ delete: doDelete
94
+ };
85
95
  }
@@ -3,18 +3,14 @@
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
-
9
+ function createClient(api) {
14
10
  /**
15
11
  * List Contacts Exports with sorting, and pagination.
16
12
  */
17
- async list(options) {
13
+ async function list(options) {
18
14
  const {
19
15
  limit,
20
16
  offset,
@@ -24,7 +20,7 @@ class Client {
24
20
  contacts,
25
21
  pagination,
26
22
  sort
27
- } = await this.apiClient.get(_routing.routing.contactsUrl, {
23
+ } = await api.get(_routing.routing.contactsUrl, {
28
24
  query: {
29
25
  limit,
30
26
  offset,
@@ -41,7 +37,7 @@ class Client {
41
37
  /**
42
38
  * List Contacts Exports with sorting, pagination, and filtering.
43
39
  */
44
- async search(options) {
40
+ async function search(options) {
45
41
  const {
46
42
  limit,
47
43
  offset,
@@ -53,7 +49,7 @@ class Client {
53
49
  contacts,
54
50
  pagination,
55
51
  sort
56
- } = await this.apiClient.post(url, {
52
+ } = await api.post(url, {
57
53
  payload: {
58
54
  limit,
59
55
  offset,
@@ -67,17 +63,17 @@ class Client {
67
63
  sortOrder: _index.SortOrder.parse(sort)
68
64
  };
69
65
  }
70
- async get(id) {
66
+ async function get(id) {
71
67
  const url = `${_routing.routing.contactsUrl}/${id}`;
72
68
  const {
73
69
  contact
74
- } = await this.apiClient.get(url);
70
+ } = await api.get(url);
75
71
  return contact;
76
72
  }
77
- async getMany(ids) {
73
+ async function getMany(ids) {
78
74
  const {
79
75
  contacts
80
- } = await this.search({
76
+ } = await search({
81
77
  query: {
82
78
  id: {
83
79
  $in: ids
@@ -88,51 +84,51 @@ class Client {
88
84
  // Reorder results to match the order of `ids`.
89
85
  return contacts.sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id));
90
86
  }
91
- async create(payload) {
87
+ async function create(payload) {
92
88
  const {
93
89
  contact
94
- } = await this.apiClient.post(_routing.routing.contactsUrl, {
90
+ } = await api.post(_routing.routing.contactsUrl, {
95
91
  payload
96
92
  });
97
93
  return contact;
98
94
  }
99
- async update(id, payload) {
95
+ async function update(id, payload) {
100
96
  const url = `${_routing.routing.contactsUrl}/${id}`;
101
97
  const {
102
98
  contact
103
- } = await this.apiClient.patch(url, {
99
+ } = await api.patch(url, {
104
100
  payload
105
101
  });
106
102
  return contact;
107
103
  }
108
- async tag(id, tags) {
104
+ async function tag(id, tags) {
109
105
  const url = `${_routing.routing.contactsUrl}/${id}`;
110
106
  const {
111
107
  contact
112
- } = await this.apiClient.patch(url, {
108
+ } = await api.patch(url, {
113
109
  payload: {
114
110
  '+tags': tags
115
111
  }
116
112
  });
117
113
  return contact;
118
114
  }
119
- async untag(id, tags) {
115
+ async function untag(id, tags) {
120
116
  const url = `${_routing.routing.contactsUrl}/${id}`;
121
117
  const {
122
118
  contact
123
- } = await this.apiClient.patch(url, {
119
+ } = await api.patch(url, {
124
120
  payload: {
125
121
  '-tags': tags
126
122
  }
127
123
  });
128
124
  return contact;
129
125
  }
130
- async bulkTag(selector, tags) {
126
+ async function bulkTag(selector, tags) {
131
127
  const {
132
128
  scope,
133
129
  query
134
130
  } = selector;
135
- return this.apiClient.patch(_routing.routing.contactsUrl, {
131
+ return api.patch(_routing.routing.contactsUrl, {
136
132
  payload: {
137
133
  query,
138
134
  scope,
@@ -140,12 +136,12 @@ class Client {
140
136
  }
141
137
  });
142
138
  }
143
- async bulkUntag(selector, tags) {
139
+ async function bulkUntag(selector, tags) {
144
140
  const {
145
141
  query,
146
142
  scope
147
143
  } = selector;
148
- return this.apiClient.patch(_routing.routing.contactsUrl, {
144
+ return api.patch(_routing.routing.contactsUrl, {
149
145
  payload: {
150
146
  query,
151
147
  scope,
@@ -153,21 +149,34 @@ class Client {
153
149
  }
154
150
  });
155
151
  }
156
- async delete(id) {
152
+ async function doDelete(id) {
157
153
  const url = `${_routing.routing.contactsUrl}/${id}`;
158
- await this.apiClient.delete(url);
154
+ await api.delete(url);
159
155
  }
160
- async bulkDelete(selector) {
156
+ async function bulkDelete(selector) {
161
157
  const {
162
158
  query,
163
159
  scope
164
160
  } = selector;
165
- return this.apiClient.delete(_routing.routing.contactsUrl, {
161
+ return api.delete(_routing.routing.contactsUrl, {
166
162
  payload: {
167
163
  query,
168
164
  scope
169
165
  }
170
166
  });
171
167
  }
172
- }
173
- exports.Client = Client;
168
+ return {
169
+ list,
170
+ search,
171
+ get,
172
+ getMany,
173
+ create,
174
+ update,
175
+ tag,
176
+ untag,
177
+ bulkTag,
178
+ bulkUntag,
179
+ delete: doDelete,
180
+ bulkDelete
181
+ };
182
+ }
@@ -4,26 +4,19 @@ import type { Contact } from '../../types';
4
4
  import type { BulkDeleteResponse, BulkSelector, CreateRequest, ListOptions, ListResponse, SearchOptions, SearchResponse, UpdateRequest } from './types';
5
5
  type TagId = number;
6
6
  type TagName = string;
7
- export declare class Client {
8
- private readonly apiClient;
9
- constructor(apiClient: DeferredJobsApiClient);
10
- /**
11
- * List Contacts Exports with sorting, and pagination.
12
- */
13
- list(options: ListOptions): Promise<ListResponse>;
14
- /**
15
- * List Contacts Exports with sorting, pagination, and filtering.
16
- */
17
- search(options: SearchOptions): Promise<SearchResponse>;
18
- get(id: Contact['id']): Promise<Contact>;
19
- getMany(ids: Contact['id'][]): Promise<Contact[]>;
20
- create(payload: CreateRequest): Promise<Contact>;
21
- update(id: Contact['id'], payload: UpdateRequest): Promise<Contact>;
22
- tag(id: Contact['id'], tags: (TagId | TagName)[]): Promise<Contact>;
23
- untag(id: Contact['id'], tags: (TagId | TagName)[]): Promise<Contact>;
24
- bulkTag(selector: BulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
25
- bulkUntag(selector: BulkSelector, tags: (TagId | TagName)[]): ProgressPromise<undefined>;
26
- delete(id: Contact['id']): Promise<void>;
27
- bulkDelete(selector: BulkSelector): Promise<BulkDeleteResponse>;
28
- }
7
+ export type Client = ReturnType<typeof createClient>;
8
+ export declare function createClient(api: DeferredJobsApiClient): {
9
+ list: (options: ListOptions) => Promise<ListResponse>;
10
+ search: (options: SearchOptions) => Promise<SearchResponse>;
11
+ get: (id: Contact['id']) => Promise<Contact>;
12
+ getMany: (ids: Contact['id'][]) => Promise<Contact[]>;
13
+ create: (payload: CreateRequest) => Promise<Contact>;
14
+ update: (id: Contact['id'], payload: UpdateRequest) => Promise<Contact>;
15
+ tag: (id: Contact['id'], tags: (TagId | TagName)[]) => Promise<Contact>;
16
+ untag: (id: Contact['id'], tags: (TagId | TagName)[]) => Promise<Contact>;
17
+ bulkTag: (selector: BulkSelector, tags: (TagId | TagName)[]) => ProgressPromise<undefined>;
18
+ bulkUntag: (selector: BulkSelector, tags: (TagId | TagName)[]) => ProgressPromise<undefined>;
19
+ delete: (id: Contact['id']) => Promise<void>;
20
+ bulkDelete: (selector: BulkSelector) => Promise<BulkDeleteResponse>;
21
+ };
29
22
  export {};
@@ -1,14 +1,10 @@
1
1
  import { routing } from "../../routing.js";
2
2
  import { SortOrder } from "../../types/index.js";
3
- export class Client {
4
- constructor(apiClient) {
5
- this.apiClient = apiClient;
6
- }
7
-
3
+ export function createClient(api) {
8
4
  /**
9
5
  * List Contacts Exports with sorting, and pagination.
10
6
  */
11
- async list(options) {
7
+ async function list(options) {
12
8
  const {
13
9
  limit,
14
10
  offset,
@@ -18,7 +14,7 @@ export class Client {
18
14
  contacts,
19
15
  pagination,
20
16
  sort
21
- } = await this.apiClient.get(routing.contactsUrl, {
17
+ } = await api.get(routing.contactsUrl, {
22
18
  query: {
23
19
  limit,
24
20
  offset,
@@ -35,7 +31,7 @@ export class Client {
35
31
  /**
36
32
  * List Contacts Exports with sorting, pagination, and filtering.
37
33
  */
38
- async search(options) {
34
+ async function search(options) {
39
35
  const {
40
36
  limit,
41
37
  offset,
@@ -47,7 +43,7 @@ export class Client {
47
43
  contacts,
48
44
  pagination,
49
45
  sort
50
- } = await this.apiClient.post(url, {
46
+ } = await api.post(url, {
51
47
  payload: {
52
48
  limit,
53
49
  offset,
@@ -61,17 +57,17 @@ export class Client {
61
57
  sortOrder: SortOrder.parse(sort)
62
58
  };
63
59
  }
64
- async get(id) {
60
+ async function get(id) {
65
61
  const url = `${routing.contactsUrl}/${id}`;
66
62
  const {
67
63
  contact
68
- } = await this.apiClient.get(url);
64
+ } = await api.get(url);
69
65
  return contact;
70
66
  }
71
- async getMany(ids) {
67
+ async function getMany(ids) {
72
68
  const {
73
69
  contacts
74
- } = await this.search({
70
+ } = await search({
75
71
  query: {
76
72
  id: {
77
73
  $in: ids
@@ -82,51 +78,51 @@ export class Client {
82
78
  // Reorder results to match the order of `ids`.
83
79
  return contacts.sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id));
84
80
  }
85
- async create(payload) {
81
+ async function create(payload) {
86
82
  const {
87
83
  contact
88
- } = await this.apiClient.post(routing.contactsUrl, {
84
+ } = await api.post(routing.contactsUrl, {
89
85
  payload
90
86
  });
91
87
  return contact;
92
88
  }
93
- async update(id, payload) {
89
+ async function update(id, payload) {
94
90
  const url = `${routing.contactsUrl}/${id}`;
95
91
  const {
96
92
  contact
97
- } = await this.apiClient.patch(url, {
93
+ } = await api.patch(url, {
98
94
  payload
99
95
  });
100
96
  return contact;
101
97
  }
102
- async tag(id, tags) {
98
+ async function tag(id, tags) {
103
99
  const url = `${routing.contactsUrl}/${id}`;
104
100
  const {
105
101
  contact
106
- } = await this.apiClient.patch(url, {
102
+ } = await api.patch(url, {
107
103
  payload: {
108
104
  '+tags': tags
109
105
  }
110
106
  });
111
107
  return contact;
112
108
  }
113
- async untag(id, tags) {
109
+ async function untag(id, tags) {
114
110
  const url = `${routing.contactsUrl}/${id}`;
115
111
  const {
116
112
  contact
117
- } = await this.apiClient.patch(url, {
113
+ } = await api.patch(url, {
118
114
  payload: {
119
115
  '-tags': tags
120
116
  }
121
117
  });
122
118
  return contact;
123
119
  }
124
- async bulkTag(selector, tags) {
120
+ async function bulkTag(selector, tags) {
125
121
  const {
126
122
  scope,
127
123
  query
128
124
  } = selector;
129
- return this.apiClient.patch(routing.contactsUrl, {
125
+ return api.patch(routing.contactsUrl, {
130
126
  payload: {
131
127
  query,
132
128
  scope,
@@ -134,12 +130,12 @@ export class Client {
134
130
  }
135
131
  });
136
132
  }
137
- async bulkUntag(selector, tags) {
133
+ async function bulkUntag(selector, tags) {
138
134
  const {
139
135
  query,
140
136
  scope
141
137
  } = selector;
142
- return this.apiClient.patch(routing.contactsUrl, {
138
+ return api.patch(routing.contactsUrl, {
143
139
  payload: {
144
140
  query,
145
141
  scope,
@@ -147,20 +143,34 @@ export class Client {
147
143
  }
148
144
  });
149
145
  }
150
- async delete(id) {
146
+ async function doDelete(id) {
151
147
  const url = `${routing.contactsUrl}/${id}`;
152
- await this.apiClient.delete(url);
148
+ await api.delete(url);
153
149
  }
154
- async bulkDelete(selector) {
150
+ async function bulkDelete(selector) {
155
151
  const {
156
152
  query,
157
153
  scope
158
154
  } = selector;
159
- return this.apiClient.delete(routing.contactsUrl, {
155
+ return api.delete(routing.contactsUrl, {
160
156
  payload: {
161
157
  query,
162
158
  scope
163
159
  }
164
160
  });
165
161
  }
162
+ return {
163
+ list,
164
+ search,
165
+ get,
166
+ getMany,
167
+ create,
168
+ update,
169
+ tag,
170
+ untag,
171
+ bulkTag,
172
+ bulkUntag,
173
+ delete: doDelete,
174
+ bulkDelete
175
+ };
166
176
  }
@@ -3,24 +3,20 @@
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
-
9
+ function createClient(api) {
14
10
  /**
15
11
  * List Contacts Exports with sorting, and pagination.
16
12
  */
17
- async list(options) {
13
+ async function list(options) {
18
14
  const {
19
15
  limit,
20
16
  offset,
21
17
  sortOrder
22
18
  } = options;
23
- return this.apiClient.get(_routing.routing.contactsExportsUrl, {
19
+ return api.get(_routing.routing.contactsExportsUrl, {
24
20
  query: {
25
21
  limit,
26
22
  offset,
@@ -32,7 +28,7 @@ class Client {
32
28
  /**
33
29
  * List Contacts Exports with sorting, pagination, and filtering.
34
30
  */
35
- async search(options) {
31
+ async function search(options) {
36
32
  const {
37
33
  query,
38
34
  limit,
@@ -40,7 +36,7 @@ class Client {
40
36
  sortOrder
41
37
  } = options;
42
38
  const url = `${_routing.routing.contactsExportsUrl}/search`;
43
- return this.apiClient.post(url, {
39
+ return api.post(url, {
44
40
  payload: {
45
41
  limit,
46
42
  offset,
@@ -53,9 +49,9 @@ class Client {
53
49
  /**
54
50
  * Fetch Contacts Export object by its uuid.
55
51
  */
56
- async get(uuid) {
52
+ async function get(uuid) {
57
53
  const url = `${_routing.routing.contactsExportsUrl}/${uuid}`;
58
- const response = await this.apiClient.get(url);
54
+ const response = await api.get(url);
59
55
  return response.export;
60
56
  }
61
57
 
@@ -67,12 +63,12 @@ class Client {
67
63
  * Otherwise, returns an export with `status: "new"`,
68
64
  * and will notify the user over email when it's done.
69
65
  */
70
- async create(selector) {
66
+ async function create(selector) {
71
67
  const {
72
68
  query,
73
69
  scope
74
70
  } = selector;
75
- const response = await this.apiClient.post(_routing.routing.contactsExportsUrl, {
71
+ const response = await api.post(_routing.routing.contactsExportsUrl, {
76
72
  payload: {
77
73
  contacts: {
78
74
  query,
@@ -88,12 +84,18 @@ class Client {
88
84
  * Only works for exports with status = "done"
89
85
  * Fails with Method Not Allowed (405) error for pending and failed exports.
90
86
  */
91
- async download(uuid) {
87
+ async function download(uuid) {
92
88
  const url = `${_routing.routing.contactsExportsUrl}/${uuid}/download`;
93
- const response = await this.apiClient.post(url);
89
+ const response = await api.post(url);
94
90
  return {
95
91
  downloadUrl: response.download_url
96
92
  };
97
93
  }
98
- }
99
- exports.Client = Client;
94
+ return {
95
+ list,
96
+ search,
97
+ get,
98
+ create,
99
+ download
100
+ };
101
+ }
@@ -1,36 +1,13 @@
1
1
  import type { DeferredJobsApiClient } from '../../api';
2
2
  import type { ContactsExport } from '../../types';
3
3
  import type { ContactsBulkSelector, ListOptions, ListResponse, SearchOptions } from './types';
4
- export declare class Client {
5
- private readonly apiClient;
6
- constructor(apiClient: DeferredJobsApiClient);
7
- /**
8
- * List Contacts Exports with sorting, and pagination.
9
- */
10
- list(options: ListOptions): Promise<ListResponse>;
11
- /**
12
- * List Contacts Exports with sorting, pagination, and filtering.
13
- */
14
- search(options: SearchOptions): Promise<ListResponse>;
15
- /**
16
- * Fetch Contacts Export object by its uuid.
17
- */
18
- get(uuid: ContactsExport['uuid']): Promise<ContactsExport>;
19
- /**
20
- * Request export of the given selection of Contacts.
21
- * If the selection size is small enough, it can be processed right away,
22
- * returning an export with `status: "done"`.
23
- *
24
- * Otherwise, returns an export with `status: "new"`,
25
- * and will notify the user over email when it's done.
26
- */
27
- create(selector: ContactsBulkSelector): Promise<ContactsExport>;
28
- /**
29
- * Fetch a download URL to retrieve the given Contacts Export file.
30
- * Only works for exports with status = "done"
31
- * Fails with Method Not Allowed (405) error for pending and failed exports.
32
- */
33
- download(uuid: ContactsExport['uuid']): Promise<{
4
+ export type Client = ReturnType<typeof createClient>;
5
+ export declare function createClient(api: DeferredJobsApiClient): {
6
+ list: (options: ListOptions) => Promise<ListResponse>;
7
+ search: (options: SearchOptions) => Promise<ListResponse>;
8
+ get: (uuid: ContactsExport['uuid']) => Promise<ContactsExport>;
9
+ create: (selector: ContactsBulkSelector) => Promise<ContactsExport>;
10
+ download: (uuid: ContactsExport['uuid']) => Promise<{
34
11
  downloadUrl: string;
35
12
  }>;
36
- }
13
+ };