@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.
- package/CHANGELOG.md +46 -0
- package/README.md +182 -3
- package/dist/{cards-ofoGRU9v.d.cts → cards-BiXmrz7h.d.cts} +126 -11
- package/dist/{cards-BrqeBqLV.d.ts → cards-DwmzjKDC.d.ts} +126 -11
- package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
- package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
- package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
- package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
- package/dist/index.cjs +200 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -10
- package/dist/index.d.ts +22 -10
- package/dist/index.js +199 -16
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +6 -3
- package/dist/react/index.d.ts +6 -3
- package/dist/resources/attribution.d.cts +1 -1
- package/dist/resources/attribution.d.ts +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +2 -2
- package/dist/resources/auth.d.ts +2 -2
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/bonus.d.cts +1 -1
- package/dist/resources/bonus.d.ts +1 -1
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +9 -2
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -2
- package/dist/resources/cards.d.ts +2 -2
- package/dist/resources/cards.js +9 -2
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/close-requests.cjs +54 -0
- package/dist/resources/close-requests.cjs.map +1 -0
- package/dist/resources/close-requests.d.cts +155 -0
- package/dist/resources/close-requests.d.ts +155 -0
- package/dist/resources/close-requests.js +52 -0
- package/dist/resources/close-requests.js.map +1 -0
- package/dist/resources/codes.d.cts +1 -1
- package/dist/resources/codes.d.ts +1 -1
- package/dist/resources/consents.cjs +42 -7
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.d.cts +59 -9
- package/dist/resources/consents.d.ts +59 -9
- package/dist/resources/consents.js +41 -8
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/debt.cjs +22 -0
- package/dist/resources/debt.cjs.map +1 -0
- package/dist/resources/debt.d.cts +76 -0
- package/dist/resources/debt.d.ts +76 -0
- package/dist/resources/debt.js +20 -0
- package/dist/resources/debt.js.map +1 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -2
- package/dist/resources/deposits.d.ts +2 -2
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/documents.d.cts +1 -1
- package/dist/resources/documents.d.ts +1 -1
- package/dist/resources/funding-options.d.cts +2 -2
- package/dist/resources/funding-options.d.ts +2 -2
- package/dist/resources/history.cjs.map +1 -1
- package/dist/resources/history.d.cts +13 -2
- package/dist/resources/history.d.ts +13 -2
- package/dist/resources/history.js.map +1 -1
- package/dist/resources/me.d.cts +2 -2
- package/dist/resources/me.d.ts +2 -2
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/receipts.d.cts +1 -1
- package/dist/resources/receipts.d.ts +1 -1
- package/dist/resources/referral.d.cts +1 -1
- package/dist/resources/referral.d.ts +1 -1
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.d.cts +1 -1
- package/dist/resources/subscription.d.ts +1 -1
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/support.cjs +69 -0
- package/dist/resources/support.cjs.map +1 -0
- package/dist/resources/support.d.cts +110 -0
- package/dist/resources/support.d.ts +110 -0
- package/dist/resources/support.js +67 -0
- package/dist/resources/support.js.map +1 -0
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +198 -15
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +6 -3
- package/dist/telegram.d.ts +6 -3
- package/dist/telegram.js +198 -15
- package/dist/telegram.js.map +1 -1
- package/package.json +16 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
2
|
-
import { H as HttpClient } from './http-
|
|
2
|
+
import { H as HttpClient } from './http-CL97TjMO.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Structured customer billing details — shared by the deposits and cards
|
|
@@ -164,8 +164,13 @@ interface CreateQuoteInput {
|
|
|
164
164
|
* a line of its own on the credited amount.
|
|
165
165
|
*/
|
|
166
166
|
type FeeKind = "spread" | "markup" | "commission";
|
|
167
|
-
/**
|
|
168
|
-
|
|
167
|
+
/**
|
|
168
|
+
* How far a top-up meant for a card has got. `waiting`: the card's provider
|
|
169
|
+
* took the load and hasn't done it yet. `stalled`: it has taken longer than
|
|
170
|
+
* the platform waits. `refunding` / `refunded`: the card never got the money,
|
|
171
|
+
* and the payment is going back, or has gone back, to where it was paid from.
|
|
172
|
+
*/
|
|
173
|
+
type CardLoadStatus = "pending" | "waiting" | "stalled" | "succeeded" | "failed" | "refunding" | "refunded";
|
|
169
174
|
/**
|
|
170
175
|
* A card to issue with the top-up: the fields of `cards.create` without
|
|
171
176
|
* its idempotency key (the deposit's covers both). The card's price is
|
|
@@ -205,6 +210,13 @@ interface FundingQuote {
|
|
|
205
210
|
method?: DepositMethod;
|
|
206
211
|
/** The rate is locked until then; the deposit made with it waits for its payment as long. */
|
|
207
212
|
expires_at: string;
|
|
213
|
+
/**
|
|
214
|
+
* What the user owes in card fees, in `credited_currency`, that this
|
|
215
|
+
* top-up pays first: it comes off `credited_amount` and the rest is
|
|
216
|
+
* credited. `"0"` when nothing is owed. Show it before the payment. Older
|
|
217
|
+
* platforms leave it out.
|
|
218
|
+
*/
|
|
219
|
+
debt_withheld?: string;
|
|
208
220
|
}
|
|
209
221
|
interface Deposit {
|
|
210
222
|
id: string;
|
|
@@ -274,6 +286,17 @@ interface Deposit {
|
|
|
274
286
|
* wallet instead (funding connectors in `mixed` mode). The user is told.
|
|
275
287
|
*/
|
|
276
288
|
returned_to_wallet_at?: string | null;
|
|
289
|
+
/**
|
|
290
|
+
* The user's debt in card fees shown before the payment, in the credited
|
|
291
|
+
* currency: the most this top-up pays towards it before the rest is
|
|
292
|
+
* credited. Absent when nothing was owed.
|
|
293
|
+
*/
|
|
294
|
+
debt_quoted?: string | null;
|
|
295
|
+
/**
|
|
296
|
+
* What the top-up did pay towards the debt. For a top-up onto a card,
|
|
297
|
+
* `card_amount` is already net of it.
|
|
298
|
+
*/
|
|
299
|
+
debt_withheld?: string | null;
|
|
277
300
|
created_at: string;
|
|
278
301
|
updated_at: string;
|
|
279
302
|
}
|
|
@@ -368,6 +391,7 @@ interface Refund {
|
|
|
368
391
|
status: string;
|
|
369
392
|
provider_refund_reference?: string;
|
|
370
393
|
failure_reason?: string;
|
|
394
|
+
/** `user`, `operator`, or `system` when the platform refunded by itself. */
|
|
371
395
|
requestor_type: string;
|
|
372
396
|
requestor_id: string;
|
|
373
397
|
created_at: string;
|
|
@@ -543,6 +567,45 @@ interface CardProduct {
|
|
|
543
567
|
starting_balance: CardBalance | null;
|
|
544
568
|
/** True for the product the deployment issues when none is chosen. */
|
|
545
569
|
is_default: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Issuing this card sends the user's real personal details to the card
|
|
572
|
+
* issuer. Show the consent screen before the order and send
|
|
573
|
+
* `holder_data_transfer` in its `consents` (or give it once with
|
|
574
|
+
* `client.consents.allowHolderData()`); without it the order fails with
|
|
575
|
+
* 409 `holder_data_consent_required`. `false`: the issuer gets no real
|
|
576
|
+
* details and no extra consent is asked.
|
|
577
|
+
*/
|
|
578
|
+
holder_data_required: boolean;
|
|
579
|
+
/**
|
|
580
|
+
* What a card on this product costs to use, on top of the payments
|
|
581
|
+
* themselves. A fee the card can't cover is owed and paid from the next
|
|
582
|
+
* top-up (see `client.debt`). Every line is `"0"` when the product
|
|
583
|
+
* charges nothing for it.
|
|
584
|
+
*/
|
|
585
|
+
tariff: CardTariff;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* A card product's fees for using the card. Decimal strings: the fixed
|
|
589
|
+
* amounts are in `currency` (the card's), the shares in percent of the
|
|
590
|
+
* operation's amount.
|
|
591
|
+
*/
|
|
592
|
+
interface CardTariff {
|
|
593
|
+
/** `null` for a product held in several currencies: the card's own then. */
|
|
594
|
+
currency: string | null;
|
|
595
|
+
/** Per settled card payment, fixed. */
|
|
596
|
+
operation_fixed: string;
|
|
597
|
+
/** Per settled card payment, percent of its amount. */
|
|
598
|
+
operation_percent: string;
|
|
599
|
+
/**
|
|
600
|
+
* Per payment declined through the user's own doing: not enough money,
|
|
601
|
+
* wrong card details, a frozen card, a subscription not cancelled with the
|
|
602
|
+
* merchant. A decline caused by the issuer or the platform costs nothing.
|
|
603
|
+
*/
|
|
604
|
+
decline: string;
|
|
605
|
+
/** Per cash withdrawal, fixed; charged instead of the payment fee. */
|
|
606
|
+
cash_withdrawal_fixed: string;
|
|
607
|
+
/** Per cash withdrawal, percent of its amount. */
|
|
608
|
+
cash_withdrawal_percent: string;
|
|
546
609
|
}
|
|
547
610
|
/**
|
|
548
611
|
* A card record as the Takeal API returns it. Mirrors the `cards` table. Note the
|
|
@@ -583,6 +646,19 @@ interface Card {
|
|
|
583
646
|
* support to settle it; say so instead of offering a retry.
|
|
584
647
|
*/
|
|
585
648
|
topups_held: string | null;
|
|
649
|
+
/**
|
|
650
|
+
* The card this one replaced: support reissued it for free because that
|
|
651
|
+
* card stopped working before its term. `null` otherwise.
|
|
652
|
+
*/
|
|
653
|
+
reissued_from_card_id?: string | null;
|
|
654
|
+
/** The card support issued to replace this one, or `null`. */
|
|
655
|
+
reissued_to_card_id?: string | null;
|
|
656
|
+
/**
|
|
657
|
+
* What was left on the card this one replaced, on its way here. Show it as
|
|
658
|
+
* money in transit next to the balance, not as part of it. `null` when
|
|
659
|
+
* nothing is on its way.
|
|
660
|
+
*/
|
|
661
|
+
in_transit?: CardInTransit | null;
|
|
586
662
|
/** The name the user gave the card, or `null`. */
|
|
587
663
|
name: string | null;
|
|
588
664
|
/** The artwork the card is shown with. Always present. */
|
|
@@ -597,6 +673,21 @@ interface Card {
|
|
|
597
673
|
/** Only on the result of `create`, when bonuses paid part of the price. */
|
|
598
674
|
bonus?: IssuanceBonus;
|
|
599
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* The balance of a closed card on its way to the card that replaced it. It
|
|
678
|
+
* waits for the old card's issuer to return the money (`stage: "issuer"`),
|
|
679
|
+
* then it is loaded onto this card (`stage: "loading"`); once it is there,
|
|
680
|
+
* `in_transit` is `null` and the card's balance has it. The move is in the
|
|
681
|
+
* history as a `closed_card_balance` entry.
|
|
682
|
+
*/
|
|
683
|
+
interface CardInTransit {
|
|
684
|
+
/** Decimal string in `currency`. What the issuer returned once it did; before that, what the old card held. */
|
|
685
|
+
amount: string;
|
|
686
|
+
currency: string;
|
|
687
|
+
/** The closed card the money comes from. */
|
|
688
|
+
from_card_id: string;
|
|
689
|
+
stage: "issuer" | "loading" | (string & {});
|
|
690
|
+
}
|
|
600
691
|
/** How bonuses changed a new card's price ("was / now"). Decimal strings in `currency`. */
|
|
601
692
|
interface IssuanceBonus {
|
|
602
693
|
/** Bonuses used. */
|
|
@@ -666,9 +757,10 @@ interface CreateCardInput {
|
|
|
666
757
|
promoCode?: string;
|
|
667
758
|
/**
|
|
668
759
|
* Consents the user gave with the order (`terms`, `personal_data`,
|
|
669
|
-
* `marketing`). Recorded with the card, or with the
|
|
670
|
-
* `deposits.initiate({ issue_card })`, at the version of
|
|
671
|
-
* in force now.
|
|
760
|
+
* `marketing`, `holder_data_transfer`). Recorded with the card, or with the
|
|
761
|
+
* top-up inside `deposits.initiate({ issue_card })`, at the version of
|
|
762
|
+
* their documents in force now. A product with `holder_data_required`
|
|
763
|
+
* needs `holder_data_transfer` here unless it was given before.
|
|
672
764
|
*/
|
|
673
765
|
consents?: ConsentKind[];
|
|
674
766
|
/** Where they were given. Sent as `consent_channel`. */
|
|
@@ -712,7 +804,10 @@ interface CardOrderInput {
|
|
|
712
804
|
promoCode?: string;
|
|
713
805
|
/** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */
|
|
714
806
|
useBonus?: boolean;
|
|
715
|
-
/**
|
|
807
|
+
/**
|
|
808
|
+
* Consents given with the order. A product with `holder_data_required`
|
|
809
|
+
* needs `holder_data_transfer` here unless it was given before.
|
|
810
|
+
*/
|
|
716
811
|
consents?: ConsentKind[];
|
|
717
812
|
/** Where they were given. Sent as `consent_channel`. */
|
|
718
813
|
consentChannel?: ConsentChannel;
|
|
@@ -726,9 +821,15 @@ interface CardOrder {
|
|
|
726
821
|
/** What the user pays, decimal string, in `currency`. */
|
|
727
822
|
amount: string;
|
|
728
823
|
currency: string;
|
|
729
|
-
/** What
|
|
824
|
+
/** What the payment brings: the card's price, its starting balance and `debt_withheld`, in `card_currency`. */
|
|
730
825
|
card_amount: string;
|
|
731
826
|
card_currency: string;
|
|
827
|
+
/**
|
|
828
|
+
* What the user owes in card fees, in `card_currency`: included in
|
|
829
|
+
* `card_amount` and paid from it first. `"0"` when nothing is owed. Show
|
|
830
|
+
* it before the payment. Older platforms leave it out.
|
|
831
|
+
*/
|
|
832
|
+
debt_withheld?: string;
|
|
732
833
|
}
|
|
733
834
|
/** Why a card ordered with the sign-up was not placed. The account exists all the same. */
|
|
734
835
|
interface CardOrderError {
|
|
@@ -756,6 +857,13 @@ interface TopUpTerms {
|
|
|
756
857
|
min: CardBalance | null;
|
|
757
858
|
/** Largest single top-up the product allows, or `null` for no cap. */
|
|
758
859
|
max: CardBalance | null;
|
|
860
|
+
/**
|
|
861
|
+
* What the user owes in card fees, in the card's currency, or `null` when
|
|
862
|
+
* nothing is. A top-up from a wallet in the same currency pays it first
|
|
863
|
+
* and the card gets the rest: show it before the top-up. Older platforms
|
|
864
|
+
* leave it out.
|
|
865
|
+
*/
|
|
866
|
+
debt?: CardBalance | null;
|
|
759
867
|
}
|
|
760
868
|
interface TopUpInput {
|
|
761
869
|
/** Amount to add, decimal string, in the card's currency. */
|
|
@@ -948,6 +1056,8 @@ declare class CardsResource {
|
|
|
948
1056
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
949
1057
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
950
1058
|
* `failure_reason` on the result.
|
|
1059
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
1060
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
951
1061
|
*/
|
|
952
1062
|
create(input: CreateCardInput): Promise<Card>;
|
|
953
1063
|
/**
|
|
@@ -957,7 +1067,9 @@ declare class CardsResource {
|
|
|
957
1067
|
* `pending_payment` until the payment is confirmed. The same
|
|
958
1068
|
* `idempotencyKey` returns the same order.
|
|
959
1069
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
960
|
-
* way of paying,
|
|
1070
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
1071
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
1072
|
+
* funding connector or no exchange rate.
|
|
961
1073
|
*/
|
|
962
1074
|
order(input: CardOrderInput & {
|
|
963
1075
|
idempotencyKey: string;
|
|
@@ -1071,9 +1183,12 @@ declare class CardsResource {
|
|
|
1071
1183
|
/**
|
|
1072
1184
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
1073
1185
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
1074
|
-
* already-terminated card.
|
|
1186
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
1187
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
1188
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
1189
|
+
* way it was paid.
|
|
1075
1190
|
*/
|
|
1076
1191
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1077
1192
|
}
|
|
1078
1193
|
|
|
1079
|
-
export { type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type
|
|
1194
|
+
export { type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type DepositStatus as E, FundingOptionsResource as F, type DepositTarget as G, type FeeKind as H, type FunderMode as I, type FundingOption as J, type FundingQuote as K, type InitiateDepositInput as L, type IssuanceBonus as M, type IssueCardInput as N, type MethodTerms as O, type RevealCardInput as P, type RevealedCard as Q, type Refund as R, type SetPinInput as S, type TopUpInput as T, type TopUpResult as U, type TopUpTerms as V, type TransferInput as W, type TransferResult as X, type UpdateCardInput as Y, cardOrderBody as Z, cardRequestBody as _, type Card as a, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardProductPrice as l, type CardStatus as m, type CardStatusSource as n, type CardTariff as o, type CardTopUp as p, type CardTopUpStatus as q, type CardTransfer as r, type CardType as s, type Cardholder as t, type CloseBlockedReason as u, type CreateCardInput as v, type CreateDepositRefundInput as w, type CreateQuoteInput as x, type CustomerInfo as y, type DepositMethod as z };
|
|
@@ -84,7 +84,11 @@ declare class HttpClient {
|
|
|
84
84
|
put<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
85
85
|
patch<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
86
86
|
delete<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
87
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
88
|
+
* throws `ApiError` the same way. */
|
|
89
|
+
getBlob(path: string, opts?: HttpOptions): Promise<Blob>;
|
|
87
90
|
private request;
|
|
91
|
+
private send;
|
|
88
92
|
private absolute;
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -84,7 +84,11 @@ declare class HttpClient {
|
|
|
84
84
|
put<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
85
85
|
patch<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
86
86
|
delete<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
87
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
88
|
+
* throws `ApiError` the same way. */
|
|
89
|
+
getBlob(path: string, opts?: HttpOptions): Promise<Blob>;
|
|
87
90
|
private request;
|
|
91
|
+
private send;
|
|
88
92
|
private absolute;
|
|
89
93
|
}
|
|
90
94
|
|
package/dist/index.cjs
CHANGED
|
@@ -73,10 +73,20 @@ var HttpClient = class {
|
|
|
73
73
|
async delete(path, opts = {}) {
|
|
74
74
|
return this.request("DELETE", path, opts);
|
|
75
75
|
}
|
|
76
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
77
|
+
* throws `ApiError` the same way. */
|
|
78
|
+
async getBlob(path, opts = {}) {
|
|
79
|
+
const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
|
|
80
|
+
if (!resp.ok) return parseResponse(resp);
|
|
81
|
+
return resp.blob();
|
|
82
|
+
}
|
|
76
83
|
async request(method, path, opts) {
|
|
84
|
+
return parseResponse(await this.send(method, path, opts));
|
|
85
|
+
}
|
|
86
|
+
async send(method, path, opts) {
|
|
77
87
|
const url = this.absolute(path);
|
|
78
88
|
const headers = {
|
|
79
|
-
Accept: "application/json",
|
|
89
|
+
Accept: opts.accept ?? "application/json",
|
|
80
90
|
...this.defaultHeaders
|
|
81
91
|
};
|
|
82
92
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -102,10 +112,10 @@ var HttpClient = class {
|
|
|
102
112
|
}
|
|
103
113
|
if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
|
|
104
114
|
if (await this.refreshOnce()) {
|
|
105
|
-
return this.
|
|
115
|
+
return this.send(method, path, { ...opts, retried: true });
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
|
-
return
|
|
118
|
+
return resp;
|
|
109
119
|
}
|
|
110
120
|
absolute(path) {
|
|
111
121
|
if (path.startsWith("http://") || path.startsWith("https://")) return path;
|
|
@@ -186,6 +196,8 @@ var CardsResource = class {
|
|
|
186
196
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
187
197
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
188
198
|
* `failure_reason` on the result.
|
|
199
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
200
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
189
201
|
*/
|
|
190
202
|
async create(input) {
|
|
191
203
|
const { idempotencyKey, ...card } = input;
|
|
@@ -201,7 +213,9 @@ var CardsResource = class {
|
|
|
201
213
|
* `pending_payment` until the payment is confirmed. The same
|
|
202
214
|
* `idempotencyKey` returns the same order.
|
|
203
215
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
204
|
-
* way of paying,
|
|
216
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
217
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
218
|
+
* funding connector or no exchange rate.
|
|
205
219
|
*/
|
|
206
220
|
async order(input) {
|
|
207
221
|
const { idempotencyKey, ...order } = input;
|
|
@@ -363,7 +377,10 @@ var CardsResource = class {
|
|
|
363
377
|
/**
|
|
364
378
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
365
379
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
366
|
-
* already-terminated card.
|
|
380
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
381
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
382
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
383
|
+
* way it was paid.
|
|
367
384
|
*/
|
|
368
385
|
async terminate(id, reason) {
|
|
369
386
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
@@ -730,6 +747,72 @@ var BonusResource = class {
|
|
|
730
747
|
}
|
|
731
748
|
};
|
|
732
749
|
|
|
750
|
+
// src/resources/debt.ts
|
|
751
|
+
var DebtResource = class {
|
|
752
|
+
constructor(http) {
|
|
753
|
+
this.http = http;
|
|
754
|
+
}
|
|
755
|
+
/** What the user owes in card fees, per currency, and what for. */
|
|
756
|
+
async get(opts = {}) {
|
|
757
|
+
return this.http.get("/me/debt", { signal: opts.signal });
|
|
758
|
+
}
|
|
759
|
+
/** What the user owes in `currency`, decimal string; `"0"` when nothing. */
|
|
760
|
+
async owedIn(currency, opts = {}) {
|
|
761
|
+
const debt = await this.get(opts);
|
|
762
|
+
const want = currency.trim().toUpperCase();
|
|
763
|
+
return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
// src/resources/close-requests.ts
|
|
768
|
+
var CloseRequestsResource = class {
|
|
769
|
+
constructor(http) {
|
|
770
|
+
this.http = http;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Close a card that holds money, the rest going back the way it was paid.
|
|
774
|
+
* Asking again for the same card returns the same request. 404 no such
|
|
775
|
+
* card · 409 {@link CloseRequestError}: `no_balance` means the card holds
|
|
776
|
+
* nothing, close it with `cards.terminate()` · 503 the issuer can't be
|
|
777
|
+
* reached; the card stays as it was.
|
|
778
|
+
*/
|
|
779
|
+
async request(cardId, input = {}) {
|
|
780
|
+
return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
|
|
781
|
+
body: { reason: input.reason }
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
/** Every card close request of the user, newest first. */
|
|
785
|
+
async list(opts = {}) {
|
|
786
|
+
const res = await this.http.get("/me/close-requests", {
|
|
787
|
+
signal: opts.signal
|
|
788
|
+
});
|
|
789
|
+
return res.items;
|
|
790
|
+
}
|
|
791
|
+
/** One close request. 404 when it isn't the user's. */
|
|
792
|
+
async get(id, opts = {}) {
|
|
793
|
+
return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
|
|
794
|
+
signal: opts.signal
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
/** The request for this card, if the user made one. */
|
|
798
|
+
async forCard(cardId, opts = {}) {
|
|
799
|
+
const all = await this.list(opts);
|
|
800
|
+
return all.find((r) => r.card_id === cardId) ?? null;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Give a bank account or a card in the user's own name, when the request
|
|
804
|
+
* is `payout_details_required` (or `identity_check`, to correct them). 400
|
|
805
|
+
* `validation`: a name, number or bank code that doesn't look right · 409
|
|
806
|
+
* `details_not_needed`.
|
|
807
|
+
*/
|
|
808
|
+
async submitPayoutDetails(id, details) {
|
|
809
|
+
return this.http.post(
|
|
810
|
+
`/me/close-requests/${encodeURIComponent(id)}/payout-details`,
|
|
811
|
+
{ body: details }
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
|
|
733
816
|
// src/resources/codes.ts
|
|
734
817
|
var CodesResource = class {
|
|
735
818
|
constructor(http) {
|
|
@@ -1261,6 +1344,8 @@ var HistoryResource = class {
|
|
|
1261
1344
|
};
|
|
1262
1345
|
|
|
1263
1346
|
// src/resources/consents.ts
|
|
1347
|
+
var HOLDER_DATA_CONSENT = "holder_data_transfer";
|
|
1348
|
+
var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
|
|
1264
1349
|
var ConsentsResource = class {
|
|
1265
1350
|
constructor(http) {
|
|
1266
1351
|
this.http = http;
|
|
@@ -1269,20 +1354,51 @@ var ConsentsResource = class {
|
|
|
1269
1354
|
async get() {
|
|
1270
1355
|
return this.http.get("/me/consents");
|
|
1271
1356
|
}
|
|
1357
|
+
/** Whether `kind` stands now: given and not withdrawn since. */
|
|
1358
|
+
async stands(kind) {
|
|
1359
|
+
const { consents } = await this.get();
|
|
1360
|
+
return consents.some((c) => c.kind === kind && c.given);
|
|
1361
|
+
}
|
|
1272
1362
|
/**
|
|
1273
|
-
* Give (`true`) or withdraw (`false`) an optional consent: `marketing
|
|
1274
|
-
* `cookies_analytics
|
|
1275
|
-
*
|
|
1276
|
-
*
|
|
1363
|
+
* Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
|
|
1364
|
+
* `cookies_analytics`, `holder_data_transfer` or
|
|
1365
|
+
* `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
|
|
1366
|
+
* off in every channel at once; giving it turns on advertising by e-mail.
|
|
1367
|
+
* Withdrawing `holder_data_transfer` leaves the user's cards alone and
|
|
1368
|
+
* stops new cards whose product has `holder_data_required`. A call that
|
|
1369
|
+
* changes nothing records nothing, unless it names a card.
|
|
1370
|
+
*
|
|
1371
|
+
* The third argument is the channel, or {@link ConsentOptions} with the
|
|
1372
|
+
* channel and the card.
|
|
1277
1373
|
*
|
|
1278
1374
|
* Errors: 400 `consent_required` for `terms` or `personal_data`,
|
|
1279
|
-
* 400 `unknown_consent
|
|
1375
|
+
* 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
|
|
1376
|
+
* that takes none), 404 `not_found` (not one of the user's cards).
|
|
1280
1377
|
*/
|
|
1281
|
-
async set(kind, given,
|
|
1378
|
+
async set(kind, given, options) {
|
|
1379
|
+
const opts = typeof options === "string" ? { channel: options } : options ?? {};
|
|
1282
1380
|
const body = { kind, given };
|
|
1283
|
-
if (channel !== void 0) body.channel = channel;
|
|
1381
|
+
if (opts.channel !== void 0) body.channel = opts.channel;
|
|
1382
|
+
if (opts.cardId !== void 0) body.card_id = opts.cardId;
|
|
1284
1383
|
return this.http.post("/me/consents", { body });
|
|
1285
1384
|
}
|
|
1385
|
+
/**
|
|
1386
|
+
* The user agreed on the consent screen that their real personal details
|
|
1387
|
+
* go to the card issuer (`holder_data_transfer`). Needed before ordering a
|
|
1388
|
+
* product with `holder_data_required`, unless the order itself carries the
|
|
1389
|
+
* kind in its `consents`.
|
|
1390
|
+
*/
|
|
1391
|
+
async allowHolderData(options) {
|
|
1392
|
+
return this.set(HOLDER_DATA_CONSENT, true, options);
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* The user agreed that their documents go to the card issuer for a
|
|
1396
|
+
* dispute (`dispute_documents_transfer`). Name the disputed card with
|
|
1397
|
+
* `cardId`; each call is then recorded on its own.
|
|
1398
|
+
*/
|
|
1399
|
+
async allowDisputeDocuments(options) {
|
|
1400
|
+
return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
|
|
1401
|
+
}
|
|
1286
1402
|
/**
|
|
1287
1403
|
* Record what the cookie banner or the cookie settings say about
|
|
1288
1404
|
* analytics. Works signed in or not: before sign-in the choice is kept
|
|
@@ -1323,6 +1439,70 @@ var ReceiptsResource = class {
|
|
|
1323
1439
|
}
|
|
1324
1440
|
};
|
|
1325
1441
|
|
|
1442
|
+
// src/resources/support.ts
|
|
1443
|
+
function bytesToBase64(bytes) {
|
|
1444
|
+
let binary = "";
|
|
1445
|
+
const chunk = 32768;
|
|
1446
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
1447
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
1448
|
+
}
|
|
1449
|
+
return btoa(binary);
|
|
1450
|
+
}
|
|
1451
|
+
async function toBase64(data) {
|
|
1452
|
+
if (typeof data === "string") return data;
|
|
1453
|
+
if (data instanceof Uint8Array) return bytesToBase64(data);
|
|
1454
|
+
if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
|
|
1455
|
+
return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
|
|
1456
|
+
}
|
|
1457
|
+
var SupportResource = class {
|
|
1458
|
+
constructor(http) {
|
|
1459
|
+
this.http = http;
|
|
1460
|
+
}
|
|
1461
|
+
/** The latest messages, oldest first, and the conversation's status.
|
|
1462
|
+
* `before` reads further back; `limit` is 1 to 100 (50). */
|
|
1463
|
+
async list(opts = {}) {
|
|
1464
|
+
const q = new URLSearchParams();
|
|
1465
|
+
if (opts.before) q.set("before", opts.before);
|
|
1466
|
+
if (opts.limit !== void 0) q.set("limit", String(opts.limit));
|
|
1467
|
+
const qs = q.toString();
|
|
1468
|
+
return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
|
|
1469
|
+
signal: opts.signal
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
/** Write to support. Text, files or both; up to 10 files. */
|
|
1473
|
+
async send(message, opts = {}) {
|
|
1474
|
+
const attachments = await Promise.all(
|
|
1475
|
+
(message.files ?? []).map(async (f) => ({
|
|
1476
|
+
file_name: f.fileName,
|
|
1477
|
+
content_type: f.contentType,
|
|
1478
|
+
data_base64: await toBase64(f.data)
|
|
1479
|
+
}))
|
|
1480
|
+
);
|
|
1481
|
+
return this.http.post("/me/support/messages", {
|
|
1482
|
+
body: { text: message.text ?? "", attachments },
|
|
1483
|
+
signal: opts.signal
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
/** A file from the conversation: the person's own or one support sent. */
|
|
1487
|
+
async attachment(id, opts = {}) {
|
|
1488
|
+
return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
|
|
1489
|
+
signal: opts.signal
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
/** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
|
|
1493
|
+
* wrote one. Each question takes one answer; a second one is a 404. */
|
|
1494
|
+
async rate(id, answer, opts = {}) {
|
|
1495
|
+
await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
|
|
1496
|
+
body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
|
|
1497
|
+
signal: opts.signal
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
/** Just the conversation's status. */
|
|
1501
|
+
async status(opts = {}) {
|
|
1502
|
+
return (await this.list({ limit: 1, signal: opts.signal })).status;
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1326
1506
|
// src/resources/funding-options.ts
|
|
1327
1507
|
var FundingOptionsResource = class {
|
|
1328
1508
|
constructor(http) {
|
|
@@ -1335,7 +1515,7 @@ var FundingOptionsResource = class {
|
|
|
1335
1515
|
};
|
|
1336
1516
|
|
|
1337
1517
|
// src/version.ts
|
|
1338
|
-
var SDK_VERSION = "0.6.
|
|
1518
|
+
var SDK_VERSION = "0.6.6";
|
|
1339
1519
|
|
|
1340
1520
|
// src/client-platform.ts
|
|
1341
1521
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1410,7 +1590,7 @@ function isAbsolute(url) {
|
|
|
1410
1590
|
}
|
|
1411
1591
|
|
|
1412
1592
|
// src/compat.ts
|
|
1413
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1593
|
+
var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
|
|
1414
1594
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1415
1595
|
function parse(v) {
|
|
1416
1596
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1923,6 +2103,8 @@ function createClient(opts) {
|
|
|
1923
2103
|
cards: new CardsResource(http),
|
|
1924
2104
|
balance: new BalanceResource(http),
|
|
1925
2105
|
bonus: new BonusResource(http),
|
|
2106
|
+
debt: new DebtResource(http),
|
|
2107
|
+
closeRequests: new CloseRequestsResource(http),
|
|
1926
2108
|
codes: new CodesResource(http),
|
|
1927
2109
|
referral: new ReferralResource(http),
|
|
1928
2110
|
subscription: new SubscriptionResource(http),
|
|
@@ -1939,7 +2121,8 @@ function createClient(opts) {
|
|
|
1939
2121
|
attribution: new AttributionResource(http),
|
|
1940
2122
|
history: new HistoryResource(http),
|
|
1941
2123
|
consents: new ConsentsResource(http),
|
|
1942
|
-
receipts: new ReceiptsResource(http)
|
|
2124
|
+
receipts: new ReceiptsResource(http),
|
|
2125
|
+
support: new SupportResource(http)
|
|
1943
2126
|
};
|
|
1944
2127
|
}
|
|
1945
2128
|
function pickDefaultStore(key) {
|
|
@@ -1960,6 +2143,8 @@ function defaultFetch() {
|
|
|
1960
2143
|
exports.ANALYTICS_EVENTS = ANALYTICS_EVENTS;
|
|
1961
2144
|
exports.ApiError = ApiError;
|
|
1962
2145
|
exports.CLIENT_HEADER = CLIENT_HEADER;
|
|
2146
|
+
exports.DISPUTE_DOCUMENTS_CONSENT = DISPUTE_DOCUMENTS_CONSENT;
|
|
2147
|
+
exports.HOLDER_DATA_CONSENT = HOLDER_DATA_CONSENT;
|
|
1963
2148
|
exports.METRIKA_GOALS = METRIKA_GOALS;
|
|
1964
2149
|
exports.NO_CAPTURE_CLASS = NO_CAPTURE_CLASS;
|
|
1965
2150
|
exports.NetworkError = NetworkError;
|