@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.
@@ -1,210 +1,210 @@
1
- /**
2
- * @typedef {Object} CreateCampaignData
3
- * @property {string} brandId - The ID of the brand associated with the campaign (required)
4
- * @property {string} usecase - The use case for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
5
- * @property {Array<string>} [subUsecases] - An array of sub-use cases for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
6
- * @property {string} description - A detailed description of the campaign (required, must be between 40 and 4096 characters)
7
- * @property {boolean} [embeddedLink=true] - Whether the campaign includes an embedded link (optional, defaults to true)
8
- * @property {boolean} [embeddedPhone=false] - Whether the campaign includes an embedded phone number (optional, defaults to false)
9
- * @property {boolean} [termsAndConditions=true] - Whether the campaign includes terms and conditions (optional, defaults to true)
10
- * @property {boolean} [numberPool=false] - Whether the campaign uses a number pool (optional, defaults to false)
11
- * @property {boolean} [ageGated=false] - Whether the campaign is age-gated (optional, defaults to false)
12
- * @property {boolean} [directLending=false] - Whether the campaign uses direct lending (optional, defaults to false)
13
- * @property {boolean} [subscriberOptIn=true] - Whether the campaign requires subscriber opt-in (optional, defaults to true)
14
- * @property {boolean} [subscriberOptOut=true] - Whether the campaign allows subscriber opt-out (optional, defaults to true)
15
- * @property {boolean} [subscriberHelp=true] - Whether the campaign provides subscriber help (optional, defaults to true)
16
- * @property {string} [sample1] - Sample message 1 for the campaign (optional, must be between 20 and 1024 characters if provided)
17
- * @property {string} [sample2] - Sample message 2 for the campaign (optional, must be between 20 and 1024 characters if provided)
18
- * @property {string} [sample3] - Sample message 3 for the campaign (optional, must be between 20 and 1024 characters if provided)
19
- * @property {string} [sample4] - Sample message 4 for the campaign (optional, must be between 20 and 1024 characters if provided)
20
- * @property {string} [sample5] - Sample message 5 for the campaign (optional, must be between 20 and 1024 characters if provided)
21
- * @property {string} messageFlow - A detailed description of the message flow for the campaign (required, must be between 40 and 4096 characters)
22
- * @property {string} [helpMessage] - A message providing help information for the campaign (optional)
23
- * @property {boolean} [autoRenewal=true] - Whether the campaign should auto-renew (optional, defaults to true)
24
- * @property {string} [tag] - A tag for the campaign (optional, must be at most 255 characters)
25
- * @property {string} [optinKeywords="START,SUBSCRIBE"] - A comma-separated list of keywords for opting in to the campaign (optional, defaults to "START,SUBSCRIBE", must be at most 255 characters)
26
- * @property {string} [optoutKeywords="STOP,UNSUBSCRIBE"] - A comma-separated list of keywords for opting out of the campaign (optional, defaults to "STOP,UNSUBSCRIBE", must be at most 255 characters)
27
- * @property {string} [helpKeywords="HELP"] - A comma-separated list of keywords for getting help with the campaign (optional, defaults to "HELP", must be at most 255 characters)
28
- * @property {string} [optinMessage] - A message sent to users when they opt in to the campaign (optional, must be between 20 and 1024 characters if provided)
29
- * @property {string} [optoutMessage] - A message sent to users when they opt out of the campaign (optional, must be between 20 and 1024 characters if provided)
30
- * @property {string} privacyPolicyLink - A URL linking to the privacy policy for the campaign (required, must be at most 2048 characters)
31
- * @property {string} termsAndConditionsLink - A URL linking to the terms and conditions for the campaign (required, must be at most 2048 characters)
32
- * @property {string} [embeddedLinkSample] - A sample of the embedded link used in the campaign (optional, must be at most 255 characters)
33
- * @property {Array<string>} phoneNumbers - An array of phone numbers associated with the campaign (required, each number must be at least 10 digits and contain only digits, a maximum of 5000 numbers is allowed)
34
- */
35
-
36
- /**
37
- * @typedef {Object} UpdateCampaignData
38
- * @property {string} [usecase] - The use case for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
39
- * @property {Array<string>} [subUsecases] - An array of sub-use cases for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
40
- * @property {string} [description] - A detailed description of the campaign (optional, must be between 40 and 4096 characters if provided)
41
- * @property {boolean} [embeddedLink] - Whether the campaign includes an embedded link (optional)
42
- * @property {boolean} [embeddedPhone] - Whether the campaign includes an embedded phone number (optional)
43
- * @property {boolean} [termsAndConditions] - Whether the campaign includes terms and conditions (optional)
44
- * @property {boolean} [numberPool] - Whether the campaign uses a number pool (optional)
45
- * @property {boolean} [ageGated] - Whether the campaign is age-gated (optional)
46
- * @property {boolean} [directLending] - Whether the campaign uses direct lending (optional)
47
- * @property {boolean} [subscriberOptIn] - Whether the campaign requires subscriber opt-in (optional)
48
- * @property {boolean} [subscriberOptOut] - Whether the campaign allows subscriber opt-out (optional)
49
- * @property {boolean} [subscriberHelp] - Whether the campaign provides subscriber help (optional)
50
- * @property {string} [sample1] - Sample message 1 for the campaign (optional, must be between 20 and 1024 characters if provided)
51
- * @property {string} [sample2] - Sample message 2 for the campaign (optional, must be between 20 and 1024 characters if provided)
52
- * @property {string} [sample3] - Sample message 3 for the campaign (optional, must be between 20 and 1024 characters if provided)
53
- * @property {string} [sample4] - Sample message 4 for the campaign (optional, must be between 20 and 1024 characters if provided)
54
- * @property {string} [sample5] - Sample message 5 for the campaign (optional, must be between 20 and 1024 characters if provided)
55
- * @property {string} [messageFlow] - A detailed description of the message flow for the campaign (optional, must be between 40 and 4096 characters if provided)
56
- * @property {string} [helpMessage] - A message providing help information for the campaign (optional)
57
- * @property {boolean} [autoRenewal] - Whether the campaign should auto-renew (optional)
58
- * @property {string} [tag] - A tag for the campaign (optional, must be at most 255 characters)
59
- * @property {string} [optinKeywords] - A comma-separated list of keywords for opting in to the campaign (optional, must be at most 255 characters)
60
- * @property {string} [optoutKeywords] - A comma-separated list of keywords for opting out of the campaign (optional, must be at most 255 characters)
61
- * @property {string} [helpKeywords] - A comma-separated list of keywords for getting help with the campaign (optional, must be at most 255 characters)
62
- * @property {string} [optinMessage] - A message sent to users when they opt in to the campaign (optional, must be between 20 and 1024 characters if provided)
63
- * @property {string} [optoutMessage] - A message sent to users when they opt out of the campaign (optional, must be between 20 and 1024 characters if provided)
64
- * @property {string} [privacyPolicyLink] - A URL linking to the privacy policy for the campaign (optional, must be at most 2048 characters if provided)
65
- * @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions for the campaign (optional, must be at most 2048 characters if provided)
66
- * @property {string} [embeddedLinkSample] - A sample of the embedded link used in the campaign (optional, must be at most 255 characters if provided)
67
- */
68
-
69
- export class Campaigns {
70
- constructor(client, enableAdmin) {
71
- this.client = client;
72
- this.enableAdmin = enableAdmin;
73
-
74
- if (enableAdmin) {
75
- this.admin = {
76
- /**
77
- * Approve a campaign that is pending approval
78
- * @async
79
- * @roles signalhouse
80
- * @param {Object} params - The parameters for approving the campaign
81
- * @param {string} params.campaignId - The ID of the campaign to approve
82
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
83
- * @throws {Error} Throws an error if the campaignId parameter is missing
84
- * @returns {Promise<Object>} The response from the server
85
- */
86
- approveCampaign: async ({ campaignId, options = {} }) => {
87
- this.client._require({ campaignId });
88
- const safeCampaignId = encodeURIComponent(campaignId);
89
- return this.client(`/campaign/approve/${safeCampaignId}`, { method: "POST", ...options });
90
- },
91
- /**
92
- * Reject a campaign that is pending approval
93
- * @async
94
- * @roles signalhouse
95
- * @param {Object} params - The parameters for rejecting the campaign
96
- * @param {string} params.campaignId - The ID of the campaign to reject
97
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
98
- * @throws {Error} Throws an error if the campaignId parameter is missing
99
- * @returns {Promise<Object>} The response from the server
100
- */
101
- rejectCampaign: async ({ campaignId, options = {} }) => {
102
- this.client._require({ campaignId });
103
- const safeCampaignId = encodeURIComponent(campaignId);
104
- return this.client(`/campaign/reject/${safeCampaignId}`, { method: "POST", ...options });
105
- },
106
- };
107
- }
108
- }
109
-
110
- /**
111
- * Get a list of campaigns with optional filters
112
- * @async
113
- * @roles api, admin, developer, billing, user
114
- * @param {Object} params - The parameters for filtering the campaigns
115
- * @param {string} [params.id] - The ID of the campaign to filter by
116
- * @param {string} [params.brandId] - The ID of the brand to filter by
117
- * @param {string} [params.subgroupId] - The ID of the subgroup to filter by
118
- * @param {string} [params.groupId] - The ID of the group to filter by
119
- * @param {number} [params.page] - The page number for pagination
120
- * @param {number} [params.limit] - The number of items per page
121
- * @param {string} [params.status] - The status of the campaign to filter by
122
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
123
- * @returns {Promise<Array>} The response from the server
124
- */
125
- async getCampaigns({ id, brandId, subgroupId, groupId, page, limit, status, options = {} }) {
126
- const filters = { id, brandId, subgroupId, groupId, page, limit, status };
127
- const queryString = this.client._getQueryString(filters);
128
- return this.client(`/campaign${queryString}`, { method: "GET", ...options });
129
- }
130
-
131
- /**
132
- * Create a new campaign
133
- * @async
134
- * @roles api, admin, developer, billing, user
135
- * @param {Object} params - The parameters for creating the campaign (see CreateCampaignData typedef for details)
136
- * @param {CreateCampaignData} params.campaignData - The data for the campaign to be created (see CreateCampaignData typedef for details)
137
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
138
- * @throws {Error} Throws an error if the campaignData parameter is missing or if required fields in campaignData are missing
139
- * @returns {Promise<Object>} The response from the server
140
- */
141
- async createCampaign({ campaignData, options = {} }) {
142
- this.client._require({ campaignData: campaignData });
143
- return this.client(`/campaign`, { method: "POST", body: campaignData, ...options });
144
- }
145
-
146
- /**
147
- * Update an existing campaign
148
- * @async
149
- * @roles api, admin, developer, billing, user
150
- * @param {Object} params - The parameters for updating the campaign (see UpdateCampaignData typedef for details)
151
- * @param {string} params.campaignId - The ID of the campaign to update
152
- * @param {UpdateCampaignData} params.campaignData - The data for the campaign to be updated (see UpdateCampaignData typedef for details)
153
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
154
- * @throws {Error} Throws an error if the campaignId parameter is missing or if required fields in campaignData are missing
155
- * @returns {Promise<Object>} The response from the server
156
- */
157
- async updateCampaign({ campaignId, campaignData, options = {} }) {
158
- this.client._require({ campaignId: campaignId });
159
- const safeCampaignId = encodeURIComponent(campaignId);
160
- return this.client(`/campaign/${safeCampaignId}`, { method: "PUT", body: campaignData, ...options });
161
- }
162
-
163
- /**
164
- * Delete an existing campaign (mark it as EXPIRED). The campaign will still be retrievable
165
- * @async
166
- * @roles api, admin, developer, billing, user
167
- * @param {Object} params - The parameters for deleting the campaign
168
- * @param {string} params.campaignId - The ID of the campaign to delete
169
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
170
- * @throws {Error} Throws an error if the campaignId parameter is missing
171
- * @returns {Promise<Object>} The response from the server
172
- */
173
- async deleteCampaign({ campaignId, options = {} }) {
174
- this.client._require({ campaignId: campaignId });
175
- const safeCampaignId = encodeURIComponent(campaignId);
176
- return this.client(`/campaign/${safeCampaignId}`, { method: "DELETE", ...options });
177
- }
178
-
179
- /**
180
- * Appeal a DCA-rejected campaign
181
- * @async
182
- * @roles api, admin, developer, billing, user
183
- * @param {Object} params - The parameters for appealing the campaign rejection
184
- * @param {string} params.campaignId - The ID of the campaign to appeal
185
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request (body should include { reason })
186
- * @throws {Error} Throws an error if the campaignId parameter is missing
187
- * @returns {Promise<Object>} The response from the server
188
- */
189
- async appealDcaRejection({ campaignId, options = {} }) {
190
- this.client._require({ campaignId: campaignId });
191
- const safeCampaignId = encodeURIComponent(campaignId);
192
- return this.client(`/campaign/appealDcaRejection/${safeCampaignId}`, { method: "POST", ...options });
193
- }
194
-
195
- /**
196
- * Nudge a connectivity partner to prioritize review of a campaign in PENDING_DCA_APPROVAL status
197
- * @async
198
- * @roles api, admin, developer, billing, user
199
- * @param {Object} params - The parameters for nudging the campaign
200
- * @param {string} params.campaignId - The ID of the campaign to nudge
201
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
202
- * @throws {Error} Throws an error if the campaignId parameter is missing
203
- * @returns {Promise<Object>} The response from the server
204
- */
205
- async nudgeDcaForCampaign({ campaignId, options = {} }) {
206
- this.client._require({ campaignId: campaignId });
207
- const safeCampaignId = encodeURIComponent(campaignId);
208
- return this.client(`/campaign/nudge/${safeCampaignId}`, { method: "POST", ...options });
209
- }
210
- }
1
+ /**
2
+ * @typedef {Object} CreateCampaignData
3
+ * @property {string} brandId - The ID of the brand associated with the campaign (required)
4
+ * @property {string} usecase - The use case for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
5
+ * @property {Array<string>} [subUsecases] - An array of sub-use cases for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
6
+ * @property {string} description - A detailed description of the campaign (required, must be between 40 and 4096 characters)
7
+ * @property {boolean} [embeddedLink=true] - Whether the campaign includes an embedded link (optional, defaults to true)
8
+ * @property {boolean} [embeddedPhone=false] - Whether the campaign includes an embedded phone number (optional, defaults to false)
9
+ * @property {boolean} [termsAndConditions=true] - Whether the campaign includes terms and conditions (optional, defaults to true)
10
+ * @property {boolean} [numberPool=false] - Whether the campaign uses a number pool (optional, defaults to false)
11
+ * @property {boolean} [ageGated=false] - Whether the campaign is age-gated (optional, defaults to false)
12
+ * @property {boolean} [directLending=false] - Whether the campaign uses direct lending (optional, defaults to false)
13
+ * @property {boolean} [subscriberOptIn=true] - Whether the campaign requires subscriber opt-in (optional, defaults to true)
14
+ * @property {boolean} [subscriberOptOut=true] - Whether the campaign allows subscriber opt-out (optional, defaults to true)
15
+ * @property {boolean} [subscriberHelp=true] - Whether the campaign provides subscriber help (optional, defaults to true)
16
+ * @property {string} [sample1] - Sample message 1 for the campaign (optional, must be between 20 and 1024 characters if provided)
17
+ * @property {string} [sample2] - Sample message 2 for the campaign (optional, must be between 20 and 1024 characters if provided)
18
+ * @property {string} [sample3] - Sample message 3 for the campaign (optional, must be between 20 and 1024 characters if provided)
19
+ * @property {string} [sample4] - Sample message 4 for the campaign (optional, must be between 20 and 1024 characters if provided)
20
+ * @property {string} [sample5] - Sample message 5 for the campaign (optional, must be between 20 and 1024 characters if provided)
21
+ * @property {string} messageFlow - A detailed description of the message flow for the campaign (required, must be between 40 and 4096 characters)
22
+ * @property {string} [helpMessage] - A message providing help information for the campaign (optional)
23
+ * @property {boolean} [autoRenewal=true] - Whether the campaign should auto-renew (optional, defaults to true)
24
+ * @property {string} [tag] - A tag for the campaign (optional, must be at most 255 characters)
25
+ * @property {string} [optinKeywords="START,SUBSCRIBE"] - A comma-separated list of keywords for opting in to the campaign (optional, defaults to "START,SUBSCRIBE", must be at most 255 characters)
26
+ * @property {string} [optoutKeywords="STOP,UNSUBSCRIBE"] - A comma-separated list of keywords for opting out of the campaign (optional, defaults to "STOP,UNSUBSCRIBE", must be at most 255 characters)
27
+ * @property {string} [helpKeywords="HELP"] - A comma-separated list of keywords for getting help with the campaign (optional, defaults to "HELP", must be at most 255 characters)
28
+ * @property {string} [optinMessage] - A message sent to users when they opt in to the campaign (optional, must be between 20 and 1024 characters if provided)
29
+ * @property {string} [optoutMessage] - A message sent to users when they opt out of the campaign (optional, must be between 20 and 1024 characters if provided)
30
+ * @property {string} privacyPolicyLink - A URL linking to the privacy policy for the campaign (required, must be at most 2048 characters)
31
+ * @property {string} termsAndConditionsLink - A URL linking to the terms and conditions for the campaign (required, must be at most 2048 characters)
32
+ * @property {string} [embeddedLinkSample] - A sample of the embedded link used in the campaign (optional, must be at most 255 characters)
33
+ * @property {Array<string>} phoneNumbers - An array of phone numbers associated with the campaign (required, each number must be at least 10 digits and contain only digits, a maximum of 5000 numbers is allowed)
34
+ */
35
+
36
+ /**
37
+ * @typedef {Object} UpdateCampaignData
38
+ * @property {string} [usecase] - The use case for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
39
+ * @property {Array<string>} [subUsecases] - An array of sub-use cases for the campaign (2FA, ACCOUNT_NOTIFICATION, AGENTS_FRANCHISES, CARRIER_EXEMPT, CHARITY, CUSTOMER_CARE, DELIVERY_NOTIFICATION, EMERGENCY, FRAUD_ALERT, HIGHER_EDUCATION, K12_EDUCATION, LOW_VOLUME, M2M, MARKETING, MIXED, POLITICAL, POLLING_VOTING, PROXY, PUBLIC_SAFETY_RESTRICTED, PUBLIC_SERVICE_ANNOUNCEMENT, SECURITY_ALERT, SOCIAL, SOLE_PROPRIETOR, SWEEPSTAKE, TRIAL, UCAAS_HIGH, UCAAS_LOW)
40
+ * @property {string} [description] - A detailed description of the campaign (optional, must be between 40 and 4096 characters if provided)
41
+ * @property {boolean} [embeddedLink] - Whether the campaign includes an embedded link (optional)
42
+ * @property {boolean} [embeddedPhone] - Whether the campaign includes an embedded phone number (optional)
43
+ * @property {boolean} [termsAndConditions] - Whether the campaign includes terms and conditions (optional)
44
+ * @property {boolean} [numberPool] - Whether the campaign uses a number pool (optional)
45
+ * @property {boolean} [ageGated] - Whether the campaign is age-gated (optional)
46
+ * @property {boolean} [directLending] - Whether the campaign uses direct lending (optional)
47
+ * @property {boolean} [subscriberOptIn] - Whether the campaign requires subscriber opt-in (optional)
48
+ * @property {boolean} [subscriberOptOut] - Whether the campaign allows subscriber opt-out (optional)
49
+ * @property {boolean} [subscriberHelp] - Whether the campaign provides subscriber help (optional)
50
+ * @property {string} [sample1] - Sample message 1 for the campaign (optional, must be between 20 and 1024 characters if provided)
51
+ * @property {string} [sample2] - Sample message 2 for the campaign (optional, must be between 20 and 1024 characters if provided)
52
+ * @property {string} [sample3] - Sample message 3 for the campaign (optional, must be between 20 and 1024 characters if provided)
53
+ * @property {string} [sample4] - Sample message 4 for the campaign (optional, must be between 20 and 1024 characters if provided)
54
+ * @property {string} [sample5] - Sample message 5 for the campaign (optional, must be between 20 and 1024 characters if provided)
55
+ * @property {string} [messageFlow] - A detailed description of the message flow for the campaign (optional, must be between 40 and 4096 characters if provided)
56
+ * @property {string} [helpMessage] - A message providing help information for the campaign (optional)
57
+ * @property {boolean} [autoRenewal] - Whether the campaign should auto-renew (optional)
58
+ * @property {string} [tag] - A tag for the campaign (optional, must be at most 255 characters)
59
+ * @property {string} [optinKeywords] - A comma-separated list of keywords for opting in to the campaign (optional, must be at most 255 characters)
60
+ * @property {string} [optoutKeywords] - A comma-separated list of keywords for opting out of the campaign (optional, must be at most 255 characters)
61
+ * @property {string} [helpKeywords] - A comma-separated list of keywords for getting help with the campaign (optional, must be at most 255 characters)
62
+ * @property {string} [optinMessage] - A message sent to users when they opt in to the campaign (optional, must be between 20 and 1024 characters if provided)
63
+ * @property {string} [optoutMessage] - A message sent to users when they opt out of the campaign (optional, must be between 20 and 1024 characters if provided)
64
+ * @property {string} [privacyPolicyLink] - A URL linking to the privacy policy for the campaign (optional, must be at most 2048 characters if provided)
65
+ * @property {string} [termsAndConditionsLink] - A URL linking to the terms and conditions for the campaign (optional, must be at most 2048 characters if provided)
66
+ * @property {string} [embeddedLinkSample] - A sample of the embedded link used in the campaign (optional, must be at most 255 characters if provided)
67
+ */
68
+
69
+ export class Campaigns {
70
+ constructor(client, enableAdmin) {
71
+ this.client = client;
72
+ this.enableAdmin = enableAdmin;
73
+
74
+ if (enableAdmin) {
75
+ this.admin = {
76
+ /**
77
+ * Approve a campaign that is pending approval
78
+ * @async
79
+ * @roles signalhouse
80
+ * @param {Object} params - The parameters for approving the campaign
81
+ * @param {string} params.campaignId - The ID of the campaign to approve
82
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
83
+ * @throws {Error} Throws an error if the campaignId parameter is missing
84
+ * @returns {Promise<Object>} The response from the server
85
+ */
86
+ approveCampaign: async ({ campaignId, options = {} }) => {
87
+ this.client._require({ campaignId });
88
+ const safeCampaignId = encodeURIComponent(campaignId);
89
+ return this.client(`/campaign/approve/${safeCampaignId}`, { method: "POST", ...options });
90
+ },
91
+ /**
92
+ * Reject a campaign that is pending approval
93
+ * @async
94
+ * @roles signalhouse
95
+ * @param {Object} params - The parameters for rejecting the campaign
96
+ * @param {string} params.campaignId - The ID of the campaign to reject
97
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
98
+ * @throws {Error} Throws an error if the campaignId parameter is missing
99
+ * @returns {Promise<Object>} The response from the server
100
+ */
101
+ rejectCampaign: async ({ campaignId, options = {} }) => {
102
+ this.client._require({ campaignId });
103
+ const safeCampaignId = encodeURIComponent(campaignId);
104
+ return this.client(`/campaign/reject/${safeCampaignId}`, { method: "POST", ...options });
105
+ },
106
+ };
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Get a list of campaigns with optional filters
112
+ * @async
113
+ * @roles api, admin, developer, billing, user
114
+ * @param {Object} params - The parameters for filtering the campaigns
115
+ * @param {string} [params.id] - The ID of the campaign to filter by
116
+ * @param {string} [params.brandId] - The ID of the brand to filter by
117
+ * @param {string} [params.subgroupId] - The ID of the subgroup to filter by
118
+ * @param {string} [params.groupId] - The ID of the group to filter by
119
+ * @param {number} [params.page] - The page number for pagination
120
+ * @param {number} [params.limit] - The number of items per page
121
+ * @param {string} [params.status] - The status of the campaign to filter by
122
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
123
+ * @returns {Promise<Array>} The response from the server
124
+ */
125
+ async getCampaigns({ id, brandId, subgroupId, groupId, page, limit, status, options = {} }) {
126
+ const filters = { id, brandId, subgroupId, groupId, page, limit, status };
127
+ const queryString = this.client._getQueryString(filters);
128
+ return this.client(`/campaign${queryString}`, { method: "GET", ...options });
129
+ }
130
+
131
+ /**
132
+ * Create a new campaign
133
+ * @async
134
+ * @roles api, admin, developer, billing, user
135
+ * @param {Object} params - The parameters for creating the campaign (see CreateCampaignData typedef for details)
136
+ * @param {CreateCampaignData} params.campaignData - The data for the campaign to be created (see CreateCampaignData typedef for details)
137
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
138
+ * @throws {Error} Throws an error if the campaignData parameter is missing or if required fields in campaignData are missing
139
+ * @returns {Promise<Object>} The response from the server
140
+ */
141
+ async createCampaign({ campaignData, options = {} }) {
142
+ this.client._require({ campaignData: campaignData });
143
+ return this.client(`/campaign`, { method: "POST", body: campaignData, ...options });
144
+ }
145
+
146
+ /**
147
+ * Update an existing campaign
148
+ * @async
149
+ * @roles api, admin, developer, billing, user
150
+ * @param {Object} params - The parameters for updating the campaign (see UpdateCampaignData typedef for details)
151
+ * @param {string} params.campaignId - The ID of the campaign to update
152
+ * @param {UpdateCampaignData} params.campaignData - The data for the campaign to be updated (see UpdateCampaignData typedef for details)
153
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
154
+ * @throws {Error} Throws an error if the campaignId parameter is missing or if required fields in campaignData are missing
155
+ * @returns {Promise<Object>} The response from the server
156
+ */
157
+ async updateCampaign({ campaignId, campaignData, options = {} }) {
158
+ this.client._require({ campaignId: campaignId });
159
+ const safeCampaignId = encodeURIComponent(campaignId);
160
+ return this.client(`/campaign/${safeCampaignId}`, { method: "PUT", body: campaignData, ...options });
161
+ }
162
+
163
+ /**
164
+ * Delete an existing campaign (mark it as EXPIRED). The campaign will still be retrievable
165
+ * @async
166
+ * @roles api, admin, developer, billing, user
167
+ * @param {Object} params - The parameters for deleting the campaign
168
+ * @param {string} params.campaignId - The ID of the campaign to delete
169
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
170
+ * @throws {Error} Throws an error if the campaignId parameter is missing
171
+ * @returns {Promise<Object>} The response from the server
172
+ */
173
+ async deleteCampaign({ campaignId, options = {} }) {
174
+ this.client._require({ campaignId: campaignId });
175
+ const safeCampaignId = encodeURIComponent(campaignId);
176
+ return this.client(`/campaign/${safeCampaignId}`, { method: "DELETE", ...options });
177
+ }
178
+
179
+ /**
180
+ * Appeal a DCA-rejected campaign
181
+ * @async
182
+ * @roles api, admin, developer, billing, user
183
+ * @param {Object} params - The parameters for appealing the campaign rejection
184
+ * @param {string} params.campaignId - The ID of the campaign to appeal
185
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request (body should include { reason })
186
+ * @throws {Error} Throws an error if the campaignId parameter is missing
187
+ * @returns {Promise<Object>} The response from the server
188
+ */
189
+ async appealDcaRejection({ campaignId, options = {} }) {
190
+ this.client._require({ campaignId: campaignId });
191
+ const safeCampaignId = encodeURIComponent(campaignId);
192
+ return this.client(`/campaign/appealDcaRejection/${safeCampaignId}`, { method: "POST", ...options });
193
+ }
194
+
195
+ /**
196
+ * Nudge a connectivity partner to prioritize review of a campaign in PENDING_DCA_APPROVAL status
197
+ * @async
198
+ * @roles api, admin, developer, billing, user
199
+ * @param {Object} params - The parameters for nudging the campaign
200
+ * @param {string} params.campaignId - The ID of the campaign to nudge
201
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
202
+ * @throws {Error} Throws an error if the campaignId parameter is missing
203
+ * @returns {Promise<Object>} The response from the server
204
+ */
205
+ async nudgeDcaForCampaign({ campaignId, options = {} }) {
206
+ this.client._require({ campaignId: campaignId });
207
+ const safeCampaignId = encodeURIComponent(campaignId);
208
+ return this.client(`/campaign/nudge/${safeCampaignId}`, { method: "POST", ...options });
209
+ }
210
+ }