@delopay/sdk 0.388.0 → 0.390.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
  /**
@@ -5283,13 +5301,16 @@ var Users = class {
5283
5301
  *
5284
5302
  * Returns an empty page when a Delopay admin is impersonating a merchant,
5285
5303
  * so the admin's metadata is not exposed inside the merchant dashboard.
5304
+ *
5305
+ * Newest first unless `sort_by` says otherwise. Several `event_type` or
5306
+ * `auth_method` values match an event with any of them.
5286
5307
  */
5287
5308
  async listLoginActivity(params) {
5288
5309
  if (params === void 0) {
5289
5310
  return this.request("GET", "/user/me/login-activity");
5290
5311
  }
5291
5312
  return this.request("GET", "/user/me/login-activity", {
5292
- query: params
5313
+ query: csvQuery(params, ["event_type", "auth_method"])
5293
5314
  });
5294
5315
  }
5295
5316
  /**
@@ -6153,14 +6174,16 @@ var IdentityVerifications = class {
6153
6174
  return this.request("POST", "/identity-verifications", { body: params, ...options });
6154
6175
  }
6155
6176
  /**
6156
- * The merchant's verifications, newest first. A caller limited to one shop
6157
- * sees that shop's only.
6177
+ * The merchant's verifications, newest first unless `sort_by` says
6178
+ * otherwise. A caller limited to one shop sees that shop's only. Several
6179
+ * `outcome`, `kind` or `merchant_connector_id` values match a verification
6180
+ * with any of them.
6158
6181
  *
6159
6182
  * `GET /identity-verifications`
6160
6183
  */
6161
6184
  async list(query, options) {
6162
6185
  return this.request("GET", "/identity-verifications", {
6163
- query,
6186
+ query: csvQuery(query, ["outcome", "kind", "merchant_connector_id"]),
6164
6187
  ...options
6165
6188
  });
6166
6189
  }
@@ -6944,7 +6967,13 @@ var Export = class {
6944
6967
  );
6945
6968
  }
6946
6969
  async auditLog(params, options) {
6947
- return runExport(this.request, "GET", "/audit/export", queried(params), options);
6970
+ return runExport(
6971
+ this.request,
6972
+ "GET",
6973
+ "/audit/export",
6974
+ { query: csvQuery(params, ["profile_id", "action", "entity_type"]) },
6975
+ options
6976
+ );
6948
6977
  }
6949
6978
  };
6950
6979
  function queried(params, headers) {
@@ -7241,14 +7270,15 @@ var BuyerBlocklist = class {
7241
7270
  this.request = request;
7242
7271
  }
7243
7272
  /**
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.
7273
+ * One page of blocked buyers, newest first unless `sort_by` says otherwise,
7274
+ * filtered by scope, by `kind` (the entries that include an identifier of
7275
+ * that kind, or of any of several) and by a search over every identifier
7276
+ * and the note. Expired entries are not listed.
7247
7277
  * `GET /buyer-blocklist`
7248
7278
  */
7249
7279
  async list(params) {
7250
7280
  return this.request("GET", "/buyer-blocklist", {
7251
- query: params
7281
+ query: csvQuery(params, ["kind"])
7252
7282
  });
7253
7283
  }
7254
7284
  /**
@@ -7374,6 +7404,56 @@ var BuyerBlocklist = class {
7374
7404
  }
7375
7405
  };
7376
7406
 
7407
+ // src/resources/persons.ts
7408
+ var Persons = class {
7409
+ constructor(request) {
7410
+ this.request = request;
7411
+ }
7412
+ /**
7413
+ * One page of persons, by default the most recent payment first, with the
7414
+ * number of persons the request matches.
7415
+ * `GET /persons`
7416
+ */
7417
+ async list(params) {
7418
+ return this.request("GET", "/persons", { query: params });
7419
+ }
7420
+ /**
7421
+ * One person: its figures, the identifiers and IP addresses its payments
7422
+ * carry, and its payments by status, shop, payment method, risk band and
7423
+ * environment. The id of a person that was merged into another returns
7424
+ * that person, with `merged_from` naming the id asked for. A person with
7425
+ * no payment in the scope is not found (`404`).
7426
+ * `GET /persons/{person_id}`
7427
+ */
7428
+ async retrieve(personId, params) {
7429
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}`, {
7430
+ query: params
7431
+ });
7432
+ }
7433
+ /**
7434
+ * Other persons of the merchant that may be the same person, the likeliest
7435
+ * first, at most 20. An estimate from the devices the persons paid with;
7436
+ * related persons stay separate persons.
7437
+ * `GET /persons/{person_id}/related`
7438
+ */
7439
+ async related(personId, params) {
7440
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}/related`, {
7441
+ query: params
7442
+ });
7443
+ }
7444
+ /**
7445
+ * The person of one payment, with how many payments the person has and
7446
+ * which kinds of identifier tie this payment to the others. `404` while
7447
+ * the payment has no person yet.
7448
+ * `GET /persons/payment/{payment_id}`
7449
+ */
7450
+ async ofPayment(paymentId, params) {
7451
+ return this.request("GET", `/persons/payment/${encodeURIComponent(paymentId)}`, {
7452
+ query: params
7453
+ });
7454
+ }
7455
+ };
7456
+
7377
7457
  // src/resources/shopLabels.ts
7378
7458
  var labelsPath = (merchantId) => `/account/${encodeURIComponent(merchantId)}/business-profile/labels`;
7379
7459
  var ShopLabels = class {
@@ -7626,12 +7706,13 @@ var BuyerConversations = class {
7626
7706
  this.request = request;
7627
7707
  }
7628
7708
  /**
7629
- * One page of the inbox, the latest message first, filtered by shop,
7630
- * status, assignee, mode or buyer. `GET /buyer-conversations`
7709
+ * One page of the inbox, the latest message first unless `sort_by` says
7710
+ * otherwise, filtered by shop, status (one or several), assignee, mode or
7711
+ * buyer. `GET /buyer-conversations`
7631
7712
  */
7632
7713
  async list(params) {
7633
7714
  return this.request("GET", "/buyer-conversations", {
7634
- query: params
7715
+ query: csvQuery(params, ["status"])
7635
7716
  });
7636
7717
  }
7637
7718
  /**
@@ -7742,12 +7823,14 @@ var BuyerEvidenceReviews = class {
7742
7823
  this.request = request;
7743
7824
  }
7744
7825
  /**
7745
- * The shop's cases with buyer evidence, the nearest target first.
7746
- * `merchant_id` and `reviewer` are ignored here. `GET /buyer-evidence`
7826
+ * The shop's cases with buyer evidence, the nearest target first unless
7827
+ * `sort_by` says otherwise. Several `state` values match a case in any of
7828
+ * them. `merchant_id` and `reviewer` are ignored here, and so are the
7829
+ * `merchant` and `reviewer` sorts. `GET /buyer-evidence`
7747
7830
  */
7748
7831
  async list(params) {
7749
7832
  return this.request("GET", "/buyer-evidence", {
7750
- query: params
7833
+ query: csvQuery(params, ["state"])
7751
7834
  });
7752
7835
  }
7753
7836
  /** One case's evidence with its history and files. `GET /buyer-evidence/{id}` */
@@ -8519,10 +8602,14 @@ var Support = class {
8519
8602
  async create(body) {
8520
8603
  return this.request("POST", "/support/conversations", { body });
8521
8604
  }
8522
- /** The conversations the caller may read. `GET /support/conversations` */
8605
+ /**
8606
+ * The conversations the caller may read, the latest message first unless
8607
+ * `sort_by` says otherwise. Several `kind`, `category` or `status` values
8608
+ * match a conversation with any of them. `GET /support/conversations`
8609
+ */
8523
8610
  async list(query) {
8524
8611
  return this.request("GET", "/support/conversations", {
8525
- query: query === void 0 ? void 0 : { ...query }
8612
+ query: csvQuery(query, ["kind", "category", "status"])
8526
8613
  });
8527
8614
  }
8528
8615
  /** One conversation. `GET /support/conversations/{id}` */
@@ -8573,6 +8660,7 @@ var Support = class {
8573
8660
  };
8574
8661
 
8575
8662
  // src/resources/invoices.ts
8663
+ var INVOICE_CSV_KEYS = ["status", "kind"];
8576
8664
  var Invoices = class {
8577
8665
  constructor(request) {
8578
8666
  this.request = request;
@@ -8592,13 +8680,15 @@ var Invoices = class {
8592
8680
  return this.request("POST", "/invoices", { body: params, ...options });
8593
8681
  }
8594
8682
  /**
8595
- * One page of documents, newest first. List rows carry no `lines` unless
8596
- * `include_lines` is set, and never a `refund` summary.
8683
+ * One page of documents, newest first unless `sort_by` says otherwise. List
8684
+ * rows carry no `lines` unless `include_lines` is set, and never a `refund`
8685
+ * summary. Several `status` or `kind` values match a document in any of
8686
+ * them.
8597
8687
  * `GET /invoices`
8598
8688
  */
8599
8689
  async list(params, options) {
8600
8690
  return this.request("GET", "/invoices", {
8601
- query: params === void 0 ? void 0 : { ...params },
8691
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8602
8692
  ...options
8603
8693
  });
8604
8694
  }
@@ -8623,7 +8713,7 @@ var Invoices = class {
8623
8713
  */
8624
8714
  async listForProduct(productId, params, options) {
8625
8715
  return this.request("GET", `/products/${encodeURIComponent(productId)}/invoices`, {
8626
- query: params === void 0 ? void 0 : { ...params },
8716
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8627
8717
  ...options
8628
8718
  });
8629
8719
  }
@@ -8641,7 +8731,7 @@ var Invoices = class {
8641
8731
  */
8642
8732
  async export(params, options) {
8643
8733
  return this.request("GET", "/invoices/export", {
8644
- query: { ...params },
8734
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8645
8735
  responseType: "blob",
8646
8736
  ...options
8647
8737
  });
@@ -9336,7 +9426,10 @@ var Subscriptions = class {
9336
9426
  ...options
9337
9427
  });
9338
9428
  }
9339
- /** List subscriptions for the profile. `GET /subscriptions/list` */
9429
+ /**
9430
+ * List subscriptions for the profile, or one customer's with `customer_id`.
9431
+ * `GET /subscriptions/list`
9432
+ */
9340
9433
  async list(params, options) {
9341
9434
  return this.request("GET", "/subscriptions/list", {
9342
9435
  query: params,
@@ -10132,13 +10225,19 @@ var BuyerPortal = class {
10132
10225
  };
10133
10226
 
10134
10227
  // src/resources/audit.ts
10228
+ var MERCHANT_AUDIT_CSV_KEYS = ["profile_id", "action", "entity_type"];
10135
10229
  var Audit = class {
10136
10230
  constructor(request) {
10137
10231
  this.request = request;
10138
10232
  }
10233
+ /**
10234
+ * One page of the merchant's audit log, the newest entry first unless
10235
+ * `sort_by` says otherwise. Several `profile_id`, `action` or `entity_type`
10236
+ * values match an entry with any of them. `GET /audit`
10237
+ */
10139
10238
  async list(params) {
10140
10239
  return this.request("GET", "/audit", {
10141
- query: params
10240
+ query: csvQuery(params, MERCHANT_AUDIT_CSV_KEYS)
10142
10241
  });
10143
10242
  }
10144
10243
  /**
@@ -10151,6 +10250,33 @@ var Audit = class {
10151
10250
  };
10152
10251
 
10153
10252
  // src/resources/settlement.ts
10253
+ function statementListQuery(params) {
10254
+ return csvQuery(
10255
+ {
10256
+ test_mode: params.test_mode,
10257
+ profile_id: params.profile_id,
10258
+ limit: params.limit,
10259
+ offset: params.offset,
10260
+ payout_status: params.payout_status,
10261
+ period_from: params.period_from,
10262
+ period_to: params.period_to,
10263
+ sort_by: params.sort_by,
10264
+ sort_order: params.sort_order
10265
+ },
10266
+ ["payout_status"]
10267
+ );
10268
+ }
10269
+ function nativeListQuery(params) {
10270
+ return {
10271
+ profile_id: params.profile_id,
10272
+ currency: params.currency,
10273
+ test_mode: params.test_mode,
10274
+ limit: params.limit,
10275
+ offset: params.offset,
10276
+ sort_by: params.sort_by,
10277
+ sort_order: params.sort_order
10278
+ };
10279
+ }
10154
10280
  function exportHeaders(options, accept) {
10155
10281
  const headers = new Headers(options?.headers);
10156
10282
  headers.set("Accept", accept);
@@ -10314,18 +10440,15 @@ var Settlement = class {
10314
10440
  });
10315
10441
  }
10316
10442
  /**
10317
- * List generated settlement statements, newest first.
10443
+ * List generated settlement statements, the newest period first unless
10444
+ * `sort_by` says otherwise. Several `payout_status` values match a
10445
+ * statement in any of them.
10318
10446
  *
10319
10447
  * `GET /settlement/statements`
10320
10448
  */
10321
10449
  async listStatements(params, options) {
10322
10450
  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
- },
10451
+ query: statementListQuery(params),
10329
10452
  ...options
10330
10453
  });
10331
10454
  }
@@ -10582,16 +10705,14 @@ var Settlement = class {
10582
10705
  options
10583
10706
  );
10584
10707
  }
10585
- /** List report summaries without fetching every source row in each saved snapshot. */
10708
+ /**
10709
+ * List report summaries without fetching every source row in each saved
10710
+ * snapshot, the newest first. `sort_by` takes `period` here; another value
10711
+ * is refused.
10712
+ */
10586
10713
  async listNativeReports(params, options) {
10587
10714
  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
- },
10715
+ query: nativeListQuery(params),
10595
10716
  ...options
10596
10717
  });
10597
10718
  }
@@ -10609,15 +10730,13 @@ var Settlement = class {
10609
10730
  bodyIdempotencyKey: params.idempotency_key
10610
10731
  });
10611
10732
  }
10733
+ /**
10734
+ * List recorded payouts, the earliest value date first. `sort_by` takes
10735
+ * `value_date` or `amount` here; another value is refused.
10736
+ */
10612
10737
  async listNativePayouts(params, options) {
10613
10738
  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
- },
10739
+ query: nativeListQuery(params),
10621
10740
  ...options
10622
10741
  });
10623
10742
  }
@@ -11571,6 +11690,7 @@ var Delopay = class {
11571
11690
  this.availabilityOverrides = new AvailabilityOverrides(request);
11572
11691
  this.sellToRestrictions = new SellToRestrictions(request);
11573
11692
  this.buyerBlocklist = new BuyerBlocklist(request);
11693
+ this.persons = new Persons(request);
11574
11694
  this.shopLabels = new ShopLabels(request);
11575
11695
  this.industries = new Industries(request);
11576
11696
  this.checkoutTemplates = new CheckoutTemplates(request);
@@ -17677,6 +17797,7 @@ var encodeNativePanes = encodePanes;
17677
17797
  PAYPAL_LABEL_STYLES,
17678
17798
  PRESENTATION_CONTRACT_VERSION,
17679
17799
  PaypalDisputes,
17800
+ Persons,
17680
17801
  PresentationCache,
17681
17802
  ProcessorCosts,
17682
17803
  ProcessorImports,