@explorins/pers-sdk 1.6.47 → 2.0.1
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 +159 -23
- package/dist/api-key/api/api-key-api.d.ts +5 -2
- package/dist/api-key/api/api-key-api.d.ts.map +1 -1
- package/dist/business/api/business-api.d.ts +30 -11
- package/dist/business/api/business-api.d.ts.map +1 -1
- package/dist/business/api/business-membership-api.d.ts +24 -5
- package/dist/business/api/business-membership-api.d.ts.map +1 -1
- package/dist/business/services/business-membership-service.d.ts +9 -15
- package/dist/business/services/business-membership-service.d.ts.map +1 -1
- package/dist/business/services/business-service.d.ts +11 -7
- package/dist/business/services/business-service.d.ts.map +1 -1
- package/dist/business.cjs +101 -61
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +101 -61
- package/dist/business.js.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +50 -13
- package/dist/campaign/api/campaign-api.d.ts.map +1 -1
- package/dist/campaign/services/campaign-service.d.ts +13 -12
- package/dist/campaign/services/campaign-service.d.ts.map +1 -1
- package/dist/campaign.cjs +2 -1
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +2 -1
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/{base-token-service-BSXDwrcq.js → base-token-service-DsD6lSdq.js} +2 -48
- package/dist/chunks/base-token-service-DsD6lSdq.js.map +1 -0
- package/dist/chunks/{base-token-service-CYuqPPs0.cjs → base-token-service-_64IWVES.cjs} +2 -48
- package/dist/chunks/base-token-service-_64IWVES.cjs.map +1 -0
- package/dist/chunks/{campaign-service-D-v9ZlUB.cjs → campaign-service-Ae164xl8.cjs} +74 -46
- package/dist/chunks/campaign-service-Ae164xl8.cjs.map +1 -0
- package/dist/chunks/{campaign-service-CKwkiOLx.js → campaign-service-rlK4WeSY.js} +74 -46
- package/dist/chunks/campaign-service-rlK4WeSY.js.map +1 -0
- package/dist/chunks/{donation-service-D-xFrONi.cjs → donation-service--6cnTvWq.cjs} +9 -5
- package/dist/chunks/donation-service--6cnTvWq.cjs.map +1 -0
- package/dist/chunks/{donation-service-CyJS4DIZ.js → donation-service-xiXZ2Eto.js} +9 -5
- package/dist/chunks/donation-service-xiXZ2Eto.js.map +1 -0
- package/dist/chunks/pagination-utils-9vQ-Npkr.js +166 -0
- package/dist/chunks/pagination-utils-9vQ-Npkr.js.map +1 -0
- package/dist/chunks/pagination-utils-B2jRHMSO.cjs +173 -0
- package/dist/chunks/pagination-utils-B2jRHMSO.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-DULFjOW2.cjs → pers-sdk-B_i-bGwq.cjs} +249 -235
- package/dist/chunks/pers-sdk-B_i-bGwq.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-VmeBqUEP.js → pers-sdk-CyGgL8Dg.js} +243 -229
- package/dist/chunks/pers-sdk-CyGgL8Dg.js.map +1 -0
- package/dist/chunks/{token-service-CpVwC5Eb.js → token-service-Bfj6C0yz.js} +62 -30
- package/dist/chunks/token-service-Bfj6C0yz.js.map +1 -0
- package/dist/chunks/{token-service-BWScn8Qa.cjs → token-service-BlbXrxnS.cjs} +62 -30
- package/dist/chunks/token-service-BlbXrxnS.cjs.map +1 -0
- package/dist/chunks/{transaction-service-CXjTHCFu.cjs → transaction-service-BcJfyCcq.cjs} +68 -31
- package/dist/chunks/transaction-service-BcJfyCcq.cjs.map +1 -0
- package/dist/chunks/{transaction-service-B7h_4Hg3.js → transaction-service-CnOD3scu.js} +68 -31
- package/dist/chunks/transaction-service-CnOD3scu.js.map +1 -0
- package/dist/chunks/{user-service-doT5vsBD.js → user-service-BGP3SZpk.js} +24 -12
- package/dist/chunks/user-service-BGP3SZpk.js.map +1 -0
- package/dist/chunks/{user-service-B89wBOV1.cjs → user-service-gITOx4qj.cjs} +24 -12
- package/dist/chunks/user-service-gITOx4qj.cjs.map +1 -0
- package/dist/core.cjs +10 -9
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +10 -9
- package/dist/core.js.map +1 -1
- package/dist/donation/api/donation-api.d.ts +3 -1
- package/dist/donation/api/donation-api.d.ts.map +1 -1
- package/dist/donation/services/donation-service.d.ts +3 -1
- package/dist/donation/services/donation-service.d.ts.map +1 -1
- package/dist/donation.cjs +2 -1
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +2 -1
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +23 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +9 -9
- package/dist/managers/api-key-manager.d.ts +8 -6
- package/dist/managers/api-key-manager.d.ts.map +1 -1
- package/dist/managers/business-manager.d.ts +9 -7
- package/dist/managers/business-manager.d.ts.map +1 -1
- package/dist/managers/campaign-manager.d.ts +21 -20
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/donation-manager.d.ts +4 -2
- package/dist/managers/donation-manager.d.ts.map +1 -1
- package/dist/managers/file-manager.d.ts +2 -2
- package/dist/managers/purchase-manager.d.ts +26 -24
- package/dist/managers/purchase-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +103 -91
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/tenant-manager.d.ts +5 -2
- package/dist/managers/tenant-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +6 -4
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +18 -17
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +4 -2
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/user-status-manager.d.ts +6 -4
- package/dist/managers/user-status-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/dist/payment/api/payment-api.d.ts +15 -18
- package/dist/payment/api/payment-api.d.ts.map +1 -1
- package/dist/payment/services/payment-service.d.ts +6 -4
- package/dist/payment/services/payment-service.d.ts.map +1 -1
- package/dist/payment.cjs +219 -15
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +209 -1
- package/dist/payment.js.map +1 -1
- package/dist/redemption/api/redemption-api.d.ts +22 -11
- package/dist/redemption/api/redemption-api.d.ts.map +1 -1
- package/dist/redemption/services/redemption-service.d.ts +11 -9
- package/dist/redemption/services/redemption-service.d.ts.map +1 -1
- package/dist/redemption.cjs +347 -15
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +337 -1
- package/dist/redemption.js.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/utils/pagination-utils.d.ts +184 -0
- package/dist/shared/utils/pagination-utils.d.ts.map +1 -0
- package/dist/tenant/api/tenant-api.d.ts +6 -1
- package/dist/tenant/api/tenant-api.d.ts.map +1 -1
- package/dist/tenant/services/tenant-service.d.ts +5 -2
- package/dist/tenant/services/tenant-service.d.ts.map +1 -1
- package/dist/tenant.cjs +171 -15
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +161 -1
- package/dist/tenant.js.map +1 -1
- package/dist/token/api/token-api.d.ts +24 -7
- package/dist/token/api/token-api.d.ts.map +1 -1
- package/dist/token/base/base-token-service.d.ts +5 -4
- package/dist/token/base/base-token-service.d.ts.map +1 -1
- package/dist/token/services/token-service.d.ts +10 -8
- package/dist/token/services/token-service.d.ts.map +1 -1
- package/dist/token/token-sdk.d.ts +5 -34
- package/dist/token/token-sdk.d.ts.map +1 -1
- package/dist/token.cjs +3 -2
- package/dist/token.cjs.map +1 -1
- package/dist/token.js +3 -2
- package/dist/token.js.map +1 -1
- package/dist/transaction/api/transaction-api.d.ts +48 -6
- package/dist/transaction/api/transaction-api.d.ts.map +1 -1
- package/dist/transaction/services/transaction-service.d.ts +12 -4
- package/dist/transaction/services/transaction-service.d.ts.map +1 -1
- package/dist/transaction.cjs +2 -1
- package/dist/transaction.cjs.map +1 -1
- package/dist/transaction.js +2 -1
- package/dist/transaction.js.map +1 -1
- package/dist/user/api/user-api.d.ts +4 -2
- package/dist/user/api/user-api.d.ts.map +1 -1
- package/dist/user/services/user-service.d.ts +4 -2
- package/dist/user/services/user-service.d.ts.map +1 -1
- package/dist/user-status/api/user-status-api.d.ts +6 -4
- package/dist/user-status/api/user-status-api.d.ts.map +1 -1
- package/dist/user-status/index.d.ts +4 -2
- package/dist/user-status/index.d.ts.map +1 -1
- package/dist/user-status/services/user-status-service.d.ts +4 -2
- package/dist/user-status/services/user-status-service.d.ts.map +1 -1
- package/dist/user-status.cjs +22 -14
- package/dist/user-status.cjs.map +1 -1
- package/dist/user-status.js +22 -14
- package/dist/user-status.js.map +1 -1
- package/dist/user.cjs +2 -1
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +2 -1
- package/dist/user.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/base-token-service-BSXDwrcq.js.map +0 -1
- package/dist/chunks/base-token-service-CYuqPPs0.cjs.map +0 -1
- package/dist/chunks/campaign-service-CKwkiOLx.js.map +0 -1
- package/dist/chunks/campaign-service-D-v9ZlUB.cjs.map +0 -1
- package/dist/chunks/donation-service-CyJS4DIZ.js.map +0 -1
- package/dist/chunks/donation-service-D-xFrONi.cjs.map +0 -1
- package/dist/chunks/payment-service-B4qx0qiE.cjs +0 -220
- package/dist/chunks/payment-service-B4qx0qiE.cjs.map +0 -1
- package/dist/chunks/payment-service-DfCBFosx.js +0 -217
- package/dist/chunks/payment-service-DfCBFosx.js.map +0 -1
- package/dist/chunks/pers-sdk-DULFjOW2.cjs.map +0 -1
- package/dist/chunks/pers-sdk-VmeBqUEP.js.map +0 -1
- package/dist/chunks/redemption-service-7qbeQxEM.cjs +0 -330
- package/dist/chunks/redemption-service-7qbeQxEM.cjs.map +0 -1
- package/dist/chunks/redemption-service-BT0J5Iy7.js +0 -327
- package/dist/chunks/redemption-service-BT0J5Iy7.js.map +0 -1
- package/dist/chunks/tenant-service-DME24vr1.cjs +0 -157
- package/dist/chunks/tenant-service-DME24vr1.cjs.map +0 -1
- package/dist/chunks/tenant-service-DxtHAlaa.js +0 -154
- package/dist/chunks/tenant-service-DxtHAlaa.js.map +0 -1
- package/dist/chunks/token-service-BWScn8Qa.cjs.map +0 -1
- package/dist/chunks/token-service-CpVwC5Eb.js.map +0 -1
- package/dist/chunks/transaction-service-B7h_4Hg3.js.map +0 -1
- package/dist/chunks/transaction-service-CXjTHCFu.cjs.map +0 -1
- package/dist/chunks/user-service-B89wBOV1.cjs.map +0 -1
- package/dist/chunks/user-service-doT5vsBD.js.map +0 -1
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var persShared = require('@explorins/pers-shared');
|
|
4
4
|
var web3ChainService = require('./web3-chain-service-6vsVHPjl.cjs');
|
|
5
|
-
var userService = require('./user-service-
|
|
5
|
+
var userService = require('./user-service-gITOx4qj.cjs');
|
|
6
6
|
var userStatus = require('../user-status.cjs');
|
|
7
|
-
var tokenService = require('./token-service-
|
|
7
|
+
var tokenService = require('./token-service-BlbXrxnS.cjs');
|
|
8
8
|
var business = require('../business.cjs');
|
|
9
|
-
var campaignService = require('./campaign-service-
|
|
10
|
-
var
|
|
11
|
-
var transactionService = require('./transaction-service-
|
|
12
|
-
var
|
|
13
|
-
var
|
|
9
|
+
var campaignService = require('./campaign-service-Ae164xl8.cjs');
|
|
10
|
+
var redemption = require('../redemption.cjs');
|
|
11
|
+
var transactionService = require('./transaction-service-BcJfyCcq.cjs');
|
|
12
|
+
var payment = require('../payment.cjs');
|
|
13
|
+
var tenant = require('../tenant.cjs');
|
|
14
|
+
var paginationUtils = require('./pagination-utils-B2jRHMSO.cjs');
|
|
14
15
|
var analyticsService = require('./analytics-service-CitlimKJ.cjs');
|
|
15
|
-
var donationService = require('./donation-service
|
|
16
|
+
var donationService = require('./donation-service--6cnTvWq.cjs');
|
|
16
17
|
var explorer_utils = require('./explorer.utils-Cx3wrqAj.cjs');
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -1958,8 +1959,8 @@ class UserManager {
|
|
|
1958
1959
|
* });
|
|
1959
1960
|
* ```
|
|
1960
1961
|
*/
|
|
1961
|
-
async getAllUsersPublic(filter) {
|
|
1962
|
-
return this.userService.getAllUsersPublicProfiles(filter || null);
|
|
1962
|
+
async getAllUsersPublic(filter, options) {
|
|
1963
|
+
return this.userService.getAllUsersPublicProfiles(filter || null, options);
|
|
1963
1964
|
}
|
|
1964
1965
|
/**
|
|
1965
1966
|
* Admin: Get all users
|
|
@@ -1986,8 +1987,8 @@ class UserManager {
|
|
|
1986
1987
|
* }
|
|
1987
1988
|
* ```
|
|
1988
1989
|
*/
|
|
1989
|
-
async getAllUsers() {
|
|
1990
|
-
return this.userService.getAllRemoteUsers();
|
|
1990
|
+
async getAllUsers(options) {
|
|
1991
|
+
return this.userService.getAllRemoteUsers(options);
|
|
1991
1992
|
}
|
|
1992
1993
|
/**
|
|
1993
1994
|
* Business/Admin: Create or update a user
|
|
@@ -2140,18 +2141,18 @@ class UserStatusManager {
|
|
|
2140
2141
|
/**
|
|
2141
2142
|
* Get all user status types
|
|
2142
2143
|
*
|
|
2143
|
-
* @returns Promise resolving to
|
|
2144
|
+
* @returns Promise resolving to paginated user status types
|
|
2144
2145
|
*/
|
|
2145
|
-
async getUserStatusTypes() {
|
|
2146
|
-
return this.userStatusSDK.getRemoteUserStatusTypes();
|
|
2146
|
+
async getUserStatusTypes(options) {
|
|
2147
|
+
return this.userStatusSDK.getRemoteUserStatusTypes(options);
|
|
2147
2148
|
}
|
|
2148
2149
|
/**
|
|
2149
2150
|
* Get earned user status for authenticated user
|
|
2150
2151
|
*
|
|
2151
|
-
* @returns Promise resolving to
|
|
2152
|
+
* @returns Promise resolving to paginated earned user status
|
|
2152
2153
|
*/
|
|
2153
|
-
async getEarnedUserStatus() {
|
|
2154
|
-
return this.userStatusSDK.getRemoteEarnedUserStatus();
|
|
2154
|
+
async getEarnedUserStatus(options) {
|
|
2155
|
+
return this.userStatusSDK.getRemoteEarnedUserStatus(options);
|
|
2155
2156
|
}
|
|
2156
2157
|
/**
|
|
2157
2158
|
* Admin: Create new user status type
|
|
@@ -2250,8 +2251,8 @@ class TokenManager {
|
|
|
2250
2251
|
* });
|
|
2251
2252
|
* ```
|
|
2252
2253
|
*/
|
|
2253
|
-
async getTokens() {
|
|
2254
|
-
return this.tokenService.getRemoteTokens();
|
|
2254
|
+
async getTokens(options) {
|
|
2255
|
+
return this.tokenService.getRemoteTokens(options);
|
|
2255
2256
|
}
|
|
2256
2257
|
/**
|
|
2257
2258
|
* Get all token types
|
|
@@ -2270,8 +2271,8 @@ class TokenManager {
|
|
|
2270
2271
|
* const isValidType = types.some(type => type.name === 'REWARD');
|
|
2271
2272
|
* ```
|
|
2272
2273
|
*/
|
|
2273
|
-
async getTokenTypes() {
|
|
2274
|
-
return this.tokenService.getRemoteTokenTypes();
|
|
2274
|
+
async getTokenTypes(options) {
|
|
2275
|
+
return this.tokenService.getRemoteTokenTypes(options);
|
|
2275
2276
|
}
|
|
2276
2277
|
/**
|
|
2277
2278
|
* Get active credit token
|
|
@@ -2318,8 +2319,8 @@ class TokenManager {
|
|
|
2318
2319
|
* const discountToken = rewardTokens.find(t => t.name.includes('Discount'));
|
|
2319
2320
|
* ```
|
|
2320
2321
|
*/
|
|
2321
|
-
async getRewardTokens() {
|
|
2322
|
-
return this.tokenService.getRemoteRewardTokens();
|
|
2322
|
+
async getRewardTokens(options) {
|
|
2323
|
+
return this.tokenService.getRemoteRewardTokens(options);
|
|
2323
2324
|
}
|
|
2324
2325
|
/**
|
|
2325
2326
|
* Get status tokens
|
|
@@ -2342,8 +2343,8 @@ class TokenManager {
|
|
|
2342
2343
|
* const vipToken = statusTokens.find(t => t.name === 'VIP Status');
|
|
2343
2344
|
* ```
|
|
2344
2345
|
*/
|
|
2345
|
-
async getStatusTokens() {
|
|
2346
|
-
return this.tokenService.getRemoteStatusTokens();
|
|
2346
|
+
async getStatusTokens(options) {
|
|
2347
|
+
return this.tokenService.getRemoteStatusTokens(options);
|
|
2347
2348
|
}
|
|
2348
2349
|
/**
|
|
2349
2350
|
* Get token by contract address
|
|
@@ -2585,8 +2586,8 @@ class BusinessManager {
|
|
|
2585
2586
|
* );
|
|
2586
2587
|
* ```
|
|
2587
2588
|
*/
|
|
2588
|
-
async getActiveBusinesses() {
|
|
2589
|
-
return this.businessService.getActiveBusinesses();
|
|
2589
|
+
async getActiveBusinesses(options) {
|
|
2590
|
+
return this.businessService.getActiveBusinesses(options);
|
|
2590
2591
|
}
|
|
2591
2592
|
/**
|
|
2592
2593
|
* Get business by ID
|
|
@@ -2669,7 +2670,7 @@ class BusinessManager {
|
|
|
2669
2670
|
* }));
|
|
2670
2671
|
* ```
|
|
2671
2672
|
*/
|
|
2672
|
-
async getBusinessTypes() {
|
|
2673
|
+
async getBusinessTypes(options) {
|
|
2673
2674
|
return this.businessService.getBusinessTypes();
|
|
2674
2675
|
}
|
|
2675
2676
|
/**
|
|
@@ -2701,8 +2702,8 @@ class BusinessManager {
|
|
|
2701
2702
|
* };
|
|
2702
2703
|
* ```
|
|
2703
2704
|
*/
|
|
2704
|
-
async getBusinessesByType(typeId) {
|
|
2705
|
-
return this.businessService.getBusinessesByType(typeId);
|
|
2705
|
+
async getBusinessesByType(typeId, options) {
|
|
2706
|
+
return this.businessService.getBusinessesByType(typeId, options);
|
|
2706
2707
|
}
|
|
2707
2708
|
/**
|
|
2708
2709
|
* Admin: Get all businesses (including inactive)
|
|
@@ -2733,8 +2734,8 @@ class BusinessManager {
|
|
|
2733
2734
|
* }));
|
|
2734
2735
|
* ```
|
|
2735
2736
|
*/
|
|
2736
|
-
async getBusinesses() {
|
|
2737
|
-
return this.businessService.getBusinesses();
|
|
2737
|
+
async getBusinesses(options) {
|
|
2738
|
+
return this.businessService.getBusinesses(options);
|
|
2738
2739
|
}
|
|
2739
2740
|
/**
|
|
2740
2741
|
* Admin: Create new business
|
|
@@ -2895,8 +2896,8 @@ class BusinessManager {
|
|
|
2895
2896
|
* console.log(`Administrators: ${admins.length}`);
|
|
2896
2897
|
* ```
|
|
2897
2898
|
*/
|
|
2898
|
-
async getMembers(businessId) {
|
|
2899
|
-
return this.membershipService.getMembers(businessId);
|
|
2899
|
+
async getMembers(businessId, options) {
|
|
2900
|
+
return this.membershipService.getMembers(businessId, options);
|
|
2900
2901
|
}
|
|
2901
2902
|
/**
|
|
2902
2903
|
* Get members filtered by role
|
|
@@ -2907,12 +2908,12 @@ class BusinessManager {
|
|
|
2907
2908
|
*
|
|
2908
2909
|
* @example
|
|
2909
2910
|
* ```typescript
|
|
2910
|
-
* const owners = await sdk.business.getMembersByRole('business-123', 'OWNER');
|
|
2911
|
+
* const { data: owners } = await sdk.business.getMembersByRole('business-123', 'OWNER');
|
|
2911
2912
|
* console.log(`Business has ${owners.length} owner(s)`);
|
|
2912
2913
|
* ```
|
|
2913
2914
|
*/
|
|
2914
|
-
async getMembersByRole(businessId, role) {
|
|
2915
|
-
return this.membershipService.getMembersByRole(businessId, role);
|
|
2915
|
+
async getMembersByRole(businessId, role, options) {
|
|
2916
|
+
return this.membershipService.getMembersByRole(businessId, role, options);
|
|
2916
2917
|
}
|
|
2917
2918
|
/**
|
|
2918
2919
|
* Add a new member to a business
|
|
@@ -3160,18 +3161,18 @@ class CampaignManager {
|
|
|
3160
3161
|
* try {
|
|
3161
3162
|
* const campaign = await sdk.campaigns.getCampaignById('summer-promo-2024');
|
|
3162
3163
|
*
|
|
3163
|
-
* console.log('
|
|
3164
|
+
* console.log('Campaign Details:');
|
|
3164
3165
|
* console.log('Title:', campaign.title);
|
|
3165
3166
|
* console.log('Description:', campaign.description);
|
|
3166
3167
|
* console.log('Active:', campaign.isActive);
|
|
3167
3168
|
* console.log('Period:', `${campaign.startDate} to ${campaign.endDate}`);
|
|
3168
3169
|
*
|
|
3169
|
-
* console.log('\
|
|
3170
|
+
* console.log('\nRewards:');
|
|
3170
3171
|
* campaign.tokenUnits?.forEach(unit => {
|
|
3171
3172
|
* console.log(`- ${unit.amount} ${unit.token.symbol} (${unit.token.name})`);
|
|
3172
3173
|
* });
|
|
3173
3174
|
*
|
|
3174
|
-
* console.log('\
|
|
3175
|
+
* console.log('\nPartner Businesses:');
|
|
3175
3176
|
* campaign.businessEngagements?.forEach(engagement => {
|
|
3176
3177
|
* console.log(`- ${engagement.business.displayName}`);
|
|
3177
3178
|
* });
|
|
@@ -3203,12 +3204,12 @@ class CampaignManager {
|
|
|
3203
3204
|
* businessId: 'partner-hotel-123'
|
|
3204
3205
|
* });
|
|
3205
3206
|
*
|
|
3206
|
-
* console.log('
|
|
3207
|
+
* console.log('Campaign claimed successfully!');
|
|
3207
3208
|
* console.log('Claim ID:', claim.id);
|
|
3208
3209
|
* console.log('Claimed at:', claim.claimedAt);
|
|
3209
3210
|
*
|
|
3210
3211
|
* if (claim.rewards?.length) {
|
|
3211
|
-
* console.log('\
|
|
3212
|
+
* console.log('\nRewards received:');
|
|
3212
3213
|
* claim.rewards.forEach(reward => {
|
|
3213
3214
|
* console.log(`- ${reward.amount} ${reward.token.symbol}`);
|
|
3214
3215
|
* });
|
|
@@ -3264,15 +3265,15 @@ class CampaignManager {
|
|
|
3264
3265
|
* ```typescript
|
|
3265
3266
|
* const userClaims = await sdk.campaigns.getUserClaims();
|
|
3266
3267
|
*
|
|
3267
|
-
* console.log(
|
|
3268
|
+
* console.log(`Campaign History (${userClaims.length} claims):`);
|
|
3268
3269
|
*
|
|
3269
3270
|
* userClaims.forEach((claim, index) => {
|
|
3270
3271
|
* console.log(`\n${index + 1}. ${claim.campaign.title}`);
|
|
3271
|
-
* console.log(`
|
|
3272
|
-
* console.log(`
|
|
3272
|
+
* console.log(` Claimed: ${new Date(claim.claimedAt).toLocaleDateString()}`);
|
|
3273
|
+
* console.log(` Business: ${claim.business?.displayName || 'N/A'}`);
|
|
3273
3274
|
*
|
|
3274
3275
|
* if (claim.rewards?.length) {
|
|
3275
|
-
* console.log(`
|
|
3276
|
+
* console.log(` Rewards:`);
|
|
3276
3277
|
* claim.rewards.forEach(reward => {
|
|
3277
3278
|
* console.log(` • ${reward.amount} ${reward.token.symbol}`);
|
|
3278
3279
|
* });
|
|
@@ -3284,11 +3285,11 @@ class CampaignManager {
|
|
|
3284
3285
|
* return total + (claim.rewards?.length || 0);
|
|
3285
3286
|
* }, 0);
|
|
3286
3287
|
*
|
|
3287
|
-
* console.log(`\
|
|
3288
|
+
* console.log(`\nTotal reward items earned: ${totalRewards}`);
|
|
3288
3289
|
* ```
|
|
3289
3290
|
*/
|
|
3290
|
-
async getUserClaims() {
|
|
3291
|
-
return this.campaignService.getClaimsForLoggedUser();
|
|
3291
|
+
async getUserClaims(options) {
|
|
3292
|
+
return this.campaignService.getClaimsForLoggedUser(options);
|
|
3292
3293
|
}
|
|
3293
3294
|
/**
|
|
3294
3295
|
* Get campaigns with pagination support
|
|
@@ -3356,7 +3357,7 @@ class CampaignManager {
|
|
|
3356
3357
|
* campaignType: 'SEASONAL'
|
|
3357
3358
|
* });
|
|
3358
3359
|
*
|
|
3359
|
-
* console.log('
|
|
3360
|
+
* console.log('Campaign created:', campaign.title);
|
|
3360
3361
|
* console.log('Campaign ID:', campaign.id);
|
|
3361
3362
|
*
|
|
3362
3363
|
* // Set up campaign rewards
|
|
@@ -3416,7 +3417,7 @@ class CampaignManager {
|
|
|
3416
3417
|
* const updated = await sdk.campaigns.toggleCampaignStatus('problematic-campaign');
|
|
3417
3418
|
*
|
|
3418
3419
|
* console.log(`Campaign ${updated.isActive ? 'activated' : 'deactivated'}`);
|
|
3419
|
-
* console.log('Status:', updated.isActive ? '
|
|
3420
|
+
* console.log('Status:', updated.isActive ? 'Active' : 'Inactive');
|
|
3420
3421
|
* ```
|
|
3421
3422
|
*/
|
|
3422
3423
|
async toggleCampaignStatus(campaignId) {
|
|
@@ -3466,7 +3467,7 @@ class CampaignManager {
|
|
|
3466
3467
|
* });
|
|
3467
3468
|
* ```
|
|
3468
3469
|
*/
|
|
3469
|
-
async getCampaignTriggers() {
|
|
3470
|
+
async getCampaignTriggers(options) {
|
|
3470
3471
|
return this.campaignService.getCampaignTriggers();
|
|
3471
3472
|
}
|
|
3472
3473
|
/**
|
|
@@ -3660,7 +3661,7 @@ class CampaignManager {
|
|
|
3660
3661
|
* // Admin operation - get campaign performance data
|
|
3661
3662
|
* const allClaims = await sdk.campaigns.getCampaignClaims();
|
|
3662
3663
|
*
|
|
3663
|
-
* console.log(
|
|
3664
|
+
* console.log(`Campaign Performance Report:`);
|
|
3664
3665
|
* console.log(`Total claims: ${allClaims.length}`);
|
|
3665
3666
|
*
|
|
3666
3667
|
* // Analyze claims by campaign
|
|
@@ -3676,7 +3677,7 @@ class CampaignManager {
|
|
|
3676
3677
|
* });
|
|
3677
3678
|
* ```
|
|
3678
3679
|
*/
|
|
3679
|
-
async getCampaignClaims() {
|
|
3680
|
+
async getCampaignClaims(options) {
|
|
3680
3681
|
return this.campaignService.getCampaignClaims();
|
|
3681
3682
|
}
|
|
3682
3683
|
/**
|
|
@@ -3712,7 +3713,7 @@ class CampaignManager {
|
|
|
3712
3713
|
* console.log(`\nTotal rewards earned: ${totalRewards}`);
|
|
3713
3714
|
* ```
|
|
3714
3715
|
*/
|
|
3715
|
-
async getCampaignClaimsByUserId(userId) {
|
|
3716
|
+
async getCampaignClaimsByUserId(userId, options) {
|
|
3716
3717
|
return this.campaignService.getCampaignClaimsByUserId(userId);
|
|
3717
3718
|
}
|
|
3718
3719
|
/**
|
|
@@ -3753,7 +3754,7 @@ class CampaignManager {
|
|
|
3753
3754
|
* console.log(`\nTotal rewards distributed: ${totalRewardsDistributed}`);
|
|
3754
3755
|
* ```
|
|
3755
3756
|
*/
|
|
3756
|
-
async getCampaignClaimsByBusinessId(businessId) {
|
|
3757
|
+
async getCampaignClaimsByBusinessId(businessId, options) {
|
|
3757
3758
|
return this.campaignService.getCampaignClaimsByBusinessId(businessId);
|
|
3758
3759
|
}
|
|
3759
3760
|
/**
|
|
@@ -3801,7 +3802,7 @@ class CampaignManager {
|
|
|
3801
3802
|
* @example Basic Redemption Operations
|
|
3802
3803
|
* ```typescript
|
|
3803
3804
|
* // Browse available redemption offers
|
|
3804
|
-
* const offers = await sdk.redemptions.
|
|
3805
|
+
* const { data: offers } = await sdk.redemptions.getRedemptions();
|
|
3805
3806
|
* console.log(`${offers.length} redemption offers available`);
|
|
3806
3807
|
*
|
|
3807
3808
|
* // Redeem a specific offer
|
|
@@ -3809,7 +3810,7 @@ class CampaignManager {
|
|
|
3809
3810
|
* console.log('Redemption successful:', redemptionResult.success);
|
|
3810
3811
|
*
|
|
3811
3812
|
* // Check redemption history
|
|
3812
|
-
* const history = await sdk.redemptions.getUserRedemptions();
|
|
3813
|
+
* const { data: history } = await sdk.redemptions.getUserRedemptions();
|
|
3813
3814
|
* console.log(`You have redeemed ${history.length} offers`);
|
|
3814
3815
|
* ```
|
|
3815
3816
|
*
|
|
@@ -3852,51 +3853,105 @@ class RedemptionManager {
|
|
|
3852
3853
|
constructor(apiClient, events) {
|
|
3853
3854
|
this.apiClient = apiClient;
|
|
3854
3855
|
this.events = events;
|
|
3855
|
-
const redemptionApi = new
|
|
3856
|
-
this.redemptionService = new
|
|
3856
|
+
const redemptionApi = new redemption.RedemptionApi(apiClient);
|
|
3857
|
+
this.redemptionService = new redemption.RedemptionService(redemptionApi);
|
|
3857
3858
|
}
|
|
3858
3859
|
/**
|
|
3859
|
-
* Get
|
|
3860
|
+
* Get redemption offers
|
|
3860
3861
|
*
|
|
3861
|
-
* Retrieves
|
|
3862
|
-
*
|
|
3863
|
-
* services that can be purchased using loyalty tokens.
|
|
3862
|
+
* Retrieves redemption offers based on user permissions and optional filters.
|
|
3863
|
+
* The results returned depend on the authenticated user's role:
|
|
3864
3864
|
*
|
|
3865
|
-
*
|
|
3865
|
+
* **Regular Users:** See only active redemption offers available for purchase
|
|
3866
|
+
* **Administrators:** Can see all redemptions and filter by active/inactive status
|
|
3866
3867
|
*
|
|
3867
|
-
*
|
|
3868
|
+
* Active redemptions include discounts, vouchers, products, and services that
|
|
3869
|
+
* can be purchased using loyalty tokens. The backend automatically enforces
|
|
3870
|
+
* permission-based filtering.
|
|
3871
|
+
*
|
|
3872
|
+
* @param options - Optional filters and pagination:
|
|
3873
|
+
* - `active`: Filter by active status (true/false). Admins only - regular users always see active offers
|
|
3874
|
+
* - Pagination options: `page`, `limit`, `sortBy`, `sortOrder`
|
|
3875
|
+
* @returns Promise resolving to paginated redemption offers
|
|
3876
|
+
*
|
|
3877
|
+
* @example Regular User - Browse Active Offers
|
|
3868
3878
|
* ```typescript
|
|
3869
|
-
*
|
|
3879
|
+
* // Regular users automatically see only active offers
|
|
3880
|
+
* const { data: offers, pagination } = await sdk.redemptions.getRedemptions();
|
|
3881
|
+
*
|
|
3882
|
+
* console.log('Available Redemption Offers:');
|
|
3883
|
+
* console.log(`Showing ${offers.length} of ${pagination.total} offers`);
|
|
3870
3884
|
*
|
|
3871
|
-
*
|
|
3872
|
-
* activeOffers.forEach(offer => {
|
|
3885
|
+
* offers.forEach(offer => {
|
|
3873
3886
|
* console.log(`\n${offer.title}`);
|
|
3874
|
-
* console.log(
|
|
3875
|
-
* console.log(
|
|
3887
|
+
* console.log(`${offer.description}`);
|
|
3888
|
+
* console.log(`Type: ${offer.redemptionType?.name || 'General'}`);
|
|
3876
3889
|
*
|
|
3877
3890
|
* if (offer.tokenUnits?.length) {
|
|
3878
|
-
* console.log('
|
|
3891
|
+
* console.log('Cost:');
|
|
3879
3892
|
* offer.tokenUnits.forEach(unit => {
|
|
3880
3893
|
* console.log(` ${unit.amount} ${unit.token.symbol}`);
|
|
3881
3894
|
* });
|
|
3882
3895
|
* }
|
|
3883
3896
|
*
|
|
3884
3897
|
* if (offer.availableQuantity !== undefined) {
|
|
3885
|
-
* console.log(
|
|
3898
|
+
* console.log(`Available: ${offer.availableQuantity}`);
|
|
3886
3899
|
* }
|
|
3887
3900
|
* });
|
|
3888
3901
|
*
|
|
3889
3902
|
* // Filter offers by affordability
|
|
3890
|
-
* const userBalance = 1000;
|
|
3891
|
-
* const affordableOffers =
|
|
3903
|
+
* const userBalance = 1000;
|
|
3904
|
+
* const affordableOffers = offers.filter(offer =>
|
|
3892
3905
|
* offer.tokenUnits?.every(unit => unit.amount <= userBalance)
|
|
3893
3906
|
* );
|
|
3894
3907
|
*
|
|
3895
|
-
* console.log(`\n
|
|
3908
|
+
* console.log(`\n${affordableOffers.length} offers within your budget`);
|
|
3909
|
+
* ```
|
|
3910
|
+
*
|
|
3911
|
+
* @example Admin - Manage All Redemptions
|
|
3912
|
+
* ```typescript
|
|
3913
|
+
* // Admins can see all redemptions and filter by status
|
|
3914
|
+
* const { data: allRedemptions } = await sdk.redemptions.getRedemptions();
|
|
3915
|
+
* const { data: activeOnly } = await sdk.redemptions.getRedemptions({ active: true });
|
|
3916
|
+
* const { data: inactiveOnly } = await sdk.redemptions.getRedemptions({ active: false });
|
|
3917
|
+
*
|
|
3918
|
+
* console.log('Redemption Inventory:');
|
|
3919
|
+
* console.log(`Total offers: ${allRedemptions.length}`);
|
|
3920
|
+
* console.log(`Active offers: ${activeOnly.length}`);
|
|
3921
|
+
* console.log(`Inactive offers: ${inactiveOnly.length}`);
|
|
3922
|
+
*
|
|
3923
|
+
* // Analyze by type
|
|
3924
|
+
* const offersByType = allRedemptions.reduce((acc, offer) => {
|
|
3925
|
+
* const type = offer.redemptionType?.name || 'Unspecified';
|
|
3926
|
+
* acc[type] = (acc[type] || 0) + 1;
|
|
3927
|
+
* return acc;
|
|
3928
|
+
* }, {});
|
|
3929
|
+
*
|
|
3930
|
+
* console.log('\nBy type:', offersByType);
|
|
3931
|
+
* ```
|
|
3932
|
+
*
|
|
3933
|
+
* @example Pagination
|
|
3934
|
+
* ```typescript
|
|
3935
|
+
* // Load first page
|
|
3936
|
+
* const { data: firstPage, pagination } = await sdk.redemptions.getRedemptions({
|
|
3937
|
+
* page: 1,
|
|
3938
|
+
* limit: 10
|
|
3939
|
+
* });
|
|
3940
|
+
*
|
|
3941
|
+
* console.log(`Page ${pagination.page} of ${pagination.totalPages}`);
|
|
3942
|
+
* console.log(`${firstPage.length} offers on this page`);
|
|
3943
|
+
*
|
|
3944
|
+
* // Load next page if available
|
|
3945
|
+
* if (pagination.hasNextPage) {
|
|
3946
|
+
* const { data: nextPage } = await sdk.redemptions.getRedemptions({
|
|
3947
|
+
* page: pagination.page + 1,
|
|
3948
|
+
* limit: 10
|
|
3949
|
+
* });
|
|
3950
|
+
* }
|
|
3896
3951
|
* ```
|
|
3897
3952
|
*/
|
|
3898
|
-
async
|
|
3899
|
-
return this.redemptionService.
|
|
3953
|
+
async getRedemptions(options) {
|
|
3954
|
+
return this.redemptionService.getRedemptions(options);
|
|
3900
3955
|
}
|
|
3901
3956
|
/**
|
|
3902
3957
|
* Get available redemption types
|
|
@@ -3905,13 +3960,13 @@ class RedemptionManager {
|
|
|
3905
3960
|
* rewards and offers. Types help users navigate and filter redemption options
|
|
3906
3961
|
* based on their preferences and needs.
|
|
3907
3962
|
*
|
|
3908
|
-
* @returns Promise resolving to
|
|
3963
|
+
* @returns Promise resolving to paginated redemption type definitions
|
|
3909
3964
|
*
|
|
3910
3965
|
* @example
|
|
3911
3966
|
* ```typescript
|
|
3912
|
-
* const redemptionTypes = await sdk.redemptions.getRedemptionTypes();
|
|
3967
|
+
* const { data: redemptionTypes } = await sdk.redemptions.getRedemptionTypes();
|
|
3913
3968
|
*
|
|
3914
|
-
* console.log('
|
|
3969
|
+
* console.log('Redemption Categories:');
|
|
3915
3970
|
* redemptionTypes.forEach(type => {
|
|
3916
3971
|
* console.log(`- ${type.name}: ${type.description}`);
|
|
3917
3972
|
* });
|
|
@@ -3932,8 +3987,8 @@ class RedemptionManager {
|
|
|
3932
3987
|
* );
|
|
3933
3988
|
* ```
|
|
3934
3989
|
*/
|
|
3935
|
-
async getRedemptionTypes() {
|
|
3936
|
-
return this.redemptionService.getRedemptionTypes();
|
|
3990
|
+
async getRedemptionTypes(options) {
|
|
3991
|
+
return this.redemptionService.getRedemptionTypes(options);
|
|
3937
3992
|
}
|
|
3938
3993
|
/**
|
|
3939
3994
|
* Redeem a redemption offer
|
|
@@ -3953,30 +4008,30 @@ class RedemptionManager {
|
|
|
3953
4008
|
* const result = await sdk.redemptions.redeem('coffee-voucher-123');
|
|
3954
4009
|
*
|
|
3955
4010
|
* if (result.success) {
|
|
3956
|
-
* console.log('
|
|
4011
|
+
* console.log('Redemption Successful!');
|
|
3957
4012
|
* console.log('Confirmation ID:', result.id);
|
|
3958
4013
|
* console.log('Redeemed at:', result.redeemedAt);
|
|
3959
4014
|
*
|
|
3960
4015
|
* // Display redemption details
|
|
3961
4016
|
* if (result.voucherCode) {
|
|
3962
|
-
* console.log('
|
|
4017
|
+
* console.log('Voucher Code:', result.voucherCode);
|
|
3963
4018
|
* console.log('Present this code to redeem your reward');
|
|
3964
4019
|
* }
|
|
3965
4020
|
*
|
|
3966
4021
|
* if (result.instructions) {
|
|
3967
|
-
* console.log('
|
|
4022
|
+
* console.log('Instructions:', result.instructions);
|
|
3968
4023
|
* }
|
|
3969
4024
|
*
|
|
3970
4025
|
* // Show tokens deducted
|
|
3971
4026
|
* if (result.tokensUsed?.length) {
|
|
3972
|
-
* console.log('\
|
|
4027
|
+
* console.log('\nTokens Used:');
|
|
3973
4028
|
* result.tokensUsed.forEach(token => {
|
|
3974
4029
|
* console.log(`- ${token.amount} ${token.symbol}`);
|
|
3975
4030
|
* });
|
|
3976
4031
|
* }
|
|
3977
4032
|
*
|
|
3978
4033
|
* } else {
|
|
3979
|
-
* console.log('
|
|
4034
|
+
* console.log('Redemption failed:', result.error);
|
|
3980
4035
|
* }
|
|
3981
4036
|
*
|
|
3982
4037
|
* } catch (error) {
|
|
@@ -3984,9 +4039,9 @@ class RedemptionManager {
|
|
|
3984
4039
|
*
|
|
3985
4040
|
* // Handle specific error cases
|
|
3986
4041
|
* if (error.message.includes('insufficient')) {
|
|
3987
|
-
* console.log('
|
|
4042
|
+
* console.log('You need more loyalty points for this redemption');
|
|
3988
4043
|
* } else if (error.message.includes('unavailable')) {
|
|
3989
|
-
* console.log('
|
|
4044
|
+
* console.log('This offer is no longer available');
|
|
3990
4045
|
* }
|
|
3991
4046
|
* }
|
|
3992
4047
|
* ```
|
|
@@ -3994,7 +4049,7 @@ class RedemptionManager {
|
|
|
3994
4049
|
* @example Redemption with Pre-Validation
|
|
3995
4050
|
* ```typescript
|
|
3996
4051
|
* // Get offer details first
|
|
3997
|
-
* const offers = await sdk.redemptions.
|
|
4052
|
+
* const { data: offers } = await sdk.redemptions.getRedemptions();
|
|
3998
4053
|
* const targetOffer = offers.find(o => o.id === 'premium-discount');
|
|
3999
4054
|
*
|
|
4000
4055
|
* if (targetOffer) {
|
|
@@ -4031,25 +4086,25 @@ class RedemptionManager {
|
|
|
4031
4086
|
* completed. Includes redemption details, timestamps, voucher codes, and
|
|
4032
4087
|
* token usage. Useful for user account history and support purposes.
|
|
4033
4088
|
*
|
|
4034
|
-
* @returns Promise resolving to
|
|
4089
|
+
* @returns Promise resolving to paginated user redemption records
|
|
4035
4090
|
*
|
|
4036
4091
|
* @example
|
|
4037
4092
|
* ```typescript
|
|
4038
|
-
* const userRedemptions = await sdk.redemptions.getUserRedemptions();
|
|
4093
|
+
* const { data: userRedemptions, pagination } = await sdk.redemptions.getUserRedemptions();
|
|
4039
4094
|
*
|
|
4040
|
-
* console.log(
|
|
4095
|
+
* console.log(`Redemption History (${userRedemptions.length} of ${pagination.total} items):`);
|
|
4041
4096
|
*
|
|
4042
4097
|
* userRedemptions.forEach((redemption, index) => {
|
|
4043
4098
|
* console.log(`\n${index + 1}. ${redemption.redemption.title}`);
|
|
4044
|
-
* console.log(`
|
|
4045
|
-
* console.log(`
|
|
4099
|
+
* console.log(` Date: ${new Date(redemption.redeemedAt).toLocaleDateString()}`);
|
|
4100
|
+
* console.log(` Type: ${redemption.redemption.redemptionType?.name || 'General'}`);
|
|
4046
4101
|
*
|
|
4047
4102
|
* if (redemption.voucherCode) {
|
|
4048
|
-
* console.log(`
|
|
4103
|
+
* console.log(` Voucher: ${redemption.voucherCode}`);
|
|
4049
4104
|
* }
|
|
4050
4105
|
*
|
|
4051
4106
|
* if (redemption.tokensUsed?.length) {
|
|
4052
|
-
* console.log(`
|
|
4107
|
+
* console.log(` Cost:`);
|
|
4053
4108
|
* redemption.tokensUsed.forEach(token => {
|
|
4054
4109
|
* console.log(` ${token.amount} ${token.symbol}`);
|
|
4055
4110
|
* });
|
|
@@ -4057,7 +4112,7 @@ class RedemptionManager {
|
|
|
4057
4112
|
*
|
|
4058
4113
|
* // Show status if available
|
|
4059
4114
|
* if (redemption.status) {
|
|
4060
|
-
* console.log(`
|
|
4115
|
+
* console.log(` Status: ${redemption.status}`);
|
|
4061
4116
|
* }
|
|
4062
4117
|
* });
|
|
4063
4118
|
*
|
|
@@ -4067,7 +4122,7 @@ class RedemptionManager {
|
|
|
4067
4122
|
* new Date(r.redeemedAt) > new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)
|
|
4068
4123
|
* ).length;
|
|
4069
4124
|
*
|
|
4070
|
-
* console.log(`\
|
|
4125
|
+
* console.log(`\nStatistics:`);
|
|
4071
4126
|
* console.log(`Total redemptions: ${totalRedemptions}`);
|
|
4072
4127
|
* console.log(`This month: ${recentRedemptions}`);
|
|
4073
4128
|
*
|
|
@@ -4078,62 +4133,14 @@ class RedemptionManager {
|
|
|
4078
4133
|
* return acc;
|
|
4079
4134
|
* }, {});
|
|
4080
4135
|
*
|
|
4081
|
-
* console.log(`\
|
|
4136
|
+
* console.log(`\nBy category:`);
|
|
4082
4137
|
* Object.entries(byType).forEach(([type, count]) => {
|
|
4083
4138
|
* console.log(`${type}: ${count} redemptions`);
|
|
4084
4139
|
* });
|
|
4085
4140
|
* ```
|
|
4086
4141
|
*/
|
|
4087
|
-
async getUserRedemptions() {
|
|
4088
|
-
return this.redemptionService.getUserRedeems();
|
|
4089
|
-
}
|
|
4090
|
-
/**
|
|
4091
|
-
* Admin: Get all redemptions
|
|
4092
|
-
*
|
|
4093
|
-
* Retrieves all redemption offers in the system regardless of status. This
|
|
4094
|
-
* operation requires administrator privileges and is used for comprehensive
|
|
4095
|
-
* redemption management, reporting, and lifecycle operations.
|
|
4096
|
-
*
|
|
4097
|
-
* @param active - Optional filter to show only active or inactive redemptions
|
|
4098
|
-
* @returns Promise resolving to array of all redemptions
|
|
4099
|
-
* @throws {PersApiError} When not authenticated as administrator
|
|
4100
|
-
*
|
|
4101
|
-
* @example
|
|
4102
|
-
* ```typescript
|
|
4103
|
-
* // Admin operation - get redemption overview
|
|
4104
|
-
* const allRedemptions = await sdk.redemptions.getAllRedemptions();
|
|
4105
|
-
* const activeRedemptions = await sdk.redemptions.getAllRedemptions(true);
|
|
4106
|
-
* const inactiveRedemptions = await sdk.redemptions.getAllRedemptions(false);
|
|
4107
|
-
*
|
|
4108
|
-
* console.log('📊 Redemption Inventory:');
|
|
4109
|
-
* console.log(`Total offers: ${allRedemptions.length}`);
|
|
4110
|
-
* console.log(`Active offers: ${activeRedemptions.length}`);
|
|
4111
|
-
* console.log(`Inactive offers: ${inactiveRedemptions.length}`);
|
|
4112
|
-
*
|
|
4113
|
-
* // Analyze offers by type
|
|
4114
|
-
* const offersByType = allRedemptions.reduce((acc, offer) => {
|
|
4115
|
-
* const type = offer.redemptionType?.name || 'Unspecified';
|
|
4116
|
-
* acc[type] = (acc[type] || 0) + 1;
|
|
4117
|
-
* return acc;
|
|
4118
|
-
* }, {});
|
|
4119
|
-
*
|
|
4120
|
-
* console.log('\n🏷️ Offers by type:');
|
|
4121
|
-
* Object.entries(offersByType).forEach(([type, count]) => {
|
|
4122
|
-
* console.log(`${type}: ${count} offers`);
|
|
4123
|
-
* });
|
|
4124
|
-
*
|
|
4125
|
-
* // Find offers needing attention
|
|
4126
|
-
* const lowStock = allRedemptions.filter(offer =>
|
|
4127
|
-
* offer.availableQuantity && offer.availableQuantity < 10
|
|
4128
|
-
* );
|
|
4129
|
-
*
|
|
4130
|
-
* if (lowStock.length > 0) {
|
|
4131
|
-
* console.log(`\n⚠️ ${lowStock.length} offers running low on stock`);
|
|
4132
|
-
* }
|
|
4133
|
-
* ```
|
|
4134
|
-
*/
|
|
4135
|
-
async getAllRedemptions(active) {
|
|
4136
|
-
return this.redemptionService.getRedemptionsAsAdmin(active);
|
|
4142
|
+
async getUserRedemptions(options) {
|
|
4143
|
+
return this.redemptionService.getUserRedeems(options);
|
|
4137
4144
|
}
|
|
4138
4145
|
/**
|
|
4139
4146
|
* Admin: Create new redemption offer
|
|
@@ -4159,7 +4166,7 @@ class RedemptionManager {
|
|
|
4159
4166
|
* validUntil: '2024-08-31T23:59:59Z'
|
|
4160
4167
|
* });
|
|
4161
4168
|
*
|
|
4162
|
-
* console.log('
|
|
4169
|
+
* console.log('New redemption created:', newRedemption.title);
|
|
4163
4170
|
* console.log('Redemption ID:', newRedemption.id);
|
|
4164
4171
|
*
|
|
4165
4172
|
* // Set redemption cost
|
|
@@ -4169,7 +4176,7 @@ class RedemptionManager {
|
|
|
4169
4176
|
* type: 'COST'
|
|
4170
4177
|
* });
|
|
4171
4178
|
*
|
|
4172
|
-
* console.log('
|
|
4179
|
+
* console.log('Cost set: 750 loyalty points');
|
|
4173
4180
|
* ```
|
|
4174
4181
|
*/
|
|
4175
4182
|
async createRedemption(redemptionData) {
|
|
@@ -4221,7 +4228,7 @@ class RedemptionManager {
|
|
|
4221
4228
|
* const updated = await sdk.redemptions.toggleRedemptionStatus('seasonal-offer');
|
|
4222
4229
|
*
|
|
4223
4230
|
* console.log(`Redemption ${updated.isActive ? 'activated' : 'deactivated'}`);
|
|
4224
|
-
* console.log('Status:', updated.isActive ? '
|
|
4231
|
+
* console.log('Status:', updated.isActive ? 'Available' : 'Unavailable');
|
|
4225
4232
|
*
|
|
4226
4233
|
* // Reactivate when ready
|
|
4227
4234
|
* if (!updated.isActive) {
|
|
@@ -4408,7 +4415,7 @@ class TransactionManager {
|
|
|
4408
4415
|
* try {
|
|
4409
4416
|
* const transaction = await sdk.transactions.getTransactionById('txn-abc123');
|
|
4410
4417
|
*
|
|
4411
|
-
* console.log('
|
|
4418
|
+
* console.log('Transaction Details:');
|
|
4412
4419
|
* console.log('ID:', transaction.id);
|
|
4413
4420
|
* console.log('Type:', transaction.type);
|
|
4414
4421
|
* console.log('Status:', transaction.status);
|
|
@@ -4425,7 +4432,7 @@ class TransactionManager {
|
|
|
4425
4432
|
*
|
|
4426
4433
|
* // Show token movements
|
|
4427
4434
|
* if (transaction.tokenTransfers?.length) {
|
|
4428
|
-
* console.log('\
|
|
4435
|
+
* console.log('\nToken Transfers:');
|
|
4429
4436
|
* transaction.tokenTransfers.forEach(transfer => {
|
|
4430
4437
|
* console.log(`${transfer.amount} ${transfer.token.symbol} ${transfer.direction}`);
|
|
4431
4438
|
* });
|
|
@@ -4433,7 +4440,7 @@ class TransactionManager {
|
|
|
4433
4440
|
*
|
|
4434
4441
|
* // Show blockchain confirmation
|
|
4435
4442
|
* if (transaction.blockchainHash) {
|
|
4436
|
-
* console.log('
|
|
4443
|
+
* console.log('Blockchain:', transaction.blockchainHash);
|
|
4437
4444
|
* }
|
|
4438
4445
|
*
|
|
4439
4446
|
* } catch (error) {
|
|
@@ -4470,12 +4477,12 @@ class TransactionManager {
|
|
|
4470
4477
|
* }
|
|
4471
4478
|
* });
|
|
4472
4479
|
*
|
|
4473
|
-
* console.log('
|
|
4480
|
+
* console.log('Purchase completed!');
|
|
4474
4481
|
* console.log('Transaction ID:', purchase.id);
|
|
4475
4482
|
* console.log('Status:', purchase.status);
|
|
4476
4483
|
*
|
|
4477
4484
|
* if (purchase.tokensEarned?.length) {
|
|
4478
|
-
* console.log('\
|
|
4485
|
+
* console.log('\nLoyalty rewards earned:');
|
|
4479
4486
|
* purchase.tokensEarned.forEach(reward => {
|
|
4480
4487
|
* console.log(`${reward.amount} ${reward.token.symbol}`);
|
|
4481
4488
|
* });
|
|
@@ -4586,7 +4593,7 @@ class TransactionManager {
|
|
|
4586
4593
|
* }
|
|
4587
4594
|
* });
|
|
4588
4595
|
*
|
|
4589
|
-
* console.log('
|
|
4596
|
+
* console.log('Purchase Summary:');
|
|
4590
4597
|
* console.log(`Total purchases: ${purchases.length}`);
|
|
4591
4598
|
* console.log(`Total spent: $${totalSpent.toFixed(2)}`);
|
|
4592
4599
|
* console.log(`Total rewards earned: ${totalRewards} points`);
|
|
@@ -4602,7 +4609,7 @@ class TransactionManager {
|
|
|
4602
4609
|
* new Date(t.createdAt) > thirtyDaysAgo
|
|
4603
4610
|
* );
|
|
4604
4611
|
*
|
|
4605
|
-
* console.log(
|
|
4612
|
+
* console.log(`Recent Activity (${recentActivity.length} transactions in last 30 days):`);
|
|
4606
4613
|
*
|
|
4607
4614
|
* // Group by type
|
|
4608
4615
|
* const activityByType = recentActivity.reduce((acc, t) => {
|
|
@@ -4615,8 +4622,8 @@ class TransactionManager {
|
|
|
4615
4622
|
* });
|
|
4616
4623
|
* ```
|
|
4617
4624
|
*/
|
|
4618
|
-
async getUserTransactionHistory(role,
|
|
4619
|
-
return this.transactionService.getUserTransactionHistory(role,
|
|
4625
|
+
async getUserTransactionHistory(role, options) {
|
|
4626
|
+
return this.transactionService.getUserTransactionHistory(role, options);
|
|
4620
4627
|
}
|
|
4621
4628
|
/**
|
|
4622
4629
|
* Admin: Get all tenant transactions
|
|
@@ -4634,7 +4641,7 @@ class TransactionManager {
|
|
|
4634
4641
|
* // Admin operation - comprehensive transaction analysis
|
|
4635
4642
|
* const allTransactions = await sdk.transactions.getTenantTransactions();
|
|
4636
4643
|
*
|
|
4637
|
-
* console.log(
|
|
4644
|
+
* console.log(`Tenant Transaction Overview:`);
|
|
4638
4645
|
* console.log(`Total transactions: ${allTransactions.length}`);
|
|
4639
4646
|
*
|
|
4640
4647
|
* // Analyze by status
|
|
@@ -4643,7 +4650,7 @@ class TransactionManager {
|
|
|
4643
4650
|
* return acc;
|
|
4644
4651
|
* }, {});
|
|
4645
4652
|
*
|
|
4646
|
-
* console.log('\
|
|
4653
|
+
* console.log('\nBy status:');
|
|
4647
4654
|
* Object.entries(statusCounts).forEach(([status, count]) => {
|
|
4648
4655
|
* console.log(`${status}: ${count} transactions`);
|
|
4649
4656
|
* });
|
|
@@ -4654,7 +4661,7 @@ class TransactionManager {
|
|
|
4654
4661
|
* return acc;
|
|
4655
4662
|
* }, {});
|
|
4656
4663
|
*
|
|
4657
|
-
* console.log('\
|
|
4664
|
+
* console.log('\nBy type:');
|
|
4658
4665
|
* Object.entries(typeCounts).forEach(([type, count]) => {
|
|
4659
4666
|
* console.log(`${type}: ${count} transactions`);
|
|
4660
4667
|
* });
|
|
@@ -4666,7 +4673,7 @@ class TransactionManager {
|
|
|
4666
4673
|
*
|
|
4667
4674
|
* const avgTransactionSize = totalVolume / allTransactions.length;
|
|
4668
4675
|
*
|
|
4669
|
-
* console.log('\
|
|
4676
|
+
* console.log('\nVolume metrics:');
|
|
4670
4677
|
* console.log(`Total volume: $${totalVolume.toFixed(2)}`);
|
|
4671
4678
|
* console.log(`Average transaction: $${avgTransactionSize.toFixed(2)}`);
|
|
4672
4679
|
*
|
|
@@ -4678,8 +4685,8 @@ class TransactionManager {
|
|
|
4678
4685
|
* console.log(`\n⏰ Last 24 hours: ${last24Hours.length} transactions`);
|
|
4679
4686
|
* ```
|
|
4680
4687
|
*/
|
|
4681
|
-
async getTenantTransactions(
|
|
4682
|
-
return this.transactionService.getTenantTransactions(
|
|
4688
|
+
async getTenantTransactions(options) {
|
|
4689
|
+
return this.transactionService.getTenantTransactions(options);
|
|
4683
4690
|
}
|
|
4684
4691
|
/**
|
|
4685
4692
|
* Admin: Get paginated transactions
|
|
@@ -4702,7 +4709,7 @@ class TransactionManager {
|
|
|
4702
4709
|
* sortOrder: 'DESC'
|
|
4703
4710
|
* });
|
|
4704
4711
|
*
|
|
4705
|
-
* console.log(
|
|
4712
|
+
* console.log(`� Page ${result.page} of ${result.totalPages}`);
|
|
4706
4713
|
* console.log(`Showing ${result.data.length} of ${result.total} transactions`);
|
|
4707
4714
|
*
|
|
4708
4715
|
* result.data.forEach((transaction, index) => {
|
|
@@ -4736,7 +4743,7 @@ class TransactionManager {
|
|
|
4736
4743
|
* sortOrder: 'DESC'
|
|
4737
4744
|
* });
|
|
4738
4745
|
*
|
|
4739
|
-
* console.log('
|
|
4746
|
+
* console.log('Filtered Results:');
|
|
4740
4747
|
* console.log(`Found ${filteredResult.total} matching transactions`);
|
|
4741
4748
|
*
|
|
4742
4749
|
* filteredResult.data.forEach(transaction => {
|
|
@@ -4777,10 +4784,10 @@ class TransactionManager {
|
|
|
4777
4784
|
* // Clean up object URL
|
|
4778
4785
|
* URL.revokeObjectURL(downloadUrl);
|
|
4779
4786
|
*
|
|
4780
|
-
* console.log('
|
|
4787
|
+
* console.log('Transaction export downloaded successfully');
|
|
4781
4788
|
*
|
|
4782
4789
|
* } catch (error) {
|
|
4783
|
-
* console.log('
|
|
4790
|
+
* console.log('Export failed:', error.message);
|
|
4784
4791
|
* }
|
|
4785
4792
|
* ```
|
|
4786
4793
|
*
|
|
@@ -4955,7 +4962,7 @@ class TransactionManager {
|
|
|
4955
4962
|
* // Browse available token packages
|
|
4956
4963
|
* const availableTokens = await sdk.purchases.getActivePurchaseTokens(true);
|
|
4957
4964
|
*
|
|
4958
|
-
* console.log('
|
|
4965
|
+
* console.log('Available Token Packages:');
|
|
4959
4966
|
* availableTokens.forEach(token => {
|
|
4960
4967
|
* console.log(`\n${token.name}`);
|
|
4961
4968
|
* console.log(`Price: $${token.price} ${token.currency}`);
|
|
@@ -4982,8 +4989,8 @@ class TransactionManager {
|
|
|
4982
4989
|
class PurchaseManager {
|
|
4983
4990
|
constructor(apiClient) {
|
|
4984
4991
|
this.apiClient = apiClient;
|
|
4985
|
-
const paymentApi = new
|
|
4986
|
-
this.paymentService = new
|
|
4992
|
+
const paymentApi = new payment.PaymentApi(apiClient);
|
|
4993
|
+
this.paymentService = new payment.PaymentService(paymentApi);
|
|
4987
4994
|
}
|
|
4988
4995
|
/**
|
|
4989
4996
|
* Create a payment intent
|
|
@@ -5010,7 +5017,7 @@ class PurchaseManager {
|
|
|
5010
5017
|
* '1000 Loyalty Points Package'
|
|
5011
5018
|
* );
|
|
5012
5019
|
*
|
|
5013
|
-
* console.log('
|
|
5020
|
+
* console.log('Payment Intent Created:');
|
|
5014
5021
|
* console.log('ID:', paymentIntent.id);
|
|
5015
5022
|
* console.log('Amount:', paymentIntent.amount / 100, paymentIntent.currency);
|
|
5016
5023
|
* console.log('Status:', paymentIntent.status);
|
|
@@ -5087,23 +5094,23 @@ class PurchaseManager {
|
|
|
5087
5094
|
* const allPackages = await sdk.purchases.getActivePurchaseTokens();
|
|
5088
5095
|
* const activeOnly = await sdk.purchases.getActivePurchaseTokens(true);
|
|
5089
5096
|
*
|
|
5090
|
-
* console.log('
|
|
5097
|
+
* console.log('Token Package Catalog:');
|
|
5091
5098
|
*
|
|
5092
5099
|
* activeOnly.forEach(package => {
|
|
5093
|
-
* console.log(`\n
|
|
5094
|
-
* console.log(
|
|
5100
|
+
* console.log(`\n${package.name}`);
|
|
5101
|
+
* console.log(`Price: $${package.price} ${package.currency}`);
|
|
5095
5102
|
* console.log(`🪙 Tokens: ${package.tokenAmount} ${package.tokenSymbol}`);
|
|
5096
|
-
* console.log(
|
|
5103
|
+
* console.log(`${package.description}`);
|
|
5097
5104
|
*
|
|
5098
5105
|
* // Calculate value per token
|
|
5099
5106
|
* const costPerToken = package.price / package.tokenAmount;
|
|
5100
|
-
* console.log(
|
|
5107
|
+
* console.log(`Value: $${costPerToken.toFixed(4)} per token`);
|
|
5101
5108
|
*
|
|
5102
5109
|
* if (package.bonusTokens && package.bonusTokens > 0) {
|
|
5103
|
-
* console.log(
|
|
5110
|
+
* console.log(`Bonus: +${package.bonusTokens} extra tokens`);
|
|
5104
5111
|
* const totalTokens = package.tokenAmount + package.bonusTokens;
|
|
5105
5112
|
* const actualCostPerToken = package.price / totalTokens;
|
|
5106
|
-
* console.log(
|
|
5113
|
+
* console.log(`With bonus: $${actualCostPerToken.toFixed(4)} per token`);
|
|
5107
5114
|
* }
|
|
5108
5115
|
*
|
|
5109
5116
|
* if (package.validUntil) {
|
|
@@ -5118,7 +5125,7 @@ class PurchaseManager {
|
|
|
5118
5125
|
* return currentValue < bestValue ? current : best;
|
|
5119
5126
|
* });
|
|
5120
5127
|
*
|
|
5121
|
-
* console.log(`\n
|
|
5128
|
+
* console.log(`\n� Best Value: ${bestValue.name}`);
|
|
5122
5129
|
* ```
|
|
5123
5130
|
*
|
|
5124
5131
|
* @example Filter by Currency and Price
|
|
@@ -5144,15 +5151,15 @@ class PurchaseManager {
|
|
|
5144
5151
|
* (b.tokenAmount + (b.bonusTokens || 0)) - (a.tokenAmount + (a.bonusTokens || 0))
|
|
5145
5152
|
* );
|
|
5146
5153
|
*
|
|
5147
|
-
* console.log('\
|
|
5154
|
+
* console.log('\nTop 3 by token amount:');
|
|
5148
5155
|
* sortedByTokens.slice(0, 3).forEach((pkg, index) => {
|
|
5149
5156
|
* const totalTokens = pkg.tokenAmount + (pkg.bonusTokens || 0);
|
|
5150
5157
|
* console.log(`${index + 1}. ${pkg.name}: ${totalTokens} tokens`);
|
|
5151
5158
|
* });
|
|
5152
5159
|
* ```
|
|
5153
5160
|
*/
|
|
5154
|
-
async getActivePurchaseTokens(active) {
|
|
5155
|
-
return this.paymentService.getActivePurchaseTokens(active);
|
|
5161
|
+
async getActivePurchaseTokens(active, options) {
|
|
5162
|
+
return this.paymentService.getActivePurchaseTokens(active, options);
|
|
5156
5163
|
}
|
|
5157
5164
|
/**
|
|
5158
5165
|
* Get all user purchases
|
|
@@ -5167,16 +5174,16 @@ class PurchaseManager {
|
|
|
5167
5174
|
* ```typescript
|
|
5168
5175
|
* const userPurchases = await sdk.purchases.getAllUserPurchases();
|
|
5169
5176
|
*
|
|
5170
|
-
* console.log(
|
|
5177
|
+
* console.log(`Purchase History (${userPurchases.length} purchases):`);
|
|
5171
5178
|
*
|
|
5172
5179
|
* userPurchases.forEach((purchase, index) => {
|
|
5173
5180
|
* console.log(`\n${index + 1}. Purchase #${purchase.id}`);
|
|
5174
|
-
* console.log(
|
|
5175
|
-
* console.log(
|
|
5176
|
-
* console.log(
|
|
5181
|
+
* console.log(`Date: ${new Date(purchase.createdAt).toLocaleDateString()}`);
|
|
5182
|
+
* console.log(`Amount: $${purchase.amount} ${purchase.currency}`);
|
|
5183
|
+
* console.log(`Status: ${purchase.status}`);
|
|
5177
5184
|
*
|
|
5178
5185
|
* if (purchase.description) {
|
|
5179
|
-
* console.log(
|
|
5186
|
+
* console.log(`Description: ${purchase.description}`);
|
|
5180
5187
|
* }
|
|
5181
5188
|
*
|
|
5182
5189
|
* if (purchase.tokensReceived) {
|
|
@@ -5184,11 +5191,11 @@ class PurchaseManager {
|
|
|
5184
5191
|
* }
|
|
5185
5192
|
*
|
|
5186
5193
|
* if (purchase.paymentMethod) {
|
|
5187
|
-
* console.log(
|
|
5194
|
+
* console.log(`Payment method: ${purchase.paymentMethod}`);
|
|
5188
5195
|
* }
|
|
5189
5196
|
*
|
|
5190
5197
|
* if (purchase.receiptEmail) {
|
|
5191
|
-
* console.log(
|
|
5198
|
+
* console.log(`� Receipt sent to: ${purchase.receiptEmail}`);
|
|
5192
5199
|
* }
|
|
5193
5200
|
* });
|
|
5194
5201
|
*
|
|
@@ -5197,7 +5204,7 @@ class PurchaseManager {
|
|
|
5197
5204
|
* const totalSpent = successfulPurchases.reduce((sum, p) => sum + p.amount, 0);
|
|
5198
5205
|
* const totalTokens = successfulPurchases.reduce((sum, p) => sum + (p.tokensReceived || 0), 0);
|
|
5199
5206
|
*
|
|
5200
|
-
* console.log('\
|
|
5207
|
+
* console.log('\nPurchase Statistics:');
|
|
5201
5208
|
* console.log(`Total purchases: ${userPurchases.length}`);
|
|
5202
5209
|
* console.log(`Successful purchases: ${successfulPurchases.length}`);
|
|
5203
5210
|
* console.log(`Total spent: $${totalSpent.toFixed(2)}`);
|
|
@@ -5222,7 +5229,7 @@ class PurchaseManager {
|
|
|
5222
5229
|
* new Date(p.createdAt) > new Date(Date.now() - 180 * 24 * 60 * 60 * 1000)
|
|
5223
5230
|
* );
|
|
5224
5231
|
*
|
|
5225
|
-
* console.log('
|
|
5232
|
+
* console.log('Purchase Timeline:');
|
|
5226
5233
|
* console.log(`Last 30 days: ${last30Days.length} purchases`);
|
|
5227
5234
|
* console.log(`Last 6 months: ${last6Months.length} purchases`);
|
|
5228
5235
|
*
|
|
@@ -5232,7 +5239,7 @@ class PurchaseManager {
|
|
|
5232
5239
|
* return acc;
|
|
5233
5240
|
* }, {});
|
|
5234
5241
|
*
|
|
5235
|
-
* console.log('\
|
|
5242
|
+
* console.log('\nBy status:');
|
|
5236
5243
|
* Object.entries(statusCounts).forEach(([status, count]) => {
|
|
5237
5244
|
* console.log(`${status}: ${count} purchases`);
|
|
5238
5245
|
* });
|
|
@@ -5247,7 +5254,7 @@ class PurchaseManager {
|
|
|
5247
5254
|
* );
|
|
5248
5255
|
*
|
|
5249
5256
|
* if (largestPurchase) {
|
|
5250
|
-
* console.log(`\
|
|
5257
|
+
* console.log(`\nLargest purchase: $${largestPurchase.amount} on ${new Date(largestPurchase.createdAt).toLocaleDateString()}`);
|
|
5251
5258
|
* }
|
|
5252
5259
|
*
|
|
5253
5260
|
* if (mostRecent) {
|
|
@@ -5255,8 +5262,8 @@ class PurchaseManager {
|
|
|
5255
5262
|
* }
|
|
5256
5263
|
* ```
|
|
5257
5264
|
*/
|
|
5258
|
-
async getAllUserPurchases() {
|
|
5259
|
-
return this.paymentService.getAllUserPurchases();
|
|
5265
|
+
async getAllUserPurchases(options) {
|
|
5266
|
+
return this.paymentService.getAllUserPurchases(options);
|
|
5260
5267
|
}
|
|
5261
5268
|
/**
|
|
5262
5269
|
* Get the full purchase service for advanced operations
|
|
@@ -5530,9 +5537,9 @@ class FileManager {
|
|
|
5530
5537
|
* });
|
|
5531
5538
|
*
|
|
5532
5539
|
* if (uploadResponse.ok) {
|
|
5533
|
-
* console.log('
|
|
5540
|
+
* console.log('Campaign banner uploaded successfully');
|
|
5534
5541
|
* } else {
|
|
5535
|
-
* console.log('
|
|
5542
|
+
* console.log('Upload failed:', uploadResponse.status);
|
|
5536
5543
|
* }
|
|
5537
5544
|
* }
|
|
5538
5545
|
*
|
|
@@ -5913,8 +5920,8 @@ class FileManager {
|
|
|
5913
5920
|
class TenantManager {
|
|
5914
5921
|
constructor(apiClient) {
|
|
5915
5922
|
this.apiClient = apiClient;
|
|
5916
|
-
const tenantApi = new
|
|
5917
|
-
this.tenantService = new
|
|
5923
|
+
const tenantApi = new tenant.TenantApi(apiClient);
|
|
5924
|
+
this.tenantService = new tenant.TenantService(tenantApi);
|
|
5918
5925
|
}
|
|
5919
5926
|
/**
|
|
5920
5927
|
* Get current tenant information
|
|
@@ -5952,10 +5959,11 @@ class TenantManager {
|
|
|
5952
5959
|
/**
|
|
5953
5960
|
* Admin: Get all admins
|
|
5954
5961
|
*
|
|
5955
|
-
* @
|
|
5962
|
+
* @param options - Pagination options
|
|
5963
|
+
* @returns Promise resolving to paginated admins
|
|
5956
5964
|
*/
|
|
5957
|
-
async getAdmins() {
|
|
5958
|
-
return this.tenantService.getAdmins();
|
|
5965
|
+
async getAdmins(options) {
|
|
5966
|
+
return this.tenantService.getAdmins(options);
|
|
5959
5967
|
}
|
|
5960
5968
|
/**
|
|
5961
5969
|
* Admin: Create new admin
|
|
@@ -6002,17 +6010,17 @@ class ApiKeyApi {
|
|
|
6002
6010
|
*
|
|
6003
6011
|
* @param type Optional filter by integration API key type (database-stored tokens that can be revoked)
|
|
6004
6012
|
* @param includeRevoked Include revoked API keys in results (default: false)
|
|
6005
|
-
* @
|
|
6013
|
+
* @param options Pagination options (page, limit, sortBy, sortOrder)
|
|
6014
|
+
* @returns Paginated response with API keys for the current tenant
|
|
6006
6015
|
*/
|
|
6007
|
-
async getTenantApiKeys(type, includeRevoked = false) {
|
|
6008
|
-
const params =
|
|
6016
|
+
async getTenantApiKeys(type, includeRevoked = false, options) {
|
|
6017
|
+
const params = paginationUtils.buildPaginationParams(options);
|
|
6009
6018
|
if (type)
|
|
6010
6019
|
params.append('type', type);
|
|
6011
6020
|
if (includeRevoked)
|
|
6012
6021
|
params.append('includeRevoked', 'true');
|
|
6013
|
-
const
|
|
6014
|
-
|
|
6015
|
-
return this.apiClient.get(url);
|
|
6022
|
+
const response = await this.apiClient.get(`${this.basePath}?${params.toString()}`);
|
|
6023
|
+
return paginationUtils.normalizeToPaginated(response);
|
|
6016
6024
|
}
|
|
6017
6025
|
/**
|
|
6018
6026
|
* ADMIN: Create new API key
|
|
@@ -6066,27 +6074,27 @@ class ApiKeyManager {
|
|
|
6066
6074
|
// TENANT API KEY OPERATIONS (Admin Only)
|
|
6067
6075
|
// ==========================================
|
|
6068
6076
|
/**
|
|
6069
|
-
* Get all API keys for the current tenant
|
|
6077
|
+
* Get all API keys for the current tenant with pagination
|
|
6070
6078
|
*
|
|
6071
6079
|
* **Admin Only**: Requires tenant admin authentication
|
|
6072
6080
|
*
|
|
6073
6081
|
* @param type Optional filter by integration API key type (database-stored tokens)
|
|
6074
6082
|
* @param includeRevoked Include revoked API keys in results (default: false)
|
|
6075
|
-
* @returns
|
|
6083
|
+
* @returns Paginated API keys with metadata (excludes actual key values)
|
|
6076
6084
|
*
|
|
6077
6085
|
* @example
|
|
6078
6086
|
* ```typescript
|
|
6079
6087
|
* // Get all active API keys
|
|
6080
|
-
* const allKeys = await sdk.apiKeys.listApiKeys();
|
|
6088
|
+
* const { data: allKeys } = await sdk.apiKeys.listApiKeys();
|
|
6081
6089
|
*
|
|
6082
6090
|
* // Get only active JWT tokens
|
|
6083
|
-
* const jwtKeys = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT');
|
|
6091
|
+
* const { data: jwtKeys } = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT');
|
|
6084
6092
|
*
|
|
6085
6093
|
* // Get all JWT tokens including revoked ones
|
|
6086
|
-
* const allJwtKeys = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT', true);
|
|
6094
|
+
* const { data: allJwtKeys } = await sdk.apiKeys.listApiKeys('TENANT_SYSTEM_JWT', true);
|
|
6087
6095
|
* ```
|
|
6088
6096
|
*/
|
|
6089
|
-
async listApiKeys(type, includeRevoked = false) {
|
|
6097
|
+
async listApiKeys(type, includeRevoked = false, options) {
|
|
6090
6098
|
try {
|
|
6091
6099
|
return await this.apiKeyApi.getTenantApiKeys(type, includeRevoked);
|
|
6092
6100
|
}
|
|
@@ -6247,7 +6255,7 @@ class AnalyticsManager {
|
|
|
6247
6255
|
* includeComparisons: true // Compare with previous period
|
|
6248
6256
|
* });
|
|
6249
6257
|
*
|
|
6250
|
-
* console.log('
|
|
6258
|
+
* console.log('Transaction Analytics Summary:');
|
|
6251
6259
|
* console.log(`Total Volume: $${analytics.totalVolume.toLocaleString()}`);
|
|
6252
6260
|
* console.log(`Total Transactions: ${analytics.totalCount.toLocaleString()}`);
|
|
6253
6261
|
* console.log(`Average Transaction: $${analytics.averageValue.toFixed(2)}`);
|
|
@@ -6257,14 +6265,14 @@ class AnalyticsManager {
|
|
|
6257
6265
|
* const volumeChange = analytics.periodComparison.volumeChangePercent;
|
|
6258
6266
|
* const countChange = analytics.periodComparison.countChangePercent;
|
|
6259
6267
|
*
|
|
6260
|
-
* console.log('\
|
|
6268
|
+
* console.log('\nPeriod-over-Period Changes:');
|
|
6261
6269
|
* console.log(`Volume: ${volumeChange > 0 ? '+' : ''}${volumeChange}%`);
|
|
6262
6270
|
* console.log(`Count: ${countChange > 0 ? '+' : ''}${countChange}%`);
|
|
6263
6271
|
* }
|
|
6264
6272
|
*
|
|
6265
6273
|
* // Display daily trend data
|
|
6266
6274
|
* if (analytics.dailyBreakdown) {
|
|
6267
|
-
* console.log('\
|
|
6275
|
+
* console.log('\nDaily Trends:');
|
|
6268
6276
|
* analytics.dailyBreakdown.forEach(day => {
|
|
6269
6277
|
* console.log(`${day.date}: $${day.volume} (${day.count} transactions)`);
|
|
6270
6278
|
* });
|
|
@@ -6287,7 +6295,7 @@ class AnalyticsManager {
|
|
|
6287
6295
|
* minimumTransactionCount: 10 // Only include businesses with 10+ transactions
|
|
6288
6296
|
* });
|
|
6289
6297
|
*
|
|
6290
|
-
* console.log('
|
|
6298
|
+
* console.log('Business Partner Performance:');
|
|
6291
6299
|
*
|
|
6292
6300
|
* if (businessAnalytics.businessBreakdown) {
|
|
6293
6301
|
* // Sort by volume descending
|
|
@@ -6310,7 +6318,7 @@ class AnalyticsManager {
|
|
|
6310
6318
|
* );
|
|
6311
6319
|
*
|
|
6312
6320
|
* if (lowVolumeHighFrequency.length > 0) {
|
|
6313
|
-
* console.log('\
|
|
6321
|
+
* console.log('\nGrowth Opportunities (High Frequency, Low Value):');
|
|
6314
6322
|
* lowVolumeHighFrequency.forEach(business => {
|
|
6315
6323
|
* console.log(`${business.name}: ${business.count} transactions, $${business.averageValue} avg`);
|
|
6316
6324
|
* });
|
|
@@ -6330,7 +6338,7 @@ class AnalyticsManager {
|
|
|
6330
6338
|
* includeTrendLine: true
|
|
6331
6339
|
* });
|
|
6332
6340
|
*
|
|
6333
|
-
* console.log('
|
|
6341
|
+
* console.log('Seasonal Analysis:');
|
|
6334
6342
|
*
|
|
6335
6343
|
* if (seasonalAnalytics.monthlyBreakdown) {
|
|
6336
6344
|
* const monthlyData = seasonalAnalytics.monthlyBreakdown;
|
|
@@ -6355,14 +6363,14 @@ class AnalyticsManager {
|
|
|
6355
6363
|
* Q4: monthlyData.slice(9, 12).reduce((sum, m) => sum + m.volume, 0)
|
|
6356
6364
|
* };
|
|
6357
6365
|
*
|
|
6358
|
-
* console.log('\
|
|
6366
|
+
* console.log('\nQuarterly Performance:');
|
|
6359
6367
|
* Object.entries(quarters).forEach(([quarter, volume]) => {
|
|
6360
6368
|
* console.log(`${quarter}: $${volume.toLocaleString()}`);
|
|
6361
6369
|
* });
|
|
6362
6370
|
* }
|
|
6363
6371
|
*
|
|
6364
6372
|
* if (seasonalAnalytics.trendAnalysis) {
|
|
6365
|
-
* console.log('\
|
|
6373
|
+
* console.log('\nTrend Analysis:');
|
|
6366
6374
|
* console.log(`Growth Rate: ${seasonalAnalytics.trendAnalysis.growthRate}%/month`);
|
|
6367
6375
|
* console.log(`Trend Direction: ${seasonalAnalytics.trendAnalysis.direction}`);
|
|
6368
6376
|
* console.log(`Seasonality Score: ${seasonalAnalytics.trendAnalysis.seasonalityScore}`);
|
|
@@ -6388,7 +6396,7 @@ class AnalyticsManager {
|
|
|
6388
6396
|
* if (realTimeMetrics.hourlyBreakdown) {
|
|
6389
6397
|
* // Show last 6 hours
|
|
6390
6398
|
* const lastSixHours = realTimeMetrics.hourlyBreakdown.slice(-6);
|
|
6391
|
-
* console.log('\n
|
|
6399
|
+
* console.log('\n� Last 6 Hours:');
|
|
6392
6400
|
* lastSixHours.forEach(hour => {
|
|
6393
6401
|
* console.log(`${hour.hour}:00 - $${hour.volume} (${hour.count} txns)`);
|
|
6394
6402
|
* });
|
|
@@ -6486,10 +6494,10 @@ class DonationManager {
|
|
|
6486
6494
|
/**
|
|
6487
6495
|
* Get available donation types
|
|
6488
6496
|
*
|
|
6489
|
-
* @returns Promise resolving to
|
|
6497
|
+
* @returns Promise resolving to paginated donation types
|
|
6490
6498
|
*/
|
|
6491
|
-
async getDonationTypes() {
|
|
6492
|
-
return this.donationService.getAllDonationTypes();
|
|
6499
|
+
async getDonationTypes(options) {
|
|
6500
|
+
return this.donationService.getAllDonationTypes(options);
|
|
6493
6501
|
}
|
|
6494
6502
|
/**
|
|
6495
6503
|
* Get the full donation service for advanced operations
|
|
@@ -6721,10 +6729,16 @@ class Web3Manager {
|
|
|
6721
6729
|
const ownedTokens = token.type === persShared.NativeTokenTypes.ERC721
|
|
6722
6730
|
? collection.tokens
|
|
6723
6731
|
: collection.tokens.filter(t => t.hasBalance);
|
|
6732
|
+
// Calculate total owned:
|
|
6733
|
+
// - ERC-1155: sum balances (can own multiple copies of same tokenId)
|
|
6734
|
+
// - ERC-721: count unique tokens (each token is unique, balance always 1)
|
|
6735
|
+
const totalOwned = token.type === persShared.NativeTokenTypes.ERC1155
|
|
6736
|
+
? ownedTokens.reduce((sum, t) => sum + (t.balance || 0), 0)
|
|
6737
|
+
: ownedTokens.length;
|
|
6724
6738
|
return {
|
|
6725
6739
|
token,
|
|
6726
6740
|
ownedTokens,
|
|
6727
|
-
totalOwned
|
|
6741
|
+
totalOwned
|
|
6728
6742
|
};
|
|
6729
6743
|
}
|
|
6730
6744
|
/**
|
|
@@ -7257,4 +7271,4 @@ exports.detectEnvironment = detectEnvironment;
|
|
|
7257
7271
|
exports.environment = environment;
|
|
7258
7272
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
7259
7273
|
exports.warnIfProblematicEnvironment = warnIfProblematicEnvironment;
|
|
7260
|
-
//# sourceMappingURL=pers-sdk-
|
|
7274
|
+
//# sourceMappingURL=pers-sdk-B_i-bGwq.cjs.map
|