@ophelio/sdk 0.5.1 → 0.6.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 CHANGED
@@ -151,35 +151,38 @@ To page manually — for example to show `total_size` or build numbered pages
151
151
  `page_size` defaults to 50 and is capped at 250. Because pagination is
152
152
  offset-based, a row can be seen twice or skipped across a page boundary if the
153
153
  collection is written to while you iterate. Paginated methods are marked
154
- `(params?)` in the table below; every other list — the bounded ones such as
155
- member roles, pricing groups, sales channels, entitlements, plans and
156
- `listMembers` — returns a plain array.
154
+ `(params?)` in the table below; every other list returns a plain array.
155
+
156
+ On `members.listEntitlements` the page parameters compose with `type` and
157
+ `targets` rather than replacing them: the page is a window onto the
158
+ already-filtered result, and a page token is bound to the filters it was
159
+ issued under.
157
160
 
158
161
  ## API surface
159
162
 
160
163
  Everything reachable with an API key is covered:
161
164
 
162
- | Namespace | Methods |
163
- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
164
- | `admit` | `check({ card, targets? })` |
165
- | `members` | `sync({ since?, targets? })`, `get(id)`, `listEntitlements(id, { type?, targets? })`, `update(id, ...)`, `remove(id)`, `setPrimary(id)`, `reissueCard(id, { note? })` |
166
- | `memberships` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `cancel(id, ...)`, `uncancel(id)`, `renew(id, ...)`, `upgrade(id, ...)`, `downgrade(id, ...)`, `listMembers(id)`, `addMember(id, ...)`, `listScheduledChanges(id, params?)`, `cancelScheduledChange(id, changeId)`, `listTransactions(id, params?)`, `listTermTransactions(id, termId, params?)`, `createTransaction(id, ...)` |
167
- | `customers` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listMemberships(id, params?)` — `list`/`get` accept `view: 'full'` to include `membership_summary` |
168
- | `entitlements` | `redeem(...)`, `recordUsage(...)`, `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
169
- | `plans` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listBillingOptions(id)`, `createBillingOption(id, ...)`, `listEntitlements(id)`, `createEntitlement(id, ...)`, `listPlanLinks(id)`, `createPlanLink(id, ...)`, `listPricingGroupMappings(id)`, `createPricingGroupMapping(id, ...)` |
170
- | `billingOptions` | `list()`, `get(id)`, `update(id, ...)`, `delete(id)`, `listSalesChannels(id)`, `createSalesChannelLink(id, ...)` |
171
- | `memberRoles` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
172
- | `pricingGroups` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
173
- | `salesChannels` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
174
- | `targetCodes` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)` — `list`/`get` accept `view: 'full'` to include `plan_entitlement_count`; `update` takes `display_name` / `description` only, as `code` is immutable |
175
- | `calendars` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listRules(id, params?)`, `createRule(id, ...)` — `list`/`get` accept `view: 'full'` to include `plan_entitlement_count` |
176
- | `calendarRules` | `get(id)`, `update(id, ...)`, `delete(id)` |
177
- | `planEntitlements` | `get(id)`, `update(id, ...)`, `delete(id)`, `listAvailabilities(id, params?)`, `createAvailability(id, ...)` |
178
- | `planEntitlementAvailabilities` | `get(id)`, `update(id, ...)`, `delete(id)` |
179
- | `planLinks` | `delete(id)` |
180
- | `planPricingGroupMappings` | `delete(id)` |
181
- | `billingOptionSalesChannels` | `delete(id)` |
182
- | `webhookSubscriptions` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listDeliveries(id, params?)` |
165
+ | Namespace | Methods |
166
+ | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
167
+ | `admit` | `check({ card, targets? })` |
168
+ | `members` | `sync({ since?, targets? })`, `get(id)`, `listEntitlements(id, { page_size?, page_token?, type?, targets? })`, `update(id, ...)`, `remove(id)`, `setPrimary(id)`, `reissueCard(id, { note? })` |
169
+ | `memberships` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `cancel(id, ...)`, `uncancel(id)`, `renew(id, ...)`, `upgrade(id, ...)`, `downgrade(id, ...)`, `listMembers(id, params?)`, `addMember(id, ...)`, `listScheduledChanges(id, params?)`, `cancelScheduledChange(id, changeId)`, `listTransactions(id, params?)`, `listTermTransactions(id, termId, params?)`, `createTransaction(id, ...)` |
170
+ | `customers` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listMemberships(id, params?)` — `list`/`get` accept `view: 'full'` to include `membership_summary` |
171
+ | `entitlements` | `redeem(...)`, `recordUsage(...)`, `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
172
+ | `plans` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listBillingOptions(id, params?)`, `createBillingOption(id, ...)`, `listEntitlements(id, params?)`, `createEntitlement(id, ...)`, `listPlanLinks(id, params?)`, `createPlanLink(id, ...)`, `listPricingGroupMappings(id, params?)`, `createPricingGroupMapping(id, ...)` |
173
+ | `billingOptions` | `list(params?)`, `get(id)`, `update(id, ...)`, `delete(id)`, `listSalesChannels(id, params?)`, `createSalesChannelLink(id, ...)` |
174
+ | `memberRoles` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
175
+ | `pricingGroups` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
176
+ | `salesChannels` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
177
+ | `targetCodes` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)` — `list`/`get` accept `view: 'full'` to include `plan_entitlement_count`; `update` takes `display_name` / `description` only, as `code` is immutable |
178
+ | `calendars` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listRules(id, params?)`, `createRule(id, ...)` — `list`/`get` accept `view: 'full'` to include `plan_entitlement_count` |
179
+ | `calendarRules` | `get(id)`, `update(id, ...)`, `delete(id)` |
180
+ | `planEntitlements` | `get(id)`, `update(id, ...)`, `delete(id)`, `listAvailabilities(id, params?)`, `createAvailability(id, ...)` |
181
+ | `planEntitlementAvailabilities` | `get(id)`, `update(id, ...)`, `delete(id)` |
182
+ | `planLinks` | `delete(id)` |
183
+ | `planPricingGroupMappings` | `delete(id)` |
184
+ | `billingOptionSalesChannels` | `delete(id)` |
185
+ | `webhookSubscriptions` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listDeliveries(id, params?)` |
183
186
 
184
187
  Every method accepts a trailing `options` argument: `{ signal?, headers? }`
185
188
  (plus `idempotencyKey?` on the idempotency-keyed mutations: `memberships.create`
package/dist/index.cjs CHANGED
@@ -293,13 +293,25 @@ var BillingOptionSalesChannelsResource = class extends APIResource {
293
293
  //#endregion
294
294
  //#region src/resources/billing-options.ts
295
295
  var BillingOptionsResource = class extends APIResource {
296
- async list(options) {
297
- return (await this.transport.request({
296
+ /**
297
+ * Every billing option in the project, across all plans — plans multiplied
298
+ * by their options, so this is the largest of the configuration lists.
299
+ * Ordered by plan, then display name. Use `collect` or `paginate` to walk it,
300
+ * or read `total_size` off the first page for a count without loading rows.
301
+ */
302
+ async list(params, options) {
303
+ const response = await this.transport.request({
298
304
  method: "GET",
299
305
  path: "/api/v1/billing-options",
306
+ query: pageQuery(params),
300
307
  retryable: true,
301
308
  options
302
- })).billing_options;
309
+ });
310
+ return {
311
+ items: response.billing_options,
312
+ next_page_token: response.next_page_token,
313
+ total_size: response.total_size
314
+ };
303
315
  }
304
316
  get(id, options) {
305
317
  return this.transport.request({
@@ -326,13 +338,24 @@ var BillingOptionsResource = class extends APIResource {
326
338
  options
327
339
  });
328
340
  }
329
- async listSalesChannels(id, options) {
330
- return (await this.transport.request({
341
+ /**
342
+ * The sales channels a billing option is restricted to, in the order they
343
+ * were linked. No links at all means the billing option is available
344
+ * everywhere.
345
+ */
346
+ async listSalesChannels(id, params, options) {
347
+ const response = await this.transport.request({
331
348
  method: "GET",
332
349
  path: `/api/v1/billing-options/${encodeURIComponent(id)}/sales-channels`,
350
+ query: pageQuery(params),
333
351
  retryable: true,
334
352
  options
335
- })).sales_channels;
353
+ });
354
+ return {
355
+ items: response.sales_channels,
356
+ next_page_token: response.next_page_token,
357
+ total_size: response.total_size
358
+ };
336
359
  }
337
360
  createSalesChannelLink(id, params, options) {
338
361
  return this.transport.request({
@@ -592,13 +615,19 @@ var EntitlementsResource = class extends APIResource {
592
615
  options: requestOptions
593
616
  })).usage;
594
617
  }
595
- async list(options) {
596
- return (await this.transport.request({
618
+ async list(params, options) {
619
+ const response = await this.transport.request({
597
620
  method: "GET",
598
621
  path: "/api/v1/entitlements",
622
+ query: pageQuery(params),
599
623
  retryable: true,
600
624
  options
601
- })).entitlements;
625
+ });
626
+ return {
627
+ items: response.entitlements,
628
+ next_page_token: response.next_page_token,
629
+ total_size: response.total_size
630
+ };
602
631
  }
603
632
  get(id, options) {
604
633
  return this.transport.request({
@@ -638,13 +667,19 @@ var EntitlementsResource = class extends APIResource {
638
667
  //#endregion
639
668
  //#region src/resources/member-roles.ts
640
669
  var MemberRolesResource = class extends APIResource {
641
- async list(options) {
642
- return (await this.transport.request({
670
+ async list(params, options) {
671
+ const response = await this.transport.request({
643
672
  method: "GET",
644
673
  path: "/api/v1/member-roles",
674
+ query: pageQuery(params),
645
675
  retryable: true,
646
676
  options
647
- })).member_roles;
677
+ });
678
+ return {
679
+ items: response.member_roles,
680
+ next_page_token: response.next_page_token,
681
+ total_size: response.total_size
682
+ };
648
683
  }
649
684
  get(id, options) {
650
685
  return this.transport.request({
@@ -738,18 +773,29 @@ var MembersResource = class extends APIResource {
738
773
  * Each entitlement carries `valid_on` and `valid_at` when something
739
774
  * restricts it by date or by target; both list only what it matched, never
740
775
  * what it failed.
776
+ *
777
+ * `page_size` / `page_token` window the already-filtered result, so they
778
+ * compose with `type` and `targets` rather than replacing them. A page token
779
+ * is bound to the filters it was issued under: change `type` or `targets`
780
+ * and the token is refused rather than returning misaligned rows.
741
781
  */
742
782
  async listEntitlements(id, params = {}, options) {
743
- return (await this.transport.request({
783
+ const response = await this.transport.request({
744
784
  method: "GET",
745
785
  path: `/api/v1/members/${encodeURIComponent(id)}/entitlements`,
746
786
  query: {
787
+ ...pageQuery(params),
747
788
  type: params.type,
748
789
  targets: params.targets
749
790
  },
750
791
  retryable: true,
751
792
  options
752
- })).entitlements;
793
+ });
794
+ return {
795
+ items: response.entitlements,
796
+ next_page_token: response.next_page_token,
797
+ total_size: response.total_size
798
+ };
753
799
  }
754
800
  /**
755
801
  * Updates a member's details. Accepts `name`, `date_of_birth` and `role`
@@ -902,13 +948,24 @@ var MembershipsResource = class extends APIResource {
902
948
  options: requestOptions
903
949
  });
904
950
  }
905
- async listMembers(id, options) {
906
- return (await this.transport.request({
951
+ /**
952
+ * The cardholders on a membership, primary first, then in the order they
953
+ * were added. Bounded by the plan's `max_party_size`, so the default page
954
+ * size covers a membership in one request.
955
+ */
956
+ async listMembers(id, params, options) {
957
+ const response = await this.transport.request({
907
958
  method: "GET",
908
959
  path: `/api/v1/memberships/${encodeURIComponent(id)}/members`,
960
+ query: pageQuery(params),
909
961
  retryable: true,
910
962
  options
911
- })).members;
963
+ });
964
+ return {
965
+ items: response.members,
966
+ next_page_token: response.next_page_token,
967
+ total_size: response.total_size
968
+ };
912
969
  }
913
970
  /**
914
971
  * Add a member to an existing membership, up to the plan's max party size.
@@ -964,13 +1021,17 @@ var MembershipsResource = class extends APIResource {
964
1021
  options
965
1022
  });
966
1023
  }
1024
+ /**
1025
+ * Lists scheduled changes. `status` accepts one status, several, or `all`;
1026
+ * omit it to return every status.
1027
+ */
967
1028
  async listScheduledChanges(id, params, options) {
968
1029
  const response = await this.transport.request({
969
1030
  method: "GET",
970
1031
  path: `/api/v1/memberships/${encodeURIComponent(id)}/scheduled-changes`,
971
1032
  query: {
972
1033
  ...pageQuery(params),
973
- ...params?.status ? { status: params.status } : {}
1034
+ ...params?.status !== void 0 ? { status: params.status } : {}
974
1035
  },
975
1036
  retryable: true,
976
1037
  options
@@ -1125,13 +1186,19 @@ var PlanPricingGroupMappingsResource = class extends APIResource {
1125
1186
  //#endregion
1126
1187
  //#region src/resources/plans.ts
1127
1188
  var PlansResource = class extends APIResource {
1128
- async list(options) {
1129
- return (await this.transport.request({
1189
+ async list(params, options) {
1190
+ const response = await this.transport.request({
1130
1191
  method: "GET",
1131
1192
  path: "/api/v1/plans",
1193
+ query: pageQuery(params),
1132
1194
  retryable: true,
1133
1195
  options
1134
- })).plans;
1196
+ });
1197
+ return {
1198
+ items: response.plans,
1199
+ next_page_token: response.next_page_token,
1200
+ total_size: response.total_size
1201
+ };
1135
1202
  }
1136
1203
  get(id, options) {
1137
1204
  return this.transport.request({
@@ -1141,21 +1208,33 @@ var PlansResource = class extends APIResource {
1141
1208
  options
1142
1209
  });
1143
1210
  }
1144
- async listBillingOptions(id, options) {
1145
- return (await this.transport.request({
1211
+ async listBillingOptions(id, params, options) {
1212
+ const response = await this.transport.request({
1146
1213
  method: "GET",
1147
1214
  path: `/api/v1/plans/${encodeURIComponent(id)}/billing-options`,
1215
+ query: pageQuery(params),
1148
1216
  retryable: true,
1149
1217
  options
1150
- })).billing_options;
1218
+ });
1219
+ return {
1220
+ items: response.billing_options,
1221
+ next_page_token: response.next_page_token,
1222
+ total_size: response.total_size
1223
+ };
1151
1224
  }
1152
- async listEntitlements(id, options) {
1153
- return (await this.transport.request({
1225
+ async listEntitlements(id, params, options) {
1226
+ const response = await this.transport.request({
1154
1227
  method: "GET",
1155
1228
  path: `/api/v1/plans/${encodeURIComponent(id)}/entitlements`,
1229
+ query: pageQuery(params),
1156
1230
  retryable: true,
1157
1231
  options
1158
- })).entitlements;
1232
+ });
1233
+ return {
1234
+ items: response.entitlements,
1235
+ next_page_token: response.next_page_token,
1236
+ total_size: response.total_size
1237
+ };
1159
1238
  }
1160
1239
  create(params, options) {
1161
1240
  return this.transport.request({
@@ -1192,13 +1271,19 @@ var PlansResource = class extends APIResource {
1192
1271
  options
1193
1272
  });
1194
1273
  }
1195
- async listPlanLinks(id, options) {
1196
- return (await this.transport.request({
1274
+ async listPlanLinks(id, params, options) {
1275
+ const response = await this.transport.request({
1197
1276
  method: "GET",
1198
1277
  path: `/api/v1/plans/${encodeURIComponent(id)}/plan-links`,
1278
+ query: pageQuery(params),
1199
1279
  retryable: true,
1200
1280
  options
1201
- })).plan_links;
1281
+ });
1282
+ return {
1283
+ items: response.plan_links,
1284
+ next_page_token: response.next_page_token,
1285
+ total_size: response.total_size
1286
+ };
1202
1287
  }
1203
1288
  createPlanLink(id, params, options) {
1204
1289
  return this.transport.request({
@@ -1218,13 +1303,19 @@ var PlansResource = class extends APIResource {
1218
1303
  options
1219
1304
  });
1220
1305
  }
1221
- async listPricingGroupMappings(id, options) {
1222
- return (await this.transport.request({
1306
+ async listPricingGroupMappings(id, params, options) {
1307
+ const response = await this.transport.request({
1223
1308
  method: "GET",
1224
1309
  path: `/api/v1/plans/${encodeURIComponent(id)}/pricing-group-mappings`,
1310
+ query: pageQuery(params),
1225
1311
  retryable: true,
1226
1312
  options
1227
- })).pricing_group_mappings;
1313
+ });
1314
+ return {
1315
+ items: response.pricing_group_mappings,
1316
+ next_page_token: response.next_page_token,
1317
+ total_size: response.total_size
1318
+ };
1228
1319
  }
1229
1320
  createPricingGroupMapping(id, params, options) {
1230
1321
  return this.transport.request({
@@ -1239,13 +1330,19 @@ var PlansResource = class extends APIResource {
1239
1330
  //#endregion
1240
1331
  //#region src/resources/pricing-groups.ts
1241
1332
  var PricingGroupsResource = class extends APIResource {
1242
- async list(options) {
1243
- return (await this.transport.request({
1333
+ async list(params, options) {
1334
+ const response = await this.transport.request({
1244
1335
  method: "GET",
1245
1336
  path: "/api/v1/pricing-groups",
1337
+ query: pageQuery(params),
1246
1338
  retryable: true,
1247
1339
  options
1248
- })).pricing_groups;
1340
+ });
1341
+ return {
1342
+ items: response.pricing_groups,
1343
+ next_page_token: response.next_page_token,
1344
+ total_size: response.total_size
1345
+ };
1249
1346
  }
1250
1347
  get(id, options) {
1251
1348
  return this.transport.request({
@@ -1285,13 +1382,19 @@ var PricingGroupsResource = class extends APIResource {
1285
1382
  //#endregion
1286
1383
  //#region src/resources/sales-channels.ts
1287
1384
  var SalesChannelsResource = class extends APIResource {
1288
- async list(options) {
1289
- return (await this.transport.request({
1385
+ async list(params, options) {
1386
+ const response = await this.transport.request({
1290
1387
  method: "GET",
1291
1388
  path: "/api/v1/sales-channels",
1389
+ query: pageQuery(params),
1292
1390
  retryable: true,
1293
1391
  options
1294
- })).sales_channels;
1392
+ });
1393
+ return {
1394
+ items: response.sales_channels,
1395
+ next_page_token: response.next_page_token,
1396
+ total_size: response.total_size
1397
+ };
1295
1398
  }
1296
1399
  get(id, options) {
1297
1400
  return this.transport.request({
@@ -1410,13 +1513,19 @@ var TargetCodesResource = class extends APIResource {
1410
1513
  //#endregion
1411
1514
  //#region src/resources/webhook-subscriptions.ts
1412
1515
  var WebhookSubscriptionsResource = class extends APIResource {
1413
- async list(options) {
1414
- return (await this.transport.request({
1516
+ async list(params, options) {
1517
+ const response = await this.transport.request({
1415
1518
  method: "GET",
1416
1519
  path: "/api/v1/webhook-subscriptions",
1520
+ query: pageQuery(params),
1417
1521
  retryable: true,
1418
1522
  options
1419
- })).webhook_subscriptions;
1523
+ });
1524
+ return {
1525
+ items: response.webhook_subscriptions,
1526
+ next_page_token: response.next_page_token,
1527
+ total_size: response.total_size
1528
+ };
1420
1529
  }
1421
1530
  get(id, options) {
1422
1531
  return this.transport.request({