@signalhousellc/sdk 1.0.31 → 1.0.32
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/package.json +1 -1
- package/src/SignalHouseSDK.js +154 -154
- package/src/domains/Billing.js +172 -172
- package/src/domains/Brands.js +236 -236
- package/src/domains/Campaigns.js +210 -210
- package/src/domains/Messages.js +280 -257
- package/src/domains/Numbers.js +15 -0
package/src/domains/Brands.js
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} CreateBrandData
|
|
3
|
-
* @property {string} subgroupId - The ID of the subgroup to create the brand under
|
|
4
|
-
* @property {string} entityType - The type of entity for the brand (PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, GOVERNMENT)
|
|
5
|
-
* @property {string} displayName - The display name for the brand
|
|
6
|
-
* @property {string} companyName - The company name for the brand
|
|
7
|
-
* @property {string} ein - The EIN (Employer Identification Number) for the brand
|
|
8
|
-
* @property {string} [einIssuingCountry] - The country that issued the EIN for the brand
|
|
9
|
-
* @property {string} [altBusinessId] - An alternative business identifier for the brand (e.g., DUNS number)
|
|
10
|
-
* @property {string} [altBusinessIdType] - The type of the alternative business identifier ("NONE", "DUNS", "LEI", "GIIN")
|
|
11
|
-
* @property {string} [firstName] - The first name of the primary contact for the brand
|
|
12
|
-
* @property {string} [lastName] - The last name of the primary contact for the brand
|
|
13
|
-
* @property {string} phone - The phone number of the primary contact for the brand
|
|
14
|
-
* @property {string} street - The street address of the primary contact for the brand
|
|
15
|
-
* @property {string} city - The city of the primary contact for the brand
|
|
16
|
-
* @property {string} state - The state of the primary contact for the brand
|
|
17
|
-
* @property {string} postalCode - The postal code of the primary contact for the brand
|
|
18
|
-
* @property {string} country - The country code of the primary contact for the brand (e.g., "US")
|
|
19
|
-
* @property {string} email - The email address of the primary contact for the brand
|
|
20
|
-
* @property {string} [mobilePhone] - The mobile phone number of the primary contact for the brand
|
|
21
|
-
* @property {string} [stockSymbol] - The stock symbol for the brand if it is a publicly traded company
|
|
22
|
-
* @property {string} [stockExchange] - The stock exchange where the brand is listed if it is a publicly traded company
|
|
23
|
-
* @property {string} [website] - The website URL for the brand
|
|
24
|
-
* @property {string} vertical - The vertical for the brand (PROFESSIONAL, REAL_ESTATE, HEALTHCARE, HUMAN_RESOURCES, ENERGY, ENTERTAINMENT, RETAIL, TRANSPORTATION, AGRICULTURE, INSURANCE, POSTAL, EDUCATION, HOSPITALITY, FINANCIAL, POLITICAL, GAMBLING, LEGAL, CONSTRUCTION, NGO, MANUFACTURING, GOVERNMENT, TECHNOLOGY, COMMUNICATION)
|
|
25
|
-
* @property {string} [referenceId] - A unique reference for the brand
|
|
26
|
-
* @property {Array<string>} [tag] - An array of tags to associate with the brand
|
|
27
|
-
* @property {boolean} [mock] - Whether to create the brand in the mock environment (for testing purposes only)
|
|
28
|
-
* @property {string} [businessContactEmail] - The email address of the business contact for the brand (required if entityType is PUBLIC_PROFIT or NON_PROFIT)
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {Object} UpdateBrandData
|
|
33
|
-
* @property {string} [companyName] - The company name for the brand
|
|
34
|
-
* @property {string} [ein] - The EIN (Employer Identification Number) for the brand
|
|
35
|
-
* @property {string} [einIssuingCountry] - The country that issued the EIN for the brand
|
|
36
|
-
* @property {string} [entityType] - The type of entity for the brand (PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, GOVERNMENT)
|
|
37
|
-
* @property {string} [firstName] - The first name of the primary contact for the brand
|
|
38
|
-
* @property {string} [lastName] - The last name of the primary contact for the brand
|
|
39
|
-
* @property {string} [displayName] - The display name for the brand
|
|
40
|
-
* @property {string} [website] - The website URL for the brand
|
|
41
|
-
* @property {string} [street] - The street address of the primary contact for the brand
|
|
42
|
-
* @property {string} [city] - The city of the primary contact for the brand
|
|
43
|
-
* @property {string} [state] - The state of the primary contact for the brand
|
|
44
|
-
* @property {string} [postalCode] - The postal code of the primary contact for the brand
|
|
45
|
-
* @property {string} [country] - The country code of the primary contact for the brand (e.g., "US")
|
|
46
|
-
* @property {string} [email] - The email address of the primary contact for the brand
|
|
47
|
-
* @property {string} [referenceId] - A unique reference for the brand
|
|
48
|
-
* @property {string} [phone] - The phone number of the primary contact for the brand
|
|
49
|
-
* @property {string} [vertical] - The vertical for the brand (PROFESSIONAL, REAL_ESTATE, HEALTHCARE, HUMAN_RESOURCES, ENERGY, ENTERTAINMENT, RETAIL, TRANSPORTATION, AGRICULTURE, INSURANCE, POSTAL, EDUCATION, HOSPITALITY, FINANCIAL, POLITICAL, GAMBLING, LEGAL, CONSTRUCTION, NGO, MANUFACTURING, GOVERNMENT, TECHNOLOGY, COMMUNICATION)
|
|
50
|
-
* @property {string} [stockSymbol] - The stock symbol for the brand if it is a publicly traded company
|
|
51
|
-
* @property {string} [stockExchange] - The stock exchange where the brand is listed if it is a publicly traded company
|
|
52
|
-
* @property {string} [altBusinessId] - An alternative business identifier for the brand (e.g., DUNS number)
|
|
53
|
-
* @property {string} [altBusinessIdType] - The type of the alternative business identifier ("NONE", "DUNS", "LEI", "GIIN")
|
|
54
|
-
* @property {string} [brandRelationship] - Not in use - reserved for future use
|
|
55
|
-
* @property {string} [businessContactEmail] - The email address of the business contact for the brand (required if entityType is PUBLIC_PROFIT or NON_PROFIT)
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export class Brands {
|
|
59
|
-
constructor(client, multipartClient, enableAdmin) {
|
|
60
|
-
this.client = client;
|
|
61
|
-
this.multipartClient = multipartClient;
|
|
62
|
-
this.enableAdmin = enableAdmin;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get a list of brands with optional filters
|
|
67
|
-
* @async
|
|
68
|
-
* @roles api, admin, developer, user
|
|
69
|
-
* @param {Object} params - The parameters for filtering the brands
|
|
70
|
-
* @param {string} [params.id] - The ID of the brand to filter by
|
|
71
|
-
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
72
|
-
* @param {string} [params.groupId] - The ID of the group to filter by
|
|
73
|
-
* @param {number} [params.page] - The page number for pagination
|
|
74
|
-
* @param {number} [params.limit] - The number of items per page
|
|
75
|
-
* @param {string} [params.status] - The status of the brand to filter by (PENDING_CREATION, PENDING_APPROVAL, UNVERIFIED, VERIFIED, VETTED_VERIFIED, PENDING_DELETE, DELETED)
|
|
76
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
77
|
-
* @returns {Promise<Array>} The response from the server
|
|
78
|
-
*/
|
|
79
|
-
async getBrands({ id, subgroupId, groupId, page, limit, status, options = {} }) {
|
|
80
|
-
const filters = { id, subgroupId, groupId, page, limit, status };
|
|
81
|
-
const queryString = this.client._getQueryString(filters);
|
|
82
|
-
return this.client(`/brand${queryString}`, { method: "GET", ...options });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get external vetting information for a brand
|
|
87
|
-
* @async
|
|
88
|
-
* @roles api, admin, developer, user
|
|
89
|
-
* @param {Object} params - The parameters for getting the external vetting information
|
|
90
|
-
* @param {string} params.brandId - The ID of the brand to get the external vetting information for
|
|
91
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
92
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
93
|
-
* @returns {Promise<Object>} The response from the server
|
|
94
|
-
*/
|
|
95
|
-
async getExternalVetting({ brandId, options = {} }) {
|
|
96
|
-
this.client._require({ brandId });
|
|
97
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
98
|
-
return this.client(`/brand/externalvetting/${safeBrandId}`, { method: "GET", ...options });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Create a new brand
|
|
103
|
-
* @async
|
|
104
|
-
* @roles api, admin, developer, billing, user
|
|
105
|
-
* @param {Object} params - The parameters for creating the brand (see CreateBrandData typedef for details)
|
|
106
|
-
* @param {CreateBrandData} params.brandData - The data for the brand to be created
|
|
107
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
108
|
-
* @throws {Error} Throws an error if the brandData parameter is missing or if required fields in brandData are missing
|
|
109
|
-
* @returns {Promise<Object>} The response from the server
|
|
110
|
-
*/
|
|
111
|
-
async createBrand({ brandData, options = {} }) {
|
|
112
|
-
this.client._require({ brandData: brandData });
|
|
113
|
-
return this.client(`/brand`, { method: "POST", body: brandData, ...options });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Transfer one or more brands to a different subgroup
|
|
118
|
-
* @async
|
|
119
|
-
* @roles api, admin, developer, billing, user
|
|
120
|
-
* @param {Object} params - The parameters for transferring the brands
|
|
121
|
-
* @param {string} params.subgroupId - The ID of the subgroup to transfer the brands to
|
|
122
|
-
* @param {Array<string>} params.brandIds - The IDs of the brands to be transferred
|
|
123
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
124
|
-
* @throws {Error} Throws an error if the subgroupId or brandIds parameters are missing
|
|
125
|
-
* @returns {Promise<Object>} The response from the server
|
|
126
|
-
*/
|
|
127
|
-
async transferBrand({ subgroupId, brandIds, options = {} }) {
|
|
128
|
-
this.client._require({ subgroupId, brandIds });
|
|
129
|
-
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
130
|
-
return this.client(`/brand/transfer/${safeSubgroupId}`, { method: "POST", body: { brandIds }, ...options });
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Create external vetting for a brand
|
|
135
|
-
* @async
|
|
136
|
-
* @roles api, admin, developer, billing, user
|
|
137
|
-
* @param {Object} params - The parameters for creating external vetting
|
|
138
|
-
* @param {string} params.brandId - The ID of the brand to create external vetting for
|
|
139
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
140
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
141
|
-
* @returns {Promise<Object>} The response from the server
|
|
142
|
-
*/
|
|
143
|
-
async createExternalVetting({ brandId, options = {} }) {
|
|
144
|
-
this.client._require({ brandId });
|
|
145
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
146
|
-
return this.client(`/brand/externalvetting/${safeBrandId}`, { method: "POST", ...options });
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Update a brand's information
|
|
151
|
-
* @async
|
|
152
|
-
* @roles api, admin, developer, billing, user
|
|
153
|
-
* @param {Object} params - The parameters for updating the brand (see UpdateBrandData typedef for details)
|
|
154
|
-
* @param {string} params.brandId - The ID of the brand to update
|
|
155
|
-
* @param {UpdateBrandData} params.brandData - The data for the brand to be updated
|
|
156
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
157
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
158
|
-
* @returns {Promise<Object>} The response from the server
|
|
159
|
-
*/
|
|
160
|
-
async updateBrand({ brandId, brandData, options = {} }) {
|
|
161
|
-
this.client._require({ brandId });
|
|
162
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
163
|
-
return this.client(`/brand/${safeBrandId}`, { method: "PUT", body: brandData, ...options });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Revet a brand that is in UNVERIFIED status due to an update afer it was previously VERIFIED or VETTED_VERIFIED
|
|
168
|
-
* @async
|
|
169
|
-
* @roles api, admin, developer, billing, user
|
|
170
|
-
* @param {Object} params - The parameters for reverting the brand
|
|
171
|
-
* @param {string} params.brandId - The ID of the brand to revert
|
|
172
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
173
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
174
|
-
* @returns {Promise<Object>} The response from the server
|
|
175
|
-
*/
|
|
176
|
-
async revetBrand({ brandId, options = {} }) {
|
|
177
|
-
this.client._require({ brandId });
|
|
178
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
179
|
-
return this.client(`/brand/revet/${safeBrandId}`, { method: "PUT", ...options });
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Delete a brand (mark it as DELETED). The brand will still be retrievable
|
|
184
|
-
* @async
|
|
185
|
-
* @roles api, admin, developer, billing, user
|
|
186
|
-
* @param {Object} params - The parameters for deleting the brand
|
|
187
|
-
* @param {string} params.brandId - The ID of the brand to delete
|
|
188
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
189
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
190
|
-
* @returns {Promise<Object>} The response from the server
|
|
191
|
-
*/
|
|
192
|
-
async deleteBrand({ brandId, options = {} }) {
|
|
193
|
-
this.client._require({ brandId });
|
|
194
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
195
|
-
return this.client(`/brand/${safeBrandId}`, { method: "DELETE", ...options });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Get appeal history for a brand
|
|
200
|
-
* @async
|
|
201
|
-
* @roles api, admin, developer, billing, user
|
|
202
|
-
* @param {Object} params - The parameters for getting the appeal history
|
|
203
|
-
* @param {string} params.brandId - The ID of the brand to get appeal history for
|
|
204
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
205
|
-
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
206
|
-
* @returns {Promise<Array>} Array of BrandAppeal objects
|
|
207
|
-
*/
|
|
208
|
-
async getAppealHistory({ brandId, options = {} }) {
|
|
209
|
-
this.client._require({ brandId });
|
|
210
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
211
|
-
return this.client(`/brand/appeal/${safeBrandId}`, { method: "GET", ...options });
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Submit a brand identity status appeal with supporting documentation
|
|
216
|
-
* @async
|
|
217
|
-
* @roles api, admin, developer, billing, user
|
|
218
|
-
* @param {Object} params - The parameters for submitting the appeal
|
|
219
|
-
* @param {string} params.brandId - The ID of the brand to appeal
|
|
220
|
-
* @param {Array<string>} params.appealCategories - Array of appeal categories (VERIFY_TAX_ID, VERIFY_NON_PROFIT, VERIFY_GOVERNMENT)
|
|
221
|
-
* @param {string} params.explanation - Required explanation justifying the appeal
|
|
222
|
-
* @param {File|Blob} params.file - The supporting document file
|
|
223
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
224
|
-
* @throws {Error} Throws an error if required parameters are missing
|
|
225
|
-
* @returns {Promise<Object>} The response from the server
|
|
226
|
-
*/
|
|
227
|
-
async submitAppeal({ brandId, appealCategories, explanation, file, options = {} }) {
|
|
228
|
-
this.client._require({ brandId, appealCategories, explanation, file });
|
|
229
|
-
const safeBrandId = encodeURIComponent(brandId);
|
|
230
|
-
const formData = new FormData();
|
|
231
|
-
formData.append("appealCategories", JSON.stringify(appealCategories));
|
|
232
|
-
formData.append("explanation", explanation);
|
|
233
|
-
formData.append("file", file);
|
|
234
|
-
return this.multipartClient(`/brand/appeal/${safeBrandId}`, { method: "POST", body: formData, ...options });
|
|
235
|
-
}
|
|
236
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} CreateBrandData
|
|
3
|
+
* @property {string} subgroupId - The ID of the subgroup to create the brand under
|
|
4
|
+
* @property {string} entityType - The type of entity for the brand (PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, GOVERNMENT)
|
|
5
|
+
* @property {string} displayName - The display name for the brand
|
|
6
|
+
* @property {string} companyName - The company name for the brand
|
|
7
|
+
* @property {string} ein - The EIN (Employer Identification Number) for the brand
|
|
8
|
+
* @property {string} [einIssuingCountry] - The country that issued the EIN for the brand
|
|
9
|
+
* @property {string} [altBusinessId] - An alternative business identifier for the brand (e.g., DUNS number)
|
|
10
|
+
* @property {string} [altBusinessIdType] - The type of the alternative business identifier ("NONE", "DUNS", "LEI", "GIIN")
|
|
11
|
+
* @property {string} [firstName] - The first name of the primary contact for the brand
|
|
12
|
+
* @property {string} [lastName] - The last name of the primary contact for the brand
|
|
13
|
+
* @property {string} phone - The phone number of the primary contact for the brand
|
|
14
|
+
* @property {string} street - The street address of the primary contact for the brand
|
|
15
|
+
* @property {string} city - The city of the primary contact for the brand
|
|
16
|
+
* @property {string} state - The state of the primary contact for the brand
|
|
17
|
+
* @property {string} postalCode - The postal code of the primary contact for the brand
|
|
18
|
+
* @property {string} country - The country code of the primary contact for the brand (e.g., "US")
|
|
19
|
+
* @property {string} email - The email address of the primary contact for the brand
|
|
20
|
+
* @property {string} [mobilePhone] - The mobile phone number of the primary contact for the brand
|
|
21
|
+
* @property {string} [stockSymbol] - The stock symbol for the brand if it is a publicly traded company
|
|
22
|
+
* @property {string} [stockExchange] - The stock exchange where the brand is listed if it is a publicly traded company
|
|
23
|
+
* @property {string} [website] - The website URL for the brand
|
|
24
|
+
* @property {string} vertical - The vertical for the brand (PROFESSIONAL, REAL_ESTATE, HEALTHCARE, HUMAN_RESOURCES, ENERGY, ENTERTAINMENT, RETAIL, TRANSPORTATION, AGRICULTURE, INSURANCE, POSTAL, EDUCATION, HOSPITALITY, FINANCIAL, POLITICAL, GAMBLING, LEGAL, CONSTRUCTION, NGO, MANUFACTURING, GOVERNMENT, TECHNOLOGY, COMMUNICATION)
|
|
25
|
+
* @property {string} [referenceId] - A unique reference for the brand
|
|
26
|
+
* @property {Array<string>} [tag] - An array of tags to associate with the brand
|
|
27
|
+
* @property {boolean} [mock] - Whether to create the brand in the mock environment (for testing purposes only)
|
|
28
|
+
* @property {string} [businessContactEmail] - The email address of the business contact for the brand (required if entityType is PUBLIC_PROFIT or NON_PROFIT)
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {Object} UpdateBrandData
|
|
33
|
+
* @property {string} [companyName] - The company name for the brand
|
|
34
|
+
* @property {string} [ein] - The EIN (Employer Identification Number) for the brand
|
|
35
|
+
* @property {string} [einIssuingCountry] - The country that issued the EIN for the brand
|
|
36
|
+
* @property {string} [entityType] - The type of entity for the brand (PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, GOVERNMENT)
|
|
37
|
+
* @property {string} [firstName] - The first name of the primary contact for the brand
|
|
38
|
+
* @property {string} [lastName] - The last name of the primary contact for the brand
|
|
39
|
+
* @property {string} [displayName] - The display name for the brand
|
|
40
|
+
* @property {string} [website] - The website URL for the brand
|
|
41
|
+
* @property {string} [street] - The street address of the primary contact for the brand
|
|
42
|
+
* @property {string} [city] - The city of the primary contact for the brand
|
|
43
|
+
* @property {string} [state] - The state of the primary contact for the brand
|
|
44
|
+
* @property {string} [postalCode] - The postal code of the primary contact for the brand
|
|
45
|
+
* @property {string} [country] - The country code of the primary contact for the brand (e.g., "US")
|
|
46
|
+
* @property {string} [email] - The email address of the primary contact for the brand
|
|
47
|
+
* @property {string} [referenceId] - A unique reference for the brand
|
|
48
|
+
* @property {string} [phone] - The phone number of the primary contact for the brand
|
|
49
|
+
* @property {string} [vertical] - The vertical for the brand (PROFESSIONAL, REAL_ESTATE, HEALTHCARE, HUMAN_RESOURCES, ENERGY, ENTERTAINMENT, RETAIL, TRANSPORTATION, AGRICULTURE, INSURANCE, POSTAL, EDUCATION, HOSPITALITY, FINANCIAL, POLITICAL, GAMBLING, LEGAL, CONSTRUCTION, NGO, MANUFACTURING, GOVERNMENT, TECHNOLOGY, COMMUNICATION)
|
|
50
|
+
* @property {string} [stockSymbol] - The stock symbol for the brand if it is a publicly traded company
|
|
51
|
+
* @property {string} [stockExchange] - The stock exchange where the brand is listed if it is a publicly traded company
|
|
52
|
+
* @property {string} [altBusinessId] - An alternative business identifier for the brand (e.g., DUNS number)
|
|
53
|
+
* @property {string} [altBusinessIdType] - The type of the alternative business identifier ("NONE", "DUNS", "LEI", "GIIN")
|
|
54
|
+
* @property {string} [brandRelationship] - Not in use - reserved for future use
|
|
55
|
+
* @property {string} [businessContactEmail] - The email address of the business contact for the brand (required if entityType is PUBLIC_PROFIT or NON_PROFIT)
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
export class Brands {
|
|
59
|
+
constructor(client, multipartClient, enableAdmin) {
|
|
60
|
+
this.client = client;
|
|
61
|
+
this.multipartClient = multipartClient;
|
|
62
|
+
this.enableAdmin = enableAdmin;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get a list of brands with optional filters
|
|
67
|
+
* @async
|
|
68
|
+
* @roles api, admin, developer, user
|
|
69
|
+
* @param {Object} params - The parameters for filtering the brands
|
|
70
|
+
* @param {string} [params.id] - The ID of the brand to filter by
|
|
71
|
+
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
72
|
+
* @param {string} [params.groupId] - The ID of the group to filter by
|
|
73
|
+
* @param {number} [params.page] - The page number for pagination
|
|
74
|
+
* @param {number} [params.limit] - The number of items per page
|
|
75
|
+
* @param {string} [params.status] - The status of the brand to filter by (PENDING_CREATION, PENDING_APPROVAL, UNVERIFIED, VERIFIED, VETTED_VERIFIED, PENDING_DELETE, DELETED)
|
|
76
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
77
|
+
* @returns {Promise<Array>} The response from the server
|
|
78
|
+
*/
|
|
79
|
+
async getBrands({ id, subgroupId, groupId, page, limit, status, options = {} }) {
|
|
80
|
+
const filters = { id, subgroupId, groupId, page, limit, status };
|
|
81
|
+
const queryString = this.client._getQueryString(filters);
|
|
82
|
+
return this.client(`/brand${queryString}`, { method: "GET", ...options });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get external vetting information for a brand
|
|
87
|
+
* @async
|
|
88
|
+
* @roles api, admin, developer, user
|
|
89
|
+
* @param {Object} params - The parameters for getting the external vetting information
|
|
90
|
+
* @param {string} params.brandId - The ID of the brand to get the external vetting information for
|
|
91
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
92
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
93
|
+
* @returns {Promise<Object>} The response from the server
|
|
94
|
+
*/
|
|
95
|
+
async getExternalVetting({ brandId, options = {} }) {
|
|
96
|
+
this.client._require({ brandId });
|
|
97
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
98
|
+
return this.client(`/brand/externalvetting/${safeBrandId}`, { method: "GET", ...options });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create a new brand
|
|
103
|
+
* @async
|
|
104
|
+
* @roles api, admin, developer, billing, user
|
|
105
|
+
* @param {Object} params - The parameters for creating the brand (see CreateBrandData typedef for details)
|
|
106
|
+
* @param {CreateBrandData} params.brandData - The data for the brand to be created
|
|
107
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
108
|
+
* @throws {Error} Throws an error if the brandData parameter is missing or if required fields in brandData are missing
|
|
109
|
+
* @returns {Promise<Object>} The response from the server
|
|
110
|
+
*/
|
|
111
|
+
async createBrand({ brandData, options = {} }) {
|
|
112
|
+
this.client._require({ brandData: brandData });
|
|
113
|
+
return this.client(`/brand`, { method: "POST", body: brandData, ...options });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Transfer one or more brands to a different subgroup
|
|
118
|
+
* @async
|
|
119
|
+
* @roles api, admin, developer, billing, user
|
|
120
|
+
* @param {Object} params - The parameters for transferring the brands
|
|
121
|
+
* @param {string} params.subgroupId - The ID of the subgroup to transfer the brands to
|
|
122
|
+
* @param {Array<string>} params.brandIds - The IDs of the brands to be transferred
|
|
123
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
124
|
+
* @throws {Error} Throws an error if the subgroupId or brandIds parameters are missing
|
|
125
|
+
* @returns {Promise<Object>} The response from the server
|
|
126
|
+
*/
|
|
127
|
+
async transferBrand({ subgroupId, brandIds, options = {} }) {
|
|
128
|
+
this.client._require({ subgroupId, brandIds });
|
|
129
|
+
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
130
|
+
return this.client(`/brand/transfer/${safeSubgroupId}`, { method: "POST", body: { brandIds }, ...options });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Create external vetting for a brand
|
|
135
|
+
* @async
|
|
136
|
+
* @roles api, admin, developer, billing, user
|
|
137
|
+
* @param {Object} params - The parameters for creating external vetting
|
|
138
|
+
* @param {string} params.brandId - The ID of the brand to create external vetting for
|
|
139
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
140
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
141
|
+
* @returns {Promise<Object>} The response from the server
|
|
142
|
+
*/
|
|
143
|
+
async createExternalVetting({ brandId, options = {} }) {
|
|
144
|
+
this.client._require({ brandId });
|
|
145
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
146
|
+
return this.client(`/brand/externalvetting/${safeBrandId}`, { method: "POST", ...options });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Update a brand's information
|
|
151
|
+
* @async
|
|
152
|
+
* @roles api, admin, developer, billing, user
|
|
153
|
+
* @param {Object} params - The parameters for updating the brand (see UpdateBrandData typedef for details)
|
|
154
|
+
* @param {string} params.brandId - The ID of the brand to update
|
|
155
|
+
* @param {UpdateBrandData} params.brandData - The data for the brand to be updated
|
|
156
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
157
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
158
|
+
* @returns {Promise<Object>} The response from the server
|
|
159
|
+
*/
|
|
160
|
+
async updateBrand({ brandId, brandData, options = {} }) {
|
|
161
|
+
this.client._require({ brandId });
|
|
162
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
163
|
+
return this.client(`/brand/${safeBrandId}`, { method: "PUT", body: brandData, ...options });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Revet a brand that is in UNVERIFIED status due to an update afer it was previously VERIFIED or VETTED_VERIFIED
|
|
168
|
+
* @async
|
|
169
|
+
* @roles api, admin, developer, billing, user
|
|
170
|
+
* @param {Object} params - The parameters for reverting the brand
|
|
171
|
+
* @param {string} params.brandId - The ID of the brand to revert
|
|
172
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
173
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
174
|
+
* @returns {Promise<Object>} The response from the server
|
|
175
|
+
*/
|
|
176
|
+
async revetBrand({ brandId, options = {} }) {
|
|
177
|
+
this.client._require({ brandId });
|
|
178
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
179
|
+
return this.client(`/brand/revet/${safeBrandId}`, { method: "PUT", ...options });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Delete a brand (mark it as DELETED). The brand will still be retrievable
|
|
184
|
+
* @async
|
|
185
|
+
* @roles api, admin, developer, billing, user
|
|
186
|
+
* @param {Object} params - The parameters for deleting the brand
|
|
187
|
+
* @param {string} params.brandId - The ID of the brand to delete
|
|
188
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
189
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
190
|
+
* @returns {Promise<Object>} The response from the server
|
|
191
|
+
*/
|
|
192
|
+
async deleteBrand({ brandId, options = {} }) {
|
|
193
|
+
this.client._require({ brandId });
|
|
194
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
195
|
+
return this.client(`/brand/${safeBrandId}`, { method: "DELETE", ...options });
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get appeal history for a brand
|
|
200
|
+
* @async
|
|
201
|
+
* @roles api, admin, developer, billing, user
|
|
202
|
+
* @param {Object} params - The parameters for getting the appeal history
|
|
203
|
+
* @param {string} params.brandId - The ID of the brand to get appeal history for
|
|
204
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
205
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
206
|
+
* @returns {Promise<Array>} Array of BrandAppeal objects
|
|
207
|
+
*/
|
|
208
|
+
async getAppealHistory({ brandId, options = {} }) {
|
|
209
|
+
this.client._require({ brandId });
|
|
210
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
211
|
+
return this.client(`/brand/appeal/${safeBrandId}`, { method: "GET", ...options });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Submit a brand identity status appeal with supporting documentation
|
|
216
|
+
* @async
|
|
217
|
+
* @roles api, admin, developer, billing, user
|
|
218
|
+
* @param {Object} params - The parameters for submitting the appeal
|
|
219
|
+
* @param {string} params.brandId - The ID of the brand to appeal
|
|
220
|
+
* @param {Array<string>} params.appealCategories - Array of appeal categories (VERIFY_TAX_ID, VERIFY_NON_PROFIT, VERIFY_GOVERNMENT)
|
|
221
|
+
* @param {string} params.explanation - Required explanation justifying the appeal
|
|
222
|
+
* @param {File|Blob} params.file - The supporting document file
|
|
223
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
224
|
+
* @throws {Error} Throws an error if required parameters are missing
|
|
225
|
+
* @returns {Promise<Object>} The response from the server
|
|
226
|
+
*/
|
|
227
|
+
async submitAppeal({ brandId, appealCategories, explanation, file, options = {} }) {
|
|
228
|
+
this.client._require({ brandId, appealCategories, explanation, file });
|
|
229
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
230
|
+
const formData = new FormData();
|
|
231
|
+
formData.append("appealCategories", JSON.stringify(appealCategories));
|
|
232
|
+
formData.append("explanation", explanation);
|
|
233
|
+
formData.append("file", file);
|
|
234
|
+
return this.multipartClient(`/brand/appeal/${safeBrandId}`, { method: "POST", body: formData, ...options });
|
|
235
|
+
}
|
|
236
|
+
}
|