@getenginex/sdk-igaming 0.6.0 → 0.7.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @getenginex/sdk-igaming
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 28a3282: The player's bonus balance and the reward grant of a participation.
8
+
9
+ **New:**
10
+
11
+ - `bonus.getOverview()` (`GET /bonus/overview`): the restricted bonus balance per currency (`BonusOverview`).
12
+ - `bonus.listPositions({ state?, currency?, pageSize?, cursor? })` (`GET /bonus/positions`): bonus positions with their rollover progress, as a `CursorPage<BonusPosition>`; `terminalAction` comes in lowercase.
13
+ - `CampaignParticipation.rewardGrant` (`CampaignRewardGrant`): `state` (`active`, `converted`, `expired`, `forfeited`), `granted`, `balance`, `converted`, `expiresAt` and the `wagering` progress. Amounts protojson leaves out come as `0` in the currency of the grant's other amounts.
14
+ - Queries: `q.bonus.getOverview` and `q.bonus.listPositions`.
15
+ - `/testing`: claiming a reward credits a grant, which shows up in `GET /bonus/overview` and `GET /bonus/positions`.
16
+
17
+ Campaign lists the gateway leaves out (protojson with `EmitUnpopulated` off, e.g. `use_policy.casino` arriving as `{}`) were already delivered as `[]`; this is now covered by tests and documented.
18
+
3
19
  ## 0.6.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -294,6 +294,39 @@ var offerSchema = /* @__PURE__ */ extension.lazy(
294
294
  content: mini.z.optional(content())
295
295
  })
296
296
  );
297
+ function grantMoney(value, currency) {
298
+ return { amount: value?.amount ?? 0, currency: value?.currency || currency };
299
+ }
300
+ var rewardGrant = () => mini.z.pipe(
301
+ extension.wire({
302
+ state: protoEnum("CAMPAIGN_PLAYER_REWARD_GRANT_STATE_"),
303
+ granted: mini.z.optional(money()),
304
+ balance: mini.z.optional(money()),
305
+ converted: mini.z.optional(money()),
306
+ expires_at: mini.z.optional(mini.z.string()),
307
+ wagering: mini.z.optional(
308
+ extension.wire({ required: mini.z.optional(money()), accumulated: mini.z.optional(money()), completed_at: mini.z.optional(mini.z.string()) })
309
+ )
310
+ }),
311
+ mini.z.transform(({ state, granted, balance, converted, expiresAt, wagering }) => {
312
+ const currency = [granted, balance, converted, wagering?.required, wagering?.accumulated].find((m) => m?.currency)?.currency ?? "";
313
+ const out = {
314
+ state,
315
+ granted: grantMoney(granted, currency),
316
+ balance: grantMoney(balance, currency),
317
+ converted: grantMoney(converted, currency)
318
+ };
319
+ if (expiresAt !== void 0) out.expiresAt = expiresAt;
320
+ if (wagering) {
321
+ out.wagering = {
322
+ required: grantMoney(wagering.required, currency),
323
+ accumulated: grantMoney(wagering.accumulated, currency)
324
+ };
325
+ if (wagering.completedAt !== void 0) out.wagering.completedAt = wagering.completedAt;
326
+ }
327
+ return out;
328
+ })
329
+ );
297
330
  var participationSchema = /* @__PURE__ */ extension.lazy(
298
331
  () => mini.z.pipe(
299
332
  extension.wire({
@@ -311,6 +344,7 @@ var participationSchema = /* @__PURE__ */ extension.lazy(
311
344
  reward_failed: mini.z.optional(empty()),
312
345
  expired: mini.z.optional(extension.wire({ expired_at: mini.z.optional(mini.z.string()) })),
313
346
  cancelled: mini.z.optional(empty()),
347
+ reward_grant: mini.z.optional(rewardGrant()),
314
348
  snapshot: mini.z.optional(
315
349
  extension.wire({
316
350
  reward: mini.z.optional(reward()),
@@ -362,6 +396,66 @@ function toCursorPage(key, data) {
362
396
  if (data.nextCursor) page.nextCursor = data.nextCursor;
363
397
  return page;
364
398
  }
399
+ var nullableDate = () => mini.z.pipe(
400
+ mini.z.nullish(mini.z.string()),
401
+ mini.z.transform((value) => value ?? void 0)
402
+ );
403
+ function compact(value) {
404
+ return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0));
405
+ }
406
+ var overviewSchema = /* @__PURE__ */ extension.lazy(
407
+ () => mini.z.pipe(
408
+ extension.wire({
409
+ currencies: list(
410
+ mini.z.pipe(
411
+ extension.wire({
412
+ currency: currencyOrEmpty(),
413
+ decimal_places: mini.z.number(),
414
+ restricted_total: minorUnits(),
415
+ expiring_7d: minorUnits(),
416
+ open_positions: mini.z.number(),
417
+ next_expires_at: nullableDate(),
418
+ converted: minorUnits(),
419
+ converted_campaigns: mini.z.number()
420
+ }),
421
+ mini.z.transform(compact)
422
+ )
423
+ ),
424
+ as_of: nullableDate()
425
+ }),
426
+ mini.z.transform(compact)
427
+ )
428
+ );
429
+ var positionsPage = /* @__PURE__ */ extension.lazy(
430
+ () => extension.wire({
431
+ rows: list(
432
+ mini.z.pipe(
433
+ extension.wire({
434
+ position_id: mini.z.string(),
435
+ campaign_id: mini.z.string(),
436
+ currency: currencyOrEmpty(),
437
+ decimal_places: mini.z.number(),
438
+ granted: minorUnits(),
439
+ restricted: minorUnits(),
440
+ converted: minorUnits(),
441
+ required: minorUnits(),
442
+ wagered: minorUnits(),
443
+ remaining: minorUnits(),
444
+ state: mini.z.string(),
445
+ // The gateway answers `null` for an action it does not know; known ones are uppercase (`CONVERT`).
446
+ terminal_action: mini.z.pipe(
447
+ mini.z.nullish(mini.z.string()),
448
+ mini.z.transform((value) => value ? value.toLowerCase() : void 0)
449
+ ),
450
+ expires_at: nullableDate(),
451
+ created_at: nullableDate()
452
+ }),
453
+ mini.z.transform((row) => compact(row))
454
+ )
455
+ ),
456
+ next_cursor: mini.z.optional(mini.z.string())
457
+ })
458
+ );
365
459
  var terms = (acceptance) => acceptance && { locale: acceptance.locale, terms_revision: acceptance.termsRevision };
366
460
  function createBonusApi(transport) {
367
461
  const listPage = (path, key, schema, auth, input, options) => transport.request({
@@ -429,7 +523,26 @@ function createBonusApi(transport) {
429
523
  auth: "required",
430
524
  schema: participationEnvelope(),
431
525
  options
432
- }).then((data) => data.participation)
526
+ }).then((data) => data.participation),
527
+ getOverview: (_params, options) => transport.request({
528
+ method: "GET",
529
+ path: "/bonus/overview",
530
+ auth: "required",
531
+ schema: overviewSchema(),
532
+ options
533
+ }),
534
+ listPositions: (input, options) => transport.request({
535
+ method: "GET",
536
+ path: "/bonus/positions",
537
+ query: { limit: input?.pageSize, cursor: input?.cursor, state: input?.state, currency: input?.currency },
538
+ auth: "required",
539
+ schema: positionsPage(),
540
+ options
541
+ }).then(({ rows, nextCursor }) => {
542
+ const page = { items: rows };
543
+ if (nextCursor) page.nextCursor = nextCursor;
544
+ return page;
545
+ })
433
546
  };
434
547
  }
435
548
  var gameSchema = /* @__PURE__ */ extension.lazy(