@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.
@@ -370,6 +370,21 @@ var Authentication = class {
370
370
  }
371
371
  };
372
372
 
373
+ // src/listQuery.ts
374
+ function csvQuery(params, csvKeys) {
375
+ if (!params) return void 0;
376
+ const joined = csvKeys;
377
+ const query = {};
378
+ for (const [key, value] of Object.entries(params)) {
379
+ if (!joined.includes(key) || !Array.isArray(value)) {
380
+ query[key] = value;
381
+ } else if (value.length > 0) {
382
+ query[key] = value.join(",");
383
+ }
384
+ }
385
+ return query;
386
+ }
387
+
373
388
  // src/resources/billing.ts
374
389
  var BillingAllocations = class {
375
390
  constructor(request) {
@@ -485,15 +500,17 @@ var Billing = class {
485
500
  });
486
501
  }
487
502
  /**
488
- * List the balance ledger (credits and debits) for a merchant.
503
+ * List the balance ledger (credits and debits) for a merchant, the newest
504
+ * entry first unless `sort_by` says otherwise.
489
505
  *
490
506
  * @param merchantId - The merchant account ID.
491
- * @param params - Optional pagination parameters.
507
+ * @param params - Optional pagination, filters (entry types, a creation
508
+ * window) and sort.
492
509
  * @returns The ledger entries.
493
510
  */
494
511
  async listLedger(merchantId, params) {
495
512
  return this.request("GET", `/billing/${encodeURIComponent(merchantId)}/ledger`, {
496
- query: params
513
+ query: csvQuery(params, ["entry_type"])
497
514
  });
498
515
  }
499
516
  /**
@@ -1296,6 +1313,29 @@ var Customers = class {
1296
1313
  async retrieve(customerId) {
1297
1314
  return this.request("GET", `/customers/${encodeURIComponent(customerId)}`);
1298
1315
  }
1316
+ /**
1317
+ * Place an existing customer in a shop of the merchant, so the shop's API keys and team members
1318
+ * find the customer before any payment. The customer keeps the shops they already belong to;
1319
+ * placing one already in the shop changes nothing (`already_in_shop`). Needs a merchant-wide key:
1320
+ * a key bound to one shop is refused. `POST /customers/{customer_id}/shops`
1321
+ *
1322
+ * @param customerId - The customer to place.
1323
+ * @param profileId - The shop. It must belong to the merchant.
1324
+ */
1325
+ async placeInShop(customerId, profileId, options) {
1326
+ return this.request("POST", `/customers/${encodeURIComponent(customerId)}/shops`, {
1327
+ body: { profile_id: profileId },
1328
+ ...options
1329
+ });
1330
+ }
1331
+ /**
1332
+ * Place up to 500 existing customers in one shop of the merchant, for example after an import.
1333
+ * The answer lists every distinct customer in request order with what happened: `placed`,
1334
+ * `already_in_shop` or `not_found`. Needs a merchant-wide key. `POST /customers/shops/place`
1335
+ */
1336
+ async placeManyInShop(params, options) {
1337
+ return this.request("POST", "/customers/shops/place", { body: params, ...options });
1338
+ }
1299
1339
  /**
1300
1340
  * Update an existing customer's details.
1301
1341
  *
@@ -4959,13 +4999,16 @@ var Users = class {
4959
4999
  *
4960
5000
  * Returns an empty page when a Delopay admin is impersonating a merchant,
4961
5001
  * so the admin's metadata is not exposed inside the merchant dashboard.
5002
+ *
5003
+ * Newest first unless `sort_by` says otherwise. Several `event_type` or
5004
+ * `auth_method` values match an event with any of them.
4962
5005
  */
4963
5006
  async listLoginActivity(params) {
4964
5007
  if (params === void 0) {
4965
5008
  return this.request("GET", "/user/me/login-activity");
4966
5009
  }
4967
5010
  return this.request("GET", "/user/me/login-activity", {
4968
- query: params
5011
+ query: csvQuery(params, ["event_type", "auth_method"])
4969
5012
  });
4970
5013
  }
4971
5014
  /**
@@ -5829,14 +5872,16 @@ var IdentityVerifications = class {
5829
5872
  return this.request("POST", "/identity-verifications", { body: params, ...options });
5830
5873
  }
5831
5874
  /**
5832
- * The merchant's verifications, newest first. A caller limited to one shop
5833
- * sees that shop's only.
5875
+ * The merchant's verifications, newest first unless `sort_by` says
5876
+ * otherwise. A caller limited to one shop sees that shop's only. Several
5877
+ * `outcome`, `kind` or `merchant_connector_id` values match a verification
5878
+ * with any of them.
5834
5879
  *
5835
5880
  * `GET /identity-verifications`
5836
5881
  */
5837
5882
  async list(query, options) {
5838
5883
  return this.request("GET", "/identity-verifications", {
5839
- query,
5884
+ query: csvQuery(query, ["outcome", "kind", "merchant_connector_id"]),
5840
5885
  ...options
5841
5886
  });
5842
5887
  }
@@ -6620,7 +6665,13 @@ var Export = class {
6620
6665
  );
6621
6666
  }
6622
6667
  async auditLog(params, options) {
6623
- return runExport(this.request, "GET", "/audit/export", queried(params), options);
6668
+ return runExport(
6669
+ this.request,
6670
+ "GET",
6671
+ "/audit/export",
6672
+ { query: csvQuery(params, ["profile_id", "action", "entity_type"]) },
6673
+ options
6674
+ );
6624
6675
  }
6625
6676
  };
6626
6677
  function queried(params, headers) {
@@ -6917,14 +6968,15 @@ var BuyerBlocklist = class {
6917
6968
  this.request = request;
6918
6969
  }
6919
6970
  /**
6920
- * One page of blocked buyers, newest first, filtered by scope, by `kind`
6921
- * (the entries that include an identifier of that kind) and by a search
6922
- * over every identifier and the note. Expired entries are not listed.
6971
+ * One page of blocked buyers, newest first unless `sort_by` says otherwise,
6972
+ * filtered by scope, by `kind` (the entries that include an identifier of
6973
+ * that kind, or of any of several) and by a search over every identifier
6974
+ * and the note. Expired entries are not listed.
6923
6975
  * `GET /buyer-blocklist`
6924
6976
  */
6925
6977
  async list(params) {
6926
6978
  return this.request("GET", "/buyer-blocklist", {
6927
- query: params
6979
+ query: csvQuery(params, ["kind"])
6928
6980
  });
6929
6981
  }
6930
6982
  /**
@@ -7050,6 +7102,56 @@ var BuyerBlocklist = class {
7050
7102
  }
7051
7103
  };
7052
7104
 
7105
+ // src/resources/persons.ts
7106
+ var Persons = class {
7107
+ constructor(request) {
7108
+ this.request = request;
7109
+ }
7110
+ /**
7111
+ * One page of persons, by default the most recent payment first, with the
7112
+ * number of persons the request matches.
7113
+ * `GET /persons`
7114
+ */
7115
+ async list(params) {
7116
+ return this.request("GET", "/persons", { query: params });
7117
+ }
7118
+ /**
7119
+ * One person: its figures, the identifiers and IP addresses its payments
7120
+ * carry, and its payments by status, shop, payment method, risk band and
7121
+ * environment. The id of a person that was merged into another returns
7122
+ * that person, with `merged_from` naming the id asked for. A person with
7123
+ * no payment in the scope is not found (`404`).
7124
+ * `GET /persons/{person_id}`
7125
+ */
7126
+ async retrieve(personId, params) {
7127
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}`, {
7128
+ query: params
7129
+ });
7130
+ }
7131
+ /**
7132
+ * Other persons of the merchant that may be the same person, the likeliest
7133
+ * first, at most 20. An estimate from the devices the persons paid with;
7134
+ * related persons stay separate persons.
7135
+ * `GET /persons/{person_id}/related`
7136
+ */
7137
+ async related(personId, params) {
7138
+ return this.request("GET", `/persons/${encodeURIComponent(personId)}/related`, {
7139
+ query: params
7140
+ });
7141
+ }
7142
+ /**
7143
+ * The person of one payment, with how many payments the person has and
7144
+ * which kinds of identifier tie this payment to the others. `404` while
7145
+ * the payment has no person yet.
7146
+ * `GET /persons/payment/{payment_id}`
7147
+ */
7148
+ async ofPayment(paymentId, params) {
7149
+ return this.request("GET", `/persons/payment/${encodeURIComponent(paymentId)}`, {
7150
+ query: params
7151
+ });
7152
+ }
7153
+ };
7154
+
7053
7155
  // src/resources/shopLabels.ts
7054
7156
  var labelsPath = (merchantId) => `/account/${encodeURIComponent(merchantId)}/business-profile/labels`;
7055
7157
  var ShopLabels = class {
@@ -7302,12 +7404,13 @@ var BuyerConversations = class {
7302
7404
  this.request = request;
7303
7405
  }
7304
7406
  /**
7305
- * One page of the inbox, the latest message first, filtered by shop,
7306
- * status, assignee, mode or buyer. `GET /buyer-conversations`
7407
+ * One page of the inbox, the latest message first unless `sort_by` says
7408
+ * otherwise, filtered by shop, status (one or several), assignee, mode or
7409
+ * buyer. `GET /buyer-conversations`
7307
7410
  */
7308
7411
  async list(params) {
7309
7412
  return this.request("GET", "/buyer-conversations", {
7310
- query: params
7413
+ query: csvQuery(params, ["status"])
7311
7414
  });
7312
7415
  }
7313
7416
  /**
@@ -7418,12 +7521,14 @@ var BuyerEvidenceReviews = class {
7418
7521
  this.request = request;
7419
7522
  }
7420
7523
  /**
7421
- * The shop's cases with buyer evidence, the nearest target first.
7422
- * `merchant_id` and `reviewer` are ignored here. `GET /buyer-evidence`
7524
+ * The shop's cases with buyer evidence, the nearest target first unless
7525
+ * `sort_by` says otherwise. Several `state` values match a case in any of
7526
+ * them. `merchant_id` and `reviewer` are ignored here, and so are the
7527
+ * `merchant` and `reviewer` sorts. `GET /buyer-evidence`
7423
7528
  */
7424
7529
  async list(params) {
7425
7530
  return this.request("GET", "/buyer-evidence", {
7426
- query: params
7531
+ query: csvQuery(params, ["state"])
7427
7532
  });
7428
7533
  }
7429
7534
  /** One case's evidence with its history and files. `GET /buyer-evidence/{id}` */
@@ -8195,10 +8300,14 @@ var Support = class {
8195
8300
  async create(body) {
8196
8301
  return this.request("POST", "/support/conversations", { body });
8197
8302
  }
8198
- /** The conversations the caller may read. `GET /support/conversations` */
8303
+ /**
8304
+ * The conversations the caller may read, the latest message first unless
8305
+ * `sort_by` says otherwise. Several `kind`, `category` or `status` values
8306
+ * match a conversation with any of them. `GET /support/conversations`
8307
+ */
8199
8308
  async list(query) {
8200
8309
  return this.request("GET", "/support/conversations", {
8201
- query: query === void 0 ? void 0 : { ...query }
8310
+ query: csvQuery(query, ["kind", "category", "status"])
8202
8311
  });
8203
8312
  }
8204
8313
  /** One conversation. `GET /support/conversations/{id}` */
@@ -8249,6 +8358,7 @@ var Support = class {
8249
8358
  };
8250
8359
 
8251
8360
  // src/resources/invoices.ts
8361
+ var INVOICE_CSV_KEYS = ["status", "kind"];
8252
8362
  var Invoices = class {
8253
8363
  constructor(request) {
8254
8364
  this.request = request;
@@ -8268,13 +8378,15 @@ var Invoices = class {
8268
8378
  return this.request("POST", "/invoices", { body: params, ...options });
8269
8379
  }
8270
8380
  /**
8271
- * One page of documents, newest first. List rows carry no `lines` unless
8272
- * `include_lines` is set, and never a `refund` summary.
8381
+ * One page of documents, newest first unless `sort_by` says otherwise. List
8382
+ * rows carry no `lines` unless `include_lines` is set, and never a `refund`
8383
+ * summary. Several `status` or `kind` values match a document in any of
8384
+ * them.
8273
8385
  * `GET /invoices`
8274
8386
  */
8275
8387
  async list(params, options) {
8276
8388
  return this.request("GET", "/invoices", {
8277
- query: params === void 0 ? void 0 : { ...params },
8389
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8278
8390
  ...options
8279
8391
  });
8280
8392
  }
@@ -8299,7 +8411,7 @@ var Invoices = class {
8299
8411
  */
8300
8412
  async listForProduct(productId, params, options) {
8301
8413
  return this.request("GET", `/products/${encodeURIComponent(productId)}/invoices`, {
8302
- query: params === void 0 ? void 0 : { ...params },
8414
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8303
8415
  ...options
8304
8416
  });
8305
8417
  }
@@ -8317,7 +8429,7 @@ var Invoices = class {
8317
8429
  */
8318
8430
  async export(params, options) {
8319
8431
  return this.request("GET", "/invoices/export", {
8320
- query: { ...params },
8432
+ query: csvQuery(params, INVOICE_CSV_KEYS),
8321
8433
  responseType: "blob",
8322
8434
  ...options
8323
8435
  });
@@ -9012,7 +9124,10 @@ var Subscriptions = class {
9012
9124
  ...options
9013
9125
  });
9014
9126
  }
9015
- /** List subscriptions for the profile. `GET /subscriptions/list` */
9127
+ /**
9128
+ * List subscriptions for the profile, or one customer's with `customer_id`.
9129
+ * `GET /subscriptions/list`
9130
+ */
9016
9131
  async list(params, options) {
9017
9132
  return this.request("GET", "/subscriptions/list", {
9018
9133
  query: params,
@@ -9808,13 +9923,19 @@ var BuyerPortal = class {
9808
9923
  };
9809
9924
 
9810
9925
  // src/resources/audit.ts
9926
+ var MERCHANT_AUDIT_CSV_KEYS = ["profile_id", "action", "entity_type"];
9811
9927
  var Audit = class {
9812
9928
  constructor(request) {
9813
9929
  this.request = request;
9814
9930
  }
9931
+ /**
9932
+ * One page of the merchant's audit log, the newest entry first unless
9933
+ * `sort_by` says otherwise. Several `profile_id`, `action` or `entity_type`
9934
+ * values match an entry with any of them. `GET /audit`
9935
+ */
9815
9936
  async list(params) {
9816
9937
  return this.request("GET", "/audit", {
9817
- query: params
9938
+ query: csvQuery(params, MERCHANT_AUDIT_CSV_KEYS)
9818
9939
  });
9819
9940
  }
9820
9941
  /**
@@ -9827,6 +9948,33 @@ var Audit = class {
9827
9948
  };
9828
9949
 
9829
9950
  // src/resources/settlement.ts
9951
+ function statementListQuery(params) {
9952
+ return csvQuery(
9953
+ {
9954
+ test_mode: params.test_mode,
9955
+ profile_id: params.profile_id,
9956
+ limit: params.limit,
9957
+ offset: params.offset,
9958
+ payout_status: params.payout_status,
9959
+ period_from: params.period_from,
9960
+ period_to: params.period_to,
9961
+ sort_by: params.sort_by,
9962
+ sort_order: params.sort_order
9963
+ },
9964
+ ["payout_status"]
9965
+ );
9966
+ }
9967
+ function nativeListQuery(params) {
9968
+ return {
9969
+ profile_id: params.profile_id,
9970
+ currency: params.currency,
9971
+ test_mode: params.test_mode,
9972
+ limit: params.limit,
9973
+ offset: params.offset,
9974
+ sort_by: params.sort_by,
9975
+ sort_order: params.sort_order
9976
+ };
9977
+ }
9830
9978
  function exportHeaders(options, accept) {
9831
9979
  const headers = new Headers(options?.headers);
9832
9980
  headers.set("Accept", accept);
@@ -9990,18 +10138,15 @@ var Settlement = class {
9990
10138
  });
9991
10139
  }
9992
10140
  /**
9993
- * List generated settlement statements, newest first.
10141
+ * List generated settlement statements, the newest period first unless
10142
+ * `sort_by` says otherwise. Several `payout_status` values match a
10143
+ * statement in any of them.
9994
10144
  *
9995
10145
  * `GET /settlement/statements`
9996
10146
  */
9997
10147
  async listStatements(params, options) {
9998
10148
  return this.request("GET", "/settlement/statements", {
9999
- query: {
10000
- test_mode: params.test_mode,
10001
- profile_id: params.profile_id,
10002
- limit: params.limit,
10003
- offset: params.offset
10004
- },
10149
+ query: statementListQuery(params),
10005
10150
  ...options
10006
10151
  });
10007
10152
  }
@@ -10258,16 +10403,14 @@ var Settlement = class {
10258
10403
  options
10259
10404
  );
10260
10405
  }
10261
- /** List report summaries without fetching every source row in each saved snapshot. */
10406
+ /**
10407
+ * List report summaries without fetching every source row in each saved
10408
+ * snapshot, the newest first. `sort_by` takes `period` here; another value
10409
+ * is refused.
10410
+ */
10262
10411
  async listNativeReports(params, options) {
10263
10412
  return this.request("GET", "/settlement/native/reports", {
10264
- query: {
10265
- profile_id: params.profile_id,
10266
- currency: params.currency,
10267
- test_mode: params.test_mode,
10268
- limit: params.limit,
10269
- offset: params.offset
10270
- },
10413
+ query: nativeListQuery(params),
10271
10414
  ...options
10272
10415
  });
10273
10416
  }
@@ -10285,15 +10428,13 @@ var Settlement = class {
10285
10428
  bodyIdempotencyKey: params.idempotency_key
10286
10429
  });
10287
10430
  }
10431
+ /**
10432
+ * List recorded payouts, the earliest value date first. `sort_by` takes
10433
+ * `value_date` or `amount` here; another value is refused.
10434
+ */
10288
10435
  async listNativePayouts(params, options) {
10289
10436
  return this.request("GET", "/settlement/native/payouts", {
10290
- query: {
10291
- profile_id: params.profile_id,
10292
- currency: params.currency,
10293
- test_mode: params.test_mode,
10294
- limit: params.limit,
10295
- offset: params.offset
10296
- },
10437
+ query: nativeListQuery(params),
10297
10438
  ...options
10298
10439
  });
10299
10440
  }
@@ -11247,6 +11388,7 @@ var Delopay = class {
11247
11388
  this.availabilityOverrides = new AvailabilityOverrides(request);
11248
11389
  this.sellToRestrictions = new SellToRestrictions(request);
11249
11390
  this.buyerBlocklist = new BuyerBlocklist(request);
11391
+ this.persons = new Persons(request);
11250
11392
  this.shopLabels = new ShopLabels(request);
11251
11393
  this.industries = new Industries(request);
11252
11394
  this.checkoutTemplates = new CheckoutTemplates(request);
@@ -17237,6 +17379,7 @@ var encodeNativePanes = encodePanes;
17237
17379
  export {
17238
17380
  DelopayError,
17239
17381
  DelopayAuthenticationError,
17382
+ csvQuery,
17240
17383
  runExport,
17241
17384
  preventionCaseQuery,
17242
17385
  ChargebackPrevention,
@@ -17258,6 +17401,7 @@ export {
17258
17401
  AvailabilityOverrides,
17259
17402
  SellToRestrictions,
17260
17403
  BuyerBlocklist,
17404
+ Persons,
17261
17405
  ShopLabels,
17262
17406
  Industries,
17263
17407
  CheckoutTemplates,
@@ -17274,6 +17418,7 @@ export {
17274
17418
  CheckoutMethods,
17275
17419
  Subscriptions,
17276
17420
  Audit,
17421
+ statementListQuery,
17277
17422
  Settlement,
17278
17423
  OperationLimits,
17279
17424
  Settings,
@@ -17539,4 +17684,4 @@ export {
17539
17684
  decodeNativePanes,
17540
17685
  encodeNativePanes
17541
17686
  };
17542
- //# sourceMappingURL=chunk-A6CXJOUK.js.map
17687
+ //# sourceMappingURL=chunk-GN6GS4V2.js.map