@medalsocial/sdk 1.9.0 → 1.10.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.
@@ -291,11 +291,67 @@ var CapabilityConfirmer = class {
291
291
  };
292
292
 
293
293
  // src/resources/bookings.ts
294
+ var BookingsPayment = class {
295
+ constructor(client) {
296
+ this.client = client;
297
+ }
298
+ client;
299
+ /**
300
+ * Reserve (or charge) the booking's amount and get the wallet redirect.
301
+ *
302
+ * Automatically idempotent: the SDK mints an `Idempotency-Key` so its own
303
+ * 5xx retries replay instead of reserving twice. One live payment per
304
+ * booking — starting a second while one is outstanding answers 409; wait for
305
+ * the first to be approved, aborted, or to expire (ten minutes).
306
+ *
307
+ * A `return_url` the workspace's own sites do not vouch for is refused with
308
+ * 422, not 400: the URL parses, it is just not yours.
309
+ */
310
+ async start(id, input, options) {
311
+ return this.client.postOnce(
312
+ `/api/v1/bookings/${encodeURIComponent(id)}/payment`,
313
+ input,
314
+ options
315
+ );
316
+ }
317
+ /**
318
+ * The newest payment attempt on the booking.
319
+ *
320
+ * Throws `MedalApiError` with status 404 when the booking has no payment at
321
+ * all — "not started" and "unknown booking" answer alike, so this is not an
322
+ * existence oracle. Earlier attempts are not returned; attempt N+1 is what
323
+ * "the payment" means to a caller polling a retry.
324
+ */
325
+ async get(id) {
326
+ return this.client.get(`/api/v1/bookings/${encodeURIComponent(id)}/payment`);
327
+ }
328
+ };
329
+ var BookingsManagePayment = class {
330
+ constructor(client) {
331
+ this.client = client;
332
+ }
333
+ client;
334
+ /** Start a payment on the customer's behalf. See {@link BookingsPayment.start}. */
335
+ async start(token, input, options) {
336
+ return this.client.postOnce(
337
+ `/api/v1/bookings/manage/${encodeURIComponent(token)}/payment`,
338
+ input,
339
+ options
340
+ );
341
+ }
342
+ /** Read the payment on the customer's own booking. 404 when there is none. */
343
+ async get(token) {
344
+ return this.client.get(`/api/v1/bookings/manage/${encodeURIComponent(token)}/payment`);
345
+ }
346
+ };
294
347
  var BookingsManage = class {
295
348
  constructor(client) {
296
349
  this.client = client;
350
+ this.payment = new BookingsManagePayment(client);
297
351
  }
298
352
  client;
353
+ /** Payments authorized by the manage token rather than by booking id. */
354
+ payment;
299
355
  /**
300
356
  * Read what the holder of a manage token may see and do. Honour
301
357
  * `can_cancel` / `can_reschedule` — they already apply the policy windows.
@@ -383,6 +439,7 @@ var Bookings = class {
383
439
  this.persons = new BookingsPersons(client);
384
440
  this.relations = new BookingsRelations(client);
385
441
  this.events = new BookingsEvents(client);
442
+ this.payment = new BookingsPayment(client);
386
443
  }
387
444
  client;
388
445
  /** Customer-side actions addressed by manage token. */
@@ -393,6 +450,8 @@ var Bookings = class {
393
450
  relations;
394
451
  /** Arrangementer — scheduled group sessions bookings register against. */
395
452
  events;
453
+ /** Vipps payments on a booking, as the business. */
454
+ payment;
396
455
  /** List the bookable service catalogue. Active-only unless asked otherwise. */
397
456
  async listServices(options) {
398
457
  const params = {};