@takeal/cusfront-sdk 0.3.20 → 0.6.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/CHANGELOG.md +137 -2
- package/README.md +407 -8
- package/dist/analytics.cjs +438 -0
- package/dist/analytics.cjs.map +1 -0
- package/dist/analytics.d.cts +129 -0
- package/dist/analytics.d.ts +129 -0
- package/dist/analytics.js +424 -0
- package/dist/analytics.js.map +1 -0
- package/dist/cards-B_aNY35J.d.cts +514 -0
- package/dist/cards-Ba1wZttb.d.ts +514 -0
- package/dist/deposits-BEc8U80M.d.cts +310 -0
- package/dist/deposits-DScyT_D9.d.ts +310 -0
- package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
- package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
- package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
- package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
- package/dist/index.cjs +978 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -13
- package/dist/index.d.ts +101 -13
- package/dist/index.js +963 -102
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +2 -8
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +12 -5
- package/dist/react/index.d.ts +12 -5
- package/dist/react/index.js +2 -8
- package/dist/react/index.js.map +1 -1
- package/dist/resources/attribution.cjs +82 -0
- package/dist/resources/attribution.cjs.map +1 -0
- package/dist/resources/attribution.d.cts +100 -0
- package/dist/resources/attribution.d.ts +100 -0
- package/dist/resources/attribution.js +78 -0
- package/dist/resources/attribution.js.map +1 -0
- package/dist/resources/auth.cjs +81 -15
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +53 -6
- package/dist/resources/auth.d.ts +53 -6
- package/dist/resources/auth.js +81 -15
- 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.cjs.map +1 -1
- package/dist/resources/blog.d.cts +8 -1
- package/dist/resources/blog.d.ts +8 -1
- package/dist/resources/blog.js.map +1 -1
- package/dist/resources/bonus.cjs +28 -0
- package/dist/resources/bonus.cjs.map +1 -0
- package/dist/resources/bonus.d.cts +121 -0
- package/dist/resources/bonus.d.ts +121 -0
- package/dist/resources/bonus.js +26 -0
- package/dist/resources/bonus.js.map +1 -0
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +55 -28
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -347
- package/dist/resources/cards.d.ts +2 -347
- package/dist/resources/cards.js +55 -29
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/codes.cjs +20 -0
- package/dist/resources/codes.cjs.map +1 -0
- package/dist/resources/codes.d.cts +100 -0
- package/dist/resources/codes.d.ts +100 -0
- package/dist/resources/codes.js +18 -0
- package/dist/resources/codes.js.map +1 -0
- package/dist/resources/deposits.cjs +32 -7
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -176
- package/dist/resources/deposits.d.ts +3 -176
- package/dist/resources/deposits.js +32 -7
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.cjs +3 -1
- package/dist/resources/devices.cjs.map +1 -1
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/devices.js +3 -1
- package/dist/resources/devices.js.map +1 -1
- package/dist/resources/documents.cjs +66 -0
- package/dist/resources/documents.cjs.map +1 -0
- package/dist/resources/documents.d.cts +212 -0
- package/dist/resources/documents.d.ts +212 -0
- package/dist/resources/documents.js +64 -0
- package/dist/resources/documents.js.map +1 -0
- package/dist/resources/funding-options.cjs +16 -0
- package/dist/resources/funding-options.cjs.map +1 -0
- package/dist/resources/funding-options.d.cts +3 -0
- package/dist/resources/funding-options.d.ts +3 -0
- package/dist/resources/funding-options.js +14 -0
- package/dist/resources/funding-options.js.map +1 -0
- package/dist/resources/history.cjs +33 -0
- package/dist/resources/history.cjs.map +1 -0
- package/dist/resources/history.d.cts +95 -0
- package/dist/resources/history.d.ts +95 -0
- package/dist/resources/history.js +31 -0
- package/dist/resources/history.js.map +1 -0
- package/dist/resources/me.d.cts +3 -1
- package/dist/resources/me.d.ts +3 -1
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.cjs +3 -1
- package/dist/resources/push.cjs.map +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/push.js +3 -1
- package/dist/resources/push.js.map +1 -1
- package/dist/resources/referral.cjs +16 -0
- package/dist/resources/referral.cjs.map +1 -0
- package/dist/resources/referral.d.cts +58 -0
- package/dist/resources/referral.d.ts +58 -0
- package/dist/resources/referral.js +14 -0
- package/dist/resources/referral.js.map +1 -0
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.cjs +24 -0
- package/dist/resources/subscription.cjs.map +1 -0
- package/dist/resources/subscription.d.cts +48 -0
- package/dist/resources/subscription.d.ts +48 -0
- package/dist/resources/subscription.js +22 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +495 -111
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +12 -5
- package/dist/telegram.d.ts +12 -5
- package/dist/telegram.js +495 -111
- package/dist/telegram.js.map +1 -1
- package/package.json +57 -5
- package/dist/customer-CoxPwe5o.d.cts +0 -32
- package/dist/customer-CoxPwe5o.d.ts +0 -32
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* History resource — `client.history.*`: everything that happened to the
|
|
5
|
+
* user's money in one list, newest first.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const page = await client.history.list({ limit: 30 });
|
|
9
|
+
* const more = await client.history.list({ cursor: page.next_cursor! });
|
|
10
|
+
* const oneCard = await client.history.list({ cardId: card.id });
|
|
11
|
+
* for await (const item of client.history.all()) { … }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* New kinds are added over time. Render an unknown `kind` from its `title`,
|
|
15
|
+
* `amount`, `direction` and `status`; don't drop it.
|
|
16
|
+
*/
|
|
17
|
+
type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus" | (string & {});
|
|
18
|
+
type HistoryStatus = "completed" | "pending" | "declined" | "reversed" | "failed" | (string & {});
|
|
19
|
+
interface HistoryAmount {
|
|
20
|
+
/** Decimal string, never negative; see `direction`. */
|
|
21
|
+
amount: string;
|
|
22
|
+
/** ISO 4217 code. */
|
|
23
|
+
currency: string;
|
|
24
|
+
}
|
|
25
|
+
interface HistoryCard {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string | null;
|
|
28
|
+
last4: string | null;
|
|
29
|
+
}
|
|
30
|
+
interface HistoryItem {
|
|
31
|
+
/** Unique across kinds. */
|
|
32
|
+
id: string;
|
|
33
|
+
kind: HistoryKind;
|
|
34
|
+
occurred_at: string;
|
|
35
|
+
/** `pending` is not finished yet; `reversed` is an authorisation that was released. */
|
|
36
|
+
status: HistoryStatus;
|
|
37
|
+
/** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */
|
|
38
|
+
direction: "out" | "in" | "internal" | (string & {});
|
|
39
|
+
/** The merchant, or what the operation was, in the language asked for. */
|
|
40
|
+
title: string;
|
|
41
|
+
/**
|
|
42
|
+
* In the currency the operation happened in. For `bonus` the currency is
|
|
43
|
+
* `BNS` and the amount is a number of bonuses, not money.
|
|
44
|
+
*/
|
|
45
|
+
amount: HistoryAmount;
|
|
46
|
+
/**
|
|
47
|
+
* The other side of a conversion (what the card was billed, what the
|
|
48
|
+
* wallet or card received). For a `bonus` spend: the part of the price
|
|
49
|
+
* the bonuses covered, or what they added to a top-up.
|
|
50
|
+
*/
|
|
51
|
+
counter_amount: HistoryAmount | null;
|
|
52
|
+
/** Rate between `amount` and `counter_amount`, decimal string. */
|
|
53
|
+
fx_rate: string | null;
|
|
54
|
+
/** A fee charged with the operation, in the wallet's currency. */
|
|
55
|
+
fee: HistoryAmount | null;
|
|
56
|
+
/** The card; the source card of a transfer. */
|
|
57
|
+
card: HistoryCard | null;
|
|
58
|
+
/** The destination card of a transfer. */
|
|
59
|
+
to_card: HistoryCard | null;
|
|
60
|
+
merchant: {
|
|
61
|
+
name: string | null;
|
|
62
|
+
city: string | null;
|
|
63
|
+
country: string | null;
|
|
64
|
+
} | null;
|
|
65
|
+
/** On a declined payment: a stable code and the reason in plain words. */
|
|
66
|
+
decline_reason: {
|
|
67
|
+
code: "insufficient_funds" | "limit_exceeded" | "card_blocked" | "card_expired" | "wrong_details" | "merchant_not_allowed" | "other" | (string & {});
|
|
68
|
+
text: string;
|
|
69
|
+
} | null;
|
|
70
|
+
}
|
|
71
|
+
interface HistoryPage {
|
|
72
|
+
items: HistoryItem[];
|
|
73
|
+
/** Pass as `cursor` for the next, older page; `null` on the last one. */
|
|
74
|
+
next_cursor: string | null;
|
|
75
|
+
}
|
|
76
|
+
interface ListHistoryParams {
|
|
77
|
+
/** Only this card's operations, transfers to and from it included. */
|
|
78
|
+
cardId?: string;
|
|
79
|
+
cursor?: string;
|
|
80
|
+
/** 1 to 100, default 30. */
|
|
81
|
+
limit?: number;
|
|
82
|
+
/** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */
|
|
83
|
+
lang?: "en" | "ru";
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
}
|
|
86
|
+
declare class HistoryResource {
|
|
87
|
+
private readonly http;
|
|
88
|
+
constructor(http: HttpClient);
|
|
89
|
+
/** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */
|
|
90
|
+
list(params?: ListHistoryParams): Promise<HistoryPage>;
|
|
91
|
+
/** Every entry, page after page, newest first. */
|
|
92
|
+
all(params?: Omit<ListHistoryParams, "cursor">): AsyncGenerator<HistoryItem>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { type HistoryAmount, type HistoryCard, type HistoryItem, type HistoryKind, type HistoryPage, HistoryResource, type HistoryStatus, type ListHistoryParams };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* History resource — `client.history.*`: everything that happened to the
|
|
5
|
+
* user's money in one list, newest first.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const page = await client.history.list({ limit: 30 });
|
|
9
|
+
* const more = await client.history.list({ cursor: page.next_cursor! });
|
|
10
|
+
* const oneCard = await client.history.list({ cardId: card.id });
|
|
11
|
+
* for await (const item of client.history.all()) { … }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* New kinds are added over time. Render an unknown `kind` from its `title`,
|
|
15
|
+
* `amount`, `direction` and `status`; don't drop it.
|
|
16
|
+
*/
|
|
17
|
+
type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus" | (string & {});
|
|
18
|
+
type HistoryStatus = "completed" | "pending" | "declined" | "reversed" | "failed" | (string & {});
|
|
19
|
+
interface HistoryAmount {
|
|
20
|
+
/** Decimal string, never negative; see `direction`. */
|
|
21
|
+
amount: string;
|
|
22
|
+
/** ISO 4217 code. */
|
|
23
|
+
currency: string;
|
|
24
|
+
}
|
|
25
|
+
interface HistoryCard {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string | null;
|
|
28
|
+
last4: string | null;
|
|
29
|
+
}
|
|
30
|
+
interface HistoryItem {
|
|
31
|
+
/** Unique across kinds. */
|
|
32
|
+
id: string;
|
|
33
|
+
kind: HistoryKind;
|
|
34
|
+
occurred_at: string;
|
|
35
|
+
/** `pending` is not finished yet; `reversed` is an authorisation that was released. */
|
|
36
|
+
status: HistoryStatus;
|
|
37
|
+
/** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */
|
|
38
|
+
direction: "out" | "in" | "internal" | (string & {});
|
|
39
|
+
/** The merchant, or what the operation was, in the language asked for. */
|
|
40
|
+
title: string;
|
|
41
|
+
/**
|
|
42
|
+
* In the currency the operation happened in. For `bonus` the currency is
|
|
43
|
+
* `BNS` and the amount is a number of bonuses, not money.
|
|
44
|
+
*/
|
|
45
|
+
amount: HistoryAmount;
|
|
46
|
+
/**
|
|
47
|
+
* The other side of a conversion (what the card was billed, what the
|
|
48
|
+
* wallet or card received). For a `bonus` spend: the part of the price
|
|
49
|
+
* the bonuses covered, or what they added to a top-up.
|
|
50
|
+
*/
|
|
51
|
+
counter_amount: HistoryAmount | null;
|
|
52
|
+
/** Rate between `amount` and `counter_amount`, decimal string. */
|
|
53
|
+
fx_rate: string | null;
|
|
54
|
+
/** A fee charged with the operation, in the wallet's currency. */
|
|
55
|
+
fee: HistoryAmount | null;
|
|
56
|
+
/** The card; the source card of a transfer. */
|
|
57
|
+
card: HistoryCard | null;
|
|
58
|
+
/** The destination card of a transfer. */
|
|
59
|
+
to_card: HistoryCard | null;
|
|
60
|
+
merchant: {
|
|
61
|
+
name: string | null;
|
|
62
|
+
city: string | null;
|
|
63
|
+
country: string | null;
|
|
64
|
+
} | null;
|
|
65
|
+
/** On a declined payment: a stable code and the reason in plain words. */
|
|
66
|
+
decline_reason: {
|
|
67
|
+
code: "insufficient_funds" | "limit_exceeded" | "card_blocked" | "card_expired" | "wrong_details" | "merchant_not_allowed" | "other" | (string & {});
|
|
68
|
+
text: string;
|
|
69
|
+
} | null;
|
|
70
|
+
}
|
|
71
|
+
interface HistoryPage {
|
|
72
|
+
items: HistoryItem[];
|
|
73
|
+
/** Pass as `cursor` for the next, older page; `null` on the last one. */
|
|
74
|
+
next_cursor: string | null;
|
|
75
|
+
}
|
|
76
|
+
interface ListHistoryParams {
|
|
77
|
+
/** Only this card's operations, transfers to and from it included. */
|
|
78
|
+
cardId?: string;
|
|
79
|
+
cursor?: string;
|
|
80
|
+
/** 1 to 100, default 30. */
|
|
81
|
+
limit?: number;
|
|
82
|
+
/** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */
|
|
83
|
+
lang?: "en" | "ru";
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
}
|
|
86
|
+
declare class HistoryResource {
|
|
87
|
+
private readonly http;
|
|
88
|
+
constructor(http: HttpClient);
|
|
89
|
+
/** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */
|
|
90
|
+
list(params?: ListHistoryParams): Promise<HistoryPage>;
|
|
91
|
+
/** Every entry, page after page, newest first. */
|
|
92
|
+
all(params?: Omit<ListHistoryParams, "cursor">): AsyncGenerator<HistoryItem>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { type HistoryAmount, type HistoryCard, type HistoryItem, type HistoryKind, type HistoryPage, HistoryResource, type HistoryStatus, type ListHistoryParams };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/resources/history.ts
|
|
2
|
+
var HistoryResource = class {
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
/** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */
|
|
7
|
+
async list(params = {}) {
|
|
8
|
+
const q = new URLSearchParams();
|
|
9
|
+
if (params.cardId) q.set("card_id", params.cardId);
|
|
10
|
+
if (params.cursor) q.set("cursor", params.cursor);
|
|
11
|
+
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
12
|
+
if (params.lang) q.set("lang", params.lang);
|
|
13
|
+
const qs = q.toString();
|
|
14
|
+
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
15
|
+
signal: params.signal
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** Every entry, page after page, newest first. */
|
|
19
|
+
async *all(params = {}) {
|
|
20
|
+
let cursor;
|
|
21
|
+
do {
|
|
22
|
+
const page = await this.list({ ...params, cursor });
|
|
23
|
+
yield* page.items;
|
|
24
|
+
cursor = page.next_cursor ?? void 0;
|
|
25
|
+
} while (cursor);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { HistoryResource };
|
|
30
|
+
//# sourceMappingURL=history.js.map
|
|
31
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";AA8GO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
|
package/dist/resources/me.d.cts
CHANGED
package/dist/resources/me.d.ts
CHANGED
package/dist/resources/push.cjs
CHANGED
|
@@ -27,7 +27,9 @@ var PushResource = class {
|
|
|
27
27
|
async enable(registration) {
|
|
28
28
|
const { vapid_public_key } = await this.status();
|
|
29
29
|
if (!vapid_public_key) {
|
|
30
|
-
throw new Error(
|
|
30
|
+
throw new Error(
|
|
31
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
32
|
+
);
|
|
31
33
|
}
|
|
32
34
|
const sub = await registration.pushManager.subscribe({
|
|
33
35
|
userVisibleOnly: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";;;AAgDO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,MAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAgB,uBAAuB,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,KAAA,EAAmD;AAC5D,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAgB,yBAAyB,EAAE,IAAA,EAA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A,EAAQ,CAAA,EAAA,EAAK,GAAA,CAAI,CAAC,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC9D,EAAA,OAAO,GAAA;AACT","file":"push.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Push resource — `client.push.*`.\n *\n * Web Push for the signed-in user, through the older single-subscription\n * endpoint. The API now keeps one device per browser (see\n * `client.devices`), and this endpoint is an alias over the Web Push\n * devices: it keeps working, but new code should call\n * `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.\n *\n * Your service worker shows the notification: the payload is JSON with\n * `title`, `body` and `url` (where a click should lead).\n */\n\nexport interface PushStatus {\n /** `true` when a subscription is stored for this user. */\n subscribed: boolean;\n /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */\n endpoint_host?: string | null;\n /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.\n * `null` when push is not set up on this deployment. */\n vapid_public_key?: string | null;\n}\n\nexport interface PushSubscriptionInput {\n /** `PushSubscription.endpoint`; must be https. */\n endpoint: string;\n keys: {\n /** URL-safe base64. */\n p256dh: string;\n /** URL-safe base64. */\n auth: string;\n };\n}\n\n/** The part of `ServiceWorkerRegistration` the SDK needs. Typed\n * structurally so the core stays free of DOM lib types. */\nexport interface PushCapableRegistration {\n pushManager: {\n getSubscription(): Promise<{ unsubscribe(): Promise<boolean> } | null>;\n subscribe(options: {\n userVisibleOnly: boolean;\n applicationServerKey: Uint8Array;\n }): Promise<{ toJSON(): { endpoint?: string; keys?: Record<string, string> } }>;\n };\n}\n\nexport class PushResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Whether the user is subscribed, plus the VAPID key to subscribe with. */\n async status(): Promise<PushStatus> {\n return this.http.get<PushStatus>(\"/me/push-subscription\");\n }\n\n /** Store a subscription you created yourself.\n * 409 `push_disabled` when the deployment has no VAPID keys.\n * @deprecated Use `client.devices.register({ kind: \"webpush\", ... })`. */\n async save(input: PushSubscriptionInput): Promise<PushStatus> {\n return this.http.put<PushStatus>(\"/me/push-subscription\", { body: input });\n }\n\n /** Delete the stored subscription. Safe when nothing is stored.\n * @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */\n async remove(): Promise<void> {\n await this.http.delete<void>(\"/me/push-subscription\");\n }\n\n /** Subscribe this browser and store the subscription. Ask for\n * notification permission before calling. Throws when push isn't set up\n * on the deployment.\n * @deprecated Use `client.devices.registerWebPush(registration)`. */\n async enable(registration: PushCapableRegistration): Promise<PushStatus> {\n const { vapid_public_key } = await this.status();\n if (!vapid_public_key) {\n throw new Error(\n \"@takeal/cusfront-sdk: push notifications are not enabled on this deployment\",\n );\n }\n const sub = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: base64UrlToBytes(vapid_public_key),\n });\n const json = sub.toJSON();\n if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {\n throw new Error(\"@takeal/cusfront-sdk: the browser returned an incomplete push subscription\");\n }\n return this.save({\n endpoint: json.endpoint,\n keys: { p256dh: json.keys.p256dh, auth: json.keys.auth },\n });\n }\n\n /** Unsubscribe this browser and delete the stored subscription.\n * @deprecated Use `client.devices.unregisterWebPush(registration)`. */\n async disable(registration: PushCapableRegistration): Promise<void> {\n const sub = await registration.pushManager.getSubscription();\n if (sub) await sub.unsubscribe();\n await this.remove();\n }\n}\n\n/** URL-safe base64 (padding optional) → bytes. */\nexport function base64UrlToBytes(input: string): Uint8Array {\n const b64 = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = b64 + \"=\".repeat((4 - (b64.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n"]}
|
package/dist/resources/push.d.ts
CHANGED
package/dist/resources/push.js
CHANGED
|
@@ -25,7 +25,9 @@ var PushResource = class {
|
|
|
25
25
|
async enable(registration) {
|
|
26
26
|
const { vapid_public_key } = await this.status();
|
|
27
27
|
if (!vapid_public_key) {
|
|
28
|
-
throw new Error(
|
|
28
|
+
throw new Error(
|
|
29
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
30
|
+
);
|
|
29
31
|
}
|
|
30
32
|
const sub = await registration.pushManager.subscribe({
|
|
31
33
|
userVisibleOnly: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";AAgDO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,MAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAgB,uBAAuB,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,KAAA,EAAmD;AAC5D,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAgB,yBAAyB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA,EAIA,MAAM,MAAA,GAAwB;AAC5B,IAAA,MAAM,IAAA,CAAK,IAAA,CAAK,MAAA,CAAa,uBAAuB,CAAA;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,YAAA,EAA4D;AACvE,IAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,MAAM,KAAK,MAAA,EAAO;AAC/C,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,MAAM,IAAI,
|
|
1
|
+
{"version":3,"sources":["../../src/resources/push.ts"],"names":[],"mappings":";AAgDO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,MAAA,GAA8B;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA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AA,MAAM,GAAA,GAAM,MAAM,YAAA,CAAa,WAAA,CAAY,eAAA,EAAgB;AAC3D,IAAA,IAAI,GAAA,EAAK,MAAM,GAAA,CAAI,WAAA,EAAY;AAC/B,IAAA,MAAM,KAAK,MAAA,EAAO;AAAA,EACpB;AACF;AAGO,SAAS,iBAAiB,KAAA,EAA2B;AAC1D,EAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA;AACtD,EAAA,MAAM,MAAA,GAAS,MAAM,GAAA,CAAI,MAAA,CAAA,CAAQ,IAAK,GAAA,CAAI,MAAA,GAAS,KAAM,CAAC,CAAA;AAC1D,EAAA,MAAM,GAAA,GAAM,KAAK,MAAM,CAAA;AACvB,EAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA;AACrC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAA,EAAK,GAAA,CAAI,CAAC,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC9D,EAAA,OAAO,GAAA;AACT","file":"push.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Push resource — `client.push.*`.\n *\n * Web Push for the signed-in user, through the older single-subscription\n * endpoint. The API now keeps one device per browser (see\n * `client.devices`), and this endpoint is an alias over the Web Push\n * devices: it keeps working, but new code should call\n * `client.devices.registerWebPush(reg)` / `unregisterWebPush(reg)` instead.\n *\n * Your service worker shows the notification: the payload is JSON with\n * `title`, `body` and `url` (where a click should lead).\n */\n\nexport interface PushStatus {\n /** `true` when a subscription is stored for this user. */\n subscribed: boolean;\n /** Host of the stored endpoint, e.g. `fcm.googleapis.com`. */\n endpoint_host?: string | null;\n /** VAPID public key (URL-safe base64) for `pushManager.subscribe`.\n * `null` when push is not set up on this deployment. */\n vapid_public_key?: string | null;\n}\n\nexport interface PushSubscriptionInput {\n /** `PushSubscription.endpoint`; must be https. */\n endpoint: string;\n keys: {\n /** URL-safe base64. */\n p256dh: string;\n /** URL-safe base64. */\n auth: string;\n };\n}\n\n/** The part of `ServiceWorkerRegistration` the SDK needs. Typed\n * structurally so the core stays free of DOM lib types. */\nexport interface PushCapableRegistration {\n pushManager: {\n getSubscription(): Promise<{ unsubscribe(): Promise<boolean> } | null>;\n subscribe(options: {\n userVisibleOnly: boolean;\n applicationServerKey: Uint8Array;\n }): Promise<{ toJSON(): { endpoint?: string; keys?: Record<string, string> } }>;\n };\n}\n\nexport class PushResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Whether the user is subscribed, plus the VAPID key to subscribe with. */\n async status(): Promise<PushStatus> {\n return this.http.get<PushStatus>(\"/me/push-subscription\");\n }\n\n /** Store a subscription you created yourself.\n * 409 `push_disabled` when the deployment has no VAPID keys.\n * @deprecated Use `client.devices.register({ kind: \"webpush\", ... })`. */\n async save(input: PushSubscriptionInput): Promise<PushStatus> {\n return this.http.put<PushStatus>(\"/me/push-subscription\", { body: input });\n }\n\n /** Delete the stored subscription. Safe when nothing is stored.\n * @deprecated Use `client.devices.remove(id)` or `client.devices.unregisterWebPush(reg)`. */\n async remove(): Promise<void> {\n await this.http.delete<void>(\"/me/push-subscription\");\n }\n\n /** Subscribe this browser and store the subscription. Ask for\n * notification permission before calling. Throws when push isn't set up\n * on the deployment.\n * @deprecated Use `client.devices.registerWebPush(registration)`. */\n async enable(registration: PushCapableRegistration): Promise<PushStatus> {\n const { vapid_public_key } = await this.status();\n if (!vapid_public_key) {\n throw new Error(\n \"@takeal/cusfront-sdk: push notifications are not enabled on this deployment\",\n );\n }\n const sub = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: base64UrlToBytes(vapid_public_key),\n });\n const json = sub.toJSON();\n if (!json.endpoint || !json.keys?.p256dh || !json.keys.auth) {\n throw new Error(\"@takeal/cusfront-sdk: the browser returned an incomplete push subscription\");\n }\n return this.save({\n endpoint: json.endpoint,\n keys: { p256dh: json.keys.p256dh, auth: json.keys.auth },\n });\n }\n\n /** Unsubscribe this browser and delete the stored subscription.\n * @deprecated Use `client.devices.unregisterWebPush(registration)`. */\n async disable(registration: PushCapableRegistration): Promise<void> {\n const sub = await registration.pushManager.getSubscription();\n if (sub) await sub.unsubscribe();\n await this.remove();\n }\n}\n\n/** URL-safe base64 (padding optional) → bytes. */\nexport function base64UrlToBytes(input: string): Uint8Array {\n const b64 = input.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = b64 + \"=\".repeat((4 - (b64.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/referral.ts
|
|
4
|
+
var ReferralResource = class {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** The user's referral code, link, invited friends and rewards. */
|
|
9
|
+
async get(opts = {}) {
|
|
10
|
+
return this.http.get("/me/referral", { signal: opts.signal });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.ReferralResource = ReferralResource;
|
|
15
|
+
//# sourceMappingURL=referral.cjs.map
|
|
16
|
+
//# sourceMappingURL=referral.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/referral.ts"],"names":[],"mappings":";;;AAoDO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,cAAA,EAAgB,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACxE;AACF","file":"referral.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Referral resource — `client.referral.*`.\n *\n * For the people allowed to invite: their referral code, the link to\n * share, the people who signed up with it (no names or contacts, only\n * when they joined and how far they got) and what each reward was for.\n * Referral codes are given by invitation, so `code` is `null` for most\n * users. Rewards are bonuses, a discount on our services, not money.\n *\n * Mirrors `GET /me/referral`.\n */\n\n/** Someone the user invited, without anything that identifies them. */\nexport interface InvitedFriend {\n joined_at: string;\n /** Bonuses they brought so far, decimal string. */\n rewarded: string;\n has_card: boolean;\n has_topped_up: boolean;\n}\n\n/** One reward. */\nexport interface ReferralReward {\n id: string;\n /** `signup`, `card_issuance`, `first_deposit` or `deposit`. */\n event: \"signup\" | \"card_issuance\" | \"first_deposit\" | \"deposit\" | (string & {});\n /** The friend's operation a percent was taken of. */\n basis_amount: string | null;\n basis_currency: string | null;\n /** Bonuses, decimal string. */\n units: string;\n /** Always `bonus`. */\n payout_kind: string;\n /** `pending` until the bonuses are on the account. */\n status: \"pending\" | \"credited\" | (string & {});\n created_at: string;\n}\n\nexport interface Referral {\n code: string | null;\n /** The invitation link, or `null` when the deployment has none: share the code then. */\n link: string | null;\n invited_count: number;\n /** The latest invited, newest first. */\n invited: InvitedFriend[];\n /** Bonuses earned in total, decimal string. */\n total_rewarded: string;\n rewards: ReferralReward[];\n}\n\nexport class ReferralResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's referral code, link, invited friends and rewards. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Referral> {\n return this.http.get<Referral>(\"/me/referral\", { signal: opts.signal });\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Referral resource — `client.referral.*`.
|
|
5
|
+
*
|
|
6
|
+
* For the people allowed to invite: their referral code, the link to
|
|
7
|
+
* share, the people who signed up with it (no names or contacts, only
|
|
8
|
+
* when they joined and how far they got) and what each reward was for.
|
|
9
|
+
* Referral codes are given by invitation, so `code` is `null` for most
|
|
10
|
+
* users. Rewards are bonuses, a discount on our services, not money.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `GET /me/referral`.
|
|
13
|
+
*/
|
|
14
|
+
/** Someone the user invited, without anything that identifies them. */
|
|
15
|
+
interface InvitedFriend {
|
|
16
|
+
joined_at: string;
|
|
17
|
+
/** Bonuses they brought so far, decimal string. */
|
|
18
|
+
rewarded: string;
|
|
19
|
+
has_card: boolean;
|
|
20
|
+
has_topped_up: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** One reward. */
|
|
23
|
+
interface ReferralReward {
|
|
24
|
+
id: string;
|
|
25
|
+
/** `signup`, `card_issuance`, `first_deposit` or `deposit`. */
|
|
26
|
+
event: "signup" | "card_issuance" | "first_deposit" | "deposit" | (string & {});
|
|
27
|
+
/** The friend's operation a percent was taken of. */
|
|
28
|
+
basis_amount: string | null;
|
|
29
|
+
basis_currency: string | null;
|
|
30
|
+
/** Bonuses, decimal string. */
|
|
31
|
+
units: string;
|
|
32
|
+
/** Always `bonus`. */
|
|
33
|
+
payout_kind: string;
|
|
34
|
+
/** `pending` until the bonuses are on the account. */
|
|
35
|
+
status: "pending" | "credited" | (string & {});
|
|
36
|
+
created_at: string;
|
|
37
|
+
}
|
|
38
|
+
interface Referral {
|
|
39
|
+
code: string | null;
|
|
40
|
+
/** The invitation link, or `null` when the deployment has none: share the code then. */
|
|
41
|
+
link: string | null;
|
|
42
|
+
invited_count: number;
|
|
43
|
+
/** The latest invited, newest first. */
|
|
44
|
+
invited: InvitedFriend[];
|
|
45
|
+
/** Bonuses earned in total, decimal string. */
|
|
46
|
+
total_rewarded: string;
|
|
47
|
+
rewards: ReferralReward[];
|
|
48
|
+
}
|
|
49
|
+
declare class ReferralResource {
|
|
50
|
+
private readonly http;
|
|
51
|
+
constructor(http: HttpClient);
|
|
52
|
+
/** The user's referral code, link, invited friends and rewards. */
|
|
53
|
+
get(opts?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Referral>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { type InvitedFriend, type Referral, ReferralResource, type ReferralReward };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Referral resource — `client.referral.*`.
|
|
5
|
+
*
|
|
6
|
+
* For the people allowed to invite: their referral code, the link to
|
|
7
|
+
* share, the people who signed up with it (no names or contacts, only
|
|
8
|
+
* when they joined and how far they got) and what each reward was for.
|
|
9
|
+
* Referral codes are given by invitation, so `code` is `null` for most
|
|
10
|
+
* users. Rewards are bonuses, a discount on our services, not money.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `GET /me/referral`.
|
|
13
|
+
*/
|
|
14
|
+
/** Someone the user invited, without anything that identifies them. */
|
|
15
|
+
interface InvitedFriend {
|
|
16
|
+
joined_at: string;
|
|
17
|
+
/** Bonuses they brought so far, decimal string. */
|
|
18
|
+
rewarded: string;
|
|
19
|
+
has_card: boolean;
|
|
20
|
+
has_topped_up: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** One reward. */
|
|
23
|
+
interface ReferralReward {
|
|
24
|
+
id: string;
|
|
25
|
+
/** `signup`, `card_issuance`, `first_deposit` or `deposit`. */
|
|
26
|
+
event: "signup" | "card_issuance" | "first_deposit" | "deposit" | (string & {});
|
|
27
|
+
/** The friend's operation a percent was taken of. */
|
|
28
|
+
basis_amount: string | null;
|
|
29
|
+
basis_currency: string | null;
|
|
30
|
+
/** Bonuses, decimal string. */
|
|
31
|
+
units: string;
|
|
32
|
+
/** Always `bonus`. */
|
|
33
|
+
payout_kind: string;
|
|
34
|
+
/** `pending` until the bonuses are on the account. */
|
|
35
|
+
status: "pending" | "credited" | (string & {});
|
|
36
|
+
created_at: string;
|
|
37
|
+
}
|
|
38
|
+
interface Referral {
|
|
39
|
+
code: string | null;
|
|
40
|
+
/** The invitation link, or `null` when the deployment has none: share the code then. */
|
|
41
|
+
link: string | null;
|
|
42
|
+
invited_count: number;
|
|
43
|
+
/** The latest invited, newest first. */
|
|
44
|
+
invited: InvitedFriend[];
|
|
45
|
+
/** Bonuses earned in total, decimal string. */
|
|
46
|
+
total_rewarded: string;
|
|
47
|
+
rewards: ReferralReward[];
|
|
48
|
+
}
|
|
49
|
+
declare class ReferralResource {
|
|
50
|
+
private readonly http;
|
|
51
|
+
constructor(http: HttpClient);
|
|
52
|
+
/** The user's referral code, link, invited friends and rewards. */
|
|
53
|
+
get(opts?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Referral>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { type InvitedFriend, type Referral, ReferralResource, type ReferralReward };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/resources/referral.ts
|
|
2
|
+
var ReferralResource = class {
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.http = http;
|
|
5
|
+
}
|
|
6
|
+
/** The user's referral code, link, invited friends and rewards. */
|
|
7
|
+
async get(opts = {}) {
|
|
8
|
+
return this.http.get("/me/referral", { signal: opts.signal });
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { ReferralResource };
|
|
13
|
+
//# sourceMappingURL=referral.js.map
|
|
14
|
+
//# sourceMappingURL=referral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/referral.ts"],"names":[],"mappings":";AAoDO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAsB;AAChE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAc,cAAA,EAAgB,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EACxE;AACF","file":"referral.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Referral resource — `client.referral.*`.\n *\n * For the people allowed to invite: their referral code, the link to\n * share, the people who signed up with it (no names or contacts, only\n * when they joined and how far they got) and what each reward was for.\n * Referral codes are given by invitation, so `code` is `null` for most\n * users. Rewards are bonuses, a discount on our services, not money.\n *\n * Mirrors `GET /me/referral`.\n */\n\n/** Someone the user invited, without anything that identifies them. */\nexport interface InvitedFriend {\n joined_at: string;\n /** Bonuses they brought so far, decimal string. */\n rewarded: string;\n has_card: boolean;\n has_topped_up: boolean;\n}\n\n/** One reward. */\nexport interface ReferralReward {\n id: string;\n /** `signup`, `card_issuance`, `first_deposit` or `deposit`. */\n event: \"signup\" | \"card_issuance\" | \"first_deposit\" | \"deposit\" | (string & {});\n /** The friend's operation a percent was taken of. */\n basis_amount: string | null;\n basis_currency: string | null;\n /** Bonuses, decimal string. */\n units: string;\n /** Always `bonus`. */\n payout_kind: string;\n /** `pending` until the bonuses are on the account. */\n status: \"pending\" | \"credited\" | (string & {});\n created_at: string;\n}\n\nexport interface Referral {\n code: string | null;\n /** The invitation link, or `null` when the deployment has none: share the code then. */\n link: string | null;\n invited_count: number;\n /** The latest invited, newest first. */\n invited: InvitedFriend[];\n /** Bonuses earned in total, decimal string. */\n total_rewarded: string;\n rewards: ReferralReward[];\n}\n\nexport class ReferralResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's referral code, link, invited friends and rewards. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<Referral> {\n return this.http.get<Referral>(\"/me/referral\", { signal: opts.signal });\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/subscription.ts
|
|
4
|
+
var SubscriptionResource = class {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** The user's subscription, or `null` when there is none. */
|
|
9
|
+
async get(opts = {}) {
|
|
10
|
+
return this.http.get("/me/subscription", { signal: opts.signal });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Charge the monthly fee with a promo code, as long as the code allows.
|
|
14
|
+
* `null` removes it. A code that can't be used on the fee fails with 400
|
|
15
|
+
* `promo_code_*`; no paid subscription running → 404.
|
|
16
|
+
*/
|
|
17
|
+
async setPromoCode(code) {
|
|
18
|
+
return this.http.put("/me/subscription/promo-code", { body: { code } });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.SubscriptionResource = SubscriptionResource;
|
|
23
|
+
//# sourceMappingURL=subscription.cjs.map
|
|
24
|
+
//# sourceMappingURL=subscription.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resources/subscription.ts"],"names":[],"mappings":";;;AAkCO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAqC;AAC/E,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAA6B,kBAAA,EAAoB,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,IAAA,EAAgD;AACjE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAsB,6BAAA,EAA+B,EAAE,IAAA,EAAM,EAAE,IAAA,EAAK,EAAG,CAAA;AAAA,EAC1F;AACF","file":"subscription.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Subscription resource — `client.subscription.*`.\n *\n * The user's own paid tier or gift: the discounts it gives and, for a\n * gift, when it ends. Not to be confused with `client.subscriptions`, which\n * is about announcement channels.\n *\n * Mirrors `GET /me/subscription` and `PUT /me/subscription/promo-code`.\n */\n\nexport interface UserSubscription {\n id: string;\n tier_id: string;\n tier_name: string;\n /** `active`, `tryout`, `grace`, `cancelled` or `expired`. */\n status: string;\n /** `billing` (charged monthly) or `gift` (never charged). */\n kind: \"billing\" | \"gift\" | (string & {});\n /** For a gift: when it ends; `null` = no end date. */\n gift_until: string | null;\n monthly_fee: string;\n currency: string;\n /** Discount on card prices, basis points. */\n issuance_discount_bps: number;\n /** Discount on the top-up commission, basis points. */\n funding_discount_bps: number;\n started_at: string;\n current_period_end: string | null;\n /** The promo code the monthly fee is charged with, if any. */\n promo_code_id: string | null;\n}\n\nexport class SubscriptionResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's subscription, or `null` when there is none. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<UserSubscription | null> {\n return this.http.get<UserSubscription | null>(\"/me/subscription\", { signal: opts.signal });\n }\n\n /**\n * Charge the monthly fee with a promo code, as long as the code allows.\n * `null` removes it. A code that can't be used on the fee fails with 400\n * `promo_code_*`; no paid subscription running → 404.\n */\n async setPromoCode(code: string | null): Promise<UserSubscription> {\n return this.http.put<UserSubscription>(\"/me/subscription/promo-code\", { body: { code } });\n }\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { H as HttpClient } from '../http-DeANAoTs.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Subscription resource — `client.subscription.*`.
|
|
5
|
+
*
|
|
6
|
+
* The user's own paid tier or gift: the discounts it gives and, for a
|
|
7
|
+
* gift, when it ends. Not to be confused with `client.subscriptions`, which
|
|
8
|
+
* is about announcement channels.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `GET /me/subscription` and `PUT /me/subscription/promo-code`.
|
|
11
|
+
*/
|
|
12
|
+
interface UserSubscription {
|
|
13
|
+
id: string;
|
|
14
|
+
tier_id: string;
|
|
15
|
+
tier_name: string;
|
|
16
|
+
/** `active`, `tryout`, `grace`, `cancelled` or `expired`. */
|
|
17
|
+
status: string;
|
|
18
|
+
/** `billing` (charged monthly) or `gift` (never charged). */
|
|
19
|
+
kind: "billing" | "gift" | (string & {});
|
|
20
|
+
/** For a gift: when it ends; `null` = no end date. */
|
|
21
|
+
gift_until: string | null;
|
|
22
|
+
monthly_fee: string;
|
|
23
|
+
currency: string;
|
|
24
|
+
/** Discount on card prices, basis points. */
|
|
25
|
+
issuance_discount_bps: number;
|
|
26
|
+
/** Discount on the top-up commission, basis points. */
|
|
27
|
+
funding_discount_bps: number;
|
|
28
|
+
started_at: string;
|
|
29
|
+
current_period_end: string | null;
|
|
30
|
+
/** The promo code the monthly fee is charged with, if any. */
|
|
31
|
+
promo_code_id: string | null;
|
|
32
|
+
}
|
|
33
|
+
declare class SubscriptionResource {
|
|
34
|
+
private readonly http;
|
|
35
|
+
constructor(http: HttpClient);
|
|
36
|
+
/** The user's subscription, or `null` when there is none. */
|
|
37
|
+
get(opts?: {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<UserSubscription | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Charge the monthly fee with a promo code, as long as the code allows.
|
|
42
|
+
* `null` removes it. A code that can't be used on the fee fails with 400
|
|
43
|
+
* `promo_code_*`; no paid subscription running → 404.
|
|
44
|
+
*/
|
|
45
|
+
setPromoCode(code: string | null): Promise<UserSubscription>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { SubscriptionResource, type UserSubscription };
|