@signalhousellc/sdk 1.0.43 → 1.0.45

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.
package/README.md CHANGED
@@ -1,38 +1,38 @@
1
- # @signalhouse/sdk
2
-
3
- A lightweight Node.js SDK for the Signal House platform.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @signalhouse/sdk
9
- ```
10
-
11
- Quick Start
12
-
13
- ```bash
14
- import { SignalHouseSDK } from '@signalhouse/sdk';
15
-
16
- const sdk = new SignalHouseSDK({
17
- apiKey: 'your-api-key',
18
- baseUrl: 'api url'
19
- });
20
-
21
- const token = await sdk.auth.login({
22
- email: 'youremail',
23
- password: 'yourpassword'
24
- });
25
-
26
- console.log(token);
27
- ```
28
-
29
- Features
30
- Full support for Signal House API v2
31
- Integrated Axios with standardized returns
32
- Lightweight and tree-shakeable
33
-
34
- Documentation
35
- For full API reference and advanced usage, visit https://api.signalhouse.io
36
-
37
- License
38
- ISC © Signal House
1
+ # @signalhouse/sdk
2
+
3
+ A lightweight Node.js SDK for the Signal House platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @signalhouse/sdk
9
+ ```
10
+
11
+ Quick Start
12
+
13
+ ```bash
14
+ import { SignalHouseSDK } from '@signalhouse/sdk';
15
+
16
+ const sdk = new SignalHouseSDK({
17
+ apiKey: 'your-api-key',
18
+ baseUrl: 'api url'
19
+ });
20
+
21
+ const token = await sdk.auth.login({
22
+ email: 'youremail',
23
+ password: 'yourpassword'
24
+ });
25
+
26
+ console.log(token);
27
+ ```
28
+
29
+ Features
30
+ Full support for Signal House API v2
31
+ Integrated Axios with standardized returns
32
+ Lightweight and tree-shakeable
33
+
34
+ Documentation
35
+ For full API reference and advanced usage, visit https://api.signalhouse.io
36
+
37
+ License
38
+ ISC © Signal House
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalhousellc/sdk",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Signal House SDK for use with the Signal House platform",
5
5
  "type": "module",
6
6
  "main": "src/SignalHouseSDK.js",
@@ -1,54 +1,54 @@
1
- export class Auth {
2
- constructor(client, enableAdmin) {
3
- this.client = client;
4
- this.enableAdmin = enableAdmin;
5
- }
6
-
7
- /**
8
- * Login with email and password
9
- * @async
10
- * @roles public
11
- * @param {Object} params
12
- * @param {string} params.email - The user's email address
13
- * @param {string} params.password - The user's password
14
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
15
- * @returns {Promise<Object>} The response from the server
16
- */
17
- async login({ email, password, options = {} }) {
18
- return this.client(`/auth`, { method: "POST", body: { email, password }, ...options });
19
- }
20
-
21
- /**
22
- * Reset a user's password
23
- * @async
24
- * @roles api, admin, self
25
- * @param {Object} params
26
- * @param {string} params.userId - The id of the user
27
- * @param {string} params.newPassword - The new password to set for the user
28
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
- * @returns {Promise<Object>} The response from the server
30
- */
31
- async resetPassword({ userId, newPassword, options = {} }) {
32
- this.client._require({ userId, newPassword });
33
- const safeUserId = encodeURIComponent(userId);
34
- return this.client(`/auth/resetpassword/${safeUserId}`, { method: "PUT", body: { newPassword }, ...options });
35
- }
36
-
37
- /**
38
- * Get token login history for a group or user
39
- * @async
40
- * @roles signalhouse_admin, signalhouse_api, signalhouse_user, admin, api (groupId query); self (userId query)
41
- * @param {Object} params
42
- * @param {string} [params.groupId] - Returns history for all users in the group (one of groupId/userId required)
43
- * @param {string} [params.userId] - Returns history for a specific user (one of groupId/userId required)
44
- * @param {number} [params.page] - Page number (min 1, default 1)
45
- * @param {number} [params.limit] - Results per page (min 1, max 100, default 20)
46
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
- * @returns {Promise<Object>} The response from the server
48
- */
49
- async getAuthHistory({ groupId, userId, page, limit, options = {} }) {
50
- this.client._require({ "groupId or userId": groupId ?? userId });
51
- const queryString = this.client._getQueryString({ groupId, userId, page, limit });
52
- return this.client(`/auth/history${queryString}`, { method: "GET", ...options });
53
- }
54
- }
1
+ export class Auth {
2
+ constructor(client, enableAdmin) {
3
+ this.client = client;
4
+ this.enableAdmin = enableAdmin;
5
+ }
6
+
7
+ /**
8
+ * Login with email and password
9
+ * @async
10
+ * @roles public
11
+ * @param {Object} params
12
+ * @param {string} params.email - The user's email address
13
+ * @param {string} params.password - The user's password
14
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
15
+ * @returns {Promise<Object>} The response from the server
16
+ */
17
+ async login({ email, password, options = {} }) {
18
+ return this.client(`/auth`, { method: "POST", body: { email, password }, ...options });
19
+ }
20
+
21
+ /**
22
+ * Reset a user's password
23
+ * @async
24
+ * @roles api, admin, self
25
+ * @param {Object} params
26
+ * @param {string} params.userId - The id of the user
27
+ * @param {string} params.newPassword - The new password to set for the user
28
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
+ * @returns {Promise<Object>} The response from the server
30
+ */
31
+ async resetPassword({ userId, newPassword, options = {} }) {
32
+ this.client._require({ userId, newPassword });
33
+ const safeUserId = encodeURIComponent(userId);
34
+ return this.client(`/auth/resetpassword/${safeUserId}`, { method: "PUT", body: { newPassword }, ...options });
35
+ }
36
+
37
+ /**
38
+ * Get token login history for a group or user
39
+ * @async
40
+ * @roles signalhouse_admin, signalhouse_api, signalhouse_user, admin, api (groupId query); self (userId query)
41
+ * @param {Object} params
42
+ * @param {string} [params.groupId] - Returns history for all users in the group (one of groupId/userId required)
43
+ * @param {string} [params.userId] - Returns history for a specific user (one of groupId/userId required)
44
+ * @param {number} [params.page] - Page number (min 1, default 1)
45
+ * @param {number} [params.limit] - Results per page (min 1, max 100, default 20)
46
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
+ * @returns {Promise<Object>} The response from the server
48
+ */
49
+ async getAuthHistory({ groupId, userId, page, limit, options = {} }) {
50
+ this.client._require({ "groupId or userId": groupId ?? userId });
51
+ const queryString = this.client._getQueryString({ groupId, userId, page, limit });
52
+ return this.client(`/auth/history${queryString}`, { method: "GET", ...options });
53
+ }
54
+ }
@@ -1,90 +1,90 @@
1
- export class Groups {
2
- constructor(client, enableAdmin) {
3
- this.client = client;
4
- this.enableAdmin = enableAdmin;
5
-
6
- // Hidden Admin namespace INSIDE the domain
7
- if (enableAdmin) {
8
- this.admin = {
9
- /**
10
- * Get a list of all groups with optional pagination parameters
11
- * @async
12
- * @roles signalhouse
13
- * @param {Object} params - The parameters for getting groups
14
- * @param {number} [params.page] - The page number for pagination
15
- * @param {number} [params.limit] - The number of items per page
16
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
17
- * @returns {Promise<Object>} - The list of groups returned from the server
18
- */
19
- getGroups: async ({ page, limit, options = {} }) => {
20
- const filters = { page, limit };
21
- const queryString = this.client._getQueryString(filters);
22
- return this.client(`/group${queryString}`, { method: "GET", ...options });
23
- },
24
-
25
- /**
26
- * Create a new group with the specified group data
27
- * @async
28
- * @roles signalhouse
29
- * @param {Object} params - The parameters for creating a new group
30
- * @param {Object} params.groupData - The data for the new group, including required fields such as groupName
31
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
32
- * @throws {Error} Throws an error if the groupData parameter is missing or if required fields within groupData are missing
33
- * @returns {Promise<Object>} - The created group object returned from the server
34
- */
35
- createGroup: async ({ groupData, options = {} }) => {
36
- this.client._require({ groupData: groupData });
37
- return this.client(`/group`, { method: "POST", body: groupData, ...options });
38
- },
39
-
40
- /**
41
- * Delete a group with the specified group ID
42
- * @async
43
- * @roles signalhouse
44
- * @param {Object} params - The parameters for deleting a group
45
- * @param {string} params.groupId - The ID of the group to delete
46
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
- * @throws {Error} Throws an error if the groupId parameter is missing
48
- * @returns {Promise<Object>} - The deleted group object returned from the server
49
- */
50
- deleteGroup: async ({ groupId, options = {} }) => {
51
- this.client._require({ groupId });
52
- const safeGroupId = encodeURIComponent(groupId);
53
- return this.client(`/group/${safeGroupId}`, { method: "DELETE", ...options });
54
- },
55
- };
56
- }
57
- }
58
-
59
- /**
60
- * Get details of a group by its ID
61
- * @async
62
- * @roles api, admin, developer, billing, user
63
- * @param {Object} params - The parameters for getting a group
64
- * @param {string} params.id - The ID of the group to retrieve
65
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
66
- * @returns {Promise<Object>} - The group object returned from the server
67
- */
68
- async getGroup({ id, options = {} }) {
69
- const filters = { id };
70
- const queryString = this.client._getQueryString(filters);
71
- return this.client(`/group${queryString}`, { method: "GET", ...options });
72
- }
73
-
74
- /**
75
- * Update a group with the specified group data
76
- * @async
77
- * @roles api, admin, developer, billing
78
- * @param {Object} params - The parameters for updating a group
79
- * @param {string} params.id - The ID of the group to update
80
- * @param {Object} params.groupData - The data for the group, including required fields such as groupName
81
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
82
- * @throws {Error} Throws an error if the id or groupData parameter is missing
83
- * @returns {Promise<Object>} - The updated group object returned from the server
84
- */
85
- async updateGroup({ id, groupData, options = {} }) {
86
- this.client._require({ id, groupData: groupData });
87
- const safeId = encodeURIComponent(id);
88
- return this.client(`/group/${safeId}`, { method: "PUT", body: groupData, ...options });
89
- }
90
- }
1
+ export class Groups {
2
+ constructor(client, enableAdmin) {
3
+ this.client = client;
4
+ this.enableAdmin = enableAdmin;
5
+
6
+ // Hidden Admin namespace INSIDE the domain
7
+ if (enableAdmin) {
8
+ this.admin = {
9
+ /**
10
+ * Get a list of all groups with optional pagination parameters
11
+ * @async
12
+ * @roles signalhouse
13
+ * @param {Object} params - The parameters for getting groups
14
+ * @param {number} [params.page] - The page number for pagination
15
+ * @param {number} [params.limit] - The number of items per page
16
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
17
+ * @returns {Promise<Object>} - The list of groups returned from the server
18
+ */
19
+ getGroups: async ({ page, limit, options = {} }) => {
20
+ const filters = { page, limit };
21
+ const queryString = this.client._getQueryString(filters);
22
+ return this.client(`/group${queryString}`, { method: "GET", ...options });
23
+ },
24
+
25
+ /**
26
+ * Create a new group with the specified group data
27
+ * @async
28
+ * @roles signalhouse
29
+ * @param {Object} params - The parameters for creating a new group
30
+ * @param {Object} params.groupData - The data for the new group, including required fields such as groupName
31
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
32
+ * @throws {Error} Throws an error if the groupData parameter is missing or if required fields within groupData are missing
33
+ * @returns {Promise<Object>} - The created group object returned from the server
34
+ */
35
+ createGroup: async ({ groupData, options = {} }) => {
36
+ this.client._require({ groupData: groupData });
37
+ return this.client(`/group`, { method: "POST", body: groupData, ...options });
38
+ },
39
+
40
+ /**
41
+ * Delete a group with the specified group ID
42
+ * @async
43
+ * @roles signalhouse
44
+ * @param {Object} params - The parameters for deleting a group
45
+ * @param {string} params.groupId - The ID of the group to delete
46
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
+ * @throws {Error} Throws an error if the groupId parameter is missing
48
+ * @returns {Promise<Object>} - The deleted group object returned from the server
49
+ */
50
+ deleteGroup: async ({ groupId, options = {} }) => {
51
+ this.client._require({ groupId });
52
+ const safeGroupId = encodeURIComponent(groupId);
53
+ return this.client(`/group/${safeGroupId}`, { method: "DELETE", ...options });
54
+ },
55
+ };
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Get details of a group by its ID
61
+ * @async
62
+ * @roles api, admin, developer, billing, user
63
+ * @param {Object} params - The parameters for getting a group
64
+ * @param {string} params.id - The ID of the group to retrieve
65
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
66
+ * @returns {Promise<Object>} - The group object returned from the server
67
+ */
68
+ async getGroup({ id, options = {} }) {
69
+ const filters = { id };
70
+ const queryString = this.client._getQueryString(filters);
71
+ return this.client(`/group${queryString}`, { method: "GET", ...options });
72
+ }
73
+
74
+ /**
75
+ * Update a group with the specified group data
76
+ * @async
77
+ * @roles api, admin, developer, billing
78
+ * @param {Object} params - The parameters for updating a group
79
+ * @param {string} params.id - The ID of the group to update
80
+ * @param {Object} params.groupData - The data for the group, including required fields such as groupName
81
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
82
+ * @throws {Error} Throws an error if the id or groupData parameter is missing
83
+ * @returns {Promise<Object>} - The updated group object returned from the server
84
+ */
85
+ async updateGroup({ id, groupData, options = {} }) {
86
+ this.client._require({ id, groupData: groupData });
87
+ const safeId = encodeURIComponent(id);
88
+ return this.client(`/group/${safeId}`, { method: "PUT", body: groupData, ...options });
89
+ }
90
+ }
@@ -1,132 +1,132 @@
1
- /**
2
- * @typedef {Object} CreateLandingData
3
- * @property {string} brandId - The ID of the brand to associate with the landing page
4
- * @property {string} description - A description of the landing page
5
- * @property {string} primaryBackgroundColor - The primary background color for the landing page (e.g., "#FFFFFF")
6
- * @property {string} secondaryBackgroundColor - The secondary background color for the landing page (e.g., "#F0F0F0")
7
- * @property {string} primaryTextColor - The primary text color for the landing page (e.g., "#000000")
8
- * @property {string} secondaryTextColor - The secondary text color for the landing page (e.g., "#333333")
9
- * @property {Buffer} logo - A logo image file for the landing page, provided as a Buffer
10
- */
11
-
12
- /**
13
- * @typedef {Object} UpdateLandingData
14
- * @property {string} [description] - A description of the landing page
15
- * @property {string} [primaryBackgroundColor] - The primary background color for the landing page (e.g., "#FFFFFF")
16
- * @property {string} [secondaryBackgroundColor] - The secondary background color for the landing page (e.g., "#F0F0F0")
17
- * @property {string} [primaryTextColor] - The primary text color for the landing page (e.g., "#000000")
18
- * @property {string} [secondaryTextColor] - The secondary text color for the landing page (e.g., "#333333")
19
- * @property {Buffer} [logo] - A logo image file for the landing page, provided as a Buffer
20
- */
21
-
22
- export class Landings {
23
- constructor(client, multipartClient, enableAdmin) {
24
- this.client = client;
25
- this.multipartClient = multipartClient;
26
- this.enableAdmin = enableAdmin;
27
- }
28
-
29
- /**
30
- * Get details of a landing page by its ID
31
- * @async
32
- * @roles api, admin, developer, billing, user
33
- * @param {Object} params - The parameters for getting a landing page
34
- * @param {string} params.landingId - The ID of the landing page to retrieve
35
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
- * @throws {Error} Throws an error if the landingId parameter is missing
37
- * @returns {Promise<Object>} - The landing page object returned from the server
38
- */
39
- async getLandings({ landingId, options = {} }) {
40
- this.client._require({ landingId });
41
- const safeLandingId = encodeURIComponent(landingId);
42
- return this.client(`/landing/${safeLandingId}`, { method: "GET", ...options });
43
- }
44
-
45
- /**
46
- * Create a new landing page with the specified landing data and logo file
47
- * @async
48
- * @roles api, admin, developer, billing, user
49
- * @param {Object} params - The parameters for creating a new landing page (see CreateLandingData typedef for details)
50
- * @param {CreateLandingData} params.landingData - The data for the new landing page, including required fields such as brandId and description
51
- * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
52
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
53
- * @returns {Promise<Object>} - The newly created landing page object returned from the server
54
- */
55
- async createLanding({ landingData, file, options = {} }) {
56
- const formData = new FormData();
57
-
58
- if (file) {
59
- formData.append("file", file);
60
- }
61
-
62
- Object.entries(landingData).forEach(([key, value]) => {
63
- if (value !== undefined) {
64
- formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
65
- }
66
- });
67
-
68
- return this.multipartClient(`/landing`, { method: "POST", body: formData, ...options });
69
- }
70
-
71
- /**
72
- * Update an existing landing page with the specified landing data and logo file
73
- * @async
74
- * @roles api, admin, developer, billing, user
75
- * @param {Object} params - The parameters for updating a landing page (see UpdateLandingData typedef for details)
76
- * @param {string} params.landingId - The ID of the landing page to update
77
- * @param {UpdateLandingData} params.landingData - The data for the landing page, including required fields such as brandId and description
78
- * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
79
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
80
- * @throws {Error} Throws an error if the landingId parameter is missing
81
- * @returns {Promise<Object>} - The updated landing page object returned from the server
82
- */
83
- async updateLanding({ landingId, landingData, file, options = {} }) {
84
- this.client._require({ landingId });
85
- const safeLandingId = encodeURIComponent(landingId);
86
- const formData = new FormData();
87
-
88
- if (file) {
89
- formData.append("file", file);
90
- }
91
-
92
- Object.entries(landingData).forEach(([key, value]) => {
93
- if (value !== undefined) {
94
- formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
95
- }
96
- });
97
-
98
- return this.multipartClient(`/landing/${safeLandingId}`, { method: "PUT", body: formData, ...options });
99
- }
100
-
101
- /**
102
- * Delete a landing page by its ID
103
- * @async
104
- * @roles api, admin, developer, billing, user
105
- * @param {Object} params - The parameters for deleting a landing page
106
- * @param {string} params.landingId - The ID of the landing page to delete
107
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
108
- * @throws {Error} Throws an error if the landingId parameter is missing
109
- * @returns {Promise<Object>} - The response from the server after deleting the landing page
110
- */
111
- /**
112
- * Get a landing page by its associated brand ID
113
- * @async
114
- * @roles api, admin, developer, billing, user
115
- * @param {Object} params - The parameters for getting a landing page by brand
116
- * @param {string} params.brandId - The brand ID to look up the landing page for
117
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
118
- * @throws {Error} Throws an error if the brandId parameter is missing
119
- * @returns {Promise<Object>} - The landing page object returned from the server
120
- */
121
- async getLandingByBrandId({ brandId, options = {} }) {
122
- this.client._require({ brandId });
123
- const safeBrandId = encodeURIComponent(brandId);
124
- return this.client(`/landing/brand/${safeBrandId}`, { method: "GET", ...options });
125
- }
126
-
127
- async deleteLanding({ landingId, options = {} }) {
128
- this.client._require({ landingId });
129
- const safeLandingId = encodeURIComponent(landingId);
130
- return this.client(`/landing/${safeLandingId}`, { method: "DELETE", ...options });
131
- }
132
- }
1
+ /**
2
+ * @typedef {Object} CreateLandingData
3
+ * @property {string} brandId - The ID of the brand to associate with the landing page
4
+ * @property {string} description - A description of the landing page
5
+ * @property {string} primaryBackgroundColor - The primary background color for the landing page (e.g., "#FFFFFF")
6
+ * @property {string} secondaryBackgroundColor - The secondary background color for the landing page (e.g., "#F0F0F0")
7
+ * @property {string} primaryTextColor - The primary text color for the landing page (e.g., "#000000")
8
+ * @property {string} secondaryTextColor - The secondary text color for the landing page (e.g., "#333333")
9
+ * @property {Buffer} logo - A logo image file for the landing page, provided as a Buffer
10
+ */
11
+
12
+ /**
13
+ * @typedef {Object} UpdateLandingData
14
+ * @property {string} [description] - A description of the landing page
15
+ * @property {string} [primaryBackgroundColor] - The primary background color for the landing page (e.g., "#FFFFFF")
16
+ * @property {string} [secondaryBackgroundColor] - The secondary background color for the landing page (e.g., "#F0F0F0")
17
+ * @property {string} [primaryTextColor] - The primary text color for the landing page (e.g., "#000000")
18
+ * @property {string} [secondaryTextColor] - The secondary text color for the landing page (e.g., "#333333")
19
+ * @property {Buffer} [logo] - A logo image file for the landing page, provided as a Buffer
20
+ */
21
+
22
+ export class Landings {
23
+ constructor(client, multipartClient, enableAdmin) {
24
+ this.client = client;
25
+ this.multipartClient = multipartClient;
26
+ this.enableAdmin = enableAdmin;
27
+ }
28
+
29
+ /**
30
+ * Get details of a landing page by its ID
31
+ * @async
32
+ * @roles api, admin, developer, billing, user
33
+ * @param {Object} params - The parameters for getting a landing page
34
+ * @param {string} params.landingId - The ID of the landing page to retrieve
35
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
+ * @throws {Error} Throws an error if the landingId parameter is missing
37
+ * @returns {Promise<Object>} - The landing page object returned from the server
38
+ */
39
+ async getLandings({ landingId, options = {} }) {
40
+ this.client._require({ landingId });
41
+ const safeLandingId = encodeURIComponent(landingId);
42
+ return this.client(`/landing/${safeLandingId}`, { method: "GET", ...options });
43
+ }
44
+
45
+ /**
46
+ * Create a new landing page with the specified landing data and logo file
47
+ * @async
48
+ * @roles api, admin, developer, billing, user
49
+ * @param {Object} params - The parameters for creating a new landing page (see CreateLandingData typedef for details)
50
+ * @param {CreateLandingData} params.landingData - The data for the new landing page, including required fields such as brandId and description
51
+ * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
52
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
53
+ * @returns {Promise<Object>} - The newly created landing page object returned from the server
54
+ */
55
+ async createLanding({ landingData, file, options = {} }) {
56
+ const formData = new FormData();
57
+
58
+ if (file) {
59
+ formData.append("file", file);
60
+ }
61
+
62
+ Object.entries(landingData).forEach(([key, value]) => {
63
+ if (value !== undefined) {
64
+ formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
65
+ }
66
+ });
67
+
68
+ return this.multipartClient(`/landing`, { method: "POST", body: formData, ...options });
69
+ }
70
+
71
+ /**
72
+ * Update an existing landing page with the specified landing data and logo file
73
+ * @async
74
+ * @roles api, admin, developer, billing, user
75
+ * @param {Object} params - The parameters for updating a landing page (see UpdateLandingData typedef for details)
76
+ * @param {string} params.landingId - The ID of the landing page to update
77
+ * @param {UpdateLandingData} params.landingData - The data for the landing page, including required fields such as brandId and description
78
+ * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
79
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
80
+ * @throws {Error} Throws an error if the landingId parameter is missing
81
+ * @returns {Promise<Object>} - The updated landing page object returned from the server
82
+ */
83
+ async updateLanding({ landingId, landingData, file, options = {} }) {
84
+ this.client._require({ landingId });
85
+ const safeLandingId = encodeURIComponent(landingId);
86
+ const formData = new FormData();
87
+
88
+ if (file) {
89
+ formData.append("file", file);
90
+ }
91
+
92
+ Object.entries(landingData).forEach(([key, value]) => {
93
+ if (value !== undefined) {
94
+ formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
95
+ }
96
+ });
97
+
98
+ return this.multipartClient(`/landing/${safeLandingId}`, { method: "PUT", body: formData, ...options });
99
+ }
100
+
101
+ /**
102
+ * Delete a landing page by its ID
103
+ * @async
104
+ * @roles api, admin, developer, billing, user
105
+ * @param {Object} params - The parameters for deleting a landing page
106
+ * @param {string} params.landingId - The ID of the landing page to delete
107
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
108
+ * @throws {Error} Throws an error if the landingId parameter is missing
109
+ * @returns {Promise<Object>} - The response from the server after deleting the landing page
110
+ */
111
+ /**
112
+ * Get a landing page by its associated brand ID
113
+ * @async
114
+ * @roles api, admin, developer, billing, user
115
+ * @param {Object} params - The parameters for getting a landing page by brand
116
+ * @param {string} params.brandId - The brand ID to look up the landing page for
117
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
118
+ * @throws {Error} Throws an error if the brandId parameter is missing
119
+ * @returns {Promise<Object>} - The landing page object returned from the server
120
+ */
121
+ async getLandingByBrandId({ brandId, options = {} }) {
122
+ this.client._require({ brandId });
123
+ const safeBrandId = encodeURIComponent(brandId);
124
+ return this.client(`/landing/brand/${safeBrandId}`, { method: "GET", ...options });
125
+ }
126
+
127
+ async deleteLanding({ landingId, options = {} }) {
128
+ this.client._require({ landingId });
129
+ const safeLandingId = encodeURIComponent(landingId);
130
+ return this.client(`/landing/${safeLandingId}`, { method: "DELETE", ...options });
131
+ }
132
+ }