@signalhousellc/sdk 1.0.34 → 1.0.36
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 +47 -0
package/package.json
CHANGED
package/src/domains/Billing.js
CHANGED
|
@@ -2,6 +2,53 @@ export class Billing {
|
|
|
2
2
|
constructor(client, enableAdmin) {
|
|
3
3
|
this.client = client;
|
|
4
4
|
this.enableAdmin = enableAdmin;
|
|
5
|
+
|
|
6
|
+
if (enableAdmin) {
|
|
7
|
+
this.admin = {
|
|
8
|
+
/**
|
|
9
|
+
* Issue a credit to a customer's wallet
|
|
10
|
+
* @async
|
|
11
|
+
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
12
|
+
* @param {Object} params
|
|
13
|
+
* @param {string} params.groupId - The group ID to credit
|
|
14
|
+
* @param {number} params.amount - Amount in microdollars
|
|
15
|
+
* @param {string} params.transactionType - Type of credit (e.g. "Goodwill Credit", "Billing Correction")
|
|
16
|
+
* @param {string} params.description - Reason for the credit (1-500 characters)
|
|
17
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
18
|
+
* @returns {Promise<Object>} The created transaction object
|
|
19
|
+
*/
|
|
20
|
+
issueCredit: async ({ groupId, amount, transactionType, description, options = {} }) => {
|
|
21
|
+
this.client._require({ groupId, amount, transactionType, description });
|
|
22
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
23
|
+
return this.client(`/billing/wallet/credit/${safeGroupId}`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: { amount, transactionType, description },
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Update fee schedule pricing for a customer group
|
|
32
|
+
* @async
|
|
33
|
+
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
34
|
+
* @param {Object} params
|
|
35
|
+
* @param {string} params.groupId - The group ID to update fees for
|
|
36
|
+
* @param {Object} params.fees - Object of fee field names to microdollar values
|
|
37
|
+
* @param {boolean} [params.overrideActiveSubscription=false] - If true, also update the active subscription fees
|
|
38
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
39
|
+
* @returns {Promise<Object>} The updated fee schedule
|
|
40
|
+
*/
|
|
41
|
+
updateFees: async ({ groupId, fees, overrideActiveSubscription, options = {} }) => {
|
|
42
|
+
this.client._require({ groupId, fees });
|
|
43
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
44
|
+
return this.client(`/billing/fees/${safeGroupId}`, {
|
|
45
|
+
method: "PUT",
|
|
46
|
+
body: { fees, overrideActiveSubscription },
|
|
47
|
+
...options,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
5
52
|
}
|
|
6
53
|
|
|
7
54
|
/**
|