@takeal/cusfront-sdk 0.6.4 → 0.6.6

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +182 -3
  3. package/dist/{cards-ofoGRU9v.d.cts → cards-BiXmrz7h.d.cts} +126 -11
  4. package/dist/{cards-BrqeBqLV.d.ts → cards-DwmzjKDC.d.ts} +126 -11
  5. package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
  6. package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
  7. package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
  8. package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
  9. package/dist/index.cjs +200 -15
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +22 -10
  12. package/dist/index.d.ts +22 -10
  13. package/dist/index.js +199 -16
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +6 -3
  16. package/dist/react/index.d.ts +6 -3
  17. package/dist/resources/attribution.d.cts +1 -1
  18. package/dist/resources/attribution.d.ts +1 -1
  19. package/dist/resources/auth.cjs.map +1 -1
  20. package/dist/resources/auth.d.cts +2 -2
  21. package/dist/resources/auth.d.ts +2 -2
  22. package/dist/resources/auth.js.map +1 -1
  23. package/dist/resources/balance.d.cts +1 -1
  24. package/dist/resources/balance.d.ts +1 -1
  25. package/dist/resources/blog.d.cts +1 -1
  26. package/dist/resources/blog.d.ts +1 -1
  27. package/dist/resources/bonus.d.cts +1 -1
  28. package/dist/resources/bonus.d.ts +1 -1
  29. package/dist/resources/branding.d.cts +1 -1
  30. package/dist/resources/branding.d.ts +1 -1
  31. package/dist/resources/cards.cjs +9 -2
  32. package/dist/resources/cards.cjs.map +1 -1
  33. package/dist/resources/cards.d.cts +2 -2
  34. package/dist/resources/cards.d.ts +2 -2
  35. package/dist/resources/cards.js +9 -2
  36. package/dist/resources/cards.js.map +1 -1
  37. package/dist/resources/close-requests.cjs +54 -0
  38. package/dist/resources/close-requests.cjs.map +1 -0
  39. package/dist/resources/close-requests.d.cts +155 -0
  40. package/dist/resources/close-requests.d.ts +155 -0
  41. package/dist/resources/close-requests.js +52 -0
  42. package/dist/resources/close-requests.js.map +1 -0
  43. package/dist/resources/codes.d.cts +1 -1
  44. package/dist/resources/codes.d.ts +1 -1
  45. package/dist/resources/consents.cjs +42 -7
  46. package/dist/resources/consents.cjs.map +1 -1
  47. package/dist/resources/consents.d.cts +59 -9
  48. package/dist/resources/consents.d.ts +59 -9
  49. package/dist/resources/consents.js +41 -8
  50. package/dist/resources/consents.js.map +1 -1
  51. package/dist/resources/debt.cjs +22 -0
  52. package/dist/resources/debt.cjs.map +1 -0
  53. package/dist/resources/debt.d.cts +76 -0
  54. package/dist/resources/debt.d.ts +76 -0
  55. package/dist/resources/debt.js +20 -0
  56. package/dist/resources/debt.js.map +1 -0
  57. package/dist/resources/deposits.cjs.map +1 -1
  58. package/dist/resources/deposits.d.cts +2 -2
  59. package/dist/resources/deposits.d.ts +2 -2
  60. package/dist/resources/deposits.js.map +1 -1
  61. package/dist/resources/devices.d.cts +2 -2
  62. package/dist/resources/devices.d.ts +2 -2
  63. package/dist/resources/documents.d.cts +1 -1
  64. package/dist/resources/documents.d.ts +1 -1
  65. package/dist/resources/funding-options.d.cts +2 -2
  66. package/dist/resources/funding-options.d.ts +2 -2
  67. package/dist/resources/history.cjs.map +1 -1
  68. package/dist/resources/history.d.cts +13 -2
  69. package/dist/resources/history.d.ts +13 -2
  70. package/dist/resources/history.js.map +1 -1
  71. package/dist/resources/me.d.cts +2 -2
  72. package/dist/resources/me.d.ts +2 -2
  73. package/dist/resources/notifications.d.cts +1 -1
  74. package/dist/resources/notifications.d.ts +1 -1
  75. package/dist/resources/push.d.cts +1 -1
  76. package/dist/resources/push.d.ts +1 -1
  77. package/dist/resources/receipts.d.cts +1 -1
  78. package/dist/resources/receipts.d.ts +1 -1
  79. package/dist/resources/referral.d.cts +1 -1
  80. package/dist/resources/referral.d.ts +1 -1
  81. package/dist/resources/sessions.d.cts +1 -1
  82. package/dist/resources/sessions.d.ts +1 -1
  83. package/dist/resources/subscription.d.cts +1 -1
  84. package/dist/resources/subscription.d.ts +1 -1
  85. package/dist/resources/subscriptions.d.cts +1 -1
  86. package/dist/resources/subscriptions.d.ts +1 -1
  87. package/dist/resources/support.cjs +69 -0
  88. package/dist/resources/support.cjs.map +1 -0
  89. package/dist/resources/support.d.cts +110 -0
  90. package/dist/resources/support.d.ts +110 -0
  91. package/dist/resources/support.js +67 -0
  92. package/dist/resources/support.js.map +1 -0
  93. package/dist/resources/wallet.d.cts +1 -1
  94. package/dist/resources/wallet.d.ts +1 -1
  95. package/dist/telegram.cjs +198 -15
  96. package/dist/telegram.cjs.map +1 -1
  97. package/dist/telegram.d.cts +6 -3
  98. package/dist/telegram.d.ts +6 -3
  99. package/dist/telegram.js +198 -15
  100. package/dist/telegram.js.map +1 -1
  101. package/package.json +16 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":"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","file":"support.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Support resource — `client.support.*`: the chat with support.\n *\n * GET /me/support/messages → list\n * POST /me/support/messages → send\n * GET /me/support/attachments/{id} → attachment\n * POST /me/support/ratings/{id} → rate\n *\n * What the person writes shows in the conversation at once, with the status\n * `queued`, and goes to support right after (`delivered`). Support answers\n * come back in the same conversation, with the text ready as cleaned HTML in\n * `html`: show it as it is, it carries only paragraphs, line breaks, bold,\n * italic, strikethrough, code, links, lists and quotes. A new answer also\n * comes as a `support_reply` notification.\n *\n * The person may write from the Telegram bot too; it is one conversation,\n * and `channel` says where each message came from.\n */\n\n/** Where a message came from, or where an answer was sent. */\nexport type SupportChannel = \"cabinet\" | \"telegram\" | (string & {});\n\n/** How far a message got: `queued` until support has it. */\nexport type SupportMessageStatus = \"queued\" | \"delivered\" | \"failed\" | (string & {});\n\n/** The conversation's state: `none` until the person writes for the first\n * time, `resolved` once support closed it. Writing again reopens it. */\nexport type SupportConversationStatus = \"none\" | \"open\" | \"resolved\" | (string & {});\n\n/** A file in the conversation. Download it with `attachment(id)`. */\nexport interface SupportAttachment {\n id: string;\n file_name: string;\n content_type: string;\n /** Bytes. */\n size: number;\n}\n\n/** One message. */\nexport interface SupportMessage {\n id: string;\n /** `user` for what the person wrote, `support` for an answer. */\n author: \"user\" | \"support\" | (string & {});\n /** The name the support agent goes by; answers only. */\n operator_name: string | null;\n channel: SupportChannel | null;\n /** What the person wrote, plain text. Empty on answers. */\n text: string;\n /** The answer as cleaned HTML. Empty on the person's own messages. */\n html: string;\n attachments: SupportAttachment[];\n status: SupportMessageStatus;\n created_at: string;\n}\n\n/** Support closed the conversation and asks how it went. */\nexport interface SupportRatingRequest {\n id: string;\n asked_at: string;\n}\n\n/** A page of the conversation, oldest first. */\nexport interface SupportConversation {\n status: SupportConversationStatus;\n items: SupportMessage[];\n /** Older messages exist: `list({ before: items[0].created_at })`. */\n has_more: boolean;\n /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */\n rating_request: SupportRatingRequest | null;\n}\n\n/** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,\n * or base64 already. */\nexport interface SupportFile {\n fileName: string;\n /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform\n * sets the list and the size. */\n contentType: string;\n data: Blob | ArrayBuffer | Uint8Array | string;\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = \"\";\n const chunk = 0x8000;\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n\nasync function toBase64(data: SupportFile[\"data\"]): Promise<string> {\n if (typeof data === \"string\") return data;\n if (data instanceof Uint8Array) return bytesToBase64(data);\n if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));\n return bytesToBase64(new Uint8Array(await data.arrayBuffer()));\n}\n\nexport class SupportResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The latest messages, oldest first, and the conversation's status.\n * `before` reads further back; `limit` is 1 to 100 (50). */\n async list(\n opts: { before?: string; limit?: number; signal?: AbortSignal } = {},\n ): Promise<SupportConversation> {\n const q = new URLSearchParams();\n if (opts.before) q.set(\"before\", opts.before);\n if (opts.limit !== undefined) q.set(\"limit\", String(opts.limit));\n const qs = q.toString();\n return this.http.get<SupportConversation>(`/me/support/messages${qs ? `?${qs}` : \"\"}`, {\n signal: opts.signal,\n });\n }\n\n /** Write to support. Text, files or both; up to 10 files. */\n async send(\n message: { text?: string; files?: SupportFile[] },\n opts: { signal?: AbortSignal } = {},\n ): Promise<SupportMessage> {\n const attachments = await Promise.all(\n (message.files ?? []).map(async (f) => ({\n file_name: f.fileName,\n content_type: f.contentType,\n data_base64: await toBase64(f.data),\n })),\n );\n return this.http.post<SupportMessage>(\"/me/support/messages\", {\n body: { text: message.text ?? \"\", attachments },\n signal: opts.signal,\n });\n }\n\n /** A file from the conversation: the person's own or one support sent. */\n async attachment(id: string, opts: { signal?: AbortSignal } = {}): Promise<Blob> {\n return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n\n /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person\n * wrote one. Each question takes one answer; a second one is a 404. */\n async rate(\n id: string,\n answer: { rating: 1 | 2 | 3 | 4 | 5; comment?: string },\n opts: { signal?: AbortSignal } = {},\n ): Promise<void> {\n await this.http.post<void>(`/me/support/ratings/${encodeURIComponent(id)}`, {\n body: { rating: answer.rating, ...(answer.comment ? { comment: answer.comment } : {}) },\n signal: opts.signal,\n });\n }\n\n /** Just the conversation's status. */\n async status(opts: { signal?: AbortSignal } = {}): Promise<SupportConversationStatus> {\n return (await this.list({ limit: 1, signal: opts.signal })).status;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Wallet resource — `client.wallet.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Wallet resource — `client.wallet.*`.
package/dist/telegram.cjs CHANGED
@@ -70,10 +70,20 @@ var HttpClient = class {
70
70
  async delete(path, opts = {}) {
71
71
  return this.request("DELETE", path, opts);
72
72
  }
73
+ /** GET a file. Same auth and refresh as the JSON calls; an error status
74
+ * throws `ApiError` the same way. */
75
+ async getBlob(path, opts = {}) {
76
+ const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
77
+ if (!resp.ok) return parseResponse(resp);
78
+ return resp.blob();
79
+ }
73
80
  async request(method, path, opts) {
81
+ return parseResponse(await this.send(method, path, opts));
82
+ }
83
+ async send(method, path, opts) {
74
84
  const url = this.absolute(path);
75
85
  const headers = {
76
- Accept: "application/json",
86
+ Accept: opts.accept ?? "application/json",
77
87
  ...this.defaultHeaders
78
88
  };
79
89
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -99,10 +109,10 @@ var HttpClient = class {
99
109
  }
100
110
  if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
101
111
  if (await this.refreshOnce()) {
102
- return this.request(method, path, { ...opts, retried: true });
112
+ return this.send(method, path, { ...opts, retried: true });
103
113
  }
104
114
  }
105
- return parseResponse(resp);
115
+ return resp;
106
116
  }
107
117
  absolute(path) {
108
118
  if (path.startsWith("http://") || path.startsWith("https://")) return path;
@@ -183,6 +193,8 @@ var CardsResource = class {
183
193
  * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
184
194
  * to `failed` (never an orphaned active card); inspect `status` /
185
195
  * `failure_reason` on the result.
196
+ * Errors: 409 `holder_data_consent_required` when the product has
197
+ * `holder_data_required` and the user has not agreed to it.
186
198
  */
187
199
  async create(input) {
188
200
  const { idempotencyKey, ...card } = input;
@@ -198,7 +210,9 @@ var CardsResource = class {
198
210
  * `pending_payment` until the payment is confirmed. The same
199
211
  * `idempotencyKey` returns the same order.
200
212
  * Errors: 400 `unknown_product` / `method_not_available` / a limit of the
201
- * way of paying, 503 no funding connector or no exchange rate.
213
+ * way of paying, 409 `holder_data_consent_required` (the product has
214
+ * `holder_data_required` and the user has not agreed to it), 503 no
215
+ * funding connector or no exchange rate.
202
216
  */
203
217
  async order(input) {
204
218
  const { idempotencyKey, ...order } = input;
@@ -360,7 +374,10 @@ var CardsResource = class {
360
374
  /**
361
375
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
362
376
  * reactivated. The optional `reason` is audited. Idempotent on an
363
- * already-terminated card.
377
+ * already-terminated card. A card that still holds money is refused (409
378
+ * `move_balance_first` or `contact_support_to_close`): close it with
379
+ * `client.closeRequests.request(id)` instead, and the money goes back the
380
+ * way it was paid.
364
381
  */
365
382
  async terminate(id, reason) {
366
383
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
@@ -727,6 +744,72 @@ var BonusResource = class {
727
744
  }
728
745
  };
729
746
 
747
+ // src/resources/debt.ts
748
+ var DebtResource = class {
749
+ constructor(http) {
750
+ this.http = http;
751
+ }
752
+ /** What the user owes in card fees, per currency, and what for. */
753
+ async get(opts = {}) {
754
+ return this.http.get("/me/debt", { signal: opts.signal });
755
+ }
756
+ /** What the user owes in `currency`, decimal string; `"0"` when nothing. */
757
+ async owedIn(currency, opts = {}) {
758
+ const debt = await this.get(opts);
759
+ const want = currency.trim().toUpperCase();
760
+ return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
761
+ }
762
+ };
763
+
764
+ // src/resources/close-requests.ts
765
+ var CloseRequestsResource = class {
766
+ constructor(http) {
767
+ this.http = http;
768
+ }
769
+ /**
770
+ * Close a card that holds money, the rest going back the way it was paid.
771
+ * Asking again for the same card returns the same request. 404 no such
772
+ * card · 409 {@link CloseRequestError}: `no_balance` means the card holds
773
+ * nothing, close it with `cards.terminate()` · 503 the issuer can't be
774
+ * reached; the card stays as it was.
775
+ */
776
+ async request(cardId, input = {}) {
777
+ return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
778
+ body: { reason: input.reason }
779
+ });
780
+ }
781
+ /** Every card close request of the user, newest first. */
782
+ async list(opts = {}) {
783
+ const res = await this.http.get("/me/close-requests", {
784
+ signal: opts.signal
785
+ });
786
+ return res.items;
787
+ }
788
+ /** One close request. 404 when it isn't the user's. */
789
+ async get(id, opts = {}) {
790
+ return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
791
+ signal: opts.signal
792
+ });
793
+ }
794
+ /** The request for this card, if the user made one. */
795
+ async forCard(cardId, opts = {}) {
796
+ const all = await this.list(opts);
797
+ return all.find((r) => r.card_id === cardId) ?? null;
798
+ }
799
+ /**
800
+ * Give a bank account or a card in the user's own name, when the request
801
+ * is `payout_details_required` (or `identity_check`, to correct them). 400
802
+ * `validation`: a name, number or bank code that doesn't look right · 409
803
+ * `details_not_needed`.
804
+ */
805
+ async submitPayoutDetails(id, details) {
806
+ return this.http.post(
807
+ `/me/close-requests/${encodeURIComponent(id)}/payout-details`,
808
+ { body: details }
809
+ );
810
+ }
811
+ };
812
+
730
813
  // src/resources/codes.ts
731
814
  var CodesResource = class {
732
815
  constructor(http) {
@@ -1241,6 +1324,8 @@ var HistoryResource = class {
1241
1324
  };
1242
1325
 
1243
1326
  // src/resources/consents.ts
1327
+ var HOLDER_DATA_CONSENT = "holder_data_transfer";
1328
+ var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
1244
1329
  var ConsentsResource = class {
1245
1330
  constructor(http) {
1246
1331
  this.http = http;
@@ -1249,20 +1334,51 @@ var ConsentsResource = class {
1249
1334
  async get() {
1250
1335
  return this.http.get("/me/consents");
1251
1336
  }
1337
+ /** Whether `kind` stands now: given and not withdrawn since. */
1338
+ async stands(kind) {
1339
+ const { consents } = await this.get();
1340
+ return consents.some((c) => c.kind === kind && c.given);
1341
+ }
1252
1342
  /**
1253
- * Give (`true`) or withdraw (`false`) an optional consent: `marketing` or
1254
- * `cookies_analytics`. Withdrawing `marketing` turns advertising off in
1255
- * every channel at once; giving it turns on advertising by e-mail. A call
1256
- * that changes nothing records nothing.
1343
+ * Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
1344
+ * `cookies_analytics`, `holder_data_transfer` or
1345
+ * `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
1346
+ * off in every channel at once; giving it turns on advertising by e-mail.
1347
+ * Withdrawing `holder_data_transfer` leaves the user's cards alone and
1348
+ * stops new cards whose product has `holder_data_required`. A call that
1349
+ * changes nothing records nothing, unless it names a card.
1350
+ *
1351
+ * The third argument is the channel, or {@link ConsentOptions} with the
1352
+ * channel and the card.
1257
1353
  *
1258
1354
  * Errors: 400 `consent_required` for `terms` or `personal_data`,
1259
- * 400 `unknown_consent`.
1355
+ * 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
1356
+ * that takes none), 404 `not_found` (not one of the user's cards).
1260
1357
  */
1261
- async set(kind, given, channel) {
1358
+ async set(kind, given, options) {
1359
+ const opts = typeof options === "string" ? { channel: options } : options ?? {};
1262
1360
  const body = { kind, given };
1263
- if (channel !== void 0) body.channel = channel;
1361
+ if (opts.channel !== void 0) body.channel = opts.channel;
1362
+ if (opts.cardId !== void 0) body.card_id = opts.cardId;
1264
1363
  return this.http.post("/me/consents", { body });
1265
1364
  }
1365
+ /**
1366
+ * The user agreed on the consent screen that their real personal details
1367
+ * go to the card issuer (`holder_data_transfer`). Needed before ordering a
1368
+ * product with `holder_data_required`, unless the order itself carries the
1369
+ * kind in its `consents`.
1370
+ */
1371
+ async allowHolderData(options) {
1372
+ return this.set(HOLDER_DATA_CONSENT, true, options);
1373
+ }
1374
+ /**
1375
+ * The user agreed that their documents go to the card issuer for a
1376
+ * dispute (`dispute_documents_transfer`). Name the disputed card with
1377
+ * `cardId`; each call is then recorded on its own.
1378
+ */
1379
+ async allowDisputeDocuments(options) {
1380
+ return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
1381
+ }
1266
1382
  /**
1267
1383
  * Record what the cookie banner or the cookie settings say about
1268
1384
  * analytics. Works signed in or not: before sign-in the choice is kept
@@ -1303,6 +1419,70 @@ var ReceiptsResource = class {
1303
1419
  }
1304
1420
  };
1305
1421
 
1422
+ // src/resources/support.ts
1423
+ function bytesToBase64(bytes) {
1424
+ let binary = "";
1425
+ const chunk = 32768;
1426
+ for (let i = 0; i < bytes.length; i += chunk) {
1427
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
1428
+ }
1429
+ return btoa(binary);
1430
+ }
1431
+ async function toBase64(data) {
1432
+ if (typeof data === "string") return data;
1433
+ if (data instanceof Uint8Array) return bytesToBase64(data);
1434
+ if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
1435
+ return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
1436
+ }
1437
+ var SupportResource = class {
1438
+ constructor(http) {
1439
+ this.http = http;
1440
+ }
1441
+ /** The latest messages, oldest first, and the conversation's status.
1442
+ * `before` reads further back; `limit` is 1 to 100 (50). */
1443
+ async list(opts = {}) {
1444
+ const q = new URLSearchParams();
1445
+ if (opts.before) q.set("before", opts.before);
1446
+ if (opts.limit !== void 0) q.set("limit", String(opts.limit));
1447
+ const qs = q.toString();
1448
+ return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
1449
+ signal: opts.signal
1450
+ });
1451
+ }
1452
+ /** Write to support. Text, files or both; up to 10 files. */
1453
+ async send(message, opts = {}) {
1454
+ const attachments = await Promise.all(
1455
+ (message.files ?? []).map(async (f) => ({
1456
+ file_name: f.fileName,
1457
+ content_type: f.contentType,
1458
+ data_base64: await toBase64(f.data)
1459
+ }))
1460
+ );
1461
+ return this.http.post("/me/support/messages", {
1462
+ body: { text: message.text ?? "", attachments },
1463
+ signal: opts.signal
1464
+ });
1465
+ }
1466
+ /** A file from the conversation: the person's own or one support sent. */
1467
+ async attachment(id, opts = {}) {
1468
+ return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
1469
+ signal: opts.signal
1470
+ });
1471
+ }
1472
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
1473
+ * wrote one. Each question takes one answer; a second one is a 404. */
1474
+ async rate(id, answer, opts = {}) {
1475
+ await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
1476
+ body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
1477
+ signal: opts.signal
1478
+ });
1479
+ }
1480
+ /** Just the conversation's status. */
1481
+ async status(opts = {}) {
1482
+ return (await this.list({ limit: 1, signal: opts.signal })).status;
1483
+ }
1484
+ };
1485
+
1306
1486
  // src/resources/funding-options.ts
1307
1487
  var FundingOptionsResource = class {
1308
1488
  constructor(http) {
@@ -1315,7 +1495,7 @@ var FundingOptionsResource = class {
1315
1495
  };
1316
1496
 
1317
1497
  // src/version.ts
1318
- var SDK_VERSION = "0.6.4";
1498
+ var SDK_VERSION = "0.6.6";
1319
1499
 
1320
1500
  // src/client-platform.ts
1321
1501
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1390,7 +1570,7 @@ function isAbsolute(url) {
1390
1570
  }
1391
1571
 
1392
1572
  // src/compat.ts
1393
- var SUPPORTED_MEISTER = ">=0.6.9, <0.7.0";
1573
+ var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
1394
1574
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1395
1575
  function parse(v) {
1396
1576
  const m = SEMVER.exec(v.trim());
@@ -1485,6 +1665,8 @@ function createClient(opts) {
1485
1665
  cards: new CardsResource(http),
1486
1666
  balance: new BalanceResource(http),
1487
1667
  bonus: new BonusResource(http),
1668
+ debt: new DebtResource(http),
1669
+ closeRequests: new CloseRequestsResource(http),
1488
1670
  codes: new CodesResource(http),
1489
1671
  referral: new ReferralResource(http),
1490
1672
  subscription: new SubscriptionResource(http),
@@ -1501,7 +1683,8 @@ function createClient(opts) {
1501
1683
  attribution: new AttributionResource(http),
1502
1684
  history: new HistoryResource(http),
1503
1685
  consents: new ConsentsResource(http),
1504
- receipts: new ReceiptsResource(http)
1686
+ receipts: new ReceiptsResource(http),
1687
+ support: new SupportResource(http)
1505
1688
  };
1506
1689
  }
1507
1690
  function pickDefaultStore(key) {