@explorins/pers-sdk 1.6.3 → 1.6.6
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 +63 -37
- package/dist/analytics/index.d.ts +0 -16
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics.cjs +5 -73
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +1 -72
- package/dist/analytics.js.map +1 -1
- package/dist/business/index.d.ts +0 -24
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +5 -273
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +1 -272
- package/dist/business.js.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +3 -13
- package/dist/campaign/api/campaign-api.d.ts.map +1 -1
- package/dist/campaign/index.d.ts +0 -34
- package/dist/campaign/index.d.ts.map +1 -1
- package/dist/campaign.cjs +5 -470
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +1 -469
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/analytics-service-CitlimKJ.cjs +49 -0
- package/dist/chunks/analytics-service-CitlimKJ.cjs.map +1 -0
- package/dist/chunks/analytics-service-CxyrOwel.js +46 -0
- package/dist/chunks/analytics-service-CxyrOwel.js.map +1 -0
- package/dist/chunks/{token-sdk-BW4kkJb3.js → base-token-service-BSXDwrcq.js} +138 -204
- package/dist/chunks/base-token-service-BSXDwrcq.js.map +1 -0
- package/dist/chunks/{token-sdk-CiAbOb6c.cjs → base-token-service-CYuqPPs0.cjs} +140 -207
- package/dist/chunks/base-token-service-CYuqPPs0.cjs.map +1 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs +241 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs.map +1 -0
- package/dist/chunks/business-service-DrC-TNGa.js +238 -0
- package/dist/chunks/business-service-DrC-TNGa.js.map +1 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs +403 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs.map +1 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js +400 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js.map +1 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js +47 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js.map +1 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs +50 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs.map +1 -0
- package/dist/chunks/{index-CJ9Jfa4A.js → explorer.utils-Ckll15ja.js} +108 -172
- package/dist/chunks/explorer.utils-Ckll15ja.js.map +1 -0
- package/dist/chunks/{index-CzEluQmf.cjs → explorer.utils-GpskbLl1.cjs} +106 -174
- package/dist/chunks/explorer.utils-GpskbLl1.cjs.map +1 -0
- package/dist/chunks/index-BtDNXaFq.js +13 -0
- package/dist/chunks/index-BtDNXaFq.js.map +1 -0
- package/dist/chunks/index-CMk3Aqkk.cjs +15 -0
- package/dist/chunks/index-CMk3Aqkk.cjs.map +1 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs +220 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs.map +1 -0
- package/dist/chunks/payment-service-DfCBFosx.js +217 -0
- package/dist/chunks/payment-service-DfCBFosx.js.map +1 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs +5850 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs.map +1 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js +5817 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js.map +1 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs +330 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs.map +1 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js +327 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js.map +1 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs +171 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs.map +1 -0
- package/dist/chunks/tenant-service-DELk412y.js +168 -0
- package/dist/chunks/tenant-service-DELk412y.js.map +1 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs +208 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs.map +1 -0
- package/dist/chunks/token-service-CpVwC5Eb.js +205 -0
- package/dist/chunks/token-service-CpVwC5Eb.js.map +1 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs +153 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs.map +1 -0
- package/dist/chunks/user-service-D6mTa_WZ.js +150 -0
- package/dist/chunks/user-service-D6mTa_WZ.js.map +1 -0
- package/dist/chunks/{index-BfOoX87y.cjs → web3-chain-service-BYkj61DN.cjs} +1 -33
- package/dist/chunks/web3-chain-service-BYkj61DN.cjs.map +1 -0
- package/dist/chunks/{index-CM21r58m.js → web3-chain-service-DN6tJmvK.js} +2 -31
- package/dist/chunks/web3-chain-service-DN6tJmvK.js.map +1 -0
- package/dist/core/auth/auth-provider.interface.d.ts +32 -69
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -1
- package/dist/core/auth/default-auth-provider.d.ts +15 -58
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/index.d.ts +10 -12
- package/dist/core/auth/index.d.ts.map +1 -1
- package/dist/core/auth/refresh-manager.d.ts +18 -0
- package/dist/core/auth/refresh-manager.d.ts.map +1 -0
- package/dist/core/auth/services/auth-service.d.ts +11 -6
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +27 -47
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/errors/index.d.ts +1 -5
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +10 -126
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +8 -3
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/utils/jwt.function.d.ts.map +1 -1
- package/dist/core.cjs +22 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +13 -13
- package/dist/donation/index.d.ts +0 -15
- package/dist/donation/index.d.ts.map +1 -1
- package/dist/donation.cjs +5 -75
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +1 -74
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +51 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +290 -10
- package/dist/managers/analytics-manager.d.ts.map +1 -1
- package/dist/managers/auth-manager.d.ts +123 -23
- package/dist/managers/auth-manager.d.ts.map +1 -1
- package/dist/managers/business-manager.d.ts +273 -18
- package/dist/managers/business-manager.d.ts.map +1 -1
- package/dist/managers/campaign-manager.d.ts +585 -46
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/donation-manager.d.ts +5 -5
- package/dist/managers/donation-manager.d.ts.map +1 -1
- package/dist/managers/file-manager.d.ts +430 -13
- package/dist/managers/file-manager.d.ts.map +1 -1
- package/dist/managers/purchase-manager.d.ts +340 -15
- package/dist/managers/purchase-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +450 -27
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/tenant-manager.d.ts +5 -5
- package/dist/managers/tenant-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +245 -21
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +447 -18
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +216 -14
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +4 -4
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/package.json +9 -2
- package/dist/payment/index.d.ts +0 -21
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment.cjs +5 -255
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +1 -254
- package/dist/payment.js.map +1 -1
- package/dist/pers-sdk.d.ts +141 -34
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +0 -25
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption.cjs +5 -365
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +1 -364
- package/dist/redemption.js.map +1 -1
- package/dist/tenant/index.d.ts +0 -22
- package/dist/tenant/index.d.ts.map +1 -1
- package/dist/tenant.cjs +5 -203
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +1 -202
- package/dist/tenant.js.map +1 -1
- package/dist/token.cjs +6 -6
- package/dist/token.js +2 -2
- package/dist/transaction/index.d.ts +0 -22
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction.cjs +0 -40
- package/dist/transaction.cjs.map +1 -1
- package/dist/transaction.js +1 -40
- package/dist/transaction.js.map +1 -1
- package/dist/user/index.d.ts +0 -25
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user.cjs +5 -185
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +1 -184
- package/dist/user.js.map +1 -1
- package/dist/web3/index.d.ts +0 -11
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +0 -9
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -1
- package/dist/web3-chain.cjs +5 -5
- package/dist/web3-chain.js +2 -1
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3.cjs +6 -10
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +1 -4
- package/dist/web3.js.map +1 -1
- package/package.json +9 -2
- package/dist/chunks/base-token-service-D0KANDgM.js +0 -139
- package/dist/chunks/base-token-service-D0KANDgM.js.map +0 -1
- package/dist/chunks/base-token-service-zNfPjHRx.cjs +0 -141
- package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +0 -1
- package/dist/chunks/index-BfOoX87y.cjs.map +0 -1
- package/dist/chunks/index-CJ9Jfa4A.js.map +0 -1
- package/dist/chunks/index-CM21r58m.js.map +0 -1
- package/dist/chunks/index-CzEluQmf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs +0 -3378
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-Z6MKeFBX.js +0 -3353
- package/dist/chunks/pers-sdk-Z6MKeFBX.js.map +0 -1
- package/dist/chunks/token-sdk-BW4kkJb3.js.map +0 -1
- package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +0 -1
- package/dist/core/auth/auth-constants.d.ts +0 -33
- package/dist/core/auth/auth-constants.d.ts.map +0 -1
- package/dist/core/auth/auth-errors.d.ts +0 -8
- package/dist/core/auth/auth-errors.d.ts.map +0 -1
- package/dist/core/auth/create-auth-provider.d.ts +0 -27
- package/dist/core/auth/create-auth-provider.d.ts.map +0 -1
- package/dist/core/auth/token-refresh.d.ts +0 -91
- package/dist/core/auth/token-refresh.d.ts.map +0 -1
|
@@ -1,158 +1,697 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { CampaignService } from '../campaign';
|
|
3
3
|
import type { CampaignDTO, CampaignCreateRequestDTO, CampaignClaimRequestDTO, CampaignClaimDTO, TokenUnitCreateRequestDTO, CampaignBusinessEngagementCreateRequestDTO, CampaignTriggerDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
4
4
|
/**
|
|
5
5
|
* Campaign Manager - Clean, high-level interface for campaign operations
|
|
6
6
|
*
|
|
7
|
-
* Provides a
|
|
8
|
-
*
|
|
7
|
+
* Provides a comprehensive API for loyalty campaign management including campaign
|
|
8
|
+
* discovery, reward claiming, business engagement tracking, and administrative
|
|
9
|
+
* campaign lifecycle operations. Campaigns are the core promotional mechanisms
|
|
10
|
+
* that drive user engagement and reward distribution in the loyalty ecosystem.
|
|
11
|
+
*
|
|
12
|
+
* @group Managers
|
|
13
|
+
* @category Campaign Management
|
|
14
|
+
*
|
|
15
|
+
* @example Basic Campaign Operations
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Get all available campaigns for users
|
|
18
|
+
* const campaigns = await sdk.campaigns.getActiveCampaigns();
|
|
19
|
+
* console.log(`${campaigns.length} active campaigns available`);
|
|
20
|
+
*
|
|
21
|
+
* // Get specific campaign details
|
|
22
|
+
* const campaign = await sdk.campaigns.getCampaignById('summer-promo-2024');
|
|
23
|
+
* console.log('Campaign:', campaign.title);
|
|
24
|
+
*
|
|
25
|
+
* // User claims campaign reward
|
|
26
|
+
* const claim = await sdk.campaigns.claimCampaign({
|
|
27
|
+
* campaignId: 'summer-promo-2024',
|
|
28
|
+
* businessId: 'partner-hotel-123'
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example User Campaign Management
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Get user's claimed campaigns
|
|
35
|
+
* const userClaims = await sdk.campaigns.getUserClaims();
|
|
36
|
+
*
|
|
37
|
+
* console.log('My Campaign Claims:');
|
|
38
|
+
* userClaims.forEach(claim => {
|
|
39
|
+
* console.log(`- ${claim.campaign.title}`);
|
|
40
|
+
* console.log(` Rewards: ${claim.rewards?.length || 0} tokens`);
|
|
41
|
+
* console.log(` Date: ${claim.claimedAt}`);
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Check if user can claim specific campaign
|
|
45
|
+
* const eligibleCampaigns = campaigns.filter(c =>
|
|
46
|
+
* !userClaims.some(claim => claim.campaignId === c.id)
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Administrative Operations
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Admin: Create seasonal campaign
|
|
53
|
+
* const newCampaign = await sdk.campaigns.createCampaign({
|
|
54
|
+
* title: 'Holiday Rewards',
|
|
55
|
+
* description: 'Special holiday loyalty bonuses',
|
|
56
|
+
* startDate: '2024-12-01',
|
|
57
|
+
* endDate: '2024-12-31',
|
|
58
|
+
* isActive: true
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Admin: Set up campaign rewards
|
|
62
|
+
* await sdk.campaigns.createCampaignTokenUnit(newCampaign.id, {
|
|
63
|
+
* tokenId: 'loyalty-points',
|
|
64
|
+
* amount: 500,
|
|
65
|
+
* type: 'REWARD'
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
9
68
|
*/
|
|
10
69
|
export declare class CampaignManager {
|
|
11
70
|
private apiClient;
|
|
12
|
-
private
|
|
71
|
+
private campaignService;
|
|
13
72
|
constructor(apiClient: PersApiClient);
|
|
14
73
|
/**
|
|
15
74
|
* Get all active campaigns
|
|
16
75
|
*
|
|
17
|
-
*
|
|
76
|
+
* Retrieves all currently active campaigns that users can discover and claim.
|
|
77
|
+
* Active campaigns are live promotional offers with valid date ranges and
|
|
78
|
+
* available rewards. Includes campaign details, eligibility requirements, and reward information.
|
|
79
|
+
*
|
|
80
|
+
* @returns Promise resolving to array of active campaign data
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const activeCampaigns = await sdk.campaigns.getActiveCampaigns();
|
|
85
|
+
*
|
|
86
|
+
* console.log('Available Campaigns:');
|
|
87
|
+
* activeCampaigns.forEach(campaign => {
|
|
88
|
+
* console.log(`\n📢 ${campaign.title}`);
|
|
89
|
+
* console.log(` ${campaign.description}`);
|
|
90
|
+
* console.log(` Valid: ${campaign.startDate} to ${campaign.endDate}`);
|
|
91
|
+
* console.log(` Rewards: ${campaign.tokenUnits?.length || 0} types`);
|
|
92
|
+
*
|
|
93
|
+
* if (campaign.businessEngagements?.length) {
|
|
94
|
+
* console.log(` Partner businesses: ${campaign.businessEngagements.length}`);
|
|
95
|
+
* }
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Filter campaigns by type or business
|
|
99
|
+
* const hotelCampaigns = activeCampaigns.filter(c =>
|
|
100
|
+
* c.businessEngagements?.some(be =>
|
|
101
|
+
* be.business?.businessType?.name?.includes('Hotel')
|
|
102
|
+
* )
|
|
103
|
+
* );
|
|
104
|
+
* ```
|
|
18
105
|
*/
|
|
19
106
|
getActiveCampaigns(): Promise<CampaignDTO[]>;
|
|
20
107
|
/**
|
|
21
108
|
* Get campaign by ID
|
|
22
109
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
110
|
+
* Retrieves detailed information for a specific campaign including rewards,
|
|
111
|
+
* business partnerships, eligibility criteria, and claiming requirements.
|
|
112
|
+
*
|
|
113
|
+
* @param campaignId - Unique campaign identifier
|
|
114
|
+
* @returns Promise resolving to campaign data with complete details
|
|
115
|
+
* @throws {PersApiError} When campaign with specified ID is not found
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* try {
|
|
120
|
+
* const campaign = await sdk.campaigns.getCampaignById('summer-promo-2024');
|
|
121
|
+
*
|
|
122
|
+
* console.log('📢 Campaign Details:');
|
|
123
|
+
* console.log('Title:', campaign.title);
|
|
124
|
+
* console.log('Description:', campaign.description);
|
|
125
|
+
* console.log('Active:', campaign.isActive);
|
|
126
|
+
* console.log('Period:', `${campaign.startDate} to ${campaign.endDate}`);
|
|
127
|
+
*
|
|
128
|
+
* console.log('\n💎 Rewards:');
|
|
129
|
+
* campaign.tokenUnits?.forEach(unit => {
|
|
130
|
+
* console.log(`- ${unit.amount} ${unit.token.symbol} (${unit.token.name})`);
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* console.log('\n🏢 Partner Businesses:');
|
|
134
|
+
* campaign.businessEngagements?.forEach(engagement => {
|
|
135
|
+
* console.log(`- ${engagement.business.displayName}`);
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* } catch (error) {
|
|
139
|
+
* console.log('Campaign not found:', error.message);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
25
142
|
*/
|
|
26
143
|
getCampaignById(campaignId: string): Promise<CampaignDTO>;
|
|
27
144
|
/**
|
|
28
145
|
* Claim a campaign reward
|
|
29
146
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
147
|
+
* Claims rewards from a campaign for the authenticated user. This action
|
|
148
|
+
* validates eligibility, processes reward distribution, and creates a permanent
|
|
149
|
+
* claim record. Users can typically claim each campaign only once.
|
|
150
|
+
*
|
|
151
|
+
* @param claimRequest - Campaign claim request with campaign and business context
|
|
152
|
+
* @returns Promise resolving to claim result with reward details
|
|
153
|
+
* @throws {PersApiError} When campaign is not claimable or user is not eligible
|
|
154
|
+
*
|
|
155
|
+
* @example Simple Campaign Claim
|
|
156
|
+
* ```typescript
|
|
157
|
+
* try {
|
|
158
|
+
* const claim = await sdk.campaigns.claimCampaign({
|
|
159
|
+
* campaignId: 'welcome-bonus',
|
|
160
|
+
* businessId: 'partner-hotel-123'
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* console.log('✅ Campaign claimed successfully!');
|
|
164
|
+
* console.log('Claim ID:', claim.id);
|
|
165
|
+
* console.log('Claimed at:', claim.claimedAt);
|
|
166
|
+
*
|
|
167
|
+
* if (claim.rewards?.length) {
|
|
168
|
+
* console.log('\n💰 Rewards received:');
|
|
169
|
+
* claim.rewards.forEach(reward => {
|
|
170
|
+
* console.log(`- ${reward.amount} ${reward.token.symbol}`);
|
|
171
|
+
* });
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* } catch (error) {
|
|
175
|
+
* console.log('Claim failed:', error.message);
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example Campaign Claim with Validation
|
|
180
|
+
* ```typescript
|
|
181
|
+
* // Check if campaign is still active
|
|
182
|
+
* const campaign = await sdk.campaigns.getCampaignById('limited-time-offer');
|
|
183
|
+
*
|
|
184
|
+
* if (campaign.isActive && new Date() <= new Date(campaign.endDate)) {
|
|
185
|
+
* // Check if user already claimed
|
|
186
|
+
* const userClaims = await sdk.campaigns.getUserClaims();
|
|
187
|
+
* const alreadyClaimed = userClaims.some(c => c.campaignId === campaign.id);
|
|
188
|
+
*
|
|
189
|
+
* if (!alreadyClaimed) {
|
|
190
|
+
* const claim = await sdk.campaigns.claimCampaign({
|
|
191
|
+
* campaignId: campaign.id,
|
|
192
|
+
* businessId: 'partner-business-id'
|
|
193
|
+
* });
|
|
194
|
+
* console.log('Claim successful:', claim.id);
|
|
195
|
+
* } else {
|
|
196
|
+
* console.log('Campaign already claimed');
|
|
197
|
+
* }
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
32
200
|
*/
|
|
33
201
|
claimCampaign(claimRequest: CampaignClaimRequestDTO): Promise<CampaignClaimDTO>;
|
|
34
202
|
/**
|
|
35
203
|
* Get user's campaign claims
|
|
36
204
|
*
|
|
37
|
-
*
|
|
205
|
+
* Retrieves all campaigns that the authenticated user has successfully claimed.
|
|
206
|
+
* Includes claim timestamps, received rewards, and associated business context.
|
|
207
|
+
* Useful for user reward history and campaign participation tracking.
|
|
208
|
+
*
|
|
209
|
+
* @returns Promise resolving to array of user's campaign claims
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const userClaims = await sdk.campaigns.getUserClaims();
|
|
214
|
+
*
|
|
215
|
+
* console.log(`📜 Campaign History (${userClaims.length} claims):`);
|
|
216
|
+
*
|
|
217
|
+
* userClaims.forEach((claim, index) => {
|
|
218
|
+
* console.log(`\n${index + 1}. ${claim.campaign.title}`);
|
|
219
|
+
* console.log(` 📅 Claimed: ${new Date(claim.claimedAt).toLocaleDateString()}`);
|
|
220
|
+
* console.log(` 🏢 Business: ${claim.business?.displayName || 'N/A'}`);
|
|
221
|
+
*
|
|
222
|
+
* if (claim.rewards?.length) {
|
|
223
|
+
* console.log(` 💰 Rewards:`);
|
|
224
|
+
* claim.rewards.forEach(reward => {
|
|
225
|
+
* console.log(` • ${reward.amount} ${reward.token.symbol}`);
|
|
226
|
+
* });
|
|
227
|
+
* }
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* // Calculate total rewards earned
|
|
231
|
+
* const totalRewards = userClaims.reduce((total, claim) => {
|
|
232
|
+
* return total + (claim.rewards?.length || 0);
|
|
233
|
+
* }, 0);
|
|
234
|
+
*
|
|
235
|
+
* console.log(`\n🎁 Total reward items earned: ${totalRewards}`);
|
|
236
|
+
* ```
|
|
38
237
|
*/
|
|
39
238
|
getUserClaims(): Promise<CampaignClaimDTO[]>;
|
|
40
239
|
/**
|
|
41
240
|
* Admin: Get all campaigns
|
|
42
241
|
*
|
|
43
|
-
*
|
|
242
|
+
* Retrieves all campaigns in the system regardless of status. This operation
|
|
243
|
+
* requires administrator privileges and is used for comprehensive campaign
|
|
244
|
+
* management, reporting, and lifecycle operations.
|
|
245
|
+
*
|
|
246
|
+
* @param active - Optional filter to show only active or inactive campaigns
|
|
44
247
|
* @returns Promise resolving to array of campaigns
|
|
248
|
+
* @throws {PersApiError} When not authenticated as administrator
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* // Admin operation - get campaign overview
|
|
253
|
+
* const allCampaigns = await sdk.campaigns.getAllCampaigns();
|
|
254
|
+
* const activeCampaigns = await sdk.campaigns.getAllCampaigns(true);
|
|
255
|
+
* const inactiveCampaigns = await sdk.campaigns.getAllCampaigns(false);
|
|
256
|
+
*
|
|
257
|
+
* console.log('📊 Campaign Statistics:');
|
|
258
|
+
* console.log(`Total campaigns: ${allCampaigns.length}`);
|
|
259
|
+
* console.log(`Active campaigns: ${activeCampaigns.length}`);
|
|
260
|
+
* console.log(`Inactive campaigns: ${inactiveCampaigns.length}`);
|
|
261
|
+
*
|
|
262
|
+
* // Generate campaign performance report
|
|
263
|
+
* const campaignReport = allCampaigns.map(campaign => ({
|
|
264
|
+
* title: campaign.title,
|
|
265
|
+
* status: campaign.isActive ? 'Active' : 'Inactive',
|
|
266
|
+
* period: `${campaign.startDate} to ${campaign.endDate}`,
|
|
267
|
+
* businesses: campaign.businessEngagements?.length || 0,
|
|
268
|
+
* rewardTypes: campaign.tokenUnits?.length || 0
|
|
269
|
+
* }));
|
|
270
|
+
* ```
|
|
45
271
|
*/
|
|
46
272
|
getAllCampaigns(active?: boolean): Promise<CampaignDTO[]>;
|
|
47
273
|
/**
|
|
48
274
|
* Admin: Create new campaign
|
|
49
275
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
276
|
+
* Creates a new loyalty campaign with specified configuration, rewards, and
|
|
277
|
+
* business partnerships. This operation requires administrator privileges
|
|
278
|
+
* and establishes a new promotional mechanism for user engagement.
|
|
279
|
+
*
|
|
280
|
+
* @param campaignData - Campaign configuration including title, dates, and settings
|
|
281
|
+
* @returns Promise resolving to created campaign data
|
|
282
|
+
* @throws {PersApiError} When not authenticated as admin or validation fails
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* // Admin operation - create seasonal campaign
|
|
287
|
+
* const campaign = await sdk.campaigns.createCampaign({
|
|
288
|
+
* title: 'Summer Travel Rewards',
|
|
289
|
+
* description: 'Earn bonus points for summer bookings',
|
|
290
|
+
* startDate: '2024-06-01T00:00:00Z',
|
|
291
|
+
* endDate: '2024-08-31T23:59:59Z',
|
|
292
|
+
* isActive: true,
|
|
293
|
+
* isTestnet: false,
|
|
294
|
+
* campaignType: 'SEASONAL'
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* console.log('✅ Campaign created:', campaign.title);
|
|
298
|
+
* console.log('Campaign ID:', campaign.id);
|
|
299
|
+
*
|
|
300
|
+
* // Set up campaign rewards
|
|
301
|
+
* await sdk.campaigns.createCampaignTokenUnit(campaign.id, {
|
|
302
|
+
* tokenId: 'loyalty-points',
|
|
303
|
+
* amount: 1000,
|
|
304
|
+
* type: 'BONUS'
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
52
307
|
*/
|
|
53
308
|
createCampaign(campaignData: CampaignCreateRequestDTO): Promise<CampaignDTO>;
|
|
54
309
|
/**
|
|
55
310
|
* Admin: Update campaign
|
|
56
311
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
312
|
+
* Updates an existing campaign's configuration, dates, or status. This operation
|
|
313
|
+
* requires administrator privileges and can modify most campaign properties
|
|
314
|
+
* while preserving existing claims and relationships.
|
|
315
|
+
*
|
|
316
|
+
* @param campaignId - ID of the campaign to update
|
|
317
|
+
* @param campaignData - Updated campaign configuration
|
|
318
|
+
* @returns Promise resolving to updated campaign data
|
|
319
|
+
* @throws {PersApiError} When not authenticated as admin or campaign not found
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* // Admin operation - extend campaign duration
|
|
324
|
+
* const updated = await sdk.campaigns.updateCampaign('summer-2024', {
|
|
325
|
+
* title: 'Extended Summer Travel Rewards',
|
|
326
|
+
* description: 'Earn bonus points for summer and early fall bookings',
|
|
327
|
+
* endDate: '2024-09-30T23:59:59Z', // Extended end date
|
|
328
|
+
* isActive: true
|
|
329
|
+
* });
|
|
330
|
+
*
|
|
331
|
+
* console.log('Campaign updated:', updated.title);
|
|
332
|
+
* console.log('New end date:', updated.endDate);
|
|
333
|
+
* ```
|
|
60
334
|
*/
|
|
61
335
|
updateCampaign(campaignId: string, campaignData: CampaignCreateRequestDTO): Promise<CampaignDTO>;
|
|
62
336
|
/**
|
|
63
337
|
* Admin: Toggle campaign active status
|
|
64
338
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
339
|
+
* Toggles the active/inactive status of a campaign. Inactive campaigns are
|
|
340
|
+
* not available for new claims but existing claims remain valid. Requires
|
|
341
|
+
* administrator privileges.
|
|
342
|
+
*
|
|
343
|
+
* @param campaignId - ID of the campaign to toggle
|
|
344
|
+
* @returns Promise resolving to updated campaign data
|
|
345
|
+
* @throws {PersApiError} When not authenticated as admin or campaign not found
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* // Admin operation - temporarily disable campaign
|
|
350
|
+
* const updated = await sdk.campaigns.toggleCampaignStatus('problematic-campaign');
|
|
351
|
+
*
|
|
352
|
+
* console.log(`Campaign ${updated.isActive ? 'activated' : 'deactivated'}`);
|
|
353
|
+
* console.log('Status:', updated.isActive ? '✅ Active' : '❌ Inactive');
|
|
354
|
+
* ```
|
|
67
355
|
*/
|
|
68
356
|
toggleCampaignStatus(campaignId: string): Promise<CampaignDTO>;
|
|
69
357
|
/**
|
|
70
358
|
* Admin: Toggle campaign testnet environment
|
|
71
359
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
360
|
+
* Toggles the testnet/mainnet environment for a campaign. Testnet campaigns
|
|
361
|
+
* operate with test tokens and are used for validation before production deployment.
|
|
362
|
+
* Requires administrator privileges.
|
|
363
|
+
*
|
|
364
|
+
* @param campaignId - ID of the campaign to toggle
|
|
365
|
+
* @returns Promise resolving to updated campaign data
|
|
366
|
+
* @throws {PersApiError} When not authenticated as admin or campaign not found
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```typescript
|
|
370
|
+
* // Admin operation - move campaign to production
|
|
371
|
+
* const updated = await sdk.campaigns.toggleCampaignTestnet('test-campaign');
|
|
372
|
+
*
|
|
373
|
+
* console.log(`Campaign moved to ${updated.isTestnet ? 'testnet' : 'mainnet'}`);
|
|
374
|
+
* ```
|
|
74
375
|
*/
|
|
75
376
|
toggleCampaignTestnet(campaignId: string): Promise<CampaignDTO>;
|
|
76
377
|
/**
|
|
77
378
|
* Admin: Get campaign triggers
|
|
78
379
|
*
|
|
79
|
-
*
|
|
380
|
+
* Retrieves all available campaign trigger mechanisms that can be used to
|
|
381
|
+
* automatically activate campaigns based on user actions or system events.
|
|
382
|
+
* Requires administrator privileges.
|
|
383
|
+
*
|
|
384
|
+
* @returns Promise resolving to array of campaign trigger definitions
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* // Admin operation - view available triggers
|
|
389
|
+
* const triggers = await sdk.campaigns.getCampaignTriggers();
|
|
390
|
+
*
|
|
391
|
+
* console.log('Available Campaign Triggers:');
|
|
392
|
+
* triggers.forEach(trigger => {
|
|
393
|
+
* console.log(`- ${trigger.name}: ${trigger.description}`);
|
|
394
|
+
* console.log(` Type: ${trigger.type}`);
|
|
395
|
+
* console.log(` Parameters: ${JSON.stringify(trigger.parameters)}`);
|
|
396
|
+
* });
|
|
397
|
+
* ```
|
|
80
398
|
*/
|
|
81
399
|
getCampaignTriggers(): Promise<CampaignTriggerDTO[]>;
|
|
82
400
|
/**
|
|
83
401
|
* Admin: Set campaign trigger
|
|
84
402
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
403
|
+
* Associates a specific trigger mechanism with a campaign, enabling automatic
|
|
404
|
+
* campaign activation based on defined conditions. Requires administrator privileges.
|
|
405
|
+
*
|
|
406
|
+
* @param campaignId - ID of the campaign
|
|
407
|
+
* @param triggerId - ID of the trigger to associate
|
|
408
|
+
* @returns Promise resolving to updated campaign data
|
|
409
|
+
* @throws {PersApiError} When not authenticated as admin or entities not found
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```typescript
|
|
413
|
+
* // Admin operation - set up automatic campaign trigger
|
|
414
|
+
* const updated = await sdk.campaigns.setCampaignTrigger(
|
|
415
|
+
* 'new-user-welcome',
|
|
416
|
+
* 'user-registration-trigger'
|
|
417
|
+
* );
|
|
418
|
+
*
|
|
419
|
+
* console.log('Trigger set for campaign:', updated.title);
|
|
420
|
+
* console.log('Trigger will activate on user registration');
|
|
421
|
+
* ```
|
|
88
422
|
*/
|
|
89
423
|
setCampaignTrigger(campaignId: string, triggerId: string): Promise<CampaignDTO>;
|
|
90
424
|
/**
|
|
91
425
|
* Admin: Create campaign token unit
|
|
92
426
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
427
|
+
* Adds a token reward unit to a campaign, specifying the token type and amount
|
|
428
|
+
* that users will receive when claiming the campaign. Multiple token units
|
|
429
|
+
* can be added to create multi-reward campaigns. Requires administrator privileges.
|
|
430
|
+
*
|
|
431
|
+
* @param campaignId - ID of the campaign
|
|
432
|
+
* @param tokenUnit - Token unit configuration including token type and amount
|
|
433
|
+
* @returns Promise resolving to updated campaign data
|
|
434
|
+
* @throws {PersApiError} When not authenticated as admin or validation fails
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* // Admin operation - add loyalty points reward
|
|
439
|
+
* const updated = await sdk.campaigns.createCampaignTokenUnit('summer-promo', {
|
|
440
|
+
* tokenId: 'loyalty-points',
|
|
441
|
+
* amount: 500,
|
|
442
|
+
* type: 'REWARD'
|
|
443
|
+
* });
|
|
444
|
+
*
|
|
445
|
+
* console.log('Token unit added to campaign');
|
|
446
|
+
* console.log('Reward units:', updated.tokenUnits?.length);
|
|
447
|
+
*
|
|
448
|
+
* // Add multiple reward types
|
|
449
|
+
* await sdk.campaigns.createCampaignTokenUnit('summer-promo', {
|
|
450
|
+
* tokenId: 'bonus-credits',
|
|
451
|
+
* amount: 100,
|
|
452
|
+
* type: 'BONUS'
|
|
453
|
+
* });
|
|
454
|
+
* ```
|
|
96
455
|
*/
|
|
97
456
|
createCampaignTokenUnit(campaignId: string, tokenUnit: TokenUnitCreateRequestDTO): Promise<CampaignDTO>;
|
|
98
457
|
/**
|
|
99
458
|
* Admin: Delete campaign token unit
|
|
100
459
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
460
|
+
* Removes a token reward unit from a campaign. This affects future claims
|
|
461
|
+
* but does not impact rewards that have already been distributed. Requires
|
|
462
|
+
* administrator privileges.
|
|
463
|
+
*
|
|
464
|
+
* @param campaignId - ID of the campaign
|
|
465
|
+
* @param tokenUnitId - ID of the token unit to remove
|
|
466
|
+
* @returns Promise resolving to updated campaign data
|
|
467
|
+
* @throws {PersApiError} When not authenticated as admin or entities not found
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* // Admin operation - remove token unit from campaign
|
|
472
|
+
* const updated = await sdk.campaigns.deleteCampaignTokenUnit(
|
|
473
|
+
* 'summer-promo',
|
|
474
|
+
* 'token-unit-123'
|
|
475
|
+
* );
|
|
476
|
+
*
|
|
477
|
+
* console.log('Token unit removed from campaign');
|
|
478
|
+
* console.log('Remaining reward units:', updated.tokenUnits?.length);
|
|
479
|
+
* ```
|
|
104
480
|
*/
|
|
105
481
|
deleteCampaignTokenUnit(campaignId: string, tokenUnitId: string): Promise<CampaignDTO>;
|
|
106
482
|
/**
|
|
107
483
|
* Admin: Add business engagement to campaign
|
|
108
484
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
485
|
+
* Associates a business partner with a campaign, enabling the business to
|
|
486
|
+
* participate in the campaign and allowing users to claim rewards through
|
|
487
|
+
* that business. Requires administrator privileges.
|
|
488
|
+
*
|
|
489
|
+
* @param campaignId - ID of the campaign
|
|
490
|
+
* @param engagement - Business engagement configuration
|
|
491
|
+
* @returns Promise resolving to updated campaign data
|
|
492
|
+
* @throws {PersApiError} When not authenticated as admin or validation fails
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* // Admin operation - add business partner to campaign
|
|
497
|
+
* const updated = await sdk.campaigns.addBusinessEngagementToCampaign('summer-promo', {
|
|
498
|
+
* businessId: 'partner-hotel-123',
|
|
499
|
+
* engagementType: 'PROMOTION_PARTNER',
|
|
500
|
+
* isActive: true,
|
|
501
|
+
* startDate: '2024-06-01',
|
|
502
|
+
* endDate: '2024-08-31'
|
|
503
|
+
* });
|
|
504
|
+
*
|
|
505
|
+
* console.log('Business partner added to campaign');
|
|
506
|
+
* console.log('Partner businesses:', updated.businessEngagements?.length);
|
|
507
|
+
* ```
|
|
112
508
|
*/
|
|
113
509
|
addBusinessEngagementToCampaign(campaignId: string, engagement: CampaignBusinessEngagementCreateRequestDTO): Promise<CampaignDTO>;
|
|
114
510
|
/**
|
|
115
511
|
* Admin: Update campaign business engagement
|
|
116
512
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @
|
|
513
|
+
* Updates an existing business engagement within a campaign, modifying
|
|
514
|
+
* participation parameters, dates, or status. Requires administrator privileges.
|
|
515
|
+
*
|
|
516
|
+
* @param campaignId - ID of the campaign
|
|
517
|
+
* @param engagementId - ID of the engagement to update
|
|
518
|
+
* @param engagement - Updated engagement configuration
|
|
519
|
+
* @returns Promise resolving to updated campaign data
|
|
520
|
+
* @throws {PersApiError} When not authenticated as admin or entities not found
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```typescript
|
|
524
|
+
* // Admin operation - update business engagement terms
|
|
525
|
+
* const updated = await sdk.campaigns.updateCampaignBusinessEngagement(
|
|
526
|
+
* 'summer-promo',
|
|
527
|
+
* 'engagement-456',
|
|
528
|
+
* {
|
|
529
|
+
* engagementType: 'PREMIUM_PARTNER',
|
|
530
|
+
* isActive: true,
|
|
531
|
+
* endDate: '2024-09-30' // Extended participation
|
|
532
|
+
* }
|
|
533
|
+
* );
|
|
534
|
+
*
|
|
535
|
+
* console.log('Business engagement updated');
|
|
536
|
+
* ```
|
|
121
537
|
*/
|
|
122
538
|
updateCampaignBusinessEngagement(campaignId: string, engagementId: string, engagement: CampaignBusinessEngagementCreateRequestDTO): Promise<CampaignDTO>;
|
|
123
539
|
/**
|
|
124
540
|
* Admin: Delete campaign business engagement
|
|
125
541
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
542
|
+
* Removes a business engagement from a campaign, ending the business's
|
|
543
|
+
* participation in the campaign. Existing claims through this business
|
|
544
|
+
* remain valid. Requires administrator privileges.
|
|
545
|
+
*
|
|
546
|
+
* @param campaignId - ID of the campaign
|
|
547
|
+
* @param engagementId - ID of the engagement to remove
|
|
548
|
+
* @returns Promise resolving to updated campaign data
|
|
549
|
+
* @throws {PersApiError} When not authenticated as admin or entities not found
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```typescript
|
|
553
|
+
* // Admin operation - remove business from campaign
|
|
554
|
+
* const updated = await sdk.campaigns.deleteCampaignBusinessEngagement(
|
|
555
|
+
* 'summer-promo',
|
|
556
|
+
* 'engagement-456'
|
|
557
|
+
* );
|
|
558
|
+
*
|
|
559
|
+
* console.log('Business engagement removed');
|
|
560
|
+
* console.log('Remaining partners:', updated.businessEngagements?.length);
|
|
561
|
+
* ```
|
|
129
562
|
*/
|
|
130
563
|
deleteCampaignBusinessEngagement(campaignId: string, engagementId: string): Promise<CampaignDTO>;
|
|
131
564
|
/**
|
|
132
565
|
* Admin: Get all campaign claims
|
|
133
566
|
*
|
|
134
|
-
*
|
|
567
|
+
* Retrieves all campaign claims across the system for comprehensive reporting
|
|
568
|
+
* and analytics. This operation requires administrator privileges and provides
|
|
569
|
+
* system-wide visibility into campaign performance and user engagement.
|
|
570
|
+
*
|
|
571
|
+
* @returns Promise resolving to array of all campaign claims
|
|
572
|
+
* @throws {PersApiError} When not authenticated as administrator
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* // Admin operation - get campaign performance data
|
|
577
|
+
* const allClaims = await sdk.campaigns.getCampaignClaims();
|
|
578
|
+
*
|
|
579
|
+
* console.log(`📊 Campaign Performance Report:`);
|
|
580
|
+
* console.log(`Total claims: ${allClaims.length}`);
|
|
581
|
+
*
|
|
582
|
+
* // Analyze claims by campaign
|
|
583
|
+
* const claimsByCampaign = allClaims.reduce((acc, claim) => {
|
|
584
|
+
* const campaignId = claim.campaignId;
|
|
585
|
+
* acc[campaignId] = (acc[campaignId] || 0) + 1;
|
|
586
|
+
* return acc;
|
|
587
|
+
* }, {});
|
|
588
|
+
*
|
|
589
|
+
* console.log('\nClaims by Campaign:');
|
|
590
|
+
* Object.entries(claimsByCampaign).forEach(([campaignId, count]) => {
|
|
591
|
+
* console.log(`${campaignId}: ${count} claims`);
|
|
592
|
+
* });
|
|
593
|
+
* ```
|
|
135
594
|
*/
|
|
136
595
|
getCampaignClaims(): Promise<CampaignClaimDTO[]>;
|
|
137
596
|
/**
|
|
138
597
|
* Admin: Get campaign claims by user ID
|
|
139
598
|
*
|
|
140
|
-
*
|
|
599
|
+
* Retrieves all campaign claims for a specific user. This operation requires
|
|
600
|
+
* administrator privileges and is used for user support, account analysis,
|
|
601
|
+
* and individual user engagement tracking.
|
|
602
|
+
*
|
|
603
|
+
* @param userId - ID of the user to get claims for
|
|
141
604
|
* @returns Promise resolving to array of user's campaign claims
|
|
605
|
+
* @throws {PersApiError} When not authenticated as admin or user not found
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```typescript
|
|
609
|
+
* // Admin operation - analyze user's campaign participation
|
|
610
|
+
* const userClaims = await sdk.campaigns.getCampaignClaimsByUserId('user-123');
|
|
611
|
+
*
|
|
612
|
+
* console.log(`User Campaign Activity:`);
|
|
613
|
+
* console.log(`Total campaigns claimed: ${userClaims.length}`);
|
|
614
|
+
*
|
|
615
|
+
* userClaims.forEach((claim, index) => {
|
|
616
|
+
* console.log(`\n${index + 1}. ${claim.campaign.title}`);
|
|
617
|
+
* console.log(` Date: ${claim.claimedAt}`);
|
|
618
|
+
* console.log(` Business: ${claim.business?.displayName || 'Direct'}`);
|
|
619
|
+
* console.log(` Rewards: ${claim.rewards?.length || 0} items`);
|
|
620
|
+
* });
|
|
621
|
+
*
|
|
622
|
+
* // Calculate user engagement metrics
|
|
623
|
+
* const totalRewards = userClaims.reduce((sum, claim) =>
|
|
624
|
+
* sum + (claim.rewards?.length || 0), 0
|
|
625
|
+
* );
|
|
626
|
+
* console.log(`\nTotal rewards earned: ${totalRewards}`);
|
|
627
|
+
* ```
|
|
142
628
|
*/
|
|
143
629
|
getCampaignClaimsByUserId(userId: string): Promise<CampaignClaimDTO[]>;
|
|
144
630
|
/**
|
|
145
631
|
* Admin: Get campaign claims by business ID
|
|
146
632
|
*
|
|
147
|
-
*
|
|
633
|
+
* Retrieves all campaign claims processed through a specific business partner.
|
|
634
|
+
* This operation requires administrator privileges and is used for business
|
|
635
|
+
* partnership analysis and performance tracking.
|
|
636
|
+
*
|
|
637
|
+
* @param businessId - ID of the business to get claims for
|
|
148
638
|
* @returns Promise resolving to array of business's campaign claims
|
|
639
|
+
* @throws {PersApiError} When not authenticated as admin or business not found
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```typescript
|
|
643
|
+
* // Admin operation - analyze business partnership performance
|
|
644
|
+
* const businessClaims = await sdk.campaigns.getCampaignClaimsByBusinessId('partner-hotel-123');
|
|
645
|
+
*
|
|
646
|
+
* console.log(`Business Partnership Analysis:`);
|
|
647
|
+
* console.log(`Claims processed: ${businessClaims.length}`);
|
|
648
|
+
*
|
|
649
|
+
* // Analyze claims by campaign
|
|
650
|
+
* const claimsByCampaign = businessClaims.reduce((acc, claim) => {
|
|
651
|
+
* const title = claim.campaign.title;
|
|
652
|
+
* acc[title] = (acc[title] || 0) + 1;
|
|
653
|
+
* return acc;
|
|
654
|
+
* }, {});
|
|
655
|
+
*
|
|
656
|
+
* console.log('\nCampaign Performance:');
|
|
657
|
+
* Object.entries(claimsByCampaign).forEach(([campaign, count]) => {
|
|
658
|
+
* console.log(`${campaign}: ${count} claims`);
|
|
659
|
+
* });
|
|
660
|
+
*
|
|
661
|
+
* // Calculate partnership value
|
|
662
|
+
* const totalRewardsDistributed = businessClaims.reduce((sum, claim) =>
|
|
663
|
+
* sum + (claim.rewards?.length || 0), 0
|
|
664
|
+
* );
|
|
665
|
+
* console.log(`\nTotal rewards distributed: ${totalRewardsDistributed}`);
|
|
666
|
+
* ```
|
|
149
667
|
*/
|
|
150
668
|
getCampaignClaimsByBusinessId(businessId: string): Promise<CampaignClaimDTO[]>;
|
|
151
669
|
/**
|
|
152
|
-
* Get the full campaign
|
|
670
|
+
* Get the full campaign service for advanced operations
|
|
671
|
+
*
|
|
672
|
+
* Provides access to the complete CampaignService instance for advanced campaign
|
|
673
|
+
* operations, custom triggers, analytics, and operations not covered by the
|
|
674
|
+
* high-level manager methods.
|
|
675
|
+
*
|
|
676
|
+
* @returns CampaignService instance with full API access
|
|
677
|
+
*
|
|
678
|
+
* @example Advanced Operations
|
|
679
|
+
* ```typescript
|
|
680
|
+
* const campaignService = sdk.campaigns.getCampaignService();
|
|
681
|
+
*
|
|
682
|
+
* // Access advanced campaign analytics
|
|
683
|
+
* const analytics = await campaignService.getCampaignAnalytics('campaign-123');
|
|
684
|
+
*
|
|
685
|
+
* // Access custom trigger management
|
|
686
|
+
* const customTriggers = await campaignService.getCustomTriggers();
|
|
687
|
+
*
|
|
688
|
+
* // Access campaign API directly
|
|
689
|
+
* const campaignApi = campaignService.api;
|
|
153
690
|
*
|
|
154
|
-
*
|
|
691
|
+
* // Use advanced claim validation
|
|
692
|
+
* const eligibility = await campaignService.validateClaimEligibility('user-123', 'campaign-456');
|
|
693
|
+
* ```
|
|
155
694
|
*/
|
|
156
|
-
|
|
695
|
+
getCampaignService(): CampaignService;
|
|
157
696
|
}
|
|
158
697
|
//# sourceMappingURL=campaign-manager.d.ts.map
|