@ophelio/sdk 0.5.0 → 0.6.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/README.md +59 -40
- package/dist/index.cjs +166 -42
- package/dist/index.d.cts +252 -30
- package/dist/index.d.mts +252 -30
- package/dist/index.mjs +166 -42
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -292,13 +292,25 @@ var BillingOptionSalesChannelsResource = class extends APIResource {
|
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/resources/billing-options.ts
|
|
294
294
|
var BillingOptionsResource = class extends APIResource {
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Every billing option in the project, across all plans — plans multiplied
|
|
297
|
+
* by their options, so this is the largest of the configuration lists.
|
|
298
|
+
* Ordered by plan, then display name. Use `collect` or `paginate` to walk it,
|
|
299
|
+
* or read `total_size` off the first page for a count without loading rows.
|
|
300
|
+
*/
|
|
301
|
+
async list(params, options) {
|
|
302
|
+
const response = await this.transport.request({
|
|
297
303
|
method: "GET",
|
|
298
304
|
path: "/api/v1/billing-options",
|
|
305
|
+
query: pageQuery(params),
|
|
299
306
|
retryable: true,
|
|
300
307
|
options
|
|
301
|
-
})
|
|
308
|
+
});
|
|
309
|
+
return {
|
|
310
|
+
items: response.billing_options,
|
|
311
|
+
next_page_token: response.next_page_token,
|
|
312
|
+
total_size: response.total_size
|
|
313
|
+
};
|
|
302
314
|
}
|
|
303
315
|
get(id, options) {
|
|
304
316
|
return this.transport.request({
|
|
@@ -325,13 +337,24 @@ var BillingOptionsResource = class extends APIResource {
|
|
|
325
337
|
options
|
|
326
338
|
});
|
|
327
339
|
}
|
|
328
|
-
|
|
329
|
-
|
|
340
|
+
/**
|
|
341
|
+
* The sales channels a billing option is restricted to, in the order they
|
|
342
|
+
* were linked. No links at all means the billing option is available
|
|
343
|
+
* everywhere.
|
|
344
|
+
*/
|
|
345
|
+
async listSalesChannels(id, params, options) {
|
|
346
|
+
const response = await this.transport.request({
|
|
330
347
|
method: "GET",
|
|
331
348
|
path: `/api/v1/billing-options/${encodeURIComponent(id)}/sales-channels`,
|
|
349
|
+
query: pageQuery(params),
|
|
332
350
|
retryable: true,
|
|
333
351
|
options
|
|
334
|
-
})
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
items: response.sales_channels,
|
|
355
|
+
next_page_token: response.next_page_token,
|
|
356
|
+
total_size: response.total_size
|
|
357
|
+
};
|
|
335
358
|
}
|
|
336
359
|
createSalesChannelLink(id, params, options) {
|
|
337
360
|
return this.transport.request({
|
|
@@ -591,13 +614,19 @@ var EntitlementsResource = class extends APIResource {
|
|
|
591
614
|
options: requestOptions
|
|
592
615
|
})).usage;
|
|
593
616
|
}
|
|
594
|
-
async list(options) {
|
|
595
|
-
|
|
617
|
+
async list(params, options) {
|
|
618
|
+
const response = await this.transport.request({
|
|
596
619
|
method: "GET",
|
|
597
620
|
path: "/api/v1/entitlements",
|
|
621
|
+
query: pageQuery(params),
|
|
598
622
|
retryable: true,
|
|
599
623
|
options
|
|
600
|
-
})
|
|
624
|
+
});
|
|
625
|
+
return {
|
|
626
|
+
items: response.entitlements,
|
|
627
|
+
next_page_token: response.next_page_token,
|
|
628
|
+
total_size: response.total_size
|
|
629
|
+
};
|
|
601
630
|
}
|
|
602
631
|
get(id, options) {
|
|
603
632
|
return this.transport.request({
|
|
@@ -637,13 +666,19 @@ var EntitlementsResource = class extends APIResource {
|
|
|
637
666
|
//#endregion
|
|
638
667
|
//#region src/resources/member-roles.ts
|
|
639
668
|
var MemberRolesResource = class extends APIResource {
|
|
640
|
-
async list(options) {
|
|
641
|
-
|
|
669
|
+
async list(params, options) {
|
|
670
|
+
const response = await this.transport.request({
|
|
642
671
|
method: "GET",
|
|
643
672
|
path: "/api/v1/member-roles",
|
|
673
|
+
query: pageQuery(params),
|
|
644
674
|
retryable: true,
|
|
645
675
|
options
|
|
646
|
-
})
|
|
676
|
+
});
|
|
677
|
+
return {
|
|
678
|
+
items: response.member_roles,
|
|
679
|
+
next_page_token: response.next_page_token,
|
|
680
|
+
total_size: response.total_size
|
|
681
|
+
};
|
|
647
682
|
}
|
|
648
683
|
get(id, options) {
|
|
649
684
|
return this.transport.request({
|
|
@@ -686,12 +721,31 @@ var MembersResource = class extends APIResource {
|
|
|
686
721
|
/**
|
|
687
722
|
* Active-member list for offline gate caching. Pass the previous
|
|
688
723
|
* response's `generated_at` as `since` to fetch incrementally.
|
|
724
|
+
*
|
|
725
|
+
* `targets` names the venue, zone, shop or gate this roster is for, and
|
|
726
|
+
* settles what the gate can grant while it is offline: each member's
|
|
727
|
+
* entitlements are stored as they stand at the moment of the sync and are
|
|
728
|
+
* read back during an outage without being checked again. Omit it for the
|
|
729
|
+
* whole roster. Codes are matched exactly, so send them back verbatim from
|
|
730
|
+
* `targetCodes.list()` — an unregistered one is refused with a 400.
|
|
731
|
+
*
|
|
732
|
+
* Two things work differently here than on `admit.check` and
|
|
733
|
+
* `members.listEntitlements`, both on purpose. An empty `targets` is
|
|
734
|
+
* refused with a 400. It is not read as naming no targets, so it never
|
|
735
|
+
* returns only the benefits valid everywhere. And a project that requires
|
|
736
|
+
* every read to say where it is still answers a sync that omits `targets`.
|
|
737
|
+
* The roster is what a gate falls back on when it cannot reach us, so a
|
|
738
|
+
* quietly shortened or unfetchable copy would only show up during the
|
|
739
|
+
* outage it was kept for.
|
|
689
740
|
*/
|
|
690
741
|
sync(params = {}, options) {
|
|
691
742
|
return this.transport.request({
|
|
692
743
|
method: "GET",
|
|
693
744
|
path: "/api/v1/members/sync",
|
|
694
|
-
query: {
|
|
745
|
+
query: {
|
|
746
|
+
since: params.since,
|
|
747
|
+
targets: params.targets
|
|
748
|
+
},
|
|
695
749
|
retryable: true,
|
|
696
750
|
options
|
|
697
751
|
});
|
|
@@ -718,18 +772,29 @@ var MembersResource = class extends APIResource {
|
|
|
718
772
|
* Each entitlement carries `valid_on` and `valid_at` when something
|
|
719
773
|
* restricts it by date or by target; both list only what it matched, never
|
|
720
774
|
* what it failed.
|
|
775
|
+
*
|
|
776
|
+
* `page_size` / `page_token` window the already-filtered result, so they
|
|
777
|
+
* compose with `type` and `targets` rather than replacing them. A page token
|
|
778
|
+
* is bound to the filters it was issued under: change `type` or `targets`
|
|
779
|
+
* and the token is refused rather than returning misaligned rows.
|
|
721
780
|
*/
|
|
722
781
|
async listEntitlements(id, params = {}, options) {
|
|
723
|
-
|
|
782
|
+
const response = await this.transport.request({
|
|
724
783
|
method: "GET",
|
|
725
784
|
path: `/api/v1/members/${encodeURIComponent(id)}/entitlements`,
|
|
726
785
|
query: {
|
|
786
|
+
...pageQuery(params),
|
|
727
787
|
type: params.type,
|
|
728
788
|
targets: params.targets
|
|
729
789
|
},
|
|
730
790
|
retryable: true,
|
|
731
791
|
options
|
|
732
|
-
})
|
|
792
|
+
});
|
|
793
|
+
return {
|
|
794
|
+
items: response.entitlements,
|
|
795
|
+
next_page_token: response.next_page_token,
|
|
796
|
+
total_size: response.total_size
|
|
797
|
+
};
|
|
733
798
|
}
|
|
734
799
|
/**
|
|
735
800
|
* Updates a member's details. Accepts `name`, `date_of_birth` and `role`
|
|
@@ -882,13 +947,24 @@ var MembershipsResource = class extends APIResource {
|
|
|
882
947
|
options: requestOptions
|
|
883
948
|
});
|
|
884
949
|
}
|
|
885
|
-
|
|
886
|
-
|
|
950
|
+
/**
|
|
951
|
+
* The cardholders on a membership, primary first, then in the order they
|
|
952
|
+
* were added. Bounded by the plan's `max_party_size`, so the default page
|
|
953
|
+
* size covers a membership in one request.
|
|
954
|
+
*/
|
|
955
|
+
async listMembers(id, params, options) {
|
|
956
|
+
const response = await this.transport.request({
|
|
887
957
|
method: "GET",
|
|
888
958
|
path: `/api/v1/memberships/${encodeURIComponent(id)}/members`,
|
|
959
|
+
query: pageQuery(params),
|
|
889
960
|
retryable: true,
|
|
890
961
|
options
|
|
891
|
-
})
|
|
962
|
+
});
|
|
963
|
+
return {
|
|
964
|
+
items: response.members,
|
|
965
|
+
next_page_token: response.next_page_token,
|
|
966
|
+
total_size: response.total_size
|
|
967
|
+
};
|
|
892
968
|
}
|
|
893
969
|
/**
|
|
894
970
|
* Add a member to an existing membership, up to the plan's max party size.
|
|
@@ -1105,13 +1181,19 @@ var PlanPricingGroupMappingsResource = class extends APIResource {
|
|
|
1105
1181
|
//#endregion
|
|
1106
1182
|
//#region src/resources/plans.ts
|
|
1107
1183
|
var PlansResource = class extends APIResource {
|
|
1108
|
-
async list(options) {
|
|
1109
|
-
|
|
1184
|
+
async list(params, options) {
|
|
1185
|
+
const response = await this.transport.request({
|
|
1110
1186
|
method: "GET",
|
|
1111
1187
|
path: "/api/v1/plans",
|
|
1188
|
+
query: pageQuery(params),
|
|
1112
1189
|
retryable: true,
|
|
1113
1190
|
options
|
|
1114
|
-
})
|
|
1191
|
+
});
|
|
1192
|
+
return {
|
|
1193
|
+
items: response.plans,
|
|
1194
|
+
next_page_token: response.next_page_token,
|
|
1195
|
+
total_size: response.total_size
|
|
1196
|
+
};
|
|
1115
1197
|
}
|
|
1116
1198
|
get(id, options) {
|
|
1117
1199
|
return this.transport.request({
|
|
@@ -1121,21 +1203,33 @@ var PlansResource = class extends APIResource {
|
|
|
1121
1203
|
options
|
|
1122
1204
|
});
|
|
1123
1205
|
}
|
|
1124
|
-
async listBillingOptions(id, options) {
|
|
1125
|
-
|
|
1206
|
+
async listBillingOptions(id, params, options) {
|
|
1207
|
+
const response = await this.transport.request({
|
|
1126
1208
|
method: "GET",
|
|
1127
1209
|
path: `/api/v1/plans/${encodeURIComponent(id)}/billing-options`,
|
|
1210
|
+
query: pageQuery(params),
|
|
1128
1211
|
retryable: true,
|
|
1129
1212
|
options
|
|
1130
|
-
})
|
|
1213
|
+
});
|
|
1214
|
+
return {
|
|
1215
|
+
items: response.billing_options,
|
|
1216
|
+
next_page_token: response.next_page_token,
|
|
1217
|
+
total_size: response.total_size
|
|
1218
|
+
};
|
|
1131
1219
|
}
|
|
1132
|
-
async listEntitlements(id, options) {
|
|
1133
|
-
|
|
1220
|
+
async listEntitlements(id, params, options) {
|
|
1221
|
+
const response = await this.transport.request({
|
|
1134
1222
|
method: "GET",
|
|
1135
1223
|
path: `/api/v1/plans/${encodeURIComponent(id)}/entitlements`,
|
|
1224
|
+
query: pageQuery(params),
|
|
1136
1225
|
retryable: true,
|
|
1137
1226
|
options
|
|
1138
|
-
})
|
|
1227
|
+
});
|
|
1228
|
+
return {
|
|
1229
|
+
items: response.entitlements,
|
|
1230
|
+
next_page_token: response.next_page_token,
|
|
1231
|
+
total_size: response.total_size
|
|
1232
|
+
};
|
|
1139
1233
|
}
|
|
1140
1234
|
create(params, options) {
|
|
1141
1235
|
return this.transport.request({
|
|
@@ -1172,13 +1266,19 @@ var PlansResource = class extends APIResource {
|
|
|
1172
1266
|
options
|
|
1173
1267
|
});
|
|
1174
1268
|
}
|
|
1175
|
-
async listPlanLinks(id, options) {
|
|
1176
|
-
|
|
1269
|
+
async listPlanLinks(id, params, options) {
|
|
1270
|
+
const response = await this.transport.request({
|
|
1177
1271
|
method: "GET",
|
|
1178
1272
|
path: `/api/v1/plans/${encodeURIComponent(id)}/plan-links`,
|
|
1273
|
+
query: pageQuery(params),
|
|
1179
1274
|
retryable: true,
|
|
1180
1275
|
options
|
|
1181
|
-
})
|
|
1276
|
+
});
|
|
1277
|
+
return {
|
|
1278
|
+
items: response.plan_links,
|
|
1279
|
+
next_page_token: response.next_page_token,
|
|
1280
|
+
total_size: response.total_size
|
|
1281
|
+
};
|
|
1182
1282
|
}
|
|
1183
1283
|
createPlanLink(id, params, options) {
|
|
1184
1284
|
return this.transport.request({
|
|
@@ -1198,13 +1298,19 @@ var PlansResource = class extends APIResource {
|
|
|
1198
1298
|
options
|
|
1199
1299
|
});
|
|
1200
1300
|
}
|
|
1201
|
-
async listPricingGroupMappings(id, options) {
|
|
1202
|
-
|
|
1301
|
+
async listPricingGroupMappings(id, params, options) {
|
|
1302
|
+
const response = await this.transport.request({
|
|
1203
1303
|
method: "GET",
|
|
1204
1304
|
path: `/api/v1/plans/${encodeURIComponent(id)}/pricing-group-mappings`,
|
|
1305
|
+
query: pageQuery(params),
|
|
1205
1306
|
retryable: true,
|
|
1206
1307
|
options
|
|
1207
|
-
})
|
|
1308
|
+
});
|
|
1309
|
+
return {
|
|
1310
|
+
items: response.pricing_group_mappings,
|
|
1311
|
+
next_page_token: response.next_page_token,
|
|
1312
|
+
total_size: response.total_size
|
|
1313
|
+
};
|
|
1208
1314
|
}
|
|
1209
1315
|
createPricingGroupMapping(id, params, options) {
|
|
1210
1316
|
return this.transport.request({
|
|
@@ -1219,13 +1325,19 @@ var PlansResource = class extends APIResource {
|
|
|
1219
1325
|
//#endregion
|
|
1220
1326
|
//#region src/resources/pricing-groups.ts
|
|
1221
1327
|
var PricingGroupsResource = class extends APIResource {
|
|
1222
|
-
async list(options) {
|
|
1223
|
-
|
|
1328
|
+
async list(params, options) {
|
|
1329
|
+
const response = await this.transport.request({
|
|
1224
1330
|
method: "GET",
|
|
1225
1331
|
path: "/api/v1/pricing-groups",
|
|
1332
|
+
query: pageQuery(params),
|
|
1226
1333
|
retryable: true,
|
|
1227
1334
|
options
|
|
1228
|
-
})
|
|
1335
|
+
});
|
|
1336
|
+
return {
|
|
1337
|
+
items: response.pricing_groups,
|
|
1338
|
+
next_page_token: response.next_page_token,
|
|
1339
|
+
total_size: response.total_size
|
|
1340
|
+
};
|
|
1229
1341
|
}
|
|
1230
1342
|
get(id, options) {
|
|
1231
1343
|
return this.transport.request({
|
|
@@ -1265,13 +1377,19 @@ var PricingGroupsResource = class extends APIResource {
|
|
|
1265
1377
|
//#endregion
|
|
1266
1378
|
//#region src/resources/sales-channels.ts
|
|
1267
1379
|
var SalesChannelsResource = class extends APIResource {
|
|
1268
|
-
async list(options) {
|
|
1269
|
-
|
|
1380
|
+
async list(params, options) {
|
|
1381
|
+
const response = await this.transport.request({
|
|
1270
1382
|
method: "GET",
|
|
1271
1383
|
path: "/api/v1/sales-channels",
|
|
1384
|
+
query: pageQuery(params),
|
|
1272
1385
|
retryable: true,
|
|
1273
1386
|
options
|
|
1274
|
-
})
|
|
1387
|
+
});
|
|
1388
|
+
return {
|
|
1389
|
+
items: response.sales_channels,
|
|
1390
|
+
next_page_token: response.next_page_token,
|
|
1391
|
+
total_size: response.total_size
|
|
1392
|
+
};
|
|
1275
1393
|
}
|
|
1276
1394
|
get(id, options) {
|
|
1277
1395
|
return this.transport.request({
|
|
@@ -1390,13 +1508,19 @@ var TargetCodesResource = class extends APIResource {
|
|
|
1390
1508
|
//#endregion
|
|
1391
1509
|
//#region src/resources/webhook-subscriptions.ts
|
|
1392
1510
|
var WebhookSubscriptionsResource = class extends APIResource {
|
|
1393
|
-
async list(options) {
|
|
1394
|
-
|
|
1511
|
+
async list(params, options) {
|
|
1512
|
+
const response = await this.transport.request({
|
|
1395
1513
|
method: "GET",
|
|
1396
1514
|
path: "/api/v1/webhook-subscriptions",
|
|
1515
|
+
query: pageQuery(params),
|
|
1397
1516
|
retryable: true,
|
|
1398
1517
|
options
|
|
1399
|
-
})
|
|
1518
|
+
});
|
|
1519
|
+
return {
|
|
1520
|
+
items: response.webhook_subscriptions,
|
|
1521
|
+
next_page_token: response.next_page_token,
|
|
1522
|
+
total_size: response.total_size
|
|
1523
|
+
};
|
|
1400
1524
|
}
|
|
1401
1525
|
get(id, options) {
|
|
1402
1526
|
return this.transport.request({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ophelio/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Official JavaScript / TypeScript SDK for the Ophel.io membership & entitlement API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ophel.io",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"publint": "^0.3.21",
|
|
48
48
|
"tsdown": "^0.22.0",
|
|
49
49
|
"typescript": "^6.0.3",
|
|
50
|
-
"vitest": "^
|
|
50
|
+
"vitest": "^5.0.0"
|
|
51
51
|
}
|
|
52
52
|
}
|