@signalhousellc/sdk 1.0.28 → 1.0.30
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/domains/Billing.js +4 -2
- package/src/domains/Campaigns.js +32 -0
- package/src/domains/Messages.js +48 -0
- package/src/domains/Numbers.js +102 -8
package/package.json
CHANGED
package/src/domains/Billing.js
CHANGED
|
@@ -11,6 +11,8 @@ export class Billing {
|
|
|
11
11
|
* @param {Object} params - The parameters for filtering the transaction history
|
|
12
12
|
* @param {string} [params.groupId] - The ID of the group to filter by
|
|
13
13
|
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
14
|
+
* @param {string} [params.brandId] - The brand ID to filter by
|
|
15
|
+
* @param {string} [params.campaignId] - The campaign ID to filter by
|
|
14
16
|
* @param {string} [params.entryType] - The type of entry to filter by
|
|
15
17
|
* @param {string} [params.transactionType] - The type of transaction to filter by
|
|
16
18
|
* @param {string} [params.startDate] - The start date for the filter
|
|
@@ -18,8 +20,8 @@ export class Billing {
|
|
|
18
20
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
19
21
|
* @returns {Promise<Array>} The response from the server
|
|
20
22
|
*/
|
|
21
|
-
async getTransactionHistory({ groupId, subgroupId, entryType, transactionType, startDate, endDate, options = {} }) {
|
|
22
|
-
const filters = { groupId, subgroupId, entryType, transactionType, startDate, endDate };
|
|
23
|
+
async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, options = {} }) {
|
|
24
|
+
const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate };
|
|
23
25
|
const queryString = this.client._getQueryString(filters);
|
|
24
26
|
return this.client(`/billing/wallet/transactionHistory${queryString}`, { method: "GET", ...options });
|
|
25
27
|
}
|
package/src/domains/Campaigns.js
CHANGED
|
@@ -175,4 +175,36 @@ export class Campaigns {
|
|
|
175
175
|
const safeCampaignId = encodeURIComponent(campaignId);
|
|
176
176
|
return this.client(`/campaign/${safeCampaignId}`, { method: "DELETE", ...options });
|
|
177
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
|
+
}
|
|
178
210
|
}
|
package/src/domains/Messages.js
CHANGED
|
@@ -73,6 +73,54 @@ export class Messages {
|
|
|
73
73
|
return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Get aggregated DNC (Do Not Contact) opt-out analytics with optional filters
|
|
78
|
+
* @async
|
|
79
|
+
* @roles api, admin, developer, billing, user
|
|
80
|
+
* @param {Object} params - The parameters for getting DNC analytics
|
|
81
|
+
* @param {string} [params.groupId] - Filter by the ID of the associated group
|
|
82
|
+
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
83
|
+
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
84
|
+
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
85
|
+
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
86
|
+
* @param {string} [params.carrier] - Filter by the carrier
|
|
87
|
+
* @param {string} [params.startDate] - Filter by start date
|
|
88
|
+
* @param {string} [params.endDate] - Filter by end date
|
|
89
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
90
|
+
* @returns {Promise<Object>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, byCarrier)
|
|
91
|
+
*/
|
|
92
|
+
async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
|
|
93
|
+
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
|
|
94
|
+
const queryString = this.client._getQueryString(filters);
|
|
95
|
+
return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get paginated Do Not Call records with optional filters
|
|
100
|
+
* @async
|
|
101
|
+
* @roles api, admin, developer, billing, user
|
|
102
|
+
* @param {Object} params - The parameters for getting DNC records
|
|
103
|
+
* @param {string} [params.groupId] - Filter by the ID of the associated group
|
|
104
|
+
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
105
|
+
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
106
|
+
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
107
|
+
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
108
|
+
* @param {string} [params.carrier] - Filter by the carrier
|
|
109
|
+
* @param {string} [params.startDate] - Filter by start date
|
|
110
|
+
* @param {string} [params.endDate] - Filter by end date
|
|
111
|
+
* @param {number} [params.page] - Page number for pagination
|
|
112
|
+
* @param {number} [params.limit] - Number of records per page
|
|
113
|
+
* @param {string} [params.sortField] - Field to sort by
|
|
114
|
+
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
115
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
116
|
+
* @returns {Promise<Object>} - A promise that resolves to the paginated DNC records
|
|
117
|
+
*/
|
|
118
|
+
async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, options = {} }) {
|
|
119
|
+
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder };
|
|
120
|
+
const queryString = this.client._getQueryString(filters);
|
|
121
|
+
return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
/**
|
|
77
125
|
* Send an SMS message to one or more recipient phone numbers
|
|
78
126
|
* @async
|
package/src/domains/Numbers.js
CHANGED
|
@@ -2,6 +2,49 @@ export class Numbers {
|
|
|
2
2
|
constructor(client, enableAdmin) {
|
|
3
3
|
this.client = client;
|
|
4
4
|
this.enableAdmin = enableAdmin;
|
|
5
|
+
|
|
6
|
+
if (enableAdmin) {
|
|
7
|
+
this.admin = {
|
|
8
|
+
/**
|
|
9
|
+
* Update a port-in request's status (signalhouse only)
|
|
10
|
+
* @async
|
|
11
|
+
* @roles signalhouse
|
|
12
|
+
* @param {Object} params - The parameters for updating the status
|
|
13
|
+
* @param {string} params.portingId - The _id of the port-in request
|
|
14
|
+
* @param {string} params.status - The new status (PENDING, IN_PROGRESS, REJECTED)
|
|
15
|
+
* @param {string} [params.description] - Optional description for the status change
|
|
16
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
17
|
+
* @returns {Promise<Object>} A promise that resolves to the updated port-in request
|
|
18
|
+
*/
|
|
19
|
+
changePortingStatus: async ({ portingId, status, description, options = {} }) => {
|
|
20
|
+
this.client._require({ portingId, status });
|
|
21
|
+
const safeId = encodeURIComponent(portingId);
|
|
22
|
+
return this.client(`/number/portin/${safeId}/status`, {
|
|
23
|
+
method: "PUT",
|
|
24
|
+
body: { status, description },
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Approve a port-in request, setting its status to SUCCESS (signalhouse only)
|
|
31
|
+
* @async
|
|
32
|
+
* @roles signalhouse
|
|
33
|
+
* @param {Object} params - The parameters for approving the request
|
|
34
|
+
* @param {string} params.portingId - The _id of the port-in request
|
|
35
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
36
|
+
* @returns {Promise<Object>} A promise that resolves to the updated port-in request
|
|
37
|
+
*/
|
|
38
|
+
approvePortRequest: async ({ portingId, options = {} }) => {
|
|
39
|
+
this.client._require({ portingId });
|
|
40
|
+
const safeId = encodeURIComponent(portingId);
|
|
41
|
+
return this.client(`/number/portin/${safeId}/approve`, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
...options,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
5
48
|
}
|
|
6
49
|
|
|
7
50
|
/**
|
|
@@ -91,19 +134,70 @@ export class Numbers {
|
|
|
91
134
|
}
|
|
92
135
|
|
|
93
136
|
/**
|
|
94
|
-
*
|
|
137
|
+
* Submit a port-in request for one or more phone numbers from another provider
|
|
95
138
|
* @async
|
|
96
139
|
* @roles api, admin, developer, billing, user
|
|
97
|
-
* @param {Object} params - The parameters for
|
|
98
|
-
* @param {Object} params.numberData - The data
|
|
140
|
+
* @param {Object} params - The parameters for the port-in request
|
|
141
|
+
* @param {Object} params.numberData - The port-in request data including owner info, address, phone numbers, and signature
|
|
99
142
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
100
|
-
* @throws {Error} Throws an error
|
|
101
|
-
* @returns {Promise<Object>} A promise that
|
|
143
|
+
* @throws {Error} Throws an error if the numberData parameter is missing
|
|
144
|
+
* @returns {Promise<Object>} A promise that resolves to the created port-in request
|
|
102
145
|
*/
|
|
103
146
|
async portInPhoneNumber({ numberData, options = {} }) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
this.client._require({ numberData });
|
|
148
|
+
return this.client(`/number/portin`, { method: "POST", body: numberData, ...options });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get port-in requests with optional filters. Signal House staff can view all requests; regular users see only their group's requests.
|
|
153
|
+
* @async
|
|
154
|
+
* @roles api, admin, developer, billing, user
|
|
155
|
+
* @param {Object} [params] - The parameters for filtering port-in requests
|
|
156
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
157
|
+
* @param {string} [params.phoneNumber] - Filter by phone number
|
|
158
|
+
* @param {string} [params.status] - Filter by status (PENDING, IN_PROGRESS, COMPLETED, REJECTED, CANCELLED)
|
|
159
|
+
* @param {number} [params.page] - The page number for pagination (default: 1)
|
|
160
|
+
* @param {number} [params.limit] - The number of items per page (default: 20)
|
|
161
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
162
|
+
* @returns {Promise<Object>} A promise that resolves to the paginated list of port-in requests
|
|
163
|
+
*/
|
|
164
|
+
async getPortRequests({ groupId, phoneNumber, status, page, limit, options = {} } = {}) {
|
|
165
|
+
const filters = { groupId, phoneNumber, status, page, limit };
|
|
166
|
+
const queryString = this.client._getQueryString(filters);
|
|
167
|
+
return this.client(`/number/portin${queryString}`, { method: "GET", ...options });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Get a single port-in request by its ID
|
|
172
|
+
* @async
|
|
173
|
+
* @roles api, admin, developer, billing, user
|
|
174
|
+
* @param {Object} params - The parameters for getting the port request
|
|
175
|
+
* @param {string} params.id - The _id of the port-in request
|
|
176
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
177
|
+
* @returns {Promise<Object>} A promise that resolves to the port-in request object
|
|
178
|
+
*/
|
|
179
|
+
async getPortRequestById({ id, options = {} }) {
|
|
180
|
+
this.client._require({ id });
|
|
181
|
+
const safeId = encodeURIComponent(id);
|
|
182
|
+
return this.client(`/number/portin/${safeId}`, { method: "GET", ...options });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Get porting requests - fetches a single request by portingId, or delegates to getPortRequests for listing
|
|
187
|
+
* @async
|
|
188
|
+
* @roles api, admin, developer, billing, user
|
|
189
|
+
* @param {Object} params - The parameters
|
|
190
|
+
* @param {string} [params.portingId] - If provided, fetches a single port request by ID
|
|
191
|
+
* @param {number} [params.page] - Page number for pagination (used when listing)
|
|
192
|
+
* @param {number} [params.limit] - Items per page (used when listing)
|
|
193
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
194
|
+
* @returns {Promise<Object>} A promise that resolves to the port-in request(s)
|
|
195
|
+
*/
|
|
196
|
+
async getPortingRequests({ portingId, page, limit, options = {} } = {}) {
|
|
197
|
+
if (portingId) {
|
|
198
|
+
return this.getPortRequestById({ id: portingId, options });
|
|
199
|
+
}
|
|
200
|
+
return this.getPortRequests({ page, limit, options });
|
|
107
201
|
}
|
|
108
202
|
|
|
109
203
|
/**
|