@prezly/sdk 20.4.0 → 20.5.1

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.
@@ -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 = "20.2.0";
7
+ const VERSION = "20.5.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 = "20.2.0";
1
+ const VERSION = "20.5.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -15,7 +15,7 @@ function createClient(api) {
15
15
  } = options;
16
16
  const {
17
17
  tags
18
- } = await api.get(_routing.routing.contactsTagsUrl, {
18
+ } = await api.get(_routing.routing.contactTagsUrl, {
19
19
  query: {
20
20
  sort: _index.SortOrder.stringify(sortOrder)
21
21
  }
@@ -31,7 +31,7 @@ function createClient(api) {
31
31
  } = options;
32
32
  const {
33
33
  tags
34
- } = await api.post(_routing.routing.contactsTagsUrl, {
34
+ } = await api.post(_routing.routing.contactTagsUrl, {
35
35
  query: {
36
36
  sort: _index.SortOrder.stringify(sortOrder),
37
37
  query: _index.Query.stringify(query)
@@ -42,7 +42,7 @@ function createClient(api) {
42
42
  };
43
43
  }
44
44
  async function get(id) {
45
- const url = `${_routing.routing.contactsTagsUrl}/${id}`;
45
+ const url = `${_routing.routing.contactTagsUrl}/${id}`;
46
46
  const {
47
47
  tag
48
48
  } = await api.get(url);
@@ -51,7 +51,7 @@ function createClient(api) {
51
51
  async function create(payload, {
52
52
  force = false
53
53
  } = {}) {
54
- const data = await api.post(_routing.routing.contactsTagsUrl, {
54
+ const data = await api.post(_routing.routing.contactTagsUrl, {
55
55
  payload,
56
56
  query: {
57
57
  force: force || undefined // Convert `false` to `undefined`
@@ -65,7 +65,7 @@ function createClient(api) {
65
65
  async function update(id, payload, {
66
66
  force = false
67
67
  } = {}) {
68
- const url = `${_routing.routing.contactsTagsUrl}/${id}`;
68
+ const url = `${_routing.routing.contactTagsUrl}/${id}`;
69
69
  const data = await api.patch(url, {
70
70
  payload,
71
71
  query: {
@@ -81,7 +81,7 @@ function createClient(api) {
81
81
  name,
82
82
  tags
83
83
  }) {
84
- const url = `${_routing.routing.contactsTagsUrl}/merge`;
84
+ const url = `${_routing.routing.contactTagsUrl}/merge`;
85
85
  const data = await api.post(url, {
86
86
  payload: {
87
87
  name,
@@ -94,14 +94,24 @@ function createClient(api) {
94
94
  };
95
95
  }
96
96
  async function doDelete(id) {
97
- const url = `${_routing.routing.contactsTagsUrl}/${id}`;
97
+ const url = `${_routing.routing.contactTagsUrl}/${id}`;
98
98
  const data = await api.delete(url);
99
99
  return {
100
100
  deleted: data.deleted_tags_ids
101
101
  };
102
102
  }
103
+ async function doDeleteMany(ids) {
104
+ const data = await api.delete(_routing.routing.contactTagsUrl, {
105
+ query: {
106
+ id: ids
107
+ }
108
+ });
109
+ return {
110
+ deleted: data.deleted_tags_ids
111
+ };
112
+ }
103
113
  async function doDeleteUnused() {
104
- const data = await api.delete(_routing.routing.contactsTagsUrl, {
114
+ const data = await api.delete(_routing.routing.contactTagsUrl, {
105
115
  query: {
106
116
  filter: 'unused'
107
117
  }
@@ -118,6 +128,7 @@ function createClient(api) {
118
128
  update,
119
129
  merge,
120
130
  delete: doDelete,
131
+ deleteMany: doDeleteMany,
121
132
  deleteUnused: doDeleteUnused
122
133
  };
123
134
  }
@@ -12,6 +12,9 @@ export declare function createClient(api: DeferredJobsApiClient): {
12
12
  delete: (id: ContactTag['id']) => Promise<{
13
13
  deleted: number[];
14
14
  }>;
15
+ deleteMany: (ids: ContactTag['id'][]) => Promise<{
16
+ deleted: number[];
17
+ }>;
15
18
  deleteUnused: () => Promise<{
16
19
  deleted: number[];
17
20
  }>;
@@ -1,6 +1,5 @@
1
1
  import { routing } from "../../routing.js";
2
- import { Query } from "../../types/index.js";
3
- import { SortOrder } from "../../types/index.js"; // Not putting these into the `./types` module to keep it local.
2
+ import { Query, SortOrder } from "../../types/index.js"; // Not putting these into the `./types` module to keep it local.
4
3
  export function createClient(api) {
5
4
  async function list(options = {}) {
6
5
  const {
@@ -8,7 +7,7 @@ export function createClient(api) {
8
7
  } = options;
9
8
  const {
10
9
  tags
11
- } = await api.get(routing.contactsTagsUrl, {
10
+ } = await api.get(routing.contactTagsUrl, {
12
11
  query: {
13
12
  sort: SortOrder.stringify(sortOrder)
14
13
  }
@@ -24,7 +23,7 @@ export function createClient(api) {
24
23
  } = options;
25
24
  const {
26
25
  tags
27
- } = await api.post(routing.contactsTagsUrl, {
26
+ } = await api.post(routing.contactTagsUrl, {
28
27
  query: {
29
28
  sort: SortOrder.stringify(sortOrder),
30
29
  query: Query.stringify(query)
@@ -35,7 +34,7 @@ export function createClient(api) {
35
34
  };
36
35
  }
37
36
  async function get(id) {
38
- const url = `${routing.contactsTagsUrl}/${id}`;
37
+ const url = `${routing.contactTagsUrl}/${id}`;
39
38
  const {
40
39
  tag
41
40
  } = await api.get(url);
@@ -44,7 +43,7 @@ export function createClient(api) {
44
43
  async function create(payload, {
45
44
  force = false
46
45
  } = {}) {
47
- const data = await api.post(routing.contactsTagsUrl, {
46
+ const data = await api.post(routing.contactTagsUrl, {
48
47
  payload,
49
48
  query: {
50
49
  force: force || undefined // Convert `false` to `undefined`
@@ -58,7 +57,7 @@ export function createClient(api) {
58
57
  async function update(id, payload, {
59
58
  force = false
60
59
  } = {}) {
61
- const url = `${routing.contactsTagsUrl}/${id}`;
60
+ const url = `${routing.contactTagsUrl}/${id}`;
62
61
  const data = await api.patch(url, {
63
62
  payload,
64
63
  query: {
@@ -74,7 +73,7 @@ export function createClient(api) {
74
73
  name,
75
74
  tags
76
75
  }) {
77
- const url = `${routing.contactsTagsUrl}/merge`;
76
+ const url = `${routing.contactTagsUrl}/merge`;
78
77
  const data = await api.post(url, {
79
78
  payload: {
80
79
  name,
@@ -87,14 +86,24 @@ export function createClient(api) {
87
86
  };
88
87
  }
89
88
  async function doDelete(id) {
90
- const url = `${routing.contactsTagsUrl}/${id}`;
89
+ const url = `${routing.contactTagsUrl}/${id}`;
91
90
  const data = await api.delete(url);
92
91
  return {
93
92
  deleted: data.deleted_tags_ids
94
93
  };
95
94
  }
95
+ async function doDeleteMany(ids) {
96
+ const data = await api.delete(routing.contactTagsUrl, {
97
+ query: {
98
+ id: ids
99
+ }
100
+ });
101
+ return {
102
+ deleted: data.deleted_tags_ids
103
+ };
104
+ }
96
105
  async function doDeleteUnused() {
97
- const data = await api.delete(routing.contactsTagsUrl, {
106
+ const data = await api.delete(routing.contactTagsUrl, {
98
107
  query: {
99
108
  filter: 'unused'
100
109
  }
@@ -111,6 +120,7 @@ export function createClient(api) {
111
120
  update,
112
121
  merge,
113
122
  delete: doDelete,
123
+ deleteMany: doDeleteMany,
114
124
  deleteUnused: doDeleteUnused
115
125
  };
116
126
  }
package/dist/routing.cjs CHANGED
@@ -11,7 +11,7 @@ const routing = exports.routing = {
11
11
  campaignRecipientsUrl: '/v2/campaigns/:campaign_id/recipients',
12
12
  contactsExportsUrl: '/v2/contacts/exports',
13
13
  contactsUrl: '/v2/contacts',
14
- contactsTagsUrl: '/v2/contacts-tags',
14
+ contactTagsUrl: '/v2/contact-tags',
15
15
  coverageUrl: '/v2/coverage',
16
16
  jobsUrl: '/v2/jobs',
17
17
  licenseUrl: '/v2/licenses',
package/dist/routing.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const routing: {
5
5
  campaignRecipientsUrl: string;
6
6
  contactsExportsUrl: string;
7
7
  contactsUrl: string;
8
- contactsTagsUrl: string;
8
+ contactTagsUrl: string;
9
9
  coverageUrl: string;
10
10
  jobsUrl: string;
11
11
  licenseUrl: string;
package/dist/routing.js CHANGED
@@ -5,7 +5,7 @@ export const routing = {
5
5
  campaignRecipientsUrl: '/v2/campaigns/:campaign_id/recipients',
6
6
  contactsExportsUrl: '/v2/contacts/exports',
7
7
  contactsUrl: '/v2/contacts',
8
- contactsTagsUrl: '/v2/contacts-tags',
8
+ contactTagsUrl: '/v2/contact-tags',
9
9
  coverageUrl: '/v2/coverage',
10
10
  jobsUrl: '/v2/jobs',
11
11
  licenseUrl: '/v2/licenses',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "20.4.0",
3
+ "version": "20.5.1",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",