@delopay/sdk 0.290.0 → 0.291.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.
@@ -3353,15 +3353,21 @@ var Projects = class {
3353
3353
  this.request = request;
3354
3354
  }
3355
3355
  /**
3356
- * Create a new project under a merchant account.
3356
+ * Create a new project under a merchant account. Pass `parent_id` to create
3357
+ * it as a sub-project; past the merchant's maximum depth it is refused with
3358
+ * `400` and code `PR_01` (`project_depth_exceeded`).
3357
3359
  *
3358
- * @param params - Project creation parameters (name, description, etc.).
3360
+ * @param params - Project creation parameters (name, description, parent).
3359
3361
  * @param merchantId - The merchant account ID that owns this project.
3360
3362
  * @returns The created project.
3361
3363
  *
3362
3364
  * @example
3363
3365
  * ```typescript
3364
- * const project = await delopay.projects.create({ name: 'EU Stores' }, 'merch_123');
3366
+ * const eu = await delopay.projects.create({ project_name: 'EU Stores' }, 'merch_123');
3367
+ * const de = await delopay.projects.create(
3368
+ * { project_name: 'Germany', parent_id: eu.id },
3369
+ * 'merch_123',
3370
+ * );
3365
3371
  * ```
3366
3372
  */
3367
3373
  async create(params, merchantId) {
@@ -3386,7 +3392,14 @@ var Projects = class {
3386
3392
  return this.request("GET", path, { query: { merchant_id: merchantId } });
3387
3393
  }
3388
3394
  /**
3389
- * Update a project's details.
3395
+ * Update a project's details, or move it with `parent_id` (omitted keeps the
3396
+ * parent, `null` makes it a top-level project, an id moves it under that
3397
+ * project). A move is refused with `PR_01` when the moved subtree would
3398
+ * exceed the maximum depth and with `PR_02` (`project_cycle`) when the target
3399
+ * is the project itself or one of its sub-projects. When the merchant's
3400
+ * project tree changed while the move was being checked, it is refused with
3401
+ * `409` and code `PR_05` (`project_tree_changed`): read the tree again and
3402
+ * retry.
3390
3403
  *
3391
3404
  * @param projectId - The project ID to update.
3392
3405
  * @param params - Fields to update.
@@ -3402,6 +3415,9 @@ var Projects = class {
3402
3415
  * Delete a project.
3403
3416
  *
3404
3417
  * @param projectId - The project ID to delete.
3418
+ * Refused with `409` and code `PR_03` (`project_not_empty`) while the
3419
+ * project still has sub-projects or shops; move or delete those first.
3420
+ *
3405
3421
  * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.
3406
3422
  * @returns The deleted project object.
3407
3423
  */
@@ -3411,7 +3427,9 @@ var Projects = class {
3411
3427
  return this.request("DELETE", path, { query: { merchant_id: merchantId } });
3412
3428
  }
3413
3429
  /**
3414
- * List all projects for a merchant.
3430
+ * List all projects for a merchant, at every level, as a flat array. Rebuild
3431
+ * the tree from each project's `parent_id`; `level`, `path`,
3432
+ * `child_project_count` and `direct_shop_count` are filled in for each one.
3415
3433
  *
3416
3434
  * @param merchantId - The merchant account ID.
3417
3435
  * @returns Array of projects.
@@ -3424,6 +3442,11 @@ var Projects = class {
3424
3442
  /**
3425
3443
  * Get aggregate payment statistics across all projects for a merchant.
3426
3444
  *
3445
+ * Each project's figures cover its whole subtree (its own shops and the
3446
+ * shops of its sub-projects); `projects[].direct` holds the figures for the
3447
+ * project's own shops only, and `projects[].shops[]` lists only those. The
3448
+ * merchant totals count each shop once.
3449
+ *
3427
3450
  * The response's flat `shops[]` array holds every shop, including shops that
3428
3451
  * belong to no project — those are absent from `projects[].shops[]`, so look
3429
3452
  * a single shop up in `shops[]`. Requires `MerchantAccountRead`; a
@@ -3445,6 +3468,26 @@ var Projects = class {
3445
3468
  if (period !== void 0) query["period"] = String(period);
3446
3469
  return this.request("GET", "/projects/stats", { query });
3447
3470
  }
3471
+ /**
3472
+ * Get the project-depth limit that applies to a merchant: the maximum number
3473
+ * of project levels, where that limit comes from, and how deep the
3474
+ * merchant's tree currently is. Use it to tell whether a project can take a
3475
+ * sub-project (`project.level < max_depth`) before offering the action.
3476
+ *
3477
+ * @param merchantId - The merchant account ID.
3478
+ * @returns The merchant's project limits.
3479
+ *
3480
+ * @example
3481
+ * ```typescript
3482
+ * const { max_depth } = await delopay.projects.limits('merch_123');
3483
+ * const canNest = project.level < max_depth;
3484
+ * ```
3485
+ */
3486
+ async limits(merchantId) {
3487
+ return this.request("GET", "/projects/limits", {
3488
+ query: { merchant_id: merchantId }
3489
+ });
3490
+ }
3448
3491
  /**
3449
3492
  * Get a high-level overview (volume, counts, top connectors) for a merchant.
3450
3493
  *
@@ -15354,4 +15397,4 @@ export {
15354
15397
  decodeNativePanes,
15355
15398
  encodeNativePanes
15356
15399
  };
15357
- //# sourceMappingURL=chunk-7QXWTMSG.js.map
15400
+ //# sourceMappingURL=chunk-JHQBYOCA.js.map