@explorins/pers-sdk 1.3.16 → 1.5.2
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 +351 -81
- package/dist/chunks/base-token-service-D0KANDgM.js +139 -0
- package/dist/chunks/base-token-service-D0KANDgM.js.map +1 -0
- package/dist/chunks/base-token-service-zNfPjHRx.cjs +141 -0
- package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-DiwCwBiC.cjs → pers-sdk-CI2YXKb_.cjs} +1335 -50
- package/dist/chunks/pers-sdk-CI2YXKb_.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-Rc8YKyNc.js → pers-sdk-CVSAFBLh.js} +1325 -51
- package/dist/chunks/pers-sdk-CVSAFBLh.js.map +1 -0
- package/dist/chunks/{base-token-service-BA81_Ouq.js → token-sdk-BW4kkJb3.js} +2 -137
- package/dist/chunks/token-sdk-BW4kkJb3.js.map +1 -0
- package/dist/chunks/{base-token-service-BQ6uFoki.cjs → token-sdk-CiAbOb6c.cjs} +1 -137
- package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core.cjs +22 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +11 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +21 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy-pers-sdk.d.ts +79 -0
- package/dist/legacy-pers-sdk.d.ts.map +1 -0
- package/dist/managers/analytics-manager.d.ts +28 -0
- package/dist/managers/analytics-manager.d.ts.map +1 -0
- package/dist/managers/auth-manager.d.ts +80 -0
- package/dist/managers/auth-manager.d.ts.map +1 -0
- package/dist/managers/business-manager.d.ts +83 -0
- package/dist/managers/business-manager.d.ts.map +1 -0
- package/dist/managers/campaign-manager.d.ts +158 -0
- package/dist/managers/campaign-manager.d.ts.map +1 -0
- package/dist/managers/donation-manager.d.ts +27 -0
- package/dist/managers/donation-manager.d.ts.map +1 -0
- package/dist/managers/index.d.ts +18 -0
- package/dist/managers/index.d.ts.map +1 -0
- package/dist/managers/payment-manager.d.ts +44 -0
- package/dist/managers/payment-manager.d.ts.map +1 -0
- package/dist/managers/redemption-manager.d.ts +91 -0
- package/dist/managers/redemption-manager.d.ts.map +1 -0
- package/dist/managers/tenant-manager.d.ts +60 -0
- package/dist/managers/tenant-manager.d.ts.map +1 -0
- package/dist/managers/token-manager.d.ts +81 -0
- package/dist/managers/token-manager.d.ts.map +1 -0
- package/dist/managers/transaction-manager.d.ts +62 -0
- package/dist/managers/transaction-manager.d.ts.map +1 -0
- package/dist/managers/user-manager.d.ts +72 -0
- package/dist/managers/user-manager.d.ts.map +1 -0
- package/dist/package.json +6 -1
- package/dist/pers-sdk.d.ts +302 -13
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/platform-adapters/angular-http-client.d.ts +35 -0
- package/dist/platform-adapters/angular-http-client.d.ts.map +1 -0
- package/dist/platform-adapters/browser-fetch-client.d.ts +30 -0
- package/dist/platform-adapters/browser-fetch-client.d.ts.map +1 -0
- package/dist/platform-adapters/index.d.ts +11 -0
- package/dist/platform-adapters/index.d.ts.map +1 -0
- package/dist/platform-adapters/node-http-client.d.ts +30 -0
- package/dist/platform-adapters/node-http-client.d.ts.map +1 -0
- package/dist/platform-adapters.cjs +201 -0
- package/dist/platform-adapters.cjs.map +1 -0
- package/dist/platform-adapters.js +197 -0
- package/dist/platform-adapters.js.map +1 -0
- package/dist/token.cjs +6 -5
- package/dist/token.cjs.map +1 -1
- package/dist/token.js +2 -1
- package/dist/token.js.map +1 -1
- package/package.json +6 -1
- package/dist/chunks/base-token-service-BA81_Ouq.js.map +0 -1
- package/dist/chunks/base-token-service-BQ6uFoki.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DiwCwBiC.cjs.map +0 -1
- package/dist/chunks/pers-sdk-Rc8YKyNc.js.map +0 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var persShared = require('@explorins/pers-shared');
|
|
4
|
+
var user = require('../user.cjs');
|
|
5
|
+
var tokenSdk = require('./token-sdk-CiAbOb6c.cjs');
|
|
6
|
+
var business = require('../business.cjs');
|
|
7
|
+
var campaign = require('../campaign.cjs');
|
|
8
|
+
var redemption = require('../redemption.cjs');
|
|
9
|
+
var transaction = require('../transaction.cjs');
|
|
10
|
+
var payment = require('../payment.cjs');
|
|
11
|
+
var tenant = require('../tenant.cjs');
|
|
12
|
+
var analytics = require('../analytics.cjs');
|
|
13
|
+
var donation = require('../donation.cjs');
|
|
4
14
|
|
|
5
15
|
/**
|
|
6
16
|
* PERS SDK Configuration interfaces and utilities
|
|
@@ -300,7 +310,7 @@ let LocalStorageTokenStorage$1 = class LocalStorageTokenStorage {
|
|
|
300
310
|
/**
|
|
301
311
|
* Token Manager - High-level token management
|
|
302
312
|
*/
|
|
303
|
-
class TokenManager {
|
|
313
|
+
let TokenManager$1 = class TokenManager {
|
|
304
314
|
constructor(storage = new LocalStorageTokenStorage$1()) {
|
|
305
315
|
this.storage = storage;
|
|
306
316
|
}
|
|
@@ -381,7 +391,7 @@ class TokenManager {
|
|
|
381
391
|
async clearProviderToken() {
|
|
382
392
|
await this.storage.removeToken(AUTH_STORAGE_KEYS.PROVIDER_TOKEN);
|
|
383
393
|
}
|
|
384
|
-
}
|
|
394
|
+
};
|
|
385
395
|
|
|
386
396
|
/**
|
|
387
397
|
* PERS SDK Error Handling - Optimized for Performance
|
|
@@ -744,7 +754,7 @@ class DefaultAuthProvider {
|
|
|
744
754
|
this.authType = 'admin';
|
|
745
755
|
this.projectKey = projectKey || null;
|
|
746
756
|
this.authApi = authApi || null;
|
|
747
|
-
this.tokenManager = new TokenManager();
|
|
757
|
+
this.tokenManager = new TokenManager$1();
|
|
748
758
|
const refreshStrategy = new DefaultAuthRefreshStrategy(this.tokenManager, () => Promise.resolve(this.getProviderToken()), this.authApi);
|
|
749
759
|
this.tokenRefreshManager = new TokenRefreshManager(this.tokenManager, refreshStrategy);
|
|
750
760
|
}
|
|
@@ -1615,85 +1625,1360 @@ function createAuthProvider(config) {
|
|
|
1615
1625
|
} */
|
|
1616
1626
|
|
|
1617
1627
|
/**
|
|
1618
|
-
*
|
|
1628
|
+
* Authentication Manager - Clean, high-level interface for authentication operations
|
|
1619
1629
|
*
|
|
1620
|
-
* Provides a
|
|
1621
|
-
*
|
|
1630
|
+
* Provides a simplified API for common authentication tasks while maintaining
|
|
1631
|
+
* access to the underlying API client for advanced use cases.
|
|
1622
1632
|
*/
|
|
1633
|
+
class AuthManager {
|
|
1634
|
+
constructor(apiClient) {
|
|
1635
|
+
this.apiClient = apiClient;
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Login with JWT token
|
|
1639
|
+
*
|
|
1640
|
+
* @param jwtToken - JWT token to authenticate with
|
|
1641
|
+
* @param userType - Type of user ('user' | 'admin')
|
|
1642
|
+
* @returns Promise resolving to authentication response
|
|
1643
|
+
*/
|
|
1644
|
+
async loginWithToken(jwtToken, userType = 'user') {
|
|
1645
|
+
return userType === 'admin'
|
|
1646
|
+
? this.apiClient.loginAdmin(jwtToken)
|
|
1647
|
+
: this.apiClient.loginUser(jwtToken);
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Login with raw user data
|
|
1651
|
+
*
|
|
1652
|
+
* @param rawUserData - Raw user data for authentication
|
|
1653
|
+
* @returns Promise resolving to authentication response
|
|
1654
|
+
*/
|
|
1655
|
+
async loginWithRawData(rawUserData) {
|
|
1656
|
+
return this.apiClient.loginUserWithRawData(rawUserData);
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Get current authenticated user
|
|
1660
|
+
*
|
|
1661
|
+
* @returns Promise resolving to current user data
|
|
1662
|
+
*/
|
|
1663
|
+
async getCurrentUser() {
|
|
1664
|
+
return this.apiClient.get('/users/me');
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Refresh current user data
|
|
1668
|
+
*
|
|
1669
|
+
* @returns Promise resolving to updated user data
|
|
1670
|
+
*/
|
|
1671
|
+
async refreshUserData() {
|
|
1672
|
+
return this.getCurrentUser();
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Check if user is authenticated
|
|
1676
|
+
*
|
|
1677
|
+
* @returns Promise resolving to boolean indicating authentication status
|
|
1678
|
+
*/
|
|
1679
|
+
async isAuthenticated() {
|
|
1680
|
+
try {
|
|
1681
|
+
await this.getCurrentUser();
|
|
1682
|
+
return true;
|
|
1683
|
+
}
|
|
1684
|
+
catch {
|
|
1685
|
+
return false;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Refresh access token using stored refresh token
|
|
1690
|
+
*
|
|
1691
|
+
* @param refreshToken - Optional refresh token, uses stored token if not provided
|
|
1692
|
+
* @returns Promise resolving to new auth tokens
|
|
1693
|
+
*/
|
|
1694
|
+
async refreshTokens(refreshToken) {
|
|
1695
|
+
return this.apiClient.refreshTokens(refreshToken);
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Clear stored authentication tokens
|
|
1699
|
+
*
|
|
1700
|
+
* @returns Promise that resolves when tokens are cleared
|
|
1701
|
+
*/
|
|
1702
|
+
async clearAuth() {
|
|
1703
|
+
// Use auth provider to clear tokens if available
|
|
1704
|
+
const authProvider = this.apiClient.getConfig().authProvider;
|
|
1705
|
+
if (authProvider?.clearTokens) {
|
|
1706
|
+
await authProvider.clearTokens();
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Check if SDK has valid authentication
|
|
1711
|
+
*
|
|
1712
|
+
* @returns Boolean indicating if valid authentication exists
|
|
1713
|
+
*/
|
|
1714
|
+
hasValidAuth() {
|
|
1715
|
+
return this.apiClient.hasValidAuth();
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Admin login with JWT token
|
|
1719
|
+
*
|
|
1720
|
+
* @param jwt - JWT token for admin authentication
|
|
1721
|
+
* @returns Promise resolving to authentication context
|
|
1722
|
+
*/
|
|
1723
|
+
async loginAdmin(jwt) {
|
|
1724
|
+
return this.apiClient.loginAdmin(jwt);
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* User login with JWT token
|
|
1728
|
+
*
|
|
1729
|
+
* @param jwt - JWT token for user authentication
|
|
1730
|
+
* @returns Promise resolving to authentication context
|
|
1731
|
+
*/
|
|
1732
|
+
async loginUser(jwt) {
|
|
1733
|
+
return this.apiClient.loginUser(jwt);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1623
1737
|
/**
|
|
1624
|
-
*
|
|
1625
|
-
*
|
|
1626
|
-
* Minimal wrapper around PersApiClient providing a clean interface
|
|
1627
|
-
* for platform-specific implementations.
|
|
1628
|
-
*
|
|
1629
|
-
* @example
|
|
1630
|
-
* ```typescript
|
|
1631
|
-
* import { createPersSDK, createAuthProvider } from '@explorins/pers-sdk/core';
|
|
1632
|
-
* import { BrowserHttpClient } from '@explorins/pers-sdk/browser';
|
|
1738
|
+
* User Manager - Clean, high-level interface for user operations
|
|
1633
1739
|
*
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
1636
|
-
|
|
1740
|
+
* Provides a simplified API for common user management tasks while maintaining
|
|
1741
|
+
* access to the full user SDK for advanced use cases.
|
|
1742
|
+
*/
|
|
1743
|
+
class UserManager {
|
|
1744
|
+
constructor(apiClient) {
|
|
1745
|
+
this.apiClient = apiClient;
|
|
1746
|
+
this.userSDK = user.createUserSDK(apiClient);
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Get current user profile
|
|
1750
|
+
*
|
|
1751
|
+
* @returns Promise resolving to current user data
|
|
1752
|
+
*/
|
|
1753
|
+
async getCurrentUser() {
|
|
1754
|
+
return this.userSDK.getRemoteUser();
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Update current user profile
|
|
1758
|
+
*
|
|
1759
|
+
* @param userData - User data to update
|
|
1760
|
+
* @returns Promise resolving to updated user data
|
|
1761
|
+
*/
|
|
1762
|
+
async updateCurrentUser(userData) {
|
|
1763
|
+
return this.userSDK.updateRemoteUser(userData);
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Get user by unique identifier
|
|
1767
|
+
*
|
|
1768
|
+
* @param identifier - Unique identifier for the user
|
|
1769
|
+
* @returns Promise resolving to user data
|
|
1770
|
+
*/
|
|
1771
|
+
async getUserById(identifier) {
|
|
1772
|
+
return this.userSDK.getUserByUniqueIdentifier(identifier);
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Get all users public profiles with optional filtering
|
|
1776
|
+
*
|
|
1777
|
+
* @param filter - Optional filter criteria
|
|
1778
|
+
* @returns Promise resolving to array of user public profiles
|
|
1779
|
+
*/
|
|
1780
|
+
async getAllUsersPublic(filter) {
|
|
1781
|
+
return this.userSDK.getAllUsersPublicProfiles(filter || null);
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Admin: Get all users
|
|
1785
|
+
*
|
|
1786
|
+
* @returns Promise resolving to array of all users
|
|
1787
|
+
*/
|
|
1788
|
+
async getAllUsers() {
|
|
1789
|
+
return this.userSDK.getAllRemoteUsers();
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Admin: Update user data
|
|
1793
|
+
*
|
|
1794
|
+
* @param userId - ID of user to update
|
|
1795
|
+
* @param userData - User data to update
|
|
1796
|
+
* @returns Promise resolving to updated user data
|
|
1797
|
+
*/
|
|
1798
|
+
async updateUser(userId, userData) {
|
|
1799
|
+
return this.userSDK.updateUserAsAdmin(userId, userData);
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Admin: Toggle user active status
|
|
1803
|
+
*
|
|
1804
|
+
* @param user - User to toggle status for
|
|
1805
|
+
* @returns Promise resolving to updated user data
|
|
1806
|
+
*/
|
|
1807
|
+
async toggleUserStatus(user) {
|
|
1808
|
+
return this.userSDK.toggleUserActiveStatusByUser(user);
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Get the full user SDK for advanced operations
|
|
1812
|
+
*
|
|
1813
|
+
* @returns UserSDK instance
|
|
1814
|
+
*/
|
|
1815
|
+
getUserSDK() {
|
|
1816
|
+
return this.userSDK;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Token Manager - Clean, high-level interface for token operations
|
|
1637
1822
|
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1823
|
+
* Provides a simplified API for common token management tasks while maintaining
|
|
1824
|
+
* access to the full token SDK for advanced use cases.
|
|
1825
|
+
*/
|
|
1826
|
+
class TokenManager {
|
|
1827
|
+
constructor(apiClient) {
|
|
1828
|
+
this.apiClient = apiClient;
|
|
1829
|
+
this.tokenSDK = new tokenSdk.TokenSDK(apiClient);
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Get all available tokens
|
|
1833
|
+
*
|
|
1834
|
+
* @returns Promise resolving to array of tokens
|
|
1835
|
+
*/
|
|
1836
|
+
async getTokens() {
|
|
1837
|
+
return this.tokenSDK.getTokens();
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Get all token types
|
|
1841
|
+
*
|
|
1842
|
+
* @returns Promise resolving to token types
|
|
1843
|
+
*/
|
|
1844
|
+
async getTokenTypes() {
|
|
1845
|
+
return this.tokenSDK.getTokenTypes();
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Get active credit token
|
|
1849
|
+
*
|
|
1850
|
+
* @returns Promise resolving to active credit token
|
|
1851
|
+
*/
|
|
1852
|
+
async getActiveCreditToken() {
|
|
1853
|
+
return this.tokenSDK.getActiveCreditToken();
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Get reward tokens
|
|
1857
|
+
*
|
|
1858
|
+
* @returns Promise resolving to reward tokens
|
|
1859
|
+
*/
|
|
1860
|
+
async getRewardTokens() {
|
|
1861
|
+
return this.tokenSDK.getRewardTokens();
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Get status tokens
|
|
1865
|
+
*
|
|
1866
|
+
* @returns Promise resolving to status tokens
|
|
1867
|
+
*/
|
|
1868
|
+
async getStatusTokens() {
|
|
1869
|
+
return this.tokenSDK.getStatusTokens();
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Get token by contract address
|
|
1873
|
+
*
|
|
1874
|
+
* @param contractAddress - Contract address to search for
|
|
1875
|
+
* @param contractTokenId - Optional contract token ID
|
|
1876
|
+
* @returns Promise resolving to token
|
|
1877
|
+
*/
|
|
1878
|
+
async getTokenByContract(contractAddress, contractTokenId) {
|
|
1879
|
+
return this.tokenSDK.getTokenByContract(contractAddress, contractTokenId);
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Admin: Create new token
|
|
1883
|
+
*
|
|
1884
|
+
* @param tokenData - Token creation data
|
|
1885
|
+
* @returns Promise resolving to created token
|
|
1886
|
+
*/
|
|
1887
|
+
async createToken(tokenData) {
|
|
1888
|
+
return this.tokenSDK.createToken(tokenData);
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Admin: Update token
|
|
1892
|
+
*
|
|
1893
|
+
* @param tokenId - Token ID to update
|
|
1894
|
+
* @param tokenData - Token update data
|
|
1895
|
+
* @returns Promise resolving to updated token
|
|
1896
|
+
*/
|
|
1897
|
+
async updateToken(tokenId, tokenData) {
|
|
1898
|
+
return this.tokenSDK.updateToken(tokenId, tokenData);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Admin: Toggle token active status
|
|
1902
|
+
*
|
|
1903
|
+
* @param tokenId - Token ID to toggle
|
|
1904
|
+
* @returns Promise resolving to updated token
|
|
1905
|
+
*/
|
|
1906
|
+
async toggleTokenActive(tokenId) {
|
|
1907
|
+
return this.tokenSDK.toggleTokenActive(tokenId);
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Get the full token SDK for advanced operations
|
|
1911
|
+
*
|
|
1912
|
+
* @returns TokenSDK instance
|
|
1913
|
+
*/
|
|
1914
|
+
getTokenSDK() {
|
|
1915
|
+
return this.tokenSDK;
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Business Manager - Clean, high-level interface for business operations
|
|
1643
1921
|
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
* ```
|
|
1922
|
+
* Provides a simplified API for common business management tasks while maintaining
|
|
1923
|
+
* access to the full business SDK for advanced use cases.
|
|
1647
1924
|
*/
|
|
1648
|
-
class
|
|
1925
|
+
class BusinessManager {
|
|
1926
|
+
constructor(apiClient) {
|
|
1927
|
+
this.apiClient = apiClient;
|
|
1928
|
+
this.businessSDK = business.createBusinessSDK(apiClient);
|
|
1929
|
+
}
|
|
1649
1930
|
/**
|
|
1650
|
-
*
|
|
1931
|
+
* Get all active businesses
|
|
1651
1932
|
*
|
|
1652
|
-
* @
|
|
1653
|
-
* @param config SDK configuration options
|
|
1933
|
+
* @returns Promise resolving to array of active businesses
|
|
1654
1934
|
*/
|
|
1655
|
-
|
|
1656
|
-
this.
|
|
1935
|
+
async getActiveBusinesses() {
|
|
1936
|
+
return this.businessSDK.getActiveBusinesses();
|
|
1657
1937
|
}
|
|
1658
1938
|
/**
|
|
1659
|
-
*
|
|
1939
|
+
* Get business by ID
|
|
1660
1940
|
*
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1941
|
+
* @param businessId - Business ID to fetch
|
|
1942
|
+
* @returns Promise resolving to business data
|
|
1943
|
+
*/
|
|
1944
|
+
async getBusinessById(businessId) {
|
|
1945
|
+
return this.businessSDK.getBusinessById(businessId);
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Get business by account address
|
|
1663
1949
|
*
|
|
1664
|
-
* @
|
|
1950
|
+
* @param accountAddress - Account address to search for
|
|
1951
|
+
* @returns Promise resolving to business data
|
|
1952
|
+
*/
|
|
1953
|
+
async getBusinessByAccount(accountAddress) {
|
|
1954
|
+
return this.businessSDK.getBusinessByAccount(accountAddress);
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Get all business types
|
|
1665
1958
|
*
|
|
1666
|
-
* @
|
|
1667
|
-
* ```typescript
|
|
1668
|
-
* const apiClient = sdk.api();
|
|
1669
|
-
* const user = await apiClient.get<User>('/users/me');
|
|
1670
|
-
* await apiClient.post('/users', userData);
|
|
1671
|
-
* ```
|
|
1959
|
+
* @returns Promise resolving to array of business types
|
|
1672
1960
|
*/
|
|
1673
|
-
|
|
1674
|
-
return this.
|
|
1961
|
+
async getBusinessTypes() {
|
|
1962
|
+
return this.businessSDK.getAllBusinessTypes();
|
|
1675
1963
|
}
|
|
1676
1964
|
/**
|
|
1677
|
-
*
|
|
1965
|
+
* Get businesses by type
|
|
1678
1966
|
*
|
|
1679
|
-
* @
|
|
1967
|
+
* @param typeId - Business type ID to filter by
|
|
1968
|
+
* @returns Promise resolving to array of businesses
|
|
1680
1969
|
*/
|
|
1681
|
-
|
|
1682
|
-
return this.
|
|
1970
|
+
async getBusinessesByType(typeId) {
|
|
1971
|
+
return this.businessSDK.getBusinessesByType(typeId);
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Admin: Get all businesses (including inactive)
|
|
1975
|
+
*
|
|
1976
|
+
* @returns Promise resolving to array of all businesses
|
|
1977
|
+
*/
|
|
1978
|
+
async getAllBusinesses() {
|
|
1979
|
+
return this.businessSDK.getAllBusinesses();
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Admin: Create new business
|
|
1983
|
+
*
|
|
1984
|
+
* @param displayName - Display name for the business
|
|
1985
|
+
* @returns Promise resolving to created business data
|
|
1986
|
+
*/
|
|
1987
|
+
async createBusiness(displayName) {
|
|
1988
|
+
return this.businessSDK.createBusinessByDisplayName(displayName);
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Admin: Update business
|
|
1992
|
+
*
|
|
1993
|
+
* @param businessId - ID of business to update
|
|
1994
|
+
* @param businessData - Business data to update
|
|
1995
|
+
* @returns Promise resolving to updated business data
|
|
1996
|
+
*/
|
|
1997
|
+
async updateBusiness(businessId, businessData) {
|
|
1998
|
+
return this.businessSDK.updateBusiness(businessId, businessData);
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* Admin: Toggle business active status
|
|
2002
|
+
*
|
|
2003
|
+
* @param businessId - ID of business to toggle
|
|
2004
|
+
* @param toggleData - Toggle request data
|
|
2005
|
+
* @returns Promise resolving to updated business data
|
|
2006
|
+
*/
|
|
2007
|
+
async toggleBusinessStatus(businessId, toggleData) {
|
|
2008
|
+
return this.businessSDK.toggleBusinessActive(businessId, toggleData);
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Get the full business SDK for advanced operations
|
|
2012
|
+
*
|
|
2013
|
+
* @returns BusinessSDK instance
|
|
2014
|
+
*/
|
|
2015
|
+
getBusinessSDK() {
|
|
2016
|
+
return this.businessSDK;
|
|
1683
2017
|
}
|
|
1684
2018
|
}
|
|
2019
|
+
|
|
1685
2020
|
/**
|
|
1686
|
-
*
|
|
2021
|
+
* Campaign Manager - Clean, high-level interface for campaign operations
|
|
2022
|
+
*
|
|
2023
|
+
* Provides a simplified API for common campaign management tasks while maintaining
|
|
2024
|
+
* access to the full campaign SDK for advanced use cases.
|
|
2025
|
+
*/
|
|
2026
|
+
class CampaignManager {
|
|
2027
|
+
constructor(apiClient) {
|
|
2028
|
+
this.apiClient = apiClient;
|
|
2029
|
+
this.campaignSDK = campaign.createCampaignSDK(apiClient);
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Get all active campaigns
|
|
2033
|
+
*
|
|
2034
|
+
* @returns Promise resolving to array of active campaigns
|
|
2035
|
+
*/
|
|
2036
|
+
async getActiveCampaigns() {
|
|
2037
|
+
return this.campaignSDK.getActiveCampaigns();
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Get campaign by ID
|
|
2041
|
+
*
|
|
2042
|
+
* @param campaignId - ID of the campaign
|
|
2043
|
+
* @returns Promise resolving to campaign data
|
|
2044
|
+
*/
|
|
2045
|
+
async getCampaignById(campaignId) {
|
|
2046
|
+
return this.campaignSDK.getCampaignById(campaignId);
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Claim a campaign reward
|
|
2050
|
+
*
|
|
2051
|
+
* @param claimRequest - Campaign claim data
|
|
2052
|
+
* @returns Promise resolving to claim result
|
|
2053
|
+
*/
|
|
2054
|
+
async claimCampaign(claimRequest) {
|
|
2055
|
+
return this.campaignSDK.claimCampaign(claimRequest);
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Get user's campaign claims
|
|
2059
|
+
*
|
|
2060
|
+
* @returns Promise resolving to array of user's claims
|
|
2061
|
+
*/
|
|
2062
|
+
async getUserClaims() {
|
|
2063
|
+
return this.campaignSDK.getClaimsForLoggedUser();
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Admin: Get all campaigns
|
|
2067
|
+
*
|
|
2068
|
+
* @param active - Filter by active status
|
|
2069
|
+
* @returns Promise resolving to array of campaigns
|
|
2070
|
+
*/
|
|
2071
|
+
async getAllCampaigns(active) {
|
|
2072
|
+
return this.campaignSDK.getCampaigns(active);
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Admin: Create new campaign
|
|
2076
|
+
*
|
|
2077
|
+
* @param campaignData - Campaign data
|
|
2078
|
+
* @returns Promise resolving to created campaign
|
|
2079
|
+
*/
|
|
2080
|
+
async createCampaign(campaignData) {
|
|
2081
|
+
return this.campaignSDK.createCampaign(campaignData);
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Admin: Update campaign
|
|
2085
|
+
*
|
|
2086
|
+
* @param campaignId - ID of campaign to update
|
|
2087
|
+
* @param campaignData - Updated campaign data
|
|
2088
|
+
* @returns Promise resolving to updated campaign
|
|
2089
|
+
*/
|
|
2090
|
+
async updateCampaign(campaignId, campaignData) {
|
|
2091
|
+
return this.campaignSDK.updateCampaign(campaignId, campaignData);
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Admin: Toggle campaign active status
|
|
2095
|
+
*
|
|
2096
|
+
* @param campaignId - ID of campaign to toggle
|
|
2097
|
+
* @returns Promise resolving to updated campaign
|
|
2098
|
+
*/
|
|
2099
|
+
async toggleCampaignStatus(campaignId) {
|
|
2100
|
+
return this.campaignSDK.toggleCampaignActive(campaignId);
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Admin: Toggle campaign testnet environment
|
|
2104
|
+
*
|
|
2105
|
+
* @param campaignId - ID of campaign to toggle
|
|
2106
|
+
* @returns Promise resolving to updated campaign
|
|
2107
|
+
*/
|
|
2108
|
+
async toggleCampaignTestnet(campaignId) {
|
|
2109
|
+
return this.campaignSDK.toggleCampaignTestnet(campaignId);
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Admin: Get campaign triggers
|
|
2113
|
+
*
|
|
2114
|
+
* @returns Promise resolving to array of campaign triggers
|
|
2115
|
+
*/
|
|
2116
|
+
async getCampaignTriggers() {
|
|
2117
|
+
return this.campaignSDK.getCampaignTriggers();
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Admin: Set campaign trigger
|
|
2121
|
+
*
|
|
2122
|
+
* @param campaignId - ID of campaign
|
|
2123
|
+
* @param triggerId - ID of trigger to set
|
|
2124
|
+
* @returns Promise resolving to updated campaign
|
|
2125
|
+
*/
|
|
2126
|
+
async setCampaignTrigger(campaignId, triggerId) {
|
|
2127
|
+
return this.campaignSDK.setCampaignTrigger(campaignId, triggerId);
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Admin: Create campaign token unit
|
|
2131
|
+
*
|
|
2132
|
+
* @param campaignId - ID of campaign
|
|
2133
|
+
* @param tokenUnit - Token unit data
|
|
2134
|
+
* @returns Promise resolving to updated campaign
|
|
2135
|
+
*/
|
|
2136
|
+
async createCampaignTokenUnit(campaignId, tokenUnit) {
|
|
2137
|
+
return this.campaignSDK.createCampaignTokenUnit(campaignId, tokenUnit);
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Admin: Delete campaign token unit
|
|
2141
|
+
*
|
|
2142
|
+
* @param campaignId - ID of campaign
|
|
2143
|
+
* @param tokenUnitId - ID of token unit to delete
|
|
2144
|
+
* @returns Promise resolving to updated campaign
|
|
2145
|
+
*/
|
|
2146
|
+
async deleteCampaignTokenUnit(campaignId, tokenUnitId) {
|
|
2147
|
+
return this.campaignSDK.deleteCampaignTokenUnit(campaignId, tokenUnitId);
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Admin: Add business engagement to campaign
|
|
2151
|
+
*
|
|
2152
|
+
* @param campaignId - ID of campaign
|
|
2153
|
+
* @param engagement - Business engagement data
|
|
2154
|
+
* @returns Promise resolving to updated campaign
|
|
2155
|
+
*/
|
|
2156
|
+
async addBusinessEngagementToCampaign(campaignId, engagement) {
|
|
2157
|
+
return this.campaignSDK.addBusinessEngagementToCampaign(campaignId, engagement);
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Admin: Update campaign business engagement
|
|
2161
|
+
*
|
|
2162
|
+
* @param campaignId - ID of campaign
|
|
2163
|
+
* @param engagementId - ID of engagement to update
|
|
2164
|
+
* @param engagement - Updated engagement data
|
|
2165
|
+
* @returns Promise resolving to updated campaign
|
|
2166
|
+
*/
|
|
2167
|
+
async updateCampaignBusinessEngagement(campaignId, engagementId, engagement) {
|
|
2168
|
+
return this.campaignSDK.updateCampaignBusinessEngagement(campaignId, engagementId, engagement);
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Admin: Delete campaign business engagement
|
|
2172
|
+
*
|
|
2173
|
+
* @param campaignId - ID of campaign
|
|
2174
|
+
* @param engagementId - ID of engagement to delete
|
|
2175
|
+
* @returns Promise resolving to updated campaign
|
|
2176
|
+
*/
|
|
2177
|
+
async deleteCampaignBusinessEngagement(campaignId, engagementId) {
|
|
2178
|
+
return this.campaignSDK.deleteCampaignBusinessEngagement(campaignId, engagementId);
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Admin: Get all campaign claims
|
|
2182
|
+
*
|
|
2183
|
+
* @returns Promise resolving to array of campaign claims
|
|
2184
|
+
*/
|
|
2185
|
+
async getCampaignClaims() {
|
|
2186
|
+
return this.campaignSDK.getCampaignClaims();
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Admin: Get campaign claims by user ID
|
|
2190
|
+
*
|
|
2191
|
+
* @param userId - ID of user
|
|
2192
|
+
* @returns Promise resolving to array of user's campaign claims
|
|
2193
|
+
*/
|
|
2194
|
+
async getCampaignClaimsByUserId(userId) {
|
|
2195
|
+
return this.campaignSDK.getCampaignClaimsByUserId(userId);
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Admin: Get campaign claims by business ID
|
|
2199
|
+
*
|
|
2200
|
+
* @param businessId - ID of business
|
|
2201
|
+
* @returns Promise resolving to array of business's campaign claims
|
|
2202
|
+
*/
|
|
2203
|
+
async getCampaignClaimsByBusinessId(businessId) {
|
|
2204
|
+
return this.campaignSDK.getCampaignClaimsByBusinessId(businessId);
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Get the full campaign SDK for advanced operations
|
|
2208
|
+
*
|
|
2209
|
+
* @returns CampaignSDK instance
|
|
2210
|
+
*/
|
|
2211
|
+
getCampaignSDK() {
|
|
2212
|
+
return this.campaignSDK;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Redemption Manager - Clean, high-level interface for redemption operations
|
|
2218
|
+
*
|
|
2219
|
+
* Provides a simplified API for common redemption management tasks while maintaining
|
|
2220
|
+
* access to the full redemption SDK for advanced use cases.
|
|
2221
|
+
*/
|
|
2222
|
+
class RedemptionManager {
|
|
2223
|
+
constructor(apiClient) {
|
|
2224
|
+
this.apiClient = apiClient;
|
|
2225
|
+
this.redemptionSDK = redemption.createRedemptionSDK(apiClient);
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Get all active redemption offers
|
|
2229
|
+
*
|
|
2230
|
+
* @returns Promise resolving to array of active redemptions
|
|
2231
|
+
*/
|
|
2232
|
+
async getActiveRedemptions() {
|
|
2233
|
+
return this.redemptionSDK.getActiveRedemptions();
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Get available redemption types
|
|
2237
|
+
*
|
|
2238
|
+
* @returns Promise resolving to array of redemption types
|
|
2239
|
+
*/
|
|
2240
|
+
async getRedemptionTypes() {
|
|
2241
|
+
return this.redemptionSDK.getRedemptionTypes();
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Redeem a redemption offer
|
|
2245
|
+
*
|
|
2246
|
+
* @param redemptionId - ID of the redemption to redeem
|
|
2247
|
+
* @returns Promise resolving to redemption result
|
|
2248
|
+
*/
|
|
2249
|
+
async redeemOffer(redemptionId) {
|
|
2250
|
+
return this.redemptionSDK.redeemRedemption(redemptionId);
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Get user's redemption history
|
|
2254
|
+
*
|
|
2255
|
+
* @returns Promise resolving to array of user's redemptions
|
|
2256
|
+
*/
|
|
2257
|
+
async getUserRedemptions() {
|
|
2258
|
+
return this.redemptionSDK.getUserRedeems();
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Admin: Get all redemptions
|
|
2262
|
+
*
|
|
2263
|
+
* @param active - Filter by active status
|
|
2264
|
+
* @returns Promise resolving to array of redemptions
|
|
2265
|
+
*/
|
|
2266
|
+
async getAllRedemptions(active) {
|
|
2267
|
+
return this.redemptionSDK.getRedemptionsAsAdmin(active);
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Admin: Create new redemption offer
|
|
2271
|
+
*
|
|
2272
|
+
* @param redemptionData - Redemption data
|
|
2273
|
+
* @returns Promise resolving to created redemption
|
|
2274
|
+
*/
|
|
2275
|
+
async createRedemption(redemptionData) {
|
|
2276
|
+
return this.redemptionSDK.createRedemption(redemptionData);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Admin: Update redemption
|
|
2280
|
+
*
|
|
2281
|
+
* @param redemptionId - ID of redemption to update
|
|
2282
|
+
* @param redemptionData - Updated redemption data
|
|
2283
|
+
* @returns Promise resolving to updated redemption
|
|
2284
|
+
*/
|
|
2285
|
+
async updateRedemption(redemptionId, redemptionData) {
|
|
2286
|
+
return this.redemptionSDK.updateRedemption(redemptionId, redemptionData);
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Admin: Toggle redemption active status
|
|
2290
|
+
*
|
|
2291
|
+
* @param redemptionId - ID of redemption to toggle
|
|
2292
|
+
* @returns Promise resolving to updated redemption
|
|
2293
|
+
*/
|
|
2294
|
+
async toggleRedemptionStatus(redemptionId) {
|
|
2295
|
+
return this.redemptionSDK.toggleRedemptionActive(redemptionId);
|
|
2296
|
+
}
|
|
2297
|
+
/**
|
|
2298
|
+
* Admin: Create redemption token unit
|
|
2299
|
+
*
|
|
2300
|
+
* @param redemptionId - ID of redemption
|
|
2301
|
+
* @param tokenUnit - Token unit data
|
|
2302
|
+
* @returns Promise resolving to updated redemption
|
|
2303
|
+
*/
|
|
2304
|
+
async createRedemptionTokenUnit(redemptionId, tokenUnit) {
|
|
2305
|
+
return this.redemptionSDK.createRedemptionTokenUnit(redemptionId, tokenUnit);
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* Admin: Delete redemption token unit
|
|
2309
|
+
*
|
|
2310
|
+
* @param redemptionId - ID of redemption
|
|
2311
|
+
* @param tokenUnitId - ID of token unit to delete
|
|
2312
|
+
* @returns Promise resolving to updated redemption
|
|
2313
|
+
*/
|
|
2314
|
+
async deleteRedemptionTokenUnit(redemptionId, tokenUnitId) {
|
|
2315
|
+
return this.redemptionSDK.deleteRedemptionTokenUnit(redemptionId, tokenUnitId);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Get the full redemption SDK for advanced operations
|
|
2319
|
+
*
|
|
2320
|
+
* @returns RedemptionSDK instance
|
|
2321
|
+
*/
|
|
2322
|
+
getRedemptionSDK() {
|
|
2323
|
+
return this.redemptionSDK;
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Transaction Manager - Clean, high-level interface for transaction operations
|
|
2329
|
+
*
|
|
2330
|
+
* Provides a simplified API for common transaction management tasks while maintaining
|
|
2331
|
+
* access to the full transaction SDK for advanced use cases.
|
|
2332
|
+
*/
|
|
2333
|
+
class TransactionManager {
|
|
2334
|
+
constructor(apiClient) {
|
|
2335
|
+
this.apiClient = apiClient;
|
|
2336
|
+
this.transactionSDK = transaction.createTransactionSDK(apiClient);
|
|
2337
|
+
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Get transaction by ID
|
|
2340
|
+
*
|
|
2341
|
+
* @param transactionId - ID of the transaction
|
|
2342
|
+
* @returns Promise resolving to transaction data
|
|
2343
|
+
*/
|
|
2344
|
+
async getTransactionById(transactionId) {
|
|
2345
|
+
return this.transactionSDK.getTransactionById(transactionId);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Create a new transaction
|
|
2349
|
+
*
|
|
2350
|
+
* @param transactionData - Transaction data
|
|
2351
|
+
* @returns Promise resolving to transaction response
|
|
2352
|
+
*/
|
|
2353
|
+
async createTransaction(transactionData) {
|
|
2354
|
+
return this.transactionSDK.createTransaction(transactionData);
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* Get user's transaction history
|
|
2358
|
+
*
|
|
2359
|
+
* @param type - Transaction type filter
|
|
2360
|
+
* @returns Promise resolving to array of user's transactions
|
|
2361
|
+
*/
|
|
2362
|
+
async getUserTransactionHistory(type) {
|
|
2363
|
+
return this.transactionSDK.getUserTransactionHistory(type);
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Admin: Get all tenant transactions
|
|
2367
|
+
*
|
|
2368
|
+
* @returns Promise resolving to array of tenant transactions
|
|
2369
|
+
*/
|
|
2370
|
+
async getTenantTransactions() {
|
|
2371
|
+
return this.transactionSDK.getTenantTransactions();
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Admin: Get paginated transactions
|
|
2375
|
+
*
|
|
2376
|
+
* @param params - Pagination parameters
|
|
2377
|
+
* @returns Promise resolving to paginated transaction results
|
|
2378
|
+
*/
|
|
2379
|
+
async getPaginatedTransactions(params) {
|
|
2380
|
+
return this.transactionSDK.getPaginatedTransactions(params);
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Admin: Export transactions as CSV
|
|
2384
|
+
*
|
|
2385
|
+
* @returns Promise resolving to CSV blob
|
|
2386
|
+
*/
|
|
2387
|
+
async exportTransactionsCSV() {
|
|
2388
|
+
return this.transactionSDK.exportTransactionsCSV();
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Get the full transaction SDK for advanced operations
|
|
2392
|
+
*
|
|
2393
|
+
* @returns TransactionSDK instance
|
|
2394
|
+
*/
|
|
2395
|
+
getTransactionSDK() {
|
|
2396
|
+
return this.transactionSDK;
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* Payment Manager - Clean, high-level interface for payment operations
|
|
2402
|
+
*
|
|
2403
|
+
* Provides a simplified API for common payment management tasks while maintaining
|
|
2404
|
+
* access to the full payment SDK for advanced use cases.
|
|
2405
|
+
*/
|
|
2406
|
+
class PaymentManager {
|
|
2407
|
+
constructor(apiClient) {
|
|
2408
|
+
this.apiClient = apiClient;
|
|
2409
|
+
this.paymentSDK = payment.createPaymentSDK(apiClient);
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Create a payment intent
|
|
2413
|
+
*
|
|
2414
|
+
* @param amount - Payment amount
|
|
2415
|
+
* @param currency - Payment currency
|
|
2416
|
+
* @param receiptEmail - Receipt email
|
|
2417
|
+
* @param description - Payment description
|
|
2418
|
+
* @returns Promise resolving to created payment intent
|
|
2419
|
+
*/
|
|
2420
|
+
async createPaymentIntent(amount, currency, receiptEmail, description) {
|
|
2421
|
+
return this.paymentSDK.createPaymentIntent(amount, currency, receiptEmail, description);
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Get active purchase tokens
|
|
2425
|
+
*
|
|
2426
|
+
* @param active - Filter by active status
|
|
2427
|
+
* @returns Promise resolving to purchase tokens
|
|
2428
|
+
*/
|
|
2429
|
+
async getActivePurchaseTokens(active) {
|
|
2430
|
+
return this.paymentSDK.getActivePurchaseTokens(active);
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Get all user purchases
|
|
2434
|
+
*
|
|
2435
|
+
* @returns Promise resolving to array of user's purchases
|
|
2436
|
+
*/
|
|
2437
|
+
async getAllUserPurchases() {
|
|
2438
|
+
return this.paymentSDK.getAllUserPurchases();
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Get the full payment SDK for advanced operations
|
|
2442
|
+
*
|
|
2443
|
+
* @returns PaymentSDK instance
|
|
2444
|
+
*/
|
|
2445
|
+
getPaymentSDK() {
|
|
2446
|
+
return this.paymentSDK;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/**
|
|
2451
|
+
* Tenant Manager - Clean, high-level interface for tenant operations
|
|
2452
|
+
*
|
|
2453
|
+
* Provides a simplified API for common tenant management tasks while maintaining
|
|
2454
|
+
* access to the full tenant SDK for advanced use cases.
|
|
2455
|
+
*/
|
|
2456
|
+
class TenantManager {
|
|
2457
|
+
constructor(apiClient) {
|
|
2458
|
+
this.apiClient = apiClient;
|
|
2459
|
+
this.tenantSDK = tenant.createTenantSDK(apiClient);
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Get current tenant information
|
|
2463
|
+
*
|
|
2464
|
+
* @returns Promise resolving to tenant data
|
|
2465
|
+
*/
|
|
2466
|
+
async getTenantInfo() {
|
|
2467
|
+
return this.tenantSDK.getRemoteTenant();
|
|
2468
|
+
}
|
|
2469
|
+
/**
|
|
2470
|
+
* Get tenant login token
|
|
2471
|
+
*
|
|
2472
|
+
* @returns Promise resolving to login token
|
|
2473
|
+
*/
|
|
2474
|
+
async getLoginToken() {
|
|
2475
|
+
return this.tenantSDK.getRemoteLoginToken();
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Get tenant client configuration
|
|
2479
|
+
*
|
|
2480
|
+
* @returns Promise resolving to client config
|
|
2481
|
+
*/
|
|
2482
|
+
async getClientConfig() {
|
|
2483
|
+
return this.tenantSDK.getRemoteClientConfig();
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Admin: Update tenant data
|
|
2487
|
+
*
|
|
2488
|
+
* @param tenantData - Updated tenant data
|
|
2489
|
+
* @returns Promise resolving to updated tenant
|
|
2490
|
+
*/
|
|
2491
|
+
async updateTenant(tenantData) {
|
|
2492
|
+
return this.tenantSDK.updateRemoteTenant(tenantData);
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Admin: Get all admins
|
|
2496
|
+
*
|
|
2497
|
+
* @returns Promise resolving to array of admins
|
|
2498
|
+
*/
|
|
2499
|
+
async getAdmins() {
|
|
2500
|
+
return this.tenantSDK.getAdmins();
|
|
2501
|
+
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Admin: Create new admin
|
|
2504
|
+
*
|
|
2505
|
+
* @param adminData - Admin data
|
|
2506
|
+
* @returns Promise resolving to created admin
|
|
2507
|
+
*/
|
|
2508
|
+
async createAdmin(adminData) {
|
|
2509
|
+
return this.tenantSDK.postAdmin(adminData);
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Get the full tenant SDK for advanced operations
|
|
2513
|
+
*
|
|
2514
|
+
* @returns TenantSDK instance
|
|
2515
|
+
*/
|
|
2516
|
+
getTenantSDK() {
|
|
2517
|
+
return this.tenantSDK;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
/**
|
|
2522
|
+
* Analytics Manager - Clean, high-level interface for analytics operations
|
|
2523
|
+
*
|
|
2524
|
+
* Provides a simplified API for common analytics tasks while maintaining
|
|
2525
|
+
* access to the full analytics SDK for advanced use cases.
|
|
2526
|
+
*/
|
|
2527
|
+
class AnalyticsManager {
|
|
2528
|
+
constructor(apiClient) {
|
|
2529
|
+
this.apiClient = apiClient;
|
|
2530
|
+
this.analyticsSDK = analytics.createAnalyticsSDK(apiClient);
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Get transaction analytics
|
|
2534
|
+
*
|
|
2535
|
+
* @param request - Analytics request parameters
|
|
2536
|
+
* @returns Promise resolving to transaction analytics data
|
|
2537
|
+
*/
|
|
2538
|
+
async getTransactionAnalytics(request) {
|
|
2539
|
+
return this.analyticsSDK.getTransactionAnalytics(request);
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Get the full analytics SDK for advanced operations
|
|
2543
|
+
*
|
|
2544
|
+
* @returns AnalyticsSDK instance
|
|
2545
|
+
*/
|
|
2546
|
+
getAnalyticsSDK() {
|
|
2547
|
+
return this.analyticsSDK;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* Donation Manager - Clean, high-level interface for donation operations
|
|
2553
|
+
*
|
|
2554
|
+
* Provides a simplified API for common donation tasks while maintaining
|
|
2555
|
+
* access to the full donation SDK for advanced use cases.
|
|
2556
|
+
*/
|
|
2557
|
+
class DonationManager {
|
|
2558
|
+
constructor(apiClient) {
|
|
2559
|
+
this.apiClient = apiClient;
|
|
2560
|
+
this.donationSDK = donation.createDonationSDK(apiClient);
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Get available donation types
|
|
2564
|
+
*
|
|
2565
|
+
* @returns Promise resolving to array of donation types
|
|
2566
|
+
*/
|
|
2567
|
+
async getDonationTypes() {
|
|
2568
|
+
return this.donationSDK.getAllDonationTypes();
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Get the full donation SDK for advanced operations
|
|
2572
|
+
*
|
|
2573
|
+
* @returns DonationSDK instance
|
|
2574
|
+
*/
|
|
2575
|
+
getDonationSDK() {
|
|
2576
|
+
return this.donationSDK;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* PERS SDK - Platform-agnostic TypeScript SDK with High-Level Managers
|
|
2582
|
+
*
|
|
2583
|
+
* ## Overview
|
|
2584
|
+
*
|
|
2585
|
+
* The PERS SDK provides a comprehensive interface for integrating with the PERS
|
|
2586
|
+
* (Phygital Experience Rewards System) platform. It features a clean manager-based
|
|
2587
|
+
* architecture that abstracts complex domain operations into intuitive high-level APIs.
|
|
2588
|
+
*
|
|
2589
|
+
* ## Architecture
|
|
2590
|
+
*
|
|
2591
|
+
* ```
|
|
2592
|
+
* PersSDK
|
|
2593
|
+
* ├── Domain Managers (Recommended) // High-level, intuitive APIs
|
|
2594
|
+
* │ ├── auth: AuthManager // Authentication & user sessions
|
|
2595
|
+
* │ ├── users: UserManager // User profile management
|
|
2596
|
+
* │ ├── tokens: TokenManager // Token balances & transfers
|
|
2597
|
+
* │ ├── businesses: BusinessManager // Business operations
|
|
2598
|
+
* │ ├── campaigns: CampaignManager // Marketing campaigns
|
|
2599
|
+
* │ ├── redemptions: RedemptionManager // Reward redemptions
|
|
2600
|
+
* │ ├── transactions: TransactionManager // Transaction history
|
|
2601
|
+
* │ ├── payments: PaymentManager // Payment processing
|
|
2602
|
+
* │ └── analytics: AnalyticsManager // Reporting & analytics
|
|
2603
|
+
* ├── Domain SDKs (Advanced) // Full-featured domain access
|
|
2604
|
+
* │ ├── createBusinessSDK()
|
|
2605
|
+
* │ ├── createCampaignSDK()
|
|
2606
|
+
* │ └── TokenSDK, etc.
|
|
2607
|
+
* └── Core API Client (Expert) // Direct REST API access
|
|
2608
|
+
* └── api(): PersApiClient
|
|
2609
|
+
* ```
|
|
2610
|
+
*
|
|
2611
|
+
* ## Usage Patterns
|
|
2612
|
+
*
|
|
2613
|
+
* ### 1. High-Level Manager Pattern (Recommended)
|
|
2614
|
+
*
|
|
2615
|
+
* ```typescript
|
|
2616
|
+
* import { PersSDK } from '@explorins/pers-sdk';
|
|
2617
|
+
* import { BrowserFetchClientAdapter } from '@explorins/pers-sdk/platform-adapters';
|
|
2618
|
+
*
|
|
2619
|
+
* const sdk = new PersSDK(new BrowserFetchClientAdapter(), {
|
|
2620
|
+
* environment: 'production',
|
|
2621
|
+
* apiProjectKey: 'your-project-key'
|
|
2622
|
+
* });
|
|
2623
|
+
*
|
|
2624
|
+
* // Clean, intuitive manager interface
|
|
2625
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
2626
|
+
* const campaigns = await sdk.campaigns.getActiveCampaigns();
|
|
2627
|
+
* const balances = await sdk.tokens.getTokens();
|
|
2628
|
+
* ```
|
|
2629
|
+
*
|
|
2630
|
+
* ### 2. Advanced Domain SDK Access
|
|
2631
|
+
*
|
|
2632
|
+
* ```typescript
|
|
2633
|
+
* // Access full SDK capabilities when needed
|
|
2634
|
+
* const campaignSDK = sdk.campaigns.getCampaignSDK();
|
|
2635
|
+
* const advancedCampaignOps = await campaignSDK.api.createComplexCampaign(data);
|
|
2636
|
+
* ```
|
|
2637
|
+
*
|
|
2638
|
+
* ### 3. Direct API Client Access
|
|
2639
|
+
*
|
|
2640
|
+
* ```typescript
|
|
2641
|
+
* // For custom endpoints or advanced operations
|
|
2642
|
+
* const apiClient = sdk.api();
|
|
2643
|
+
* const customData = await apiClient.get('/custom-endpoint');
|
|
2644
|
+
* ```
|
|
2645
|
+
*
|
|
2646
|
+
* ## Platform Integration
|
|
2647
|
+
*
|
|
2648
|
+
* The SDK provides pre-built adapters for common platforms:
|
|
2649
|
+
*
|
|
2650
|
+
* - **Angular**: `AngularHttpClientAdapter`
|
|
2651
|
+
* - **Browser/React/Vue**: `BrowserFetchClientAdapter`
|
|
2652
|
+
* - **Node.js**: `NodeHttpClientAdapter`
|
|
2653
|
+
* - **Custom**: Implement `HttpClient` interface
|
|
2654
|
+
*
|
|
2655
|
+
* ## Features
|
|
2656
|
+
*
|
|
2657
|
+
* - ✅ **Type-safe**: Full TypeScript support with comprehensive type definitions
|
|
2658
|
+
* - ✅ **Platform-agnostic**: Works in browsers, Node.js, React Native, and more
|
|
2659
|
+
* - ✅ **Authentication**: Automatic token management and refresh
|
|
2660
|
+
* - ✅ **Error handling**: Comprehensive error handling with typed exceptions
|
|
2661
|
+
* - ✅ **Modular**: Import only the domains you need
|
|
2662
|
+
* - ✅ **Manager pattern**: Clean, high-level APIs for common operations
|
|
2663
|
+
* - ✅ **Backward compatible**: Maintains compatibility with existing integrations
|
|
2664
|
+
* - ✅ **Tree-shakable**: Optimized for minimal bundle size
|
|
2665
|
+
*
|
|
2666
|
+
* @example Basic Setup
|
|
2667
|
+
* ```typescript
|
|
2668
|
+
* import { PersSDK } from '@explorins/pers-sdk';
|
|
2669
|
+
* import { BrowserFetchClientAdapter } from '@explorins/pers-sdk/platform-adapters';
|
|
2670
|
+
*
|
|
2671
|
+
* const sdk = new PersSDK(new BrowserFetchClientAdapter(), {
|
|
2672
|
+
* environment: 'production',
|
|
2673
|
+
* apiProjectKey: 'your-project-key'
|
|
2674
|
+
* });
|
|
2675
|
+
* ```
|
|
2676
|
+
*
|
|
2677
|
+
* @example Authentication Flow
|
|
2678
|
+
* ```typescript
|
|
2679
|
+
* // Login with external JWT (Firebase, Auth0, etc.)
|
|
2680
|
+
* await sdk.auth.loginWithToken(firebaseJWT, 'user');
|
|
2681
|
+
*
|
|
2682
|
+
* // Check authentication status
|
|
2683
|
+
* if (await sdk.auth.isAuthenticated()) {
|
|
2684
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
2685
|
+
* console.log('Welcome,', user.name);
|
|
2686
|
+
* }
|
|
2687
|
+
* ```
|
|
2688
|
+
*
|
|
2689
|
+
* @example Business Operations
|
|
2690
|
+
* ```typescript
|
|
2691
|
+
* // Get active businesses
|
|
2692
|
+
* const businesses = await sdk.businesses.getActiveBusinesses();
|
|
2693
|
+
*
|
|
2694
|
+
* // Get business details
|
|
2695
|
+
* const business = await sdk.businesses.getBusinessById(businessId);
|
|
2696
|
+
*
|
|
2697
|
+
* // Admin: Create new business
|
|
2698
|
+
* const newBusiness = await sdk.businesses.createBusiness({
|
|
2699
|
+
* name: 'New Business',
|
|
2700
|
+
* location: 'City Center',
|
|
2701
|
+
* type: 'restaurant'
|
|
2702
|
+
* });
|
|
2703
|
+
* ```
|
|
2704
|
+
*
|
|
2705
|
+
* @example Campaign Management
|
|
2706
|
+
* ```typescript
|
|
2707
|
+
* // Get active campaigns
|
|
2708
|
+
* const campaigns = await sdk.campaigns.getActiveCampaigns();
|
|
2709
|
+
*
|
|
2710
|
+
* // Claim a campaign
|
|
2711
|
+
* await sdk.campaigns.claimCampaign({
|
|
2712
|
+
* campaignId: 'campaign-123',
|
|
2713
|
+
* metadata: { source: 'mobile-app' }
|
|
2714
|
+
* });
|
|
2715
|
+
*
|
|
2716
|
+
* // Get user's claims
|
|
2717
|
+
* const claims = await sdk.campaigns.getUserClaims();
|
|
2718
|
+
* ```
|
|
2719
|
+
*
|
|
2720
|
+
* @example Token Operations
|
|
2721
|
+
* ```typescript
|
|
2722
|
+
* // Get user's token balances
|
|
2723
|
+
* const tokens = await sdk.tokens.getTokens();
|
|
2724
|
+
*
|
|
2725
|
+
* // Transfer tokens between users
|
|
2726
|
+
* await sdk.tokens.transferTokens({
|
|
2727
|
+
* fromUserId: 'user-1',
|
|
2728
|
+
* toUserId: 'user-2',
|
|
2729
|
+
* tokenType: 'CREDIT',
|
|
2730
|
+
* amount: 100
|
|
2731
|
+
* });
|
|
2732
|
+
* ```
|
|
2733
|
+
*
|
|
2734
|
+
* @since 1.3.0 - Manager pattern architecture
|
|
2735
|
+
*/
|
|
2736
|
+
/**
|
|
2737
|
+
* PERS SDK class with domain managers
|
|
2738
|
+
*
|
|
2739
|
+
* Main SDK interface providing clean, high-level managers for common operations
|
|
2740
|
+
* while maintaining full access to the underlying API client and domain SDKs.
|
|
2741
|
+
*
|
|
2742
|
+
* @example
|
|
2743
|
+
* ```typescript
|
|
2744
|
+
* import { PersSDK, createAuthProvider } from '@explorins/pers-sdk/core';
|
|
2745
|
+
* import { BrowserHttpClient } from '@explorins/pers-sdk/browser';
|
|
2746
|
+
*
|
|
2747
|
+
* const authProvider = createAuthProvider({
|
|
2748
|
+
* tokenProvider: () => getFirebaseToken()
|
|
2749
|
+
* });
|
|
2750
|
+
*
|
|
2751
|
+
* const sdk = new PersSDK(new BrowserHttpClient(), {
|
|
2752
|
+
* environment: 'production',
|
|
2753
|
+
* apiProjectKey: 'your-project-key',
|
|
2754
|
+
* authProvider
|
|
2755
|
+
* });
|
|
2756
|
+
*
|
|
2757
|
+
* // High-level manager interface
|
|
2758
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
2759
|
+
* const tokens = await sdk.tokens.getTokens();
|
|
2760
|
+
* const businesses = await sdk.business.getActiveBusinesses();
|
|
2761
|
+
*
|
|
2762
|
+
* // Direct API access for advanced operations
|
|
2763
|
+
* const apiClient = sdk.api();
|
|
2764
|
+
* const customData = await apiClient.get('/custom-endpoint');
|
|
2765
|
+
* ```
|
|
2766
|
+
*/
|
|
2767
|
+
class PersSDK {
|
|
2768
|
+
/**
|
|
2769
|
+
* Creates a new PERS SDK instance
|
|
2770
|
+
*
|
|
2771
|
+
* @param httpClient Platform-specific HTTP client implementation
|
|
2772
|
+
* @param config SDK configuration options
|
|
2773
|
+
*/
|
|
2774
|
+
constructor(httpClient, config) {
|
|
2775
|
+
this.apiClient = new PersApiClient(httpClient, config);
|
|
2776
|
+
// Initialize domain managers
|
|
2777
|
+
this._auth = new AuthManager(this.apiClient);
|
|
2778
|
+
this._users = new UserManager(this.apiClient);
|
|
2779
|
+
this._tokens = new TokenManager(this.apiClient);
|
|
2780
|
+
this._businesses = new BusinessManager(this.apiClient);
|
|
2781
|
+
this._campaigns = new CampaignManager(this.apiClient);
|
|
2782
|
+
this._redemptions = new RedemptionManager(this.apiClient);
|
|
2783
|
+
this._transactions = new TransactionManager(this.apiClient);
|
|
2784
|
+
this._payments = new PaymentManager(this.apiClient);
|
|
2785
|
+
this._tenants = new TenantManager(this.apiClient);
|
|
2786
|
+
this._analytics = new AnalyticsManager(this.apiClient);
|
|
2787
|
+
this._donations = new DonationManager(this.apiClient);
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Authentication manager - High-level auth operations
|
|
2791
|
+
*
|
|
2792
|
+
* @example
|
|
2793
|
+
* ```typescript
|
|
2794
|
+
* await sdk.auth.loginWithToken(jwtToken);
|
|
2795
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
2796
|
+
* const isAuth = await sdk.auth.isAuthenticated();
|
|
2797
|
+
* ```
|
|
2798
|
+
*/
|
|
2799
|
+
get auth() {
|
|
2800
|
+
return this._auth;
|
|
2801
|
+
}
|
|
2802
|
+
/**
|
|
2803
|
+
* User manager - High-level user operations
|
|
2804
|
+
*
|
|
2805
|
+
* @example
|
|
2806
|
+
* ```typescript
|
|
2807
|
+
* const user = await sdk.user.getCurrentUser();
|
|
2808
|
+
* await sdk.user.updateCurrentUser(userData);
|
|
2809
|
+
* const users = await sdk.user.getAllUsersPublic();
|
|
2810
|
+
* ```
|
|
2811
|
+
*/
|
|
2812
|
+
get users() {
|
|
2813
|
+
return this._users;
|
|
2814
|
+
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Token manager - High-level token operations
|
|
2817
|
+
*
|
|
2818
|
+
* @example
|
|
2819
|
+
* ```typescript
|
|
2820
|
+
* const tokens = await sdk.tokens.getTokens();
|
|
2821
|
+
* const creditToken = await sdk.tokens.getActiveCreditToken();
|
|
2822
|
+
* const rewards = await sdk.tokens.getRewardTokens();
|
|
2823
|
+
* ```
|
|
2824
|
+
*/
|
|
2825
|
+
get tokens() {
|
|
2826
|
+
return this._tokens;
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Business manager - High-level business operations
|
|
2830
|
+
*
|
|
2831
|
+
* @example
|
|
2832
|
+
* ```typescript
|
|
2833
|
+
* const businesses = await sdk.business.getActiveBusinesses();
|
|
2834
|
+
* const business = await sdk.business.getBusinessById(id);
|
|
2835
|
+
* const types = await sdk.business.getBusinessTypes();
|
|
2836
|
+
* ```
|
|
2837
|
+
*/
|
|
2838
|
+
get businesses() {
|
|
2839
|
+
return this._businesses;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Campaign manager - High-level campaign operations
|
|
2843
|
+
*
|
|
2844
|
+
* @example
|
|
2845
|
+
* ```typescript
|
|
2846
|
+
* const campaigns = await sdk.campaigns.getActiveCampaigns();
|
|
2847
|
+
* await sdk.campaigns.claimCampaign(claimData);
|
|
2848
|
+
* const claims = await sdk.campaigns.getUserClaims();
|
|
2849
|
+
* ```
|
|
2850
|
+
*/
|
|
2851
|
+
get campaigns() {
|
|
2852
|
+
return this._campaigns;
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Redemption manager - High-level redemption operations
|
|
2856
|
+
*
|
|
2857
|
+
* @example
|
|
2858
|
+
* ```typescript
|
|
2859
|
+
* const redemptions = await sdk.redemptions.getActiveRedemptions();
|
|
2860
|
+
* await sdk.redemptions.redeemOffer(redemptionId);
|
|
2861
|
+
* const history = await sdk.redemptions.getUserRedemptions();
|
|
2862
|
+
* ```
|
|
2863
|
+
*/
|
|
2864
|
+
get redemptions() {
|
|
2865
|
+
return this._redemptions;
|
|
2866
|
+
}
|
|
2867
|
+
/**
|
|
2868
|
+
* Transaction manager - High-level transaction operations
|
|
2869
|
+
*
|
|
2870
|
+
* @example
|
|
2871
|
+
* ```typescript
|
|
2872
|
+
* const transaction = await sdk.transactions.getTransactionById(id);
|
|
2873
|
+
* await sdk.transactions.createTransaction(txData);
|
|
2874
|
+
* const history = await sdk.transactions.getUserTransactionHistory('all');
|
|
2875
|
+
* ```
|
|
2876
|
+
*/
|
|
2877
|
+
get transactions() {
|
|
2878
|
+
return this._transactions;
|
|
2879
|
+
}
|
|
2880
|
+
/**
|
|
2881
|
+
* Payment manager - High-level payment operations
|
|
2882
|
+
*
|
|
2883
|
+
* @example
|
|
2884
|
+
* ```typescript
|
|
2885
|
+
* const intent = await sdk.payments.createPaymentIntent(100, 'usd', 'email@example.com', 'Purchase');
|
|
2886
|
+
* const tokens = await sdk.payments.getActivePurchaseTokens();
|
|
2887
|
+
* const purchases = await sdk.payments.getAllUserPurchases();
|
|
2888
|
+
* ```
|
|
2889
|
+
*/
|
|
2890
|
+
get payments() {
|
|
2891
|
+
return this._payments;
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Tenant manager - High-level tenant operations
|
|
2895
|
+
*
|
|
2896
|
+
* @example
|
|
2897
|
+
* ```typescript
|
|
2898
|
+
* const tenant = await sdk.tenant.getTenantInfo();
|
|
2899
|
+
* const config = await sdk.tenant.getClientConfig();
|
|
2900
|
+
* const admins = await sdk.tenant.getAdmins();
|
|
2901
|
+
* ```
|
|
2902
|
+
*/
|
|
2903
|
+
get tenants() {
|
|
2904
|
+
return this._tenants;
|
|
2905
|
+
}
|
|
2906
|
+
/**
|
|
2907
|
+
* Analytics manager - High-level analytics operations
|
|
2908
|
+
*
|
|
2909
|
+
* @example
|
|
2910
|
+
* ```typescript
|
|
2911
|
+
* const analytics = await sdk.analytics.getTransactionAnalytics(request);
|
|
2912
|
+
* ```
|
|
2913
|
+
*/
|
|
2914
|
+
get analytics() {
|
|
2915
|
+
return this._analytics;
|
|
2916
|
+
}
|
|
2917
|
+
/**
|
|
2918
|
+
* Donation manager - High-level donation operations
|
|
2919
|
+
*
|
|
2920
|
+
* @example
|
|
2921
|
+
* ```typescript
|
|
2922
|
+
* const types = await sdk.donations.getDonationTypes();
|
|
2923
|
+
* ```
|
|
2924
|
+
*/
|
|
2925
|
+
get donations() {
|
|
2926
|
+
return this._donations;
|
|
2927
|
+
}
|
|
2928
|
+
/**
|
|
2929
|
+
* Gets the API client for direct PERS API requests
|
|
2930
|
+
*
|
|
2931
|
+
* Use this for advanced operations not covered by the managers.
|
|
2932
|
+
* The returned client handles authentication, token refresh, and error handling automatically.
|
|
2933
|
+
*
|
|
2934
|
+
* @returns Configured PersApiClient instance
|
|
2935
|
+
*
|
|
2936
|
+
* @example
|
|
2937
|
+
* ```typescript
|
|
2938
|
+
* const apiClient = sdk.api();
|
|
2939
|
+
* const customData = await apiClient.get<CustomType>('/custom-endpoint');
|
|
2940
|
+
* await apiClient.post('/custom-endpoint', customData);
|
|
2941
|
+
* ```
|
|
2942
|
+
*/
|
|
2943
|
+
api() {
|
|
2944
|
+
return this.apiClient;
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Checks if SDK is configured for production environment
|
|
2948
|
+
*
|
|
2949
|
+
* @returns True if environment is 'production', false otherwise
|
|
2950
|
+
*/
|
|
2951
|
+
isProduction() {
|
|
2952
|
+
return this.apiClient.getConfig().environment === 'production';
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
/**
|
|
2956
|
+
* Factory function for creating PERS SDK
|
|
2957
|
+
*
|
|
2958
|
+
* @param httpClient Platform-specific HTTP client implementation
|
|
2959
|
+
* @param config SDK configuration options
|
|
2960
|
+
* @returns PERS SDK instance
|
|
1687
2961
|
*/
|
|
1688
2962
|
function createPersSDK(httpClient, config) {
|
|
1689
2963
|
return new PersSDK(httpClient, config);
|
|
1690
2964
|
}
|
|
1691
2965
|
|
|
2966
|
+
exports.AnalyticsManager = AnalyticsManager;
|
|
2967
|
+
exports.AuthManager = AuthManager;
|
|
2968
|
+
exports.BusinessManager = BusinessManager;
|
|
2969
|
+
exports.CampaignManager = CampaignManager;
|
|
1692
2970
|
exports.DEFAULT_PERS_CONFIG = DEFAULT_PERS_CONFIG;
|
|
2971
|
+
exports.DonationManager = DonationManager;
|
|
2972
|
+
exports.PaymentManager = PaymentManager;
|
|
1693
2973
|
exports.PersApiClient = PersApiClient;
|
|
1694
2974
|
exports.PersSDK = PersSDK;
|
|
2975
|
+
exports.RedemptionManager = RedemptionManager;
|
|
2976
|
+
exports.TenantManager = TenantManager;
|
|
2977
|
+
exports.TokenManager = TokenManager;
|
|
2978
|
+
exports.TransactionManager = TransactionManager;
|
|
2979
|
+
exports.UserManager = UserManager;
|
|
1695
2980
|
exports.buildApiRoot = buildApiRoot;
|
|
1696
2981
|
exports.createAuthProvider = createAuthProvider;
|
|
1697
2982
|
exports.createPersSDK = createPersSDK;
|
|
1698
2983
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
1699
|
-
//# sourceMappingURL=pers-sdk-
|
|
2984
|
+
//# sourceMappingURL=pers-sdk-CI2YXKb_.cjs.map
|