@open-loyalty/mcp-server 1.0.3 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -177
- package/dist/auth/provider.js +2 -14
- package/dist/auth/storage.js +22 -0
- package/dist/client/http.d.ts +5 -0
- package/dist/client/http.js +62 -3
- package/dist/config.d.ts +6 -5
- package/dist/config.js +15 -11
- package/dist/http.js +170 -65
- package/dist/instructions.d.ts +5 -0
- package/dist/instructions.js +420 -0
- package/dist/prompts/fan-engagement-setup.d.ts +107 -0
- package/dist/prompts/fan-engagement-setup.js +492 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +68 -278
- package/dist/tools/achievement/handlers.d.ts +117 -0
- package/dist/tools/achievement/handlers.js +161 -0
- package/dist/tools/achievement/index.d.ts +479 -0
- package/dist/tools/achievement/index.js +74 -0
- package/dist/tools/achievement/schemas.d.ts +433 -0
- package/dist/tools/achievement/schemas.js +142 -0
- package/dist/tools/achievement.d.ts +155 -121
- package/dist/tools/achievement.js +82 -39
- package/dist/tools/admin.d.ts +18 -6
- package/dist/tools/admin.js +24 -12
- package/dist/tools/analytics.d.ts +29 -11
- package/dist/tools/analytics.js +58 -48
- package/dist/tools/apikey.d.ts +10 -3
- package/dist/tools/apikey.js +13 -6
- package/dist/tools/audit.d.ts +6 -2
- package/dist/tools/audit.js +8 -4
- package/dist/tools/badge.d.ts +14 -6
- package/dist/tools/badge.js +36 -27
- package/dist/tools/campaign/handlers.d.ts +42 -0
- package/dist/tools/campaign/handlers.js +223 -0
- package/dist/tools/campaign/index.d.ts +783 -0
- package/dist/tools/campaign/index.js +112 -0
- package/dist/tools/campaign/member-handlers.d.ts +60 -0
- package/dist/tools/campaign/member-handlers.js +159 -0
- package/dist/tools/campaign/schemas.d.ts +704 -0
- package/dist/tools/campaign/schemas.js +259 -0
- package/dist/tools/campaign/types.d.ts +161 -0
- package/dist/tools/campaign/types.js +2 -0
- package/dist/tools/campaign.d.ts +41 -16
- package/dist/tools/campaign.js +38 -25
- package/dist/tools/custom-event.d.ts +315 -0
- package/dist/tools/custom-event.js +270 -0
- package/dist/tools/export.d.ts +12 -4
- package/dist/tools/export.js +25 -20
- package/dist/tools/import.d.ts +9 -3
- package/dist/tools/import.js +33 -21
- package/dist/tools/index.d.ts +3 -11
- package/dist/tools/index.js +17 -475
- package/dist/tools/member/handlers.d.ts +111 -0
- package/dist/tools/member/handlers.js +206 -0
- package/dist/tools/member/index.d.ts +169 -0
- package/dist/tools/member/index.js +92 -0
- package/dist/tools/member/schemas.d.ts +89 -0
- package/dist/tools/member/schemas.js +65 -0
- package/dist/tools/member.d.ts +21 -0
- package/dist/tools/member.js +56 -62
- package/dist/tools/points.d.ts +19 -6
- package/dist/tools/points.js +51 -49
- package/dist/tools/referral/handlers.d.ts +47 -0
- package/dist/tools/referral/handlers.js +115 -0
- package/dist/tools/referral/index.d.ts +44 -0
- package/dist/tools/referral/index.js +44 -0
- package/dist/tools/referral/schemas.d.ts +34 -0
- package/dist/tools/referral/schemas.js +52 -0
- package/dist/tools/reward/handlers.d.ts +110 -0
- package/dist/tools/reward/handlers.js +289 -0
- package/dist/tools/reward/index.d.ts +177 -0
- package/dist/tools/reward/index.js +90 -0
- package/dist/tools/reward/schemas.d.ts +116 -0
- package/dist/tools/reward/schemas.js +91 -0
- package/dist/tools/reward.d.ts +18 -0
- package/dist/tools/reward.js +56 -66
- package/dist/tools/role.d.ts +26 -7
- package/dist/tools/role.js +25 -12
- package/dist/tools/segment/handlers.d.ts +87 -0
- package/dist/tools/segment/handlers.js +174 -0
- package/dist/tools/segment/index.d.ts +395 -0
- package/dist/tools/segment/index.js +87 -0
- package/dist/tools/segment/schemas.d.ts +337 -0
- package/dist/tools/segment/schemas.js +79 -0
- package/dist/tools/segment.d.ts +29 -10
- package/dist/tools/segment.js +84 -50
- package/dist/tools/store.d.ts +12 -4
- package/dist/tools/store.js +16 -8
- package/dist/tools/tierset.d.ts +19 -7
- package/dist/tools/tierset.js +44 -35
- package/dist/tools/transaction.d.ts +16 -8
- package/dist/tools/transaction.js +25 -21
- package/dist/tools/wallet-type.d.ts +7 -3
- package/dist/tools/wallet-type.js +14 -12
- package/dist/tools/webhook.d.ts +23 -10
- package/dist/tools/webhook.js +135 -33
- package/dist/types/schemas/achievement.d.ts +12 -309
- package/dist/types/schemas/achievement.js +0 -13
- package/dist/types/schemas/admin.d.ts +10 -97
- package/dist/types/schemas/admin.js +0 -38
- package/dist/types/schemas/badge.d.ts +0 -37
- package/dist/types/schemas/badge.js +0 -11
- package/dist/types/schemas/campaign.d.ts +64 -832
- package/dist/types/schemas/campaign.js +2 -25
- package/dist/types/schemas/common.d.ts +5 -0
- package/dist/types/schemas/common.js +5 -0
- package/dist/types/schemas/export.d.ts +0 -17
- package/dist/types/schemas/export.js +0 -7
- package/dist/types/schemas/member.d.ts +37 -176
- package/dist/types/schemas/member.js +0 -27
- package/dist/types/schemas/points.d.ts +0 -63
- package/dist/types/schemas/points.js +0 -22
- package/dist/types/schemas/reward.d.ts +71 -68
- package/dist/types/schemas/reward.js +8 -28
- package/dist/types/schemas/role.d.ts +0 -100
- package/dist/types/schemas/role.js +0 -29
- package/dist/types/schemas/segment.d.ts +0 -58
- package/dist/types/schemas/segment.js +0 -17
- package/dist/types/schemas/tierset.d.ts +0 -176
- package/dist/types/schemas/tierset.js +0 -27
- package/dist/types/schemas/transaction.d.ts +23 -254
- package/dist/types/schemas/transaction.js +0 -7
- package/dist/types/schemas/wallet-type.d.ts +8 -8
- package/dist/types/schemas/wallet-type.js +1 -1
- package/dist/types/schemas/webhook.d.ts +0 -58
- package/dist/types/schemas/webhook.js +0 -12
- package/dist/utils/errors.js +30 -3
- package/dist/utils/payload.d.ts +12 -0
- package/dist/utils/payload.js +14 -0
- package/dist/workflows/app-login-streak.d.ts +39 -0
- package/dist/workflows/app-login-streak.js +298 -0
- package/dist/workflows/early-arrival.d.ts +33 -0
- package/dist/workflows/early-arrival.js +148 -0
- package/dist/workflows/index.d.ts +101 -0
- package/dist/workflows/index.js +208 -0
- package/dist/workflows/match-attendance.d.ts +45 -0
- package/dist/workflows/match-attendance.js +308 -0
- package/dist/workflows/sportsbar-visit.d.ts +41 -0
- package/dist/workflows/sportsbar-visit.js +284 -0
- package/dist/workflows/vod-watching.d.ts +43 -0
- package/dist/workflows/vod-watching.js +326 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -236,154 +236,154 @@ npm run typecheck
|
|
|
236
236
|
## Available Tools (112 total)
|
|
237
237
|
|
|
238
238
|
### Wallet Types (2 tools)
|
|
239
|
-
- `
|
|
240
|
-
- `
|
|
239
|
+
- `ol_wallet_type_list` - List all wallet types (point currencies)
|
|
240
|
+
- `ol_wallet_type_get` - Get details for a specific wallet type
|
|
241
241
|
|
|
242
242
|
### Tier Sets (6 tools)
|
|
243
|
-
- `
|
|
244
|
-
- `
|
|
245
|
-
- `
|
|
246
|
-
- `
|
|
247
|
-
- `
|
|
248
|
-
- `
|
|
243
|
+
- `ol_tierset_list` - List all tier sets
|
|
244
|
+
- `ol_tierset_create` - Create a new tier set
|
|
245
|
+
- `ol_tierset_get` - Get tier set details with condition IDs
|
|
246
|
+
- `ol_tierset_update` - Update tier set metadata
|
|
247
|
+
- `ol_tierset_update_tiers` - Define tier thresholds
|
|
248
|
+
- `ol_tierset_get_tiers` - Get all tiers in a tier set
|
|
249
249
|
|
|
250
250
|
### Members (10 tools)
|
|
251
|
-
- `
|
|
252
|
-
- `
|
|
253
|
-
- `
|
|
254
|
-
- `
|
|
255
|
-
- `
|
|
256
|
-
- `
|
|
257
|
-
- `
|
|
258
|
-
- `
|
|
259
|
-
- `
|
|
260
|
-
- `
|
|
251
|
+
- `ol_member_create` - Register a new loyalty program member
|
|
252
|
+
- `ol_member_get` - Get member details including profile, points balance, and tier status
|
|
253
|
+
- `ol_member_list` - Search and list members with optional filters
|
|
254
|
+
- `ol_member_update` - Update member profile fields
|
|
255
|
+
- `ol_member_activate` - Activate a deactivated member
|
|
256
|
+
- `ol_member_deactivate` - Deactivate an active member
|
|
257
|
+
- `ol_member_delete` - Permanently remove member (GDPR compliance)
|
|
258
|
+
- `ol_member_get_tier_progress` - Get tier progression status
|
|
259
|
+
- `ol_member_assign_tier` - Manually assign tier to member
|
|
260
|
+
- `ol_member_remove_manual_tier` - Remove manual tier assignment
|
|
261
261
|
|
|
262
262
|
### Points (6 tools)
|
|
263
|
-
- `
|
|
264
|
-
- `
|
|
265
|
-
- `
|
|
266
|
-
- `
|
|
267
|
-
- `
|
|
268
|
-
- `
|
|
263
|
+
- `ol_points_add` - Add points to member wallet (with optional expiration/lock)
|
|
264
|
+
- `ol_points_spend` - Deduct points from member wallet
|
|
265
|
+
- `ol_points_transfer` - Transfer points between members (P2P)
|
|
266
|
+
- `ol_points_get_balance` - Get member points balance breakdown
|
|
267
|
+
- `ol_points_get_history` - Get points transaction history
|
|
268
|
+
- `ol_points_get_histogram` - Get points histogram for visualization
|
|
269
269
|
|
|
270
270
|
### Rewards (9 tools)
|
|
271
|
-
- `
|
|
272
|
-
- `
|
|
273
|
-
- `
|
|
274
|
-
- `
|
|
275
|
-
- `
|
|
276
|
-
- `
|
|
277
|
-
- `
|
|
278
|
-
- `
|
|
279
|
-
- `
|
|
271
|
+
- `ol_reward_list` - List available rewards
|
|
272
|
+
- `ol_reward_create` - Create a new reward
|
|
273
|
+
- `ol_reward_get` - Get reward details
|
|
274
|
+
- `ol_reward_update` - Update reward configuration
|
|
275
|
+
- `ol_reward_activate` - Activate a reward
|
|
276
|
+
- `ol_reward_deactivate` - Deactivate a reward
|
|
277
|
+
- `ol_reward_buy` - Purchase reward for member (deducts points)
|
|
278
|
+
- `ol_reward_redeem` - Mark coupon as used
|
|
279
|
+
- `ol_reward_category_list` - List reward categories
|
|
280
280
|
|
|
281
281
|
### Transactions (4 tools)
|
|
282
|
-
- `
|
|
283
|
-
- `
|
|
284
|
-
- `
|
|
285
|
-
- `
|
|
282
|
+
- `ol_transaction_create` - Record a purchase transaction
|
|
283
|
+
- `ol_transaction_get` - Get transaction details
|
|
284
|
+
- `ol_transaction_list` - List transactions with filters
|
|
285
|
+
- `ol_transaction_assign_member` - Assign unmatched transaction to member
|
|
286
286
|
|
|
287
287
|
### Campaigns (12 tools)
|
|
288
|
-
- `
|
|
289
|
-
- `
|
|
290
|
-
- `
|
|
291
|
-
- `
|
|
292
|
-
- `
|
|
293
|
-
- `
|
|
294
|
-
- `
|
|
295
|
-
- `
|
|
296
|
-
- `
|
|
297
|
-
- `
|
|
298
|
-
- `
|
|
299
|
-
- `
|
|
288
|
+
- `ol_campaign_list` - List all campaigns with optional filters
|
|
289
|
+
- `ol_campaign_create` - Create campaign to automate engagement
|
|
290
|
+
- `ol_campaign_get` - Get full campaign configuration
|
|
291
|
+
- `ol_campaign_update` - Update campaign (full replacement)
|
|
292
|
+
- `ol_campaign_patch` - Patch campaign (active/displayOrder only)
|
|
293
|
+
- `ol_campaign_delete` - Permanently delete a campaign
|
|
294
|
+
- `ol_campaign_simulate` - Preview campaign effects without executing
|
|
295
|
+
- `ol_campaign_generate_codes` - Generate redemption codes
|
|
296
|
+
- `ol_campaign_list_codes` - List redemption codes
|
|
297
|
+
- `ol_campaign_get_available` - Get campaigns available for member
|
|
298
|
+
- `ol_campaign_get_visible` - Get campaigns visible to member
|
|
299
|
+
- `ol_campaign_get_leaderboard` - Get campaign leaderboard
|
|
300
300
|
|
|
301
301
|
### Segments (9 tools)
|
|
302
|
-
- `
|
|
303
|
-
- `
|
|
304
|
-
- `
|
|
305
|
-
- `
|
|
306
|
-
- `
|
|
307
|
-
- `
|
|
308
|
-
- `
|
|
309
|
-
- `
|
|
310
|
-
- `
|
|
302
|
+
- `ol_segment_list` - List customer segments
|
|
303
|
+
- `ol_segment_create` - Create segment to group members
|
|
304
|
+
- `ol_segment_get` - Get segment details with criteria
|
|
305
|
+
- `ol_segment_update` - Update segment configuration
|
|
306
|
+
- `ol_segment_delete` - Permanently delete a segment
|
|
307
|
+
- `ol_segment_get_members` - Get members matching segment
|
|
308
|
+
- `ol_segment_activate` - Activate a segment
|
|
309
|
+
- `ol_segment_deactivate` - Deactivate a segment
|
|
310
|
+
- `ol_segment_get_resources` - Get resources associated with segment
|
|
311
311
|
|
|
312
312
|
### Achievements (7 tools)
|
|
313
|
-
- `
|
|
314
|
-
- `
|
|
315
|
-
- `
|
|
316
|
-
- `
|
|
317
|
-
- `
|
|
318
|
-
- `
|
|
319
|
-
- `
|
|
313
|
+
- `ol_achievement_list` - List achievements
|
|
314
|
+
- `ol_achievement_create` - Create achievement for gamification
|
|
315
|
+
- `ol_achievement_get` - Get achievement details
|
|
316
|
+
- `ol_achievement_update` - Update achievement (full replacement)
|
|
317
|
+
- `ol_achievement_patch` - Patch achievement (active/displayOrder)
|
|
318
|
+
- `ol_achievement_get_member_progress` - Get member's progress on achievement
|
|
319
|
+
- `ol_achievement_list_member_achievements` - List member's achievements
|
|
320
320
|
|
|
321
321
|
### Badges (4 tools)
|
|
322
|
-
- `
|
|
323
|
-
- `
|
|
324
|
-
- `
|
|
325
|
-
- `
|
|
322
|
+
- `ol_badge_list` - List badge types
|
|
323
|
+
- `ol_badge_get` - Get badge type details
|
|
324
|
+
- `ol_badge_update` - Update badge type configuration
|
|
325
|
+
- `ol_badge_get_member_badges` - Get badges earned by member
|
|
326
326
|
|
|
327
327
|
### Analytics (9 tools)
|
|
328
|
-
- `
|
|
329
|
-
- `
|
|
330
|
-
- `
|
|
331
|
-
- `
|
|
332
|
-
- `
|
|
333
|
-
- `
|
|
334
|
-
- `
|
|
335
|
-
- `
|
|
336
|
-
- `
|
|
328
|
+
- `ol_analytics_tiers` - Get tier distribution with member counts
|
|
329
|
+
- `ol_analytics_members` - Get member statistics (new, active, inactive)
|
|
330
|
+
- `ol_analytics_points` - Get points statistics (issued, spent, expired)
|
|
331
|
+
- `ol_analytics_transactions` - Get transaction statistics
|
|
332
|
+
- `ol_analytics_referrals` - Get referral program statistics
|
|
333
|
+
- `ol_analytics_campaigns` - Get campaign performance metrics
|
|
334
|
+
- `ol_analytics_dashboard` - Get dashboard overview metrics
|
|
335
|
+
- `ol_analytics_units` - Get wallet-specific metrics
|
|
336
|
+
- `ol_analytics_campaign_detail` - Get detailed campaign analytics
|
|
337
337
|
|
|
338
338
|
### Admin Users (6 tools)
|
|
339
|
-
- `
|
|
340
|
-
- `
|
|
341
|
-
- `
|
|
342
|
-
- `
|
|
343
|
-
- `
|
|
344
|
-
- `
|
|
339
|
+
- `ol_admin_list` - List admin users
|
|
340
|
+
- `ol_admin_create` - Create admin user
|
|
341
|
+
- `ol_admin_get` - Get admin user details
|
|
342
|
+
- `ol_admin_update` - Update admin user profile
|
|
343
|
+
- `ol_admin_change_password` - Change admin password
|
|
344
|
+
- `ol_admin_get_permissions` - Get admin permissions
|
|
345
345
|
|
|
346
346
|
### Roles/ACL (6 tools)
|
|
347
|
-
- `
|
|
348
|
-
- `
|
|
349
|
-
- `
|
|
350
|
-
- `
|
|
351
|
-
- `
|
|
352
|
-
- `
|
|
347
|
+
- `ol_role_list` - List roles
|
|
348
|
+
- `ol_role_create` - Create role with permissions
|
|
349
|
+
- `ol_role_get` - Get role details
|
|
350
|
+
- `ol_role_update` - Update role
|
|
351
|
+
- `ol_role_delete` - Delete role
|
|
352
|
+
- `ol_acl_get_resources` - Get available ACL resources and actions
|
|
353
353
|
|
|
354
354
|
### API Keys (3 tools)
|
|
355
|
-
- `
|
|
356
|
-
- `
|
|
357
|
-
- `
|
|
355
|
+
- `ol_apikey_create` - Create API key (token shown once!)
|
|
356
|
+
- `ol_apikey_list` - List API keys for admin
|
|
357
|
+
- `ol_apikey_delete` - Delete API key
|
|
358
358
|
|
|
359
359
|
### Audit Logs (2 tools)
|
|
360
|
-
- `
|
|
361
|
-
- `
|
|
360
|
+
- `ol_audit_list` - List audit log entries
|
|
361
|
+
- `ol_audit_export` - Export audit logs
|
|
362
362
|
|
|
363
363
|
### Stores (4 tools)
|
|
364
|
-
- `
|
|
365
|
-
- `
|
|
366
|
-
- `
|
|
367
|
-
- `
|
|
364
|
+
- `ol_store_list` - List stores
|
|
365
|
+
- `ol_store_create` - Create store for multi-tenancy
|
|
366
|
+
- `ol_store_get` - Get store details
|
|
367
|
+
- `ol_store_update` - Update store configuration
|
|
368
368
|
|
|
369
369
|
### Webhooks (6 tools)
|
|
370
|
-
- `
|
|
371
|
-
- `
|
|
372
|
-
- `
|
|
373
|
-
- `
|
|
374
|
-
- `
|
|
375
|
-
- `
|
|
370
|
+
- `ol_webhook_list` - List webhook subscriptions
|
|
371
|
+
- `ol_webhook_create` - Create webhook subscription for event notifications
|
|
372
|
+
- `ol_webhook_get` - Get webhook subscription details
|
|
373
|
+
- `ol_webhook_update` - Update webhook subscription
|
|
374
|
+
- `ol_webhook_delete` - Delete webhook subscription
|
|
375
|
+
- `ol_webhook_events` - List available webhook event types
|
|
376
376
|
|
|
377
377
|
### Import (3 tools)
|
|
378
|
-
- `
|
|
379
|
-
- `
|
|
380
|
-
- `
|
|
378
|
+
- `ol_import_create` - Create bulk import from CSV
|
|
379
|
+
- `ol_import_list` - List imports with status
|
|
380
|
+
- `ol_import_get` - Get import details and item statuses
|
|
381
381
|
|
|
382
382
|
### Export (4 tools)
|
|
383
|
-
- `
|
|
384
|
-
- `
|
|
385
|
-
- `
|
|
386
|
-
- `
|
|
383
|
+
- `ol_export_create` - Create data export (async)
|
|
384
|
+
- `ol_export_list` - List exports with status
|
|
385
|
+
- `ol_export_get` - Get export status and details
|
|
386
|
+
- `ol_export_download` - Download export CSV (when status='done')
|
|
387
387
|
|
|
388
388
|
---
|
|
389
389
|
|
|
@@ -392,10 +392,11 @@ npm run typecheck
|
|
|
392
392
|
### 1. Create 3-Tier Loyalty Program
|
|
393
393
|
|
|
394
394
|
```
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
395
|
+
ol_wallet_type_list
|
|
396
|
+
// Note: conditions use `attribute` (not `type`) and walletType expects the wallet CODE (e.g., "default"), not the UUID.
|
|
397
|
+
ol_tierset_create({ name: "VIP Program", conditions: [{ attribute: "activeUnits", walletType: "points" }] })
|
|
398
|
+
ol_tierset_get({ tierSetId: "..." })
|
|
399
|
+
ol_tierset_update_tiers({
|
|
399
400
|
tierSetId: "...",
|
|
400
401
|
tiers: [
|
|
401
402
|
{ name: "Bronze", conditions: [{ conditionId: "xxx", value: 400 }] },
|
|
@@ -409,56 +410,56 @@ openloyalty_tierset_update_tiers({
|
|
|
409
410
|
|
|
410
411
|
```
|
|
411
412
|
// Register member
|
|
412
|
-
|
|
413
|
+
ol_member_create({ email: "john@example.com", firstName: "John", lastName: "Doe" })
|
|
413
414
|
|
|
414
415
|
// Add welcome bonus
|
|
415
|
-
|
|
416
|
+
ol_points_add({ memberId: "...", points: 100, comment: "Welcome bonus" })
|
|
416
417
|
|
|
417
418
|
// Record purchase (auto-earns points via campaigns)
|
|
418
|
-
|
|
419
|
+
ol_transaction_create({
|
|
419
420
|
header: { documentNumber: "INV-001", purchasedAt: "2024-01-15T10:00:00Z" },
|
|
420
421
|
items: [{ sku: "PROD-1", name: "Widget", grossValue: 99.99, category: "Electronics" }],
|
|
421
422
|
customerData: { email: "john@example.com" }
|
|
422
423
|
})
|
|
423
424
|
|
|
424
425
|
// Check tier progress
|
|
425
|
-
|
|
426
|
+
ol_member_get_tier_progress({ memberId: "..." })
|
|
426
427
|
```
|
|
427
428
|
|
|
428
429
|
### 3. Reward Redemption Flow
|
|
429
430
|
|
|
430
431
|
```
|
|
431
432
|
// List available rewards
|
|
432
|
-
|
|
433
|
+
ol_reward_list({ active: true })
|
|
433
434
|
|
|
434
435
|
// Check member balance
|
|
435
|
-
|
|
436
|
+
ol_points_get_balance({ memberId: "..." })
|
|
436
437
|
|
|
437
438
|
// Purchase reward (deducts points, returns coupon code)
|
|
438
|
-
|
|
439
|
+
ol_reward_buy({ rewardId: "...", memberId: "..." })
|
|
439
440
|
|
|
440
441
|
// Later: mark coupon as used
|
|
441
|
-
|
|
442
|
+
ol_reward_redeem({ memberId: "...", couponCode: "COUP-ABC123" })
|
|
442
443
|
```
|
|
443
444
|
|
|
444
445
|
### 4. Assign Unmatched Transaction
|
|
445
446
|
|
|
446
447
|
```
|
|
447
448
|
// Find unmatched transactions
|
|
448
|
-
|
|
449
|
+
ol_transaction_list({ matched: false })
|
|
449
450
|
|
|
450
451
|
// Assign to member (triggers point campaigns)
|
|
451
|
-
|
|
452
|
+
ol_transaction_assign_member({ documentNumber: "INV-999", loyaltyCardNumber: "CARD-123" })
|
|
452
453
|
```
|
|
453
454
|
|
|
454
455
|
### 5. Create Double Points Campaign for Gold Tier
|
|
455
456
|
|
|
456
457
|
```
|
|
457
458
|
// First, find the Gold tier level ID
|
|
458
|
-
|
|
459
|
+
ol_tierset_get_tiers({ tierSetId: "..." })
|
|
459
460
|
|
|
460
461
|
// Create a segment targeting Gold tier members
|
|
461
|
-
|
|
462
|
+
ol_segment_create({
|
|
462
463
|
name: "Gold Members",
|
|
463
464
|
parts: [{
|
|
464
465
|
criteria: [{
|
|
@@ -469,16 +470,17 @@ openloyalty_segment_create({
|
|
|
469
470
|
})
|
|
470
471
|
|
|
471
472
|
// Create campaign with double points effect
|
|
472
|
-
|
|
473
|
+
ol_campaign_create({
|
|
473
474
|
type: "direct",
|
|
474
475
|
trigger: "transaction",
|
|
475
476
|
translations: { en: { name: "Double Points for Gold", description: "Gold members earn 2x points" } },
|
|
477
|
+
// Required: activity.startsAt, rules[].name. Use effects[].effect (not type). pointsRule is a STRING expression (not an object).
|
|
476
478
|
activity: { startsAt: "2024-01-01T00:00:00Z" },
|
|
477
479
|
rules: [{
|
|
478
480
|
name: "Double points",
|
|
479
481
|
effects: [{
|
|
480
482
|
effect: "give_points",
|
|
481
|
-
pointsRule:
|
|
483
|
+
pointsRule: "transaction.grossValue * 2"
|
|
482
484
|
}]
|
|
483
485
|
}],
|
|
484
486
|
audience: {
|
|
@@ -489,7 +491,7 @@ openloyalty_campaign_create({
|
|
|
489
491
|
})
|
|
490
492
|
|
|
491
493
|
// Test the campaign before it triggers
|
|
492
|
-
|
|
494
|
+
ol_campaign_simulate({
|
|
493
495
|
trigger: "transaction",
|
|
494
496
|
transaction: { grossValue: 100 },
|
|
495
497
|
customer: { email: "gold-member@example.com" }
|
|
@@ -500,7 +502,7 @@ openloyalty_campaign_simulate({
|
|
|
500
502
|
|
|
501
503
|
```
|
|
502
504
|
// Create segment for members with 10+ transactions
|
|
503
|
-
|
|
505
|
+
ol_segment_create({
|
|
504
506
|
name: "VIP Customers",
|
|
505
507
|
description: "Members with 10 or more purchases",
|
|
506
508
|
parts: [{
|
|
@@ -513,17 +515,17 @@ openloyalty_segment_create({
|
|
|
513
515
|
})
|
|
514
516
|
|
|
515
517
|
// Check segment membership
|
|
516
|
-
|
|
518
|
+
ol_segment_get_members({ segmentId: "..." })
|
|
517
519
|
|
|
518
520
|
// Use for campaign targeting
|
|
519
|
-
|
|
521
|
+
ol_campaign_create({
|
|
520
522
|
type: "direct",
|
|
521
523
|
trigger: "transaction",
|
|
522
524
|
translations: { en: { name: "VIP Bonus" } },
|
|
523
525
|
activity: { startsAt: "2024-01-01T00:00:00Z" },
|
|
524
526
|
rules: [{
|
|
525
527
|
name: "VIP Bonus Points",
|
|
526
|
-
effects: [{ effect: "give_points", pointsRule:
|
|
528
|
+
effects: [{ effect: "give_points", pointsRule: "50" }]
|
|
527
529
|
}],
|
|
528
530
|
audience: { target: "segment", segments: ["vip-segment-id"] },
|
|
529
531
|
active: true
|
|
@@ -534,13 +536,15 @@ openloyalty_campaign_create({
|
|
|
534
536
|
|
|
535
537
|
```
|
|
536
538
|
// Create an achievement for making 5 purchases
|
|
537
|
-
|
|
539
|
+
ol_achievement_create({
|
|
538
540
|
translations: { en: { name: "Frequent Shopper", description: "Make 5 purchases" } },
|
|
539
541
|
rules: [{
|
|
542
|
+
type: "direct",
|
|
540
543
|
trigger: "transaction",
|
|
544
|
+
aggregation: { type: "quantity" },
|
|
541
545
|
completeRule: {
|
|
542
546
|
periodGoal: 5,
|
|
543
|
-
period: { type: "
|
|
547
|
+
period: { type: "day", consecutive: 1 }
|
|
544
548
|
}
|
|
545
549
|
}],
|
|
546
550
|
badgeTypeId: "shopper-badge-id",
|
|
@@ -548,11 +552,11 @@ openloyalty_achievement_create({
|
|
|
548
552
|
})
|
|
549
553
|
|
|
550
554
|
// Check member progress
|
|
551
|
-
|
|
555
|
+
ol_achievement_get_member_progress({ memberId: "...", achievementId: "..." })
|
|
552
556
|
|
|
553
557
|
// List all member achievements and badges
|
|
554
|
-
|
|
555
|
-
|
|
558
|
+
ol_achievement_list_member_achievements({ memberId: "..." })
|
|
559
|
+
ol_badge_get_member_badges({ memberId: "..." })
|
|
556
560
|
```
|
|
557
561
|
|
|
558
562
|
### 8. Segment Logic: OR vs AND
|
|
@@ -561,21 +565,20 @@ openloyalty_badge_get_member_badges({ memberId: "..." })
|
|
|
561
565
|
// Parts use OR logic - member matches if ANY part matches
|
|
562
566
|
// Criteria within parts use AND logic - must match ALL criteria in that part
|
|
563
567
|
|
|
564
|
-
// Example: (
|
|
565
|
-
|
|
568
|
+
// Example: (10+ transactions) OR (5-9 transactions)
|
|
569
|
+
ol_segment_create({
|
|
566
570
|
name: "High Value Members",
|
|
567
571
|
parts: [
|
|
568
572
|
{
|
|
569
|
-
// Part 1:
|
|
573
|
+
// Part 1: Frequent shoppers
|
|
570
574
|
criteria: [
|
|
571
|
-
{ type: "
|
|
572
|
-
{ type: "points_balance", min: 1000 }
|
|
575
|
+
{ type: "transaction_count", min: 10, max: 999999 }
|
|
573
576
|
]
|
|
574
577
|
},
|
|
575
578
|
{
|
|
576
|
-
// Part 2:
|
|
579
|
+
// Part 2: Moderately frequent shoppers (OR with Part 1)
|
|
577
580
|
criteria: [
|
|
578
|
-
{ type: "transaction_count", min:
|
|
581
|
+
{ type: "transaction_count", min: 5, max: 9 }
|
|
579
582
|
]
|
|
580
583
|
}
|
|
581
584
|
]
|
|
@@ -586,10 +589,10 @@ openloyalty_segment_create({
|
|
|
586
589
|
|
|
587
590
|
```
|
|
588
591
|
// Discover available ACL resources and actions
|
|
589
|
-
|
|
592
|
+
ol_acl_get_resources()
|
|
590
593
|
|
|
591
594
|
// Create a role with VIEW-only permissions
|
|
592
|
-
|
|
595
|
+
ol_role_create({
|
|
593
596
|
name: "Analyst",
|
|
594
597
|
permissions: [
|
|
595
598
|
{ resource: "ANALYTICS", access: "VIEW" },
|
|
@@ -600,7 +603,7 @@ openloyalty_role_create({
|
|
|
600
603
|
})
|
|
601
604
|
|
|
602
605
|
// Create admin with analyst role
|
|
603
|
-
|
|
606
|
+
ol_admin_create({
|
|
604
607
|
email: "analyst@company.com",
|
|
605
608
|
password: "SecurePass123!",
|
|
606
609
|
firstName: "Data",
|
|
@@ -613,10 +616,10 @@ openloyalty_admin_create({
|
|
|
613
616
|
|
|
614
617
|
```
|
|
615
618
|
// Get admin to create API key for
|
|
616
|
-
|
|
619
|
+
ol_admin_list({ email: "integration@company.com" })
|
|
617
620
|
|
|
618
621
|
// Create API key - CRITICAL: Save the token immediately!
|
|
619
|
-
|
|
622
|
+
ol_apikey_create({
|
|
620
623
|
adminId: "admin-uuid",
|
|
621
624
|
name: "CRM Integration Key",
|
|
622
625
|
expirationDate: "2025-12-31"
|
|
@@ -624,46 +627,46 @@ openloyalty_apikey_create({
|
|
|
624
627
|
// Response includes token that is ONLY shown once
|
|
625
628
|
|
|
626
629
|
// List API keys (tokens not shown)
|
|
627
|
-
|
|
630
|
+
ol_apikey_list({ adminId: "admin-uuid" })
|
|
628
631
|
```
|
|
629
632
|
|
|
630
633
|
### 11. Analyze Program Performance
|
|
631
634
|
|
|
632
635
|
```
|
|
633
636
|
// Get high-level dashboard metrics
|
|
634
|
-
|
|
637
|
+
ol_analytics_dashboard()
|
|
635
638
|
|
|
636
639
|
// Analyze tier distribution
|
|
637
|
-
|
|
640
|
+
ol_analytics_tiers({ dateFrom: "2024-01-01", dateTo: "2024-12-31" })
|
|
638
641
|
|
|
639
642
|
// Check points economy
|
|
640
|
-
|
|
643
|
+
ol_analytics_points({ dateFrom: "2024-01-01", dateTo: "2024-12-31" })
|
|
641
644
|
|
|
642
645
|
// Analyze specific campaign
|
|
643
|
-
|
|
646
|
+
ol_analytics_campaign_detail({ campaignId: "campaign-uuid" })
|
|
644
647
|
|
|
645
648
|
// Get wallet-specific metrics
|
|
646
|
-
|
|
649
|
+
ol_analytics_units({ walletTypeCode: "points" })
|
|
647
650
|
```
|
|
648
651
|
|
|
649
652
|
### 12. Audit User Actions
|
|
650
653
|
|
|
651
654
|
```
|
|
652
655
|
// List recent audit entries
|
|
653
|
-
|
|
656
|
+
ol_audit_list({ perPage: 50 })
|
|
654
657
|
|
|
655
658
|
// Filter by specific user
|
|
656
|
-
|
|
659
|
+
ol_audit_list({ username: "admin@company.com" })
|
|
657
660
|
|
|
658
661
|
// Filter by entity type and date range
|
|
659
|
-
|
|
662
|
+
ol_audit_list({
|
|
660
663
|
entityType: "MEMBER",
|
|
661
664
|
dateFrom: "2024-01-01",
|
|
662
665
|
dateTo: "2024-01-31"
|
|
663
666
|
})
|
|
664
667
|
|
|
665
668
|
// Export audit logs for compliance
|
|
666
|
-
|
|
669
|
+
ol_audit_export({
|
|
667
670
|
dateFrom: "2024-01-01",
|
|
668
671
|
dateTo: "2024-12-31"
|
|
669
672
|
})
|
|
@@ -673,7 +676,7 @@ openloyalty_audit_export({
|
|
|
673
676
|
|
|
674
677
|
```
|
|
675
678
|
// Create a new store for a region
|
|
676
|
-
|
|
679
|
+
ol_store_create({
|
|
677
680
|
code: "EU",
|
|
678
681
|
name: "European Store",
|
|
679
682
|
currency: "EUR",
|
|
@@ -681,10 +684,10 @@ openloyalty_store_create({
|
|
|
681
684
|
})
|
|
682
685
|
|
|
683
686
|
// List all stores
|
|
684
|
-
|
|
687
|
+
ol_store_list()
|
|
685
688
|
|
|
686
689
|
// Use storeCode in subsequent operations
|
|
687
|
-
|
|
690
|
+
ol_member_create({
|
|
688
691
|
email: "customer@eu.example.com",
|
|
689
692
|
firstName: "Jean",
|
|
690
693
|
lastName: "Dupont",
|
|
@@ -696,10 +699,10 @@ openloyalty_member_create({
|
|
|
696
699
|
|
|
697
700
|
```
|
|
698
701
|
// Discover available event types
|
|
699
|
-
|
|
702
|
+
ol_webhook_events()
|
|
700
703
|
|
|
701
704
|
// Subscribe to member creation events
|
|
702
|
-
|
|
705
|
+
ol_webhook_create({
|
|
703
706
|
eventName: "member.created",
|
|
704
707
|
url: "https://crm.example.com/webhooks/loyalty",
|
|
705
708
|
headers: [
|
|
@@ -708,10 +711,10 @@ openloyalty_webhook_create({
|
|
|
708
711
|
})
|
|
709
712
|
|
|
710
713
|
// List current subscriptions
|
|
711
|
-
|
|
714
|
+
ol_webhook_list()
|
|
712
715
|
|
|
713
716
|
// Update subscription URL
|
|
714
|
-
|
|
717
|
+
ol_webhook_update({
|
|
715
718
|
webhookSubscriptionId: "...",
|
|
716
719
|
url: "https://crm-v2.example.com/webhooks/loyalty"
|
|
717
720
|
})
|
|
@@ -721,46 +724,46 @@ openloyalty_webhook_update({
|
|
|
721
724
|
|
|
722
725
|
```
|
|
723
726
|
// Create import with CSV content
|
|
724
|
-
|
|
727
|
+
ol_import_create({
|
|
725
728
|
type: "member",
|
|
726
729
|
fileContent: "email,firstName,lastName\njohn@example.com,John,Doe\njane@example.com,Jane,Smith",
|
|
727
730
|
fileName: "members.csv"
|
|
728
731
|
})
|
|
729
732
|
|
|
730
733
|
// Poll import status
|
|
731
|
-
|
|
734
|
+
ol_import_list({ type: "member" })
|
|
732
735
|
|
|
733
736
|
// Check individual item statuses
|
|
734
|
-
|
|
737
|
+
ol_import_get({ importId: "..." })
|
|
735
738
|
```
|
|
736
739
|
|
|
737
740
|
### 16. Export Campaign Codes and Download
|
|
738
741
|
|
|
739
742
|
```
|
|
740
743
|
// Create export for campaign codes
|
|
741
|
-
|
|
744
|
+
ol_export_create({
|
|
742
745
|
type: "campaignCode",
|
|
743
746
|
filters: { campaignId: "campaign-uuid" }
|
|
744
747
|
})
|
|
745
748
|
|
|
746
749
|
// Poll until status is 'done'
|
|
747
|
-
|
|
750
|
+
ol_export_get({ exportId: "..." })
|
|
748
751
|
|
|
749
752
|
// Download the CSV file
|
|
750
|
-
|
|
753
|
+
ol_export_download({ exportId: "..." })
|
|
751
754
|
```
|
|
752
755
|
|
|
753
756
|
### 17. Bulk Add Points via Import
|
|
754
757
|
|
|
755
758
|
```
|
|
756
759
|
// Create import for adding points to multiple members
|
|
757
|
-
|
|
760
|
+
ol_import_create({
|
|
758
761
|
type: "unitTransferAdding",
|
|
759
762
|
fileContent: "loyaltyCardNumber,points,comment\nCARD-001,500,Promotion bonus\nCARD-002,500,Promotion bonus"
|
|
760
763
|
})
|
|
761
764
|
|
|
762
765
|
// Check import progress
|
|
763
|
-
|
|
766
|
+
ol_import_get({ importId: "..." })
|
|
764
767
|
```
|
|
765
768
|
|
|
766
769
|
---
|