@delopay/sdk 0.388.0 → 0.392.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/dist/index.cjs CHANGED
@@ -138,6 +138,7 @@ __export(index_exports, {
138
138
  PAYPAL_LABEL_STYLES: () => PAYPAL_LABEL_STYLES,
139
139
  PRESENTATION_CONTRACT_VERSION: () => PRESENTATION_CONTRACT_VERSION,
140
140
  PaypalDisputes: () => PaypalDisputes,
141
+ Persons: () => Persons,
141
142
  PresentationCache: () => PresentationCache,
142
143
  ProcessorCosts: () => ProcessorCosts,
143
144
  ProcessorImports: () => ProcessorImports,
@@ -694,6 +695,21 @@ var Authentication = class {
694
695
  }
695
696
  };
696
697
 
698
+ // src/listQuery.ts
699
+ function csvQuery(params, csvKeys) {
700
+ if (!params) return void 0;
701
+ const joined = csvKeys;
702
+ const query = {};
703
+ for (const [key, value] of Object.entries(params)) {
704
+ if (!joined.includes(key) || !Array.isArray(value)) {
705
+ query[key] = value;
706
+ } else if (value.length > 0) {
707
+ query[key] = value.join(",");
708
+ }
709
+ }
710
+ return query;
711
+ }
712
+
697
713
  // src/resources/billing.ts
698
714
  var BillingAllocations = class {
699
715
  constructor(request) {
@@ -809,15 +825,17 @@ var Billing = class {
809
825
  });
810
826
  }
811
827
  /**
812
- * List the balance ledger (credits and debits) for a merchant.
828
+ * List the balance ledger (credits and debits) for a merchant, the newest
829
+ * entry first unless `sort_by` says otherwise.
813
830
  *
814
831
  * @param merchantId - The merchant account ID.
815
- * @param params - Optional pagination parameters.
832
+ * @param params - Optional pagination, filters (entry types, a creation
833
+ * window) and sort.
816
834
  * @returns The ledger entries.
817
835
  */
818
836
  async listLedger(merchantId, params) {
819
837
  return this.request("GET", `/billing/${encodeURIComponent(merchantId)}/ledger`, {
820
- query: params
838
+ query: csvQuery(params, ["entry_type"])
821
839
  });
822
840
  }
823
841
  /**
@@ -1620,6 +1638,29 @@ var Customers = class {
1620
1638
  async retrieve(customerId) {
1621
1639
  return this.request("GET", `/customers/${encodeURIComponent(customerId)}`);
1622
1640
  }
1641
+ /**
1642
+ * Place an existing customer in a shop of the merchant, so the shop's API keys and team members
1643
+ * find the customer before any payment. The customer keeps the shops they already belong to;
1644
+ * placing one already in the shop changes nothing (`already_in_shop`). Needs a merchant-wide key:
1645
+ * a key bound to one shop is refused. `POST /customers/{customer_id}/shops`
1646
+ *
1647
+ * @param customerId - The customer to place.
1648
+ * @param profileId - The shop. It must belong to the merchant.
1649
+ */
1650
+ async placeInShop(customerId, profileId, options) {
1651
+ return this.request("POST", `/customers/${encodeURIComponent(customerId)}/shops`, {
1652
+ body: { profile_id: profileId },
1653
+ ...options
1654
+ });
1655
+ }
1656
+ /**
1657
+ * Place up to 500 existing customers in one shop of the merchant, for example after an import.
1658
+ * The answer lists every distinct customer in request order with what happened: `placed`,
1659
+ * `already_in_shop` or `not_found`. Needs a merchant-wide key. `POST /customers/shops/place`
1660
+ */
1661
+ async placeManyInShop(params, options) {
1662
+ return this.request("POST", "/customers/shops/place", { body: params, ...options });
1663
+ }
1623
1664
  /**
1624
1665
  * Update an existing customer's details.
1625
1666
  *
@@ -5283,13 +5324,16 @@ var Users = class {
5283
5324
  *
5284
5325
  * Returns an empty page when a Delopay admin is impersonating a merchant,
5285
5326
  * so the admin's metadata is not exposed inside the merchant dashboard.
5327
+ *
5328
+ * Newest first unless `sort_by` says otherwise. Several `event_type` or
5329
+ * `auth_method` values match an event with any of them.
5286
5330
  */
5287
5331
  async listLoginActivity(params) {
5288
5332
  if (params === void 0) {
5289
5333
  return this.request("GET", "/user/me/login-activity");
5290
5334
  }
5291
5335
  return this.request("GET", "/user/me/login-activity", {
5292
- query: params
5336
+ query: csvQuery(params, ["event_type", "auth_method"])
5293
5337
  });
5294
5338
  }
5295
5339
  /**
@@ -6153,14 +6197,16 @@ var IdentityVerifications = class {
6153
6197
  return this.request("POST", "/identity-verifications", { body: params, ...options });
6154
6198
  }
6155
6199
  /**
6156
- * The merchant's verifications, newest first. A caller limited to one shop
6157
- * sees that shop's only.
6200
+ * The merchant's verifications, newest first unless `sort_by` says
6201
+ * otherwise. A caller limited to one shop sees that shop's only. Several
6202
+ * `outcome`, `kind` or `merchant_connector_id` values match a verification
6203
+ * with any of them.
6158
6204
  *
6159
6205
  * `GET /identity-verifications`
6160
6206
  */
6161
6207
  async list(query, options) {
6162
6208
  return this.request("GET", "/identity-verifications", {
6163
- query,
6209
+ query: csvQuery(query, ["outcome", "kind", "merchant_connector_id"]),
6164
6210
  ...options
6165
6211
  });
6166
6212
  }
@@ -6944,7 +6990,13 @@ var Export = class {
6944
6990
  );
6945
6991
  }
6946
6992
  async auditLog(params, options) {
6947
- return runExport(this.request, "GET", "/audit/export", queried(params), options);
6993
+ return runExport(
6994
+ this.request,
6995
+ "GET",
6996
+ "/audit/export",
6997
+ { query: csvQuery(params, ["profile_id", "action", "entity_type"]) },
6998
+ options
6999
+ );
6948
7000
  }
6949
7001
  };
6950
7002
  function queried(params, headers) {
@@ -7241,14 +7293,15 @@ var BuyerBlocklist = class {
7241
7293
  this.request = request;
7242
7294
  }
7243
7295
  /**
7244
- * One page of blocked buyers, newest first, filtered by scope, by `kind`
7245
- * (the entries that include an identifier of that kind) and by a search
7246
- * over every identifier and the note. Expired entries are not listed.
7296
+ * One page of blocked buyers, newest first unless `sort_by` says otherwise,
7297
+ * filtered by scope, by `kind` (the entries that include an identifier of
7298
+ * that kind, or of any of several) and by a search over every identifier
7299
+ * and the note. Expired entries are not listed.
7247
7300
  * `GET /buyer-blocklist`
7248
7301
  */
7249
7302
  async list(params) {
7250
7303
  return this.request("GET", "/buyer-blocklist", {
7251
- query: params
7304
+ query: csvQuery(params, ["kind"])
7252
7305
  });
7253
7306
  }
7254
7307
  /**
@@ -7374,6 +7427,56 @@ var BuyerBlocklist = class {
7374
7427
  }
7375
7428
  };
7376
7429
 
7430
+ // src/resources/persons.ts
7431
+ var Persons = class {
7432
+ constructor(request) {
7433
+ this.request = request;
7434
+ }
7435
+ /**
7436
+ * One page of persons, by default the most recent payment first, with the
7437
+ * number of persons the request matches.
7438
+ * `GET /persons`
7439
+ */
7440
+ async list(params) {
7441
+ return this.request("GET", "/persons", { query: params });
7442
+ }
7443
+ /**
7444
+ * One person: its figures, the identifiers and IP addresses its payments
7445
+ * carry, and its payments by status, shop, payment method, risk band and
7446
+ * environment. The id of a person that was merged into another returns
7447
+ * that person, with `merged_from` naming the id asked for. A person with
7448
+ * no payment in the scope is not found (`404`).
7449
+ * `GET /persons/{person_id}`
7450
+ */
7451
+ async retrieve(personId, params) {
7452
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}`, {
7453
+ query: params
7454
+ });
7455
+ }
7456
+ /**
7457
+ * Other persons of the merchant that may be the same person, the likeliest
7458
+ * first, at most 20. An estimate from the devices the persons paid with;
7459
+ * related persons stay separate persons.
7460
+ * `GET /persons/{person_id}/related`
7461
+ */
7462
+ async related(personId, params) {
7463
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}/related`, {
7464
+ query: params
7465
+ });
7466
+ }
7467
+ /**
7468
+ * The person of one payment, with how many payments the person has and
7469
+ * which kinds of identifier tie this payment to the others. `404` while
7470
+ * the payment has no person yet.
7471
+ * `GET /persons/payment/{payment_id}`
7472
+ */
7473
+ async ofPayment(paymentId, params) {
7474
+ return this.request("GET", `/persons/payment/${encodeURIComponent(paymentId)}`, {
7475
+ query: params
7476
+ });
7477
+ }
7478
+ };
7479
+
7377
7480
  // src/resources/shopLabels.ts
7378
7481
  var labelsPath = (merchantId) => `/account/${encodeURIComponent(merchantId)}/business-profile/labels`;
7379
7482
  var ShopLabels = class {
@@ -7626,12 +7729,13 @@ var BuyerConversations = class {
7626
7729
  this.request = request;
7627
7730
  }
7628
7731
  /**
7629
- * One page of the inbox, the latest message first, filtered by shop,
7630
- * status, assignee, mode or buyer. `GET /buyer-conversations`
7732
+ * One page of the inbox, the latest message first unless `sort_by` says
7733
+ * otherwise, filtered by shop, status (one or several), assignee, mode or
7734
+ * buyer. `GET /buyer-conversations`
7631
7735
  */
7632
7736
  async list(params) {
7633
7737
  return this.request("GET", "/buyer-conversations", {
7634
- query: params
7738
+ query: csvQuery(params, ["status"])
7635
7739
  });
7636
7740
  }
7637
7741
  /**
@@ -7742,12 +7846,14 @@ var BuyerEvidenceReviews = class {
7742
7846
  this.request = request;
7743
7847
  }
7744
7848
  /**
7745
- * The shop's cases with buyer evidence, the nearest target first.
7746
- * `merchant_id` and `reviewer` are ignored here. `GET /buyer-evidence`
7849
+ * The shop's cases with buyer evidence, the nearest target first unless
7850
+ * `sort_by` says otherwise. Several `state` values match a case in any of
7851
+ * them. `merchant_id` and `reviewer` are ignored here, and so are the
7852
+ * `merchant` and `reviewer` sorts. `GET /buyer-evidence`
7747
7853
  */
7748
7854
  async list(params) {
7749
7855
  return this.request("GET", "/buyer-evidence", {
7750
- query: params
7856
+ query: csvQuery(params, ["state"])
7751
7857
  });
7752
7858
  }
7753
7859
  /** One case's evidence with its history and files. `GET /buyer-evidence/{id}` */
@@ -8519,10 +8625,14 @@ var Support = class {
8519
8625
  async create(body) {
8520
8626
  return this.request("POST", "/support/conversations", { body });
8521
8627
  }
8522
- /** The conversations the caller may read. `GET /support/conversations` */
8628
+ /**
8629
+ * The conversations the caller may read, the latest message first unless
8630
+ * `sort_by` says otherwise. Several `kind`, `category` or `status` values
8631
+ * match a conversation with any of them. `GET /support/conversations`
8632
+ */
8523
8633
  async list(query) {
8524
8634
  return this.request("GET", "/support/conversations", {
8525
- query: query === void 0 ? void 0 : { ...query }
8635
+ query: csvQuery(query, ["kind", "category", "status"])
8526
8636
  });
8527
8637
  }
8528
8638
  /** One conversation. `GET /support/conversations/{id}` */
@@ -8573,6 +8683,7 @@ var Support = class {
8573
8683
  };
8574
8684
 
8575
8685
  // src/resources/invoices.ts
8686
+ var INVOICE_CSV_KEYS = ["status", "kind"];
8576
8687
  var Invoices = class {
8577
8688
  constructor(request) {
8578
8689
  this.request = request;
@@ -8592,13 +8703,15 @@ var Invoices = class {
8592
8703
  return this.request("POST", "/invoices", { body: params, ...options });
8593
8704
  }
8594
8705
  /**
8595
- * One page of documents, newest first. List rows carry no `lines` unless
8596
- * `include_lines` is set, and never a `refund` summary.
8706
+ * One page of documents, newest first unless `sort_by` says otherwise. List
8707
+ * rows carry no `lines` unless `include_lines` is set, and never a `refund`
8708
+ * summary. Several `status` or `kind` values match a document in any of
8709
+ * them.
8597
8710
  * `GET /invoices`
8598
8711
  */
8599
8712
  async list(params, options) {
8600
8713
  return this.request("GET", "/invoices", {
8601
- query: params === void 0 ? void 0 : { ...params },
8714
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8602
8715
  ...options
8603
8716
  });
8604
8717
  }
@@ -8623,7 +8736,7 @@ var Invoices = class {
8623
8736
  */
8624
8737
  async listForProduct(productId, params, options) {
8625
8738
  return this.request("GET", `/products/${encodeURIComponent(productId)}/invoices`, {
8626
- query: params === void 0 ? void 0 : { ...params },
8739
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8627
8740
  ...options
8628
8741
  });
8629
8742
  }
@@ -8641,7 +8754,7 @@ var Invoices = class {
8641
8754
  */
8642
8755
  async export(params, options) {
8643
8756
  return this.request("GET", "/invoices/export", {
8644
- query: { ...params },
8757
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8645
8758
  responseType: "blob",
8646
8759
  ...options
8647
8760
  });
@@ -9336,7 +9449,10 @@ var Subscriptions = class {
9336
9449
  ...options
9337
9450
  });
9338
9451
  }
9339
- /** List subscriptions for the profile. `GET /subscriptions/list` */
9452
+ /**
9453
+ * List subscriptions for the profile, or one customer's with `customer_id`.
9454
+ * `GET /subscriptions/list`
9455
+ */
9340
9456
  async list(params, options) {
9341
9457
  return this.request("GET", "/subscriptions/list", {
9342
9458
  query: params,
@@ -10132,13 +10248,19 @@ var BuyerPortal = class {
10132
10248
  };
10133
10249
 
10134
10250
  // src/resources/audit.ts
10251
+ var MERCHANT_AUDIT_CSV_KEYS = ["profile_id", "action", "entity_type"];
10135
10252
  var Audit = class {
10136
10253
  constructor(request) {
10137
10254
  this.request = request;
10138
10255
  }
10256
+ /**
10257
+ * One page of the merchant's audit log, the newest entry first unless
10258
+ * `sort_by` says otherwise. Several `profile_id`, `action` or `entity_type`
10259
+ * values match an entry with any of them. `GET /audit`
10260
+ */
10139
10261
  async list(params) {
10140
10262
  return this.request("GET", "/audit", {
10141
- query: params
10263
+ query: csvQuery(params, MERCHANT_AUDIT_CSV_KEYS)
10142
10264
  });
10143
10265
  }
10144
10266
  /**
@@ -10151,6 +10273,33 @@ var Audit = class {
10151
10273
  };
10152
10274
 
10153
10275
  // src/resources/settlement.ts
10276
+ function statementListQuery(params) {
10277
+ return csvQuery(
10278
+ {
10279
+ test_mode: params.test_mode,
10280
+ profile_id: params.profile_id,
10281
+ limit: params.limit,
10282
+ offset: params.offset,
10283
+ payout_status: params.payout_status,
10284
+ period_from: params.period_from,
10285
+ period_to: params.period_to,
10286
+ sort_by: params.sort_by,
10287
+ sort_order: params.sort_order
10288
+ },
10289
+ ["payout_status"]
10290
+ );
10291
+ }
10292
+ function nativeListQuery(params) {
10293
+ return {
10294
+ profile_id: params.profile_id,
10295
+ currency: params.currency,
10296
+ test_mode: params.test_mode,
10297
+ limit: params.limit,
10298
+ offset: params.offset,
10299
+ sort_by: params.sort_by,
10300
+ sort_order: params.sort_order
10301
+ };
10302
+ }
10154
10303
  function exportHeaders(options, accept) {
10155
10304
  const headers = new Headers(options?.headers);
10156
10305
  headers.set("Accept", accept);
@@ -10314,18 +10463,15 @@ var Settlement = class {
10314
10463
  });
10315
10464
  }
10316
10465
  /**
10317
- * List generated settlement statements, newest first.
10466
+ * List generated settlement statements, the newest period first unless
10467
+ * `sort_by` says otherwise. Several `payout_status` values match a
10468
+ * statement in any of them.
10318
10469
  *
10319
10470
  * `GET /settlement/statements`
10320
10471
  */
10321
10472
  async listStatements(params, options) {
10322
10473
  return this.request("GET", "/settlement/statements", {
10323
- query: {
10324
- test_mode: params.test_mode,
10325
- profile_id: params.profile_id,
10326
- limit: params.limit,
10327
- offset: params.offset
10328
- },
10474
+ query: statementListQuery(params),
10329
10475
  ...options
10330
10476
  });
10331
10477
  }
@@ -10582,16 +10728,14 @@ var Settlement = class {
10582
10728
  options
10583
10729
  );
10584
10730
  }
10585
- /** List report summaries without fetching every source row in each saved snapshot. */
10731
+ /**
10732
+ * List report summaries without fetching every source row in each saved
10733
+ * snapshot, the newest first. `sort_by` takes `period` here; another value
10734
+ * is refused.
10735
+ */
10586
10736
  async listNativeReports(params, options) {
10587
10737
  return this.request("GET", "/settlement/native/reports", {
10588
- query: {
10589
- profile_id: params.profile_id,
10590
- currency: params.currency,
10591
- test_mode: params.test_mode,
10592
- limit: params.limit,
10593
- offset: params.offset
10594
- },
10738
+ query: nativeListQuery(params),
10595
10739
  ...options
10596
10740
  });
10597
10741
  }
@@ -10609,15 +10753,13 @@ var Settlement = class {
10609
10753
  bodyIdempotencyKey: params.idempotency_key
10610
10754
  });
10611
10755
  }
10756
+ /**
10757
+ * List recorded payouts, the earliest value date first. `sort_by` takes
10758
+ * `value_date` or `amount` here; another value is refused.
10759
+ */
10612
10760
  async listNativePayouts(params, options) {
10613
10761
  return this.request("GET", "/settlement/native/payouts", {
10614
- query: {
10615
- profile_id: params.profile_id,
10616
- currency: params.currency,
10617
- test_mode: params.test_mode,
10618
- limit: params.limit,
10619
- offset: params.offset
10620
- },
10762
+ query: nativeListQuery(params),
10621
10763
  ...options
10622
10764
  });
10623
10765
  }
@@ -11571,6 +11713,7 @@ var Delopay = class {
11571
11713
  this.availabilityOverrides = new AvailabilityOverrides(request);
11572
11714
  this.sellToRestrictions = new SellToRestrictions(request);
11573
11715
  this.buyerBlocklist = new BuyerBlocklist(request);
11716
+ this.persons = new Persons(request);
11574
11717
  this.shopLabels = new ShopLabels(request);
11575
11718
  this.industries = new Industries(request);
11576
11719
  this.checkoutTemplates = new CheckoutTemplates(request);
@@ -17677,6 +17820,7 @@ var encodeNativePanes = encodePanes;
17677
17820
  PAYPAL_LABEL_STYLES,
17678
17821
  PRESENTATION_CONTRACT_VERSION,
17679
17822
  PaypalDisputes,
17823
+ Persons,
17680
17824
  PresentationCache,
17681
17825
  ProcessorCosts,
17682
17826
  ProcessorImports,