@signalhousellc/sdk 1.5.1 → 1.6.0
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 +5 -56
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +32 -34
- package/voice-browser.d.ts +1 -0
- package/voice-browser.js +2 -0
- package/warn.js +7 -0
- package/webhooks.d.ts +1 -0
- package/webhooks.js +2 -0
- package/scripts/install-skills.mjs +0 -329
- package/skills/VENDORED.json +0 -22
- package/skills/signalhouse-10dlc/SKILL.md +0 -172
- package/skills/signalhouse-10dlc/examples/brightsmile-onboarding.md +0 -62
- package/skills/signalhouse-10dlc/references/tcr-rejection-causes.md +0 -104
- package/skills/signalhouse-advisor/SKILL.md +0 -84
- package/skills/signalhouse-numbers/SKILL.md +0 -82
- package/skills/signalhouse-setup/SKILL.md +0 -121
- package/skills/signalhouse-sms/SKILL.md +0 -81
- package/skills/signalhouse-webhooks/SKILL.md +0 -148
- package/src/SignalHouseSDK.js +0 -201
- package/src/domains/Agents.js +0 -987
- package/src/domains/Auth.js +0 -225
- package/src/domains/Billing.js +0 -265
- package/src/domains/Brands.js +0 -566
- package/src/domains/Campaigns.js +0 -691
- package/src/domains/Dnc.js +0 -168
- package/src/domains/Groups.js +0 -187
- package/src/domains/Landings.js +0 -237
- package/src/domains/Messages.js +0 -609
- package/src/domains/Notifications.js +0 -62
- package/src/domains/Numbers.js +0 -574
- package/src/domains/Onboarding.js +0 -128
- package/src/domains/Registrations.js +0 -246
- package/src/domains/Shortlinks.js +0 -80
- package/src/domains/Subgroups.js +0 -136
- package/src/domains/Subscriptions.js +0 -164
- package/src/domains/Templates.js +0 -403
- package/src/domains/Tickets.js +0 -100
- package/src/domains/Users.js +0 -228
- package/src/domains/Voice.js +0 -41
- package/src/domains/Webhooks.js +0 -125
- package/src/domains/voice/Analytics.js +0 -82
- package/src/domains/voice/CallLogs.js +0 -111
- package/src/domains/voice/Calls.js +0 -118
- package/src/domains/voice/GlobalVoiceSettings.js +0 -54
- package/src/domains/voice/NumberRoutes.js +0 -82
- package/src/domains/voice/ProgrammableVoiceProfiles.js +0 -191
- package/src/domains/voice/SipProfiles.js +0 -203
- package/src/domains/voice/SipTrunks.js +0 -203
- package/src/domains/voice/Tokens.js +0 -96
- package/src/domains/voice/browser/Call.js +0 -366
- package/src/domains/voice/browser/Device.js +0 -484
- package/src/domains/voice/browser/index.js +0 -17
- package/src/webhooks/verifySignature.js +0 -66
package/src/domains/Auth.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export class Auth {
|
|
8
|
-
constructor(client, enableAdmin) {
|
|
9
|
-
this.client = client;
|
|
10
|
-
this.enableAdmin = enableAdmin;
|
|
11
|
-
|
|
12
|
-
// Hidden Admin namespace INSIDE the domain
|
|
13
|
-
if (enableAdmin) {
|
|
14
|
-
this.admin = {
|
|
15
|
-
/**
|
|
16
|
-
* Force-log-out every human user in a specific group (SHGHL-2740) - for account-takeover
|
|
17
|
-
* response, independent of the automatic Rejected-lockout trigger.
|
|
18
|
-
* @async
|
|
19
|
-
* @roles signalhouse
|
|
20
|
-
* @param {Object} params - The parameters for forcing a group logout
|
|
21
|
-
* @param {string} params.groupId - The ID of the group whose users should be force-logged-out
|
|
22
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
23
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
24
|
-
* @returns {Promise<SdkResponse<any>>} - The response containing loggedOutCount
|
|
25
|
-
*/
|
|
26
|
-
forceLogoutGroupUsers: async ({ groupId, options = {} }) => {
|
|
27
|
-
this.client._require({ groupId });
|
|
28
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
29
|
-
return this.client(`/auth/groups/${safeGroupId}/logout-all`, { method: "POST", ...options });
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Login with email and password
|
|
37
|
-
* @async
|
|
38
|
-
* @roles public
|
|
39
|
-
* @param {Object} params
|
|
40
|
-
* @param {string} params.email - The user's email address
|
|
41
|
-
* @param {string} params.password - The user's password
|
|
42
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
43
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
44
|
-
*/
|
|
45
|
-
async login({ email, password, options = {} }) {
|
|
46
|
-
return this.client(`/auth`, { method: "POST", body: { email, password }, ...options });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Register a new account (creates a group and its owner user) and receive a JWT Bearer token
|
|
51
|
-
* @async
|
|
52
|
-
* @roles public
|
|
53
|
-
* @param {Object} params
|
|
54
|
-
* @param {string} params.businessName - The business / group name
|
|
55
|
-
* @param {string} params.fullName - The owner's full name
|
|
56
|
-
* @param {string} params.email - The owner's work email
|
|
57
|
-
* @param {string} params.password - The owner's password (min 8 characters)
|
|
58
|
-
* @param {string} [params.phone] - National phone number
|
|
59
|
-
* @param {string} [params.dialCode] - Country dial code (e.g. "1")
|
|
60
|
-
* @param {string} [params.country] - Country ISO code (e.g. "US")
|
|
61
|
-
* @param {string} [params.volume] - Estimated monthly message volume
|
|
62
|
-
* @param {string[]} [params.products] - Products the account intends to integrate
|
|
63
|
-
* @param {boolean} [params.acceptedTermsOfService] - Whether the user accepted the Terms of Service
|
|
64
|
-
* @param {string} [params.psXid] - PartnerStack click id (ps_xid) captured from a referral link
|
|
65
|
-
* @param {string} [params.psPartnerKey] - PartnerStack partner key (ps_partner_key) captured from a referral link
|
|
66
|
-
* @param {Object} [params.attribution] - Marketing attribution captured at signup
|
|
67
|
-
* @param {string} [params.attribution.posthogDistinctId] - PostHog distinct id of the registering visitor
|
|
68
|
-
* @param {Object} [params.attribution.firstTouch] - First-ever visit: utmSource, utmMedium, utmCampaign, utmTerm, utmContent, gclid, gbraid, wbraid, fbclid, msclkid, referrer, landingUrl, timestamp
|
|
69
|
-
* @param {Object} [params.attribution.lastTouch] - Visit that registered, same keys as firstTouch
|
|
70
|
-
* @param {string} [params.attribution.shLanding] - Marketing-site landing page passed on the register link (sh_landing)
|
|
71
|
-
* @param {string} [params.attribution.shCta] - Marketing-site CTA that sent the visitor (sh_cta)
|
|
72
|
-
* @param {string} [params.attribution.shGuide] - Marketing-site guide the CTA was on (sh_guide)
|
|
73
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
74
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server (contains the JWT token)
|
|
75
|
-
*/
|
|
76
|
-
async register({ businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution, options = {} }) {
|
|
77
|
-
return this.client(`/auth/register`, {
|
|
78
|
-
method: "POST",
|
|
79
|
-
body: { businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution },
|
|
80
|
-
...options,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Verify an account email using the single-use token from the verification link, signing the
|
|
86
|
-
* account in on success.
|
|
87
|
-
*
|
|
88
|
-
* The response carries a session JWT (`token`) for the user the link was emailed to, so a click
|
|
89
|
-
* from any device establishes a session — use it exactly as you would the token from `login`.
|
|
90
|
-
* `token` is omitted when the link cannot establish a session (issued before auto-login shipped,
|
|
91
|
-
* or the account is inactive/ineligible); `verified` is still true in that case, so treat a
|
|
92
|
-
* missing token as "verified, ask them to log in" rather than as a failure.
|
|
93
|
-
*
|
|
94
|
-
* Rate limited per source IP. The token is single-use and expires 24 hours after it is issued.
|
|
95
|
-
* @async
|
|
96
|
-
* @roles public
|
|
97
|
-
* @param {Object} params
|
|
98
|
-
* @param {string} params.token - The verification token from the email link
|
|
99
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
100
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ verified: true, token?: string })
|
|
101
|
-
*/
|
|
102
|
-
async verifyEmail({ token, options = {} }) {
|
|
103
|
-
this.client._require({ token });
|
|
104
|
-
return this.client(`/auth/verify-email`, { method: "POST", body: { token }, ...options });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Request a password-reset link be emailed to the given address (public). Always resolves
|
|
109
|
-
* successfully regardless of whether an account exists for the email, so it cannot be used to
|
|
110
|
-
* enumerate registered emails.
|
|
111
|
-
* @async
|
|
112
|
-
* @roles public
|
|
113
|
-
* @param {Object} params
|
|
114
|
-
* @param {string} params.email - The email address to send a reset link to
|
|
115
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
116
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ success: true })
|
|
117
|
-
*/
|
|
118
|
-
async forgotPassword({ email, options = {} }) {
|
|
119
|
-
this.client._require({ email });
|
|
120
|
-
return this.client(`/auth/forgot-password`, { method: "POST", body: { email }, ...options });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Reset a password using the single-use token from a password-reset email link (public)
|
|
125
|
-
* @async
|
|
126
|
-
* @roles public
|
|
127
|
-
* @param {Object} params
|
|
128
|
-
* @param {string} params.token - The single-use reset token from the email link
|
|
129
|
-
* @param {string} params.password - The new password to set (min 8 characters)
|
|
130
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
131
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ success: true })
|
|
132
|
-
*/
|
|
133
|
-
async resetPasswordWithToken({ token, password, options = {} }) {
|
|
134
|
-
this.client._require({ token, password });
|
|
135
|
-
return this.client(`/auth/reset-password`, { method: "POST", body: { token, password }, ...options });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Resend the account verification email to the authenticated caller.
|
|
140
|
-
*
|
|
141
|
-
* Rate limited per user; issuing a new link invalidates the previous one.
|
|
142
|
-
* @async
|
|
143
|
-
* @roles admin, developer, billing, user
|
|
144
|
-
* @param {Object} [params]
|
|
145
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
146
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ sent: true })
|
|
147
|
-
*/
|
|
148
|
-
async sendVerificationEmail({ options = {} } = {}) {
|
|
149
|
-
return this.client(`/auth/send-verification-email`, { method: "POST", ...options });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Reset a user's password
|
|
154
|
-
* @async
|
|
155
|
-
* @roles api, admin, self
|
|
156
|
-
* @param {Object} params
|
|
157
|
-
* @param {string} params.userId - The id of the user
|
|
158
|
-
* @param {string} params.newPassword - The new password to set for the user
|
|
159
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
160
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
161
|
-
*/
|
|
162
|
-
async resetPassword({ userId, newPassword, options = {} }) {
|
|
163
|
-
this.client._require({ userId, newPassword });
|
|
164
|
-
const safeUserId = encodeURIComponent(userId);
|
|
165
|
-
return this.client(`/auth/resetpassword/${safeUserId}`, { method: "PUT", body: { newPassword }, ...options });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Get token login history for a group or user
|
|
170
|
-
* @async
|
|
171
|
-
* @roles signalhouse_admin, signalhouse_api, signalhouse_user, admin, api (groupId query); self (userId query)
|
|
172
|
-
* @param {Object} params
|
|
173
|
-
* @param {string} [params.groupId] - Returns history for all users in the group (one of groupId/userId required)
|
|
174
|
-
* @param {string} [params.userId] - Returns history for a specific user (one of groupId/userId required)
|
|
175
|
-
* @param {number} [params.page] - Page number (min 1, default 1)
|
|
176
|
-
* @param {number} [params.limit] - Results per page (min 1, max 100, default 20)
|
|
177
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
178
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
179
|
-
*/
|
|
180
|
-
async getAuthHistory({ groupId, userId, page, limit, options = {} }) {
|
|
181
|
-
this.client._require({ "groupId or userId": groupId ?? userId });
|
|
182
|
-
const queryString = this.client._getQueryString({ groupId, userId, page, limit });
|
|
183
|
-
return this.client(`/auth/history${queryString}`, { method: "GET", ...options });
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Log out all other users in the caller's active group
|
|
188
|
-
* @async
|
|
189
|
-
* @roles admin
|
|
190
|
-
* @param {Object} [params]
|
|
191
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
192
|
-
* @returns {Promise<SdkResponse<any>>} The response containing loggedOutCount
|
|
193
|
-
*/
|
|
194
|
-
async logoutAll({ options = {} } = {}) {
|
|
195
|
-
return this.client(`/auth/logout-all`, { method: "POST", ...options });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Get the Group ID associated with the caller's JWT (the caller's active group). Useful for
|
|
200
|
-
* discovering your own groupId, which is required on most other API requests.
|
|
201
|
-
* @async
|
|
202
|
-
* @roles admin, developer, billing, user, api
|
|
203
|
-
* @param {Object} [params]
|
|
204
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
205
|
-
* @returns {Promise<SdkResponse<any>>} The response containing { groupId }
|
|
206
|
-
*/
|
|
207
|
-
async getGroupId({ options = {} } = {}) {
|
|
208
|
-
return this.client(`/auth/group-id`, { method: "GET", ...options });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Mint a single-use, short-lived external-link token for the authenticated caller. The token is
|
|
213
|
-
* handed to the GHL/Shopify backend so it can link the caller's existing V2 group to its tenant.
|
|
214
|
-
* @async
|
|
215
|
-
* @roles admin, developer, billing, user
|
|
216
|
-
* @param {Object} params
|
|
217
|
-
* @param {string} params.product - The external system to link to ("ghl" or "shopify")
|
|
218
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
219
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server ({ token })
|
|
220
|
-
*/
|
|
221
|
-
async requestExternalLinkToken({ product, options = {} }) {
|
|
222
|
-
this.client._require({ product });
|
|
223
|
-
return this.client(`/auth/external-link-token`, { method: "POST", body: { product }, ...options });
|
|
224
|
-
}
|
|
225
|
-
}
|
package/src/domains/Billing.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
-
/**
|
|
3
|
-
* @template T
|
|
4
|
-
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export class Billing {
|
|
8
|
-
constructor(client, enableAdmin) {
|
|
9
|
-
this.client = client;
|
|
10
|
-
this.enableAdmin = enableAdmin;
|
|
11
|
-
|
|
12
|
-
if (enableAdmin) {
|
|
13
|
-
this.admin = {
|
|
14
|
-
/**
|
|
15
|
-
* Issue a credit to a customer's wallet
|
|
16
|
-
* @async
|
|
17
|
-
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
18
|
-
* @param {Object} params
|
|
19
|
-
* @param {string} params.groupId - The group ID to credit
|
|
20
|
-
* @param {number} params.amount - Amount in microdollars
|
|
21
|
-
* @param {string} params.transactionType - Type of credit (e.g. "Goodwill Credit", "Billing Correction")
|
|
22
|
-
* @param {string} params.description - Reason for the credit (1-500 characters)
|
|
23
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
24
|
-
* @returns {Promise<SdkResponse<any>>} The created transaction object
|
|
25
|
-
*/
|
|
26
|
-
issueCredit: async ({ groupId, amount, transactionType, description, options = {} }) => {
|
|
27
|
-
this.client._require({ groupId, amount, transactionType, description });
|
|
28
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
29
|
-
return this.client(`/billing/wallet/credit/${safeGroupId}`, {
|
|
30
|
-
method: "POST",
|
|
31
|
-
body: { amount, transactionType, description },
|
|
32
|
-
...options,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Update fee schedule pricing for a customer group
|
|
38
|
-
* @async
|
|
39
|
-
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
40
|
-
* @param {Object} params
|
|
41
|
-
* @param {string} params.groupId - The group ID to update fees for
|
|
42
|
-
* @param {Object} params.fees - Object of fee field names to microdollar values
|
|
43
|
-
* @param {boolean} [params.overrideActiveSubscription=false] - If true, also update the active subscription fees
|
|
44
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
45
|
-
* @returns {Promise<SdkResponse<any>>} The updated fee schedule
|
|
46
|
-
*/
|
|
47
|
-
updateFees: async ({ groupId, fees, overrideActiveSubscription, options = {} }) => {
|
|
48
|
-
this.client._require({ groupId, fees });
|
|
49
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
50
|
-
return this.client(`/billing/fees/${safeGroupId}`, {
|
|
51
|
-
method: "PUT",
|
|
52
|
-
body: { fees, overrideActiveSubscription },
|
|
53
|
-
...options,
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Get transaction history with optional filters
|
|
62
|
-
* @async
|
|
63
|
-
* @roles api, admin, developer, billing, user
|
|
64
|
-
* @param {Object} params - The parameters for filtering the transaction history
|
|
65
|
-
* @param {string} [params.groupId] - The ID of the group to filter by
|
|
66
|
-
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
67
|
-
* @param {string} [params.brandId] - The brand ID to filter by
|
|
68
|
-
* @param {string} [params.campaignId] - The campaign ID to filter by
|
|
69
|
-
* @param {string} [params.entryType] - The type of entry to filter by
|
|
70
|
-
* @param {string} [params.transactionType] - The type of transaction to filter by
|
|
71
|
-
* @param {string} [params.startDate] - ISO-8601 date or timestamp; normalized to start-of-UTC-day (inclusive)
|
|
72
|
-
* @param {string} [params.endDate] - ISO-8601 date or timestamp; normalized to end-of-UTC-day (inclusive). Hourly resolution is not supported
|
|
73
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
74
|
-
* @returns {Promise<SdkResponse<Array>>} The response from the server
|
|
75
|
-
*/
|
|
76
|
-
async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, options = {} }) {
|
|
77
|
-
const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate };
|
|
78
|
-
const queryString = this.client._getQueryString(filters);
|
|
79
|
-
return this.client(`/billing/wallet/transactionHistory${queryString}`, { method: "GET", ...options });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get payment history (wallet recharge transactions) with server-side pagination
|
|
84
|
-
* @async
|
|
85
|
-
* @roles api, admin, developer, billing, user
|
|
86
|
-
* @param {Object} params - The parameters for filtering payment history
|
|
87
|
-
* @param {string} params.groupId - The ID of the group to filter by
|
|
88
|
-
* @param {string} params.startDate - Start date in YYYY-MM-DD format (inclusive)
|
|
89
|
-
* @param {string} params.endDate - End date in YYYY-MM-DD format (inclusive)
|
|
90
|
-
* @param {number} [params.page=1] - Page number (positive integer)
|
|
91
|
-
* @param {number} [params.limit=10] - Results per page (positive integer, max 10000)
|
|
92
|
-
* @param {string} [params.timezone] - IANA timezone (default: "UTC")
|
|
93
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
94
|
-
* @returns {Promise<SdkResponse<{data: Array<Object>, pagination: {page: number, limit: number, totalRecords: number, totalPages: number, totalAmount: number}}>>}
|
|
95
|
-
*/
|
|
96
|
-
async getPaymentHistory({ groupId, startDate, endDate, page, limit, timezone, options = {} }) {
|
|
97
|
-
const filters = { groupId, startDate, endDate, page, limit, timezone };
|
|
98
|
-
const queryString = this.client._getQueryString(filters);
|
|
99
|
-
return this.client(`/billing/wallet/paymentHistory${queryString}`, { method: "GET", ...options });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Get the wallet information for a specific group
|
|
104
|
-
* @async
|
|
105
|
-
* @roles api, admin, developer, billing, user
|
|
106
|
-
* @param {Object} params - The parameters for getting the wallet information
|
|
107
|
-
* @param {string} params.groupId - The ID of the group to get the wallet information for
|
|
108
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
109
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
110
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
111
|
-
*/
|
|
112
|
-
async getWallet({ groupId, options = {} }) {
|
|
113
|
-
this.client._require({ groupId });
|
|
114
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
115
|
-
return this.client(`/billing/wallet/${safeGroupId}`, { method: "GET", ...options });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Update the wallet settings for a specific group
|
|
120
|
-
* @async
|
|
121
|
-
* @roles api, admin, developer, billing, user
|
|
122
|
-
* @param {Object} params - The parameters for updating the wallet settings
|
|
123
|
-
* @param {string} params.groupId - The ID of the group to update the wallet settings for
|
|
124
|
-
* @param {boolean} [params.autoRechargeEnabled] - Whether auto-recharge is enabled for the wallet
|
|
125
|
-
* @param {number} [params.autoRechargeThreshold] - The threshold amount for auto-recharge to trigger
|
|
126
|
-
* @param {number} [params.autoRechargeToAmount] - The amount to recharge to when auto-recharge is triggered
|
|
127
|
-
* @param {string} [params.primaryPaymentMethodId] - The ID of the primary payment method to use for auto-recharge
|
|
128
|
-
* @param {string} [params.secondaryPaymentMethodId] - The ID of the secondary payment method to use for auto-recharge if the primary method fails
|
|
129
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
130
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
131
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
132
|
-
*/
|
|
133
|
-
async updateWallet({ groupId, autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId, options = {} }) {
|
|
134
|
-
this.client._require({ groupId });
|
|
135
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
136
|
-
return this.client(`/billing/wallet/${safeGroupId}`, {
|
|
137
|
-
method: "PUT",
|
|
138
|
-
body: { autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId },
|
|
139
|
-
...options,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Get the payment methods for a specific group
|
|
145
|
-
* @async
|
|
146
|
-
* @roles api, admin, developer, billing, user
|
|
147
|
-
* @param {Object} params - The parameters for getting the payment methods
|
|
148
|
-
* @param {string} params.groupId - The ID of the group to get the payment methods for
|
|
149
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
150
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
151
|
-
* @returns {Promise<SdkResponse<Array>>} The response from the server
|
|
152
|
-
*/
|
|
153
|
-
async getPaymentMethods({ groupId, options = {} }) {
|
|
154
|
-
this.client._require({ groupId });
|
|
155
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
156
|
-
return this.client(`/billing/wallet/paymentMethods/${safeGroupId}`, { method: "GET", ...options });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Add funds to a group's wallet
|
|
161
|
-
* @async
|
|
162
|
-
* @roles api, admin, developer, billing, user
|
|
163
|
-
* @param {Object} params - The parameters for adding funds
|
|
164
|
-
* @param {string} params.groupId - The ID of the group to add funds to
|
|
165
|
-
* @param {number} params.amount - The amount to add to the group's wallet in microdollars (e.g., $10 would be 10000000)
|
|
166
|
-
* @param {string} [params.paymentMethodId] - The ID of the payment method to use for adding funds
|
|
167
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
168
|
-
* @throws {Error} Throws an error if the groupId or amount parameters are missing
|
|
169
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
170
|
-
*/
|
|
171
|
-
async addFunds({ groupId, amount, paymentMethodId = undefined, options = {} }) {
|
|
172
|
-
this.client._require({ groupId, amount });
|
|
173
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
174
|
-
return this.client(`/billing/wallet/addfunds/${safeGroupId}`, { method: "POST", body: { amount, paymentMethodId }, ...options });
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Add a payment method to a group's wallet
|
|
179
|
-
* @async
|
|
180
|
-
* @roles api, admin, developer, billing, user
|
|
181
|
-
* @param {Object} params - The parameters for adding a payment method
|
|
182
|
-
* @param {string} params.groupId - The ID of the group to add the payment method to
|
|
183
|
-
* @param {string} params.paymentMethodId - The ID of the payment method to add
|
|
184
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
185
|
-
* @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
|
|
186
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
187
|
-
*/
|
|
188
|
-
async addPaymentMethod({ groupId, paymentMethodId, options = {} }) {
|
|
189
|
-
this.client._require({ groupId, paymentMethodId });
|
|
190
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
191
|
-
return this.client(`/billing/wallet/paymentMethod/${safeGroupId}`, { method: "POST", body: { paymentMethodId }, ...options });
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Remove a payment method from a group's wallet
|
|
196
|
-
* @async
|
|
197
|
-
* @roles api, admin, developer, billing, user
|
|
198
|
-
* @param {Object} params - The parameters for removing a payment method
|
|
199
|
-
* @param {string} params.groupId - The ID of the group to remove the payment method from
|
|
200
|
-
* @param {string} params.paymentMethodId - The ID of the payment method to remove
|
|
201
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
202
|
-
* @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
|
|
203
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
204
|
-
*/
|
|
205
|
-
async removePaymentMethod({ groupId, paymentMethodId, options = {} }) {
|
|
206
|
-
this.client._require({ groupId, paymentMethodId });
|
|
207
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
208
|
-
const safePaymentMethodId = encodeURIComponent(paymentMethodId);
|
|
209
|
-
return this.client(`/billing/wallet/paymentMethod/${safeGroupId}/${safePaymentMethodId}`, { method: "DELETE", ...options });
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Get invoice details with optional filters
|
|
214
|
-
* @async
|
|
215
|
-
* @roles api, admin, developer, billing, user
|
|
216
|
-
* @param {Object} params - The parameters for filtering the invoice details
|
|
217
|
-
* @param {string} [params.groupId] - The ID of the group to filter by
|
|
218
|
-
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
219
|
-
* @param {string} [params.startDate] - ISO-8601 date or timestamp; normalized to start-of-UTC-day (inclusive)
|
|
220
|
-
* @param {string} [params.endDate] - ISO-8601 date or timestamp; normalized to end-of-UTC-day (inclusive). Hourly resolution is not supported
|
|
221
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
222
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
223
|
-
*/
|
|
224
|
-
async getInvoiceDetails({ groupId, subgroupId, startDate, endDate, options = {} }) {
|
|
225
|
-
const filters = { groupId, subgroupId, startDate, endDate };
|
|
226
|
-
const queryString = this.client._getQueryString(filters);
|
|
227
|
-
return this.client(`/billing/invoiceDetails${queryString}`, { method: "GET", ...options });
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Get ledger-backed invoice summary from raw ClickHouse transactions
|
|
232
|
-
* @async
|
|
233
|
-
* @roles api, admin, developer, billing, user
|
|
234
|
-
* @param {Object} params
|
|
235
|
-
* @param {string} params.groupId - The ID of the group to filter by
|
|
236
|
-
* @param {string} [params.subgroupId] - The ID of the subgroup to filter by
|
|
237
|
-
* @param {string} params.startDate - Start date in YYYY-MM-DD format (inclusive)
|
|
238
|
-
* @param {string} params.endDate - End date in YYYY-MM-DD format (inclusive)
|
|
239
|
-
* @param {string} [params.timezone] - IANA timezone (default: "UTC")
|
|
240
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
241
|
-
* @returns {Promise<SdkResponse<Array<{entryType: string, transactionType: string, unitPrice: number, quantity: number, amount: number}>>>}
|
|
242
|
-
*/
|
|
243
|
-
async getInvoiceLedger({ groupId, subgroupId, startDate, endDate, timezone, options = {} }) {
|
|
244
|
-
const filters = { groupId, subgroupId, startDate, endDate, timezone };
|
|
245
|
-
const queryString = this.client._getQueryString(filters);
|
|
246
|
-
return this.client(`/billing/invoiceDetails/ledger${queryString}`, { method: "GET", ...options });
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Get the fee schedule for a specific group.
|
|
251
|
-
* When the group is on a custom volume-tiered plan, the response also includes volumePricing: tiers, the current period's dates, count and minimum, ramp, and current rate (rates in microdollars per segment).
|
|
252
|
-
* @async
|
|
253
|
-
* @roles api, admin, developer, billing, user
|
|
254
|
-
* @param {Object} params - The parameters for getting the fees
|
|
255
|
-
* @param {string} params.groupId - The ID of the group to get fees for
|
|
256
|
-
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
257
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
258
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
259
|
-
*/
|
|
260
|
-
async getFees({ groupId, options = {} }) {
|
|
261
|
-
this.client._require({ groupId });
|
|
262
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
263
|
-
return this.client(`/billing/fees/${safeGroupId}`, { method: "GET", ...options });
|
|
264
|
-
}
|
|
265
|
-
}
|