@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,172 +1,172 @@
1
- export class Billing {
2
- constructor(client, enableAdmin) {
3
- this.client = client;
4
- this.enableAdmin = enableAdmin;
5
- }
6
-
7
- /**
8
- * Get transaction history with optional filters
9
- * @async
10
- * @roles api, admin, developer, billing, user
11
- * @param {Object} params - The parameters for filtering the transaction history
12
- * @param {string} [params.groupId] - The ID of the group to filter by
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
16
- * @param {string} [params.entryType] - The type of entry to filter by
17
- * @param {string} [params.transactionType] - The type of transaction to filter by
18
- * @param {string} [params.startDate] - The start date for the filter
19
- * @param {string} [params.endDate] - The end date for the filter
20
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
21
- * @returns {Promise<Array>} The response from the server
22
- */
23
- async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, options = {} }) {
24
- const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate };
25
- const queryString = this.client._getQueryString(filters);
26
- return this.client(`/billing/wallet/transactionHistory${queryString}`, { method: "GET", ...options });
27
- }
28
-
29
- /**
30
- * Get the wallet information for a specific group
31
- * @async
32
- * @roles api, admin, developer, billing, user
33
- * @param {Object} params - The parameters for getting the wallet information
34
- * @param {string} params.groupId - The ID of the group to get the wallet information for
35
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
- * @throws {Error} Throws an error if the groupId parameter is missing
37
- * @returns {Promise<Object>} The response from the server
38
- */
39
- async getWallet({ groupId, options = {} }) {
40
- this.client._require({ groupId });
41
- const safeGroupId = encodeURIComponent(groupId);
42
- return this.client(`/billing/wallet/${safeGroupId}`, { method: "GET", ...options });
43
- }
44
-
45
- /**
46
- * Update the wallet settings for a specific group
47
- * @async
48
- * @roles api, admin, developer, billing, user
49
- * @param {Object} params - The parameters for updating the wallet settings
50
- * @param {string} params.groupId - The ID of the group to update the wallet settings for
51
- * @param {boolean} [params.autoRechargeEnabled] - Whether auto-recharge is enabled for the wallet
52
- * @param {number} [params.autoRechargeThreshold] - The threshold amount for auto-recharge to trigger
53
- * @param {number} [params.autoRechargeToAmount] - The amount to recharge to when auto-recharge is triggered
54
- * @param {string} [params.primaryPaymentMethodId] - The ID of the primary payment method to use for auto-recharge
55
- * @param {string} [params.secondaryPaymentMethodId] - The ID of the secondary payment method to use for auto-recharge if the primary method fails
56
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
57
- * @throws {Error} Throws an error if the groupId parameter is missing
58
- * @returns {Promise<Object>} The response from the server
59
- */
60
- async updateWallet({ groupId, autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId, options = {} }) {
61
- this.client._require({ groupId });
62
- const safeGroupId = encodeURIComponent(groupId);
63
- return this.client(`/billing/wallet/${safeGroupId}`, {
64
- method: "PUT",
65
- body: { autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId },
66
- ...options,
67
- });
68
- }
69
-
70
- /**
71
- * Get the payment methods for a specific group
72
- * @async
73
- * @roles api, admin, developer, billing, user
74
- * @param {Object} params - The parameters for getting the payment methods
75
- * @param {string} params.groupId - The ID of the group to get the payment methods for
76
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
77
- * @throws {Error} Throws an error if the groupId parameter is missing
78
- * @returns {Promise<Array>} The response from the server
79
- */
80
- async getPaymentMethods({ groupId, options = {} }) {
81
- this.client._require({ groupId });
82
- const safeGroupId = encodeURIComponent(groupId);
83
- return this.client(`/billing/wallet/paymentMethods/${safeGroupId}`, { method: "GET", ...options });
84
- }
85
-
86
- /**
87
- * Add funds to a group's wallet
88
- * @async
89
- * @roles api, admin, developer, billing, user
90
- * @param {Object} params - The parameters for adding funds
91
- * @param {string} params.groupId - The ID of the group to add funds to
92
- * @param {number} params.amount - The amount to add to the group's wallet in microdollars (e.g., $10 would be 10000000)
93
- * @param {string} [params.paymentMethodId] - The ID of the payment method to use for adding funds
94
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
95
- * @throws {Error} Throws an error if the groupId or amount parameters are missing
96
- * @returns {Promise<Object>} The response from the server
97
- */
98
- async addFunds({ groupId, amount, paymentMethodId = undefined, options = {} }) {
99
- this.client._require({ groupId, amount });
100
- const safeGroupId = encodeURIComponent(groupId);
101
- return this.client(`/billing/wallet/addfunds/${safeGroupId}`, { method: "POST", body: { amount, paymentMethodId }, ...options });
102
- }
103
-
104
- /**
105
- * Add a payment method to a group's wallet
106
- * @async
107
- * @roles api, admin, developer, billing, user
108
- * @param {Object} params - The parameters for adding a payment method
109
- * @param {string} params.groupId - The ID of the group to add the payment method to
110
- * @param {string} params.paymentMethodId - The ID of the payment method to add
111
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
112
- * @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
113
- * @returns {Promise<Object>} The response from the server
114
- */
115
- async addPaymentMethod({ groupId, paymentMethodId, options = {} }) {
116
- this.client._require({ groupId, paymentMethodId });
117
- const safeGroupId = encodeURIComponent(groupId);
118
- return this.client(`/billing/wallet/paymentMethod/${safeGroupId}`, { method: "POST", body: { paymentMethodId }, ...options });
119
- }
120
-
121
- /**
122
- * Remove a payment method from a group's wallet
123
- * @async
124
- * @roles api, admin, developer, billing, user
125
- * @param {Object} params - The parameters for removing a payment method
126
- * @param {string} params.groupId - The ID of the group to remove the payment method from
127
- * @param {string} params.paymentMethodId - The ID of the payment method to remove
128
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
129
- * @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
130
- * @returns {Promise<Object>} The response from the server
131
- */
132
- async removePaymentMethod({ groupId, paymentMethodId, options = {} }) {
133
- this.client._require({ groupId, paymentMethodId });
134
- const safeGroupId = encodeURIComponent(groupId);
135
- const safePaymentMethodId = encodeURIComponent(paymentMethodId);
136
- return this.client(`/billing/wallet/paymentMethod/${safeGroupId}/${safePaymentMethodId}`, { method: "DELETE", ...options });
137
- }
138
-
139
- /**
140
- * Get invoice details with optional filters
141
- * @async
142
- * @roles api, admin, developer, billing, user
143
- * @param {Object} params - The parameters for filtering the invoice details
144
- * @param {string} [params.groupId] - The ID of the group to filter by
145
- * @param {string} [params.subgroupId] - The ID of the subgroup to filter by
146
- * @param {string} [params.startDate] - The start date for the filter
147
- * @param {string} [params.endDate] - The end date for the filter
148
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
149
- * @returns {Promise<Object>} The response from the server
150
- */
151
- async getInvoiceDetails({ groupId, subgroupId, startDate, endDate, options = {} }) {
152
- const filters = { groupId, subgroupId, startDate, endDate };
153
- const queryString = this.client._getQueryString(filters);
154
- return this.client(`/billing/invoiceDetails${queryString}`, { method: "GET", ...options });
155
- }
156
-
157
- /**
158
- * Get the fee schedule for a specific group
159
- * @async
160
- * @roles api, admin, developer, billing, user
161
- * @param {Object} params - The parameters for getting the fees
162
- * @param {string} params.groupId - The ID of the group to get fees for
163
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
164
- * @throws {Error} Throws an error if the groupId parameter is missing
165
- * @returns {Promise<Object>} The response from the server
166
- */
167
- async getFees({ groupId, options = {} }) {
168
- this.client._require({ groupId });
169
- const safeGroupId = encodeURIComponent(groupId);
170
- return this.client(`/billing/fees/${safeGroupId}`, { method: "GET", ...options });
171
- }
172
- }
1
+ export class Billing {
2
+ constructor(client, enableAdmin) {
3
+ this.client = client;
4
+ this.enableAdmin = enableAdmin;
5
+ }
6
+
7
+ /**
8
+ * Get transaction history with optional filters
9
+ * @async
10
+ * @roles api, admin, developer, billing, user
11
+ * @param {Object} params - The parameters for filtering the transaction history
12
+ * @param {string} [params.groupId] - The ID of the group to filter by
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
16
+ * @param {string} [params.entryType] - The type of entry to filter by
17
+ * @param {string} [params.transactionType] - The type of transaction to filter by
18
+ * @param {string} [params.startDate] - The start date for the filter
19
+ * @param {string} [params.endDate] - The end date for the filter
20
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
21
+ * @returns {Promise<Array>} The response from the server
22
+ */
23
+ async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, options = {} }) {
24
+ const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate };
25
+ const queryString = this.client._getQueryString(filters);
26
+ return this.client(`/billing/wallet/transactionHistory${queryString}`, { method: "GET", ...options });
27
+ }
28
+
29
+ /**
30
+ * Get the wallet information for a specific group
31
+ * @async
32
+ * @roles api, admin, developer, billing, user
33
+ * @param {Object} params - The parameters for getting the wallet information
34
+ * @param {string} params.groupId - The ID of the group to get the wallet information for
35
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
+ * @throws {Error} Throws an error if the groupId parameter is missing
37
+ * @returns {Promise<Object>} The response from the server
38
+ */
39
+ async getWallet({ groupId, options = {} }) {
40
+ this.client._require({ groupId });
41
+ const safeGroupId = encodeURIComponent(groupId);
42
+ return this.client(`/billing/wallet/${safeGroupId}`, { method: "GET", ...options });
43
+ }
44
+
45
+ /**
46
+ * Update the wallet settings for a specific group
47
+ * @async
48
+ * @roles api, admin, developer, billing, user
49
+ * @param {Object} params - The parameters for updating the wallet settings
50
+ * @param {string} params.groupId - The ID of the group to update the wallet settings for
51
+ * @param {boolean} [params.autoRechargeEnabled] - Whether auto-recharge is enabled for the wallet
52
+ * @param {number} [params.autoRechargeThreshold] - The threshold amount for auto-recharge to trigger
53
+ * @param {number} [params.autoRechargeToAmount] - The amount to recharge to when auto-recharge is triggered
54
+ * @param {string} [params.primaryPaymentMethodId] - The ID of the primary payment method to use for auto-recharge
55
+ * @param {string} [params.secondaryPaymentMethodId] - The ID of the secondary payment method to use for auto-recharge if the primary method fails
56
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
57
+ * @throws {Error} Throws an error if the groupId parameter is missing
58
+ * @returns {Promise<Object>} The response from the server
59
+ */
60
+ async updateWallet({ groupId, autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId, options = {} }) {
61
+ this.client._require({ groupId });
62
+ const safeGroupId = encodeURIComponent(groupId);
63
+ return this.client(`/billing/wallet/${safeGroupId}`, {
64
+ method: "PUT",
65
+ body: { autoRechargeEnabled, autoRechargeThreshold, autoRechargeToAmount, primaryPaymentMethodId, secondaryPaymentMethodId },
66
+ ...options,
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Get the payment methods for a specific group
72
+ * @async
73
+ * @roles api, admin, developer, billing, user
74
+ * @param {Object} params - The parameters for getting the payment methods
75
+ * @param {string} params.groupId - The ID of the group to get the payment methods for
76
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
77
+ * @throws {Error} Throws an error if the groupId parameter is missing
78
+ * @returns {Promise<Array>} The response from the server
79
+ */
80
+ async getPaymentMethods({ groupId, options = {} }) {
81
+ this.client._require({ groupId });
82
+ const safeGroupId = encodeURIComponent(groupId);
83
+ return this.client(`/billing/wallet/paymentMethods/${safeGroupId}`, { method: "GET", ...options });
84
+ }
85
+
86
+ /**
87
+ * Add funds to a group's wallet
88
+ * @async
89
+ * @roles api, admin, developer, billing, user
90
+ * @param {Object} params - The parameters for adding funds
91
+ * @param {string} params.groupId - The ID of the group to add funds to
92
+ * @param {number} params.amount - The amount to add to the group's wallet in microdollars (e.g., $10 would be 10000000)
93
+ * @param {string} [params.paymentMethodId] - The ID of the payment method to use for adding funds
94
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
95
+ * @throws {Error} Throws an error if the groupId or amount parameters are missing
96
+ * @returns {Promise<Object>} The response from the server
97
+ */
98
+ async addFunds({ groupId, amount, paymentMethodId = undefined, options = {} }) {
99
+ this.client._require({ groupId, amount });
100
+ const safeGroupId = encodeURIComponent(groupId);
101
+ return this.client(`/billing/wallet/addfunds/${safeGroupId}`, { method: "POST", body: { amount, paymentMethodId }, ...options });
102
+ }
103
+
104
+ /**
105
+ * Add a payment method to a group's wallet
106
+ * @async
107
+ * @roles api, admin, developer, billing, user
108
+ * @param {Object} params - The parameters for adding a payment method
109
+ * @param {string} params.groupId - The ID of the group to add the payment method to
110
+ * @param {string} params.paymentMethodId - The ID of the payment method to add
111
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
112
+ * @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
113
+ * @returns {Promise<Object>} The response from the server
114
+ */
115
+ async addPaymentMethod({ groupId, paymentMethodId, options = {} }) {
116
+ this.client._require({ groupId, paymentMethodId });
117
+ const safeGroupId = encodeURIComponent(groupId);
118
+ return this.client(`/billing/wallet/paymentMethod/${safeGroupId}`, { method: "POST", body: { paymentMethodId }, ...options });
119
+ }
120
+
121
+ /**
122
+ * Remove a payment method from a group's wallet
123
+ * @async
124
+ * @roles api, admin, developer, billing, user
125
+ * @param {Object} params - The parameters for removing a payment method
126
+ * @param {string} params.groupId - The ID of the group to remove the payment method from
127
+ * @param {string} params.paymentMethodId - The ID of the payment method to remove
128
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
129
+ * @throws {Error} Throws an error if the groupId or paymentMethodId parameters are missing
130
+ * @returns {Promise<Object>} The response from the server
131
+ */
132
+ async removePaymentMethod({ groupId, paymentMethodId, options = {} }) {
133
+ this.client._require({ groupId, paymentMethodId });
134
+ const safeGroupId = encodeURIComponent(groupId);
135
+ const safePaymentMethodId = encodeURIComponent(paymentMethodId);
136
+ return this.client(`/billing/wallet/paymentMethod/${safeGroupId}/${safePaymentMethodId}`, { method: "DELETE", ...options });
137
+ }
138
+
139
+ /**
140
+ * Get invoice details with optional filters
141
+ * @async
142
+ * @roles api, admin, developer, billing, user
143
+ * @param {Object} params - The parameters for filtering the invoice details
144
+ * @param {string} [params.groupId] - The ID of the group to filter by
145
+ * @param {string} [params.subgroupId] - The ID of the subgroup to filter by
146
+ * @param {string} [params.startDate] - The start date for the filter
147
+ * @param {string} [params.endDate] - The end date for the filter
148
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
149
+ * @returns {Promise<Object>} The response from the server
150
+ */
151
+ async getInvoiceDetails({ groupId, subgroupId, startDate, endDate, options = {} }) {
152
+ const filters = { groupId, subgroupId, startDate, endDate };
153
+ const queryString = this.client._getQueryString(filters);
154
+ return this.client(`/billing/invoiceDetails${queryString}`, { method: "GET", ...options });
155
+ }
156
+
157
+ /**
158
+ * Get the fee schedule for a specific group
159
+ * @async
160
+ * @roles api, admin, developer, billing, user
161
+ * @param {Object} params - The parameters for getting the fees
162
+ * @param {string} params.groupId - The ID of the group to get fees for
163
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
164
+ * @throws {Error} Throws an error if the groupId parameter is missing
165
+ * @returns {Promise<Object>} The response from the server
166
+ */
167
+ async getFees({ groupId, options = {} }) {
168
+ this.client._require({ groupId });
169
+ const safeGroupId = encodeURIComponent(groupId);
170
+ return this.client(`/billing/fees/${safeGroupId}`, { method: "GET", ...options });
171
+ }
172
+ }