velirapay 0.1.0 → 0.2.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +699 -51
  3. package/dist/cjs/client.d.ts +1 -1
  4. package/dist/cjs/enums.d.ts +159 -27
  5. package/dist/cjs/enums.js +150 -25
  6. package/dist/cjs/errors.d.ts +10 -1
  7. package/dist/cjs/errors.js +12 -1
  8. package/dist/cjs/http/transport.js +18 -3
  9. package/dist/cjs/index.d.ts +4 -4
  10. package/dist/cjs/index.js +12 -2
  11. package/dist/cjs/page.d.ts +14 -2
  12. package/dist/cjs/page.js +19 -2
  13. package/dist/cjs/params.d.ts +17 -10
  14. package/dist/cjs/resources/account.d.ts +13 -13
  15. package/dist/cjs/resources/account.js +7 -7
  16. package/dist/cjs/resources/activity.d.ts +4 -3
  17. package/dist/cjs/resources/activity.js +1 -1
  18. package/dist/cjs/resources/api-key.d.ts +3 -2
  19. package/dist/cjs/resources/api-resource.d.ts +2 -0
  20. package/dist/cjs/resources/api-resource.js +5 -0
  21. package/dist/cjs/resources/charge.d.ts +10 -2
  22. package/dist/cjs/resources/charge.js +6 -0
  23. package/dist/cjs/resources/coupon.d.ts +2 -1
  24. package/dist/cjs/resources/event.d.ts +3 -3
  25. package/dist/cjs/resources/event.js +1 -1
  26. package/dist/cjs/resources/invoice.d.ts +4 -4
  27. package/dist/cjs/resources/member.d.ts +5 -4
  28. package/dist/cjs/resources/member.js +2 -2
  29. package/dist/cjs/resources/overview.d.ts +116 -4
  30. package/dist/cjs/resources/overview.js +76 -3
  31. package/dist/cjs/resources/payment-link.d.ts +3 -3
  32. package/dist/cjs/resources/payout.d.ts +5 -5
  33. package/dist/cjs/resources/payout.js +1 -1
  34. package/dist/cjs/resources/pro-payment.d.ts +3 -2
  35. package/dist/cjs/resources/supported-asset.d.ts +2 -2
  36. package/dist/cjs/resources/webhook-endpoint.d.ts +5 -4
  37. package/dist/cjs/resources/webhook-endpoint.js +3 -2
  38. package/dist/cjs/services/account.js +1 -1
  39. package/dist/cjs/services/api-keys.d.ts +7 -1
  40. package/dist/cjs/services/api-keys.js +7 -1
  41. package/dist/cjs/services/assets.d.ts +3 -4
  42. package/dist/cjs/services/assets.js +3 -2
  43. package/dist/cjs/services/charges.d.ts +10 -10
  44. package/dist/cjs/services/charges.js +12 -8
  45. package/dist/cjs/services/coupons.js +1 -1
  46. package/dist/cjs/services/invoices.js +5 -1
  47. package/dist/cjs/services/members.d.ts +2 -2
  48. package/dist/cjs/services/members.js +2 -2
  49. package/dist/cjs/services/overview.d.ts +1 -1
  50. package/dist/cjs/services/overview.js +3 -2
  51. package/dist/cjs/services/payment-links.js +4 -2
  52. package/dist/cjs/services/payout-addresses.d.ts +9 -4
  53. package/dist/cjs/services/payout-addresses.js +6 -2
  54. package/dist/cjs/services/service.d.ts +8 -3
  55. package/dist/cjs/services/service.js +45 -10
  56. package/dist/cjs/services/webhook-endpoints.d.ts +15 -2
  57. package/dist/cjs/services/webhook-endpoints.js +15 -2
  58. package/dist/cjs/version.d.ts +1 -1
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/client.d.ts +1 -1
  61. package/dist/esm/enums.d.ts +159 -27
  62. package/dist/esm/enums.js +149 -24
  63. package/dist/esm/errors.d.ts +10 -1
  64. package/dist/esm/errors.js +12 -1
  65. package/dist/esm/http/transport.js +18 -3
  66. package/dist/esm/index.d.ts +4 -4
  67. package/dist/esm/index.js +3 -3
  68. package/dist/esm/page.d.ts +14 -2
  69. package/dist/esm/page.js +17 -1
  70. package/dist/esm/params.d.ts +17 -10
  71. package/dist/esm/resources/account.d.ts +13 -13
  72. package/dist/esm/resources/account.js +8 -8
  73. package/dist/esm/resources/activity.d.ts +4 -3
  74. package/dist/esm/resources/activity.js +1 -1
  75. package/dist/esm/resources/api-key.d.ts +3 -2
  76. package/dist/esm/resources/api-resource.d.ts +2 -0
  77. package/dist/esm/resources/api-resource.js +4 -0
  78. package/dist/esm/resources/charge.d.ts +10 -2
  79. package/dist/esm/resources/charge.js +6 -0
  80. package/dist/esm/resources/coupon.d.ts +2 -1
  81. package/dist/esm/resources/event.d.ts +3 -3
  82. package/dist/esm/resources/event.js +1 -1
  83. package/dist/esm/resources/invoice.d.ts +4 -4
  84. package/dist/esm/resources/member.d.ts +5 -4
  85. package/dist/esm/resources/member.js +2 -2
  86. package/dist/esm/resources/overview.d.ts +116 -4
  87. package/dist/esm/resources/overview.js +77 -4
  88. package/dist/esm/resources/payment-link.d.ts +3 -3
  89. package/dist/esm/resources/payout.d.ts +5 -5
  90. package/dist/esm/resources/payout.js +1 -1
  91. package/dist/esm/resources/pro-payment.d.ts +3 -2
  92. package/dist/esm/resources/supported-asset.d.ts +2 -2
  93. package/dist/esm/resources/webhook-endpoint.d.ts +5 -4
  94. package/dist/esm/resources/webhook-endpoint.js +3 -2
  95. package/dist/esm/services/account.js +2 -2
  96. package/dist/esm/services/api-keys.d.ts +7 -1
  97. package/dist/esm/services/api-keys.js +7 -1
  98. package/dist/esm/services/assets.d.ts +3 -4
  99. package/dist/esm/services/assets.js +3 -2
  100. package/dist/esm/services/charges.d.ts +10 -10
  101. package/dist/esm/services/charges.js +13 -9
  102. package/dist/esm/services/coupons.js +2 -2
  103. package/dist/esm/services/invoices.js +6 -2
  104. package/dist/esm/services/members.d.ts +2 -2
  105. package/dist/esm/services/members.js +2 -2
  106. package/dist/esm/services/overview.d.ts +1 -1
  107. package/dist/esm/services/overview.js +4 -3
  108. package/dist/esm/services/payment-links.js +5 -3
  109. package/dist/esm/services/payout-addresses.d.ts +9 -4
  110. package/dist/esm/services/payout-addresses.js +6 -2
  111. package/dist/esm/services/service.d.ts +8 -3
  112. package/dist/esm/services/service.js +44 -10
  113. package/dist/esm/services/webhook-endpoints.d.ts +15 -2
  114. package/dist/esm/services/webhook-endpoints.js +15 -2
  115. package/dist/esm/version.d.ts +1 -1
  116. package/dist/esm/version.js +1 -1
  117. package/package.json +12 -2
@@ -1,8 +1,106 @@
1
+ import type { Asset, Currency, Mode, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
- /** The dashboard's figures for the last 30 days. Everything else it carries, such as the funnel and what needs attention, is read with get(). */
3
+ /** The days an overview covers: the last 30, today included. */
4
+ export interface OverviewPeriod {
5
+ /** The first day, at midnight UTC. */
6
+ from: Date | null;
7
+ /** The last day, today, at midnight UTC. */
8
+ to: Date | null;
9
+ }
10
+ /** How the period's attempts to pay ended, each in exactly one bucket; a new quote or a switch of coin carries an attempt on rather than starting another. */
11
+ export interface OverviewFunnel {
12
+ /** How many attempts were started. */
13
+ started: number;
14
+ /** How many were paid. */
15
+ paid: number;
16
+ /** How many are still pending or underpaid. */
17
+ waiting: number;
18
+ /** How many expired or were canceled without a transfer. */
19
+ abandoned: number;
20
+ /** How many expired or were canceled after a transfer arrived. */
21
+ incomplete: number;
22
+ /** The attempts per coin, the most started first. */
23
+ assets: OverviewFunnelAsset[];
24
+ }
25
+ /** How the period's attempts to pay in one coin ended. */
26
+ export interface OverviewFunnelAsset {
27
+ asset: OrString<Asset>;
28
+ started: number;
29
+ paid: number;
30
+ abandoned: number;
31
+ }
32
+ /** What needs a person now. */
33
+ export interface OverviewAttention {
34
+ /** The latest underpaid charges that received something, at most five, to accept or chase. */
35
+ underpaidCharges: OverviewChargeAmount[];
36
+ /** The latest expired or canceled charges with a payment still waiting to be accepted, at most five. */
37
+ latePayments: OverviewChargeAmount[];
38
+ /** The payouts per coin that wait for a payout address. */
39
+ payoutsWaitingForAddress: OverviewWaitingPayouts[];
40
+ /** How many active webhook endpoints had a delivery fail in the last 7 days. */
41
+ failingWebhookEndpoints: number;
42
+ }
43
+ /** A charge that needs a person, with what it asked for and what arrived. */
44
+ export interface OverviewChargeAmount {
45
+ /** The charge's id. */
46
+ id: string;
47
+ asset: OrString<Asset>;
48
+ /** What the charge asked for, in the coin. */
49
+ amount: string;
50
+ /** What arrived, in the coin: for a late payment, what came after the charge closed. */
51
+ receivedAmount: string;
52
+ }
53
+ /** How many payouts in one coin wait for a payout address. */
54
+ export interface OverviewWaitingPayouts {
55
+ asset: OrString<Asset>;
56
+ count: number;
57
+ }
58
+ /** One coin's share of the period's paid charges. */
59
+ export interface OverviewAsset {
60
+ asset: OrString<Asset>;
61
+ /** How many charges in the coin were paid. */
62
+ paidCharges: number;
63
+ /** Their share of every paid charge, in percent. */
64
+ sharePercent: number;
65
+ }
66
+ /** A payment link among those paid through most in the period. */
67
+ export interface OverviewPaymentLink {
68
+ /** The link's id. */
69
+ id: string | null;
70
+ title: string | null;
71
+ /** How many charges were paid through it. */
72
+ paidCharges: number;
73
+ }
74
+ /** Which first steps the account has taken in the mode. */
75
+ export interface OverviewSetup {
76
+ /** Whether it has a payout address. */
77
+ payoutAddress: boolean;
78
+ /** Whether it has a payment link. */
79
+ paymentLink: boolean;
80
+ /** Whether a charge has been paid. */
81
+ paidCharge: boolean;
82
+ /** Whether it has a webhook endpoint. */
83
+ webhookEndpoint: boolean;
84
+ /** Whether its public profile has a logo, a display name or a website. */
85
+ publicProfile: boolean;
86
+ }
87
+ /** One day of the period. */
88
+ export interface OverviewDay {
89
+ /** The day, at midnight UTC. */
90
+ date: Date | null;
91
+ /** What was paid that day in the overview's currency. */
92
+ volume: string;
93
+ /** What the payouts confirmed that day came to. */
94
+ sentVolume: string;
95
+ /** How many charges in the overview's currency were paid that day. */
96
+ paidCharges: number;
97
+ }
98
+ /** The dashboard's figures for the last 30 days, and what needs attention now. */
3
99
  export declare class Overview extends ApiResource {
4
- /** The currency the amounts are in. */
5
- readonly currency: string;
100
+ /** The days the figures cover. */
101
+ readonly period: OverviewPeriod;
102
+ /** The currency the amounts are in: the one most charges were paid in lately, or the account's default. */
103
+ readonly currency: OrString<Currency>;
6
104
  /** What was paid in the period. */
7
105
  readonly volume: string;
8
106
  /** How the volume changed against the 30 days before, in percent, or null when nothing was paid then. */
@@ -21,5 +119,19 @@ export declare class Overview extends ApiResource {
21
119
  readonly openInvoices: number;
22
120
  /** How many open invoices are past due. */
23
121
  readonly overdueInvoices: number;
24
- constructor(attributes: Attributes);
122
+ /** How the period's attempts to pay ended, in all and per coin. */
123
+ readonly funnel: OverviewFunnel;
124
+ /** What needs a person now: short and late payments, payouts without an address and failing webhook endpoints. */
125
+ readonly attention: OverviewAttention;
126
+ /** Each coin's share of the period's paid charges, the most paid first. */
127
+ readonly assets: OverviewAsset[];
128
+ /** The payment links paid through most in the period. */
129
+ readonly topPaymentLinks: OverviewPaymentLink[];
130
+ /** Which first steps the account has taken in the mode. */
131
+ readonly setup: OverviewSetup;
132
+ /** Every day of the period, oldest first. */
133
+ readonly daily: OverviewDay[];
134
+ /** The mode of the API key that fetched the overview: "live" or "test". */
135
+ readonly mode: OrString<Mode> | null;
136
+ constructor(attributes: Attributes, meta?: Attributes);
25
137
  }
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Overview = void 0;
4
4
  const api_resource_ts_1 = require("./api-resource.js");
5
- /** The dashboard's figures for the last 30 days. Everything else it carries, such as the funnel and what needs attention, is read with get(). */
5
+ /** The dashboard's figures for the last 30 days, and what needs attention now. */
6
6
  class Overview extends api_resource_ts_1.ApiResource {
7
- /** The currency the amounts are in. */
7
+ /** The days the figures cover. */
8
+ period;
9
+ /** The currency the amounts are in: the one most charges were paid in lately, or the account's default. */
8
10
  currency;
9
11
  /** What was paid in the period. */
10
12
  volume;
@@ -24,8 +26,27 @@ class Overview extends api_resource_ts_1.ApiResource {
24
26
  openInvoices;
25
27
  /** How many open invoices are past due. */
26
28
  overdueInvoices;
27
- constructor(attributes) {
29
+ /** How the period's attempts to pay ended, in all and per coin. */
30
+ funnel;
31
+ /** What needs a person now: short and late payments, payouts without an address and failing webhook endpoints. */
32
+ attention;
33
+ /** Each coin's share of the period's paid charges, the most paid first. */
34
+ assets;
35
+ /** The payment links paid through most in the period. */
36
+ topPaymentLinks;
37
+ /** Which first steps the account has taken in the mode. */
38
+ setup;
39
+ /** Every day of the period, oldest first. */
40
+ daily;
41
+ /** The mode of the API key that fetched the overview: "live" or "test". */
42
+ mode;
43
+ constructor(attributes, meta = {}) {
28
44
  super(attributes);
45
+ const period = (0, api_resource_ts_1.map)(attributes, 'period');
46
+ const funnel = (0, api_resource_ts_1.map)(attributes, 'funnel');
47
+ const attention = (0, api_resource_ts_1.map)(attributes, 'attention');
48
+ const setup = (0, api_resource_ts_1.map)(attributes, 'setup');
49
+ this.period = { from: (0, api_resource_ts_1.date)(period, 'from'), to: (0, api_resource_ts_1.date)(period, 'to') };
29
50
  this.currency = (0, api_resource_ts_1.string)(attributes, 'currency');
30
51
  this.volume = (0, api_resource_ts_1.string)(attributes, 'volume', '0');
31
52
  this.volumeChangePercent = (0, api_resource_ts_1.nullableNumber)(attributes, 'volume_change_percent');
@@ -36,6 +57,58 @@ class Overview extends api_resource_ts_1.ApiResource {
36
57
  this.activePaymentLinks = (0, api_resource_ts_1.int)(attributes, 'active_payment_links');
37
58
  this.openInvoices = (0, api_resource_ts_1.int)(attributes, 'open_invoices');
38
59
  this.overdueInvoices = (0, api_resource_ts_1.int)(attributes, 'overdue_invoices');
60
+ this.funnel = {
61
+ started: (0, api_resource_ts_1.int)(funnel, 'started'),
62
+ paid: (0, api_resource_ts_1.int)(funnel, 'paid'),
63
+ waiting: (0, api_resource_ts_1.int)(funnel, 'waiting'),
64
+ abandoned: (0, api_resource_ts_1.int)(funnel, 'abandoned'),
65
+ incomplete: (0, api_resource_ts_1.int)(funnel, 'incomplete'),
66
+ assets: (0, api_resource_ts_1.records)(funnel, 'assets').map((row) => ({
67
+ asset: (0, api_resource_ts_1.string)(row, 'asset'),
68
+ started: (0, api_resource_ts_1.int)(row, 'started'),
69
+ paid: (0, api_resource_ts_1.int)(row, 'paid'),
70
+ abandoned: (0, api_resource_ts_1.int)(row, 'abandoned'),
71
+ })),
72
+ };
73
+ this.attention = {
74
+ underpaidCharges: (0, api_resource_ts_1.records)(attention, 'underpaid_charges').map(chargeAmount),
75
+ latePayments: (0, api_resource_ts_1.records)(attention, 'late_payments').map(chargeAmount),
76
+ payoutsWaitingForAddress: (0, api_resource_ts_1.records)(attention, 'payouts_waiting_for_address').map((row) => ({ asset: (0, api_resource_ts_1.string)(row, 'asset'), count: (0, api_resource_ts_1.int)(row, 'count') })),
77
+ failingWebhookEndpoints: (0, api_resource_ts_1.int)(attention, 'failing_webhook_endpoints'),
78
+ };
79
+ this.assets = (0, api_resource_ts_1.records)(attributes, 'assets').map((row) => ({
80
+ asset: (0, api_resource_ts_1.string)(row, 'asset'),
81
+ paidCharges: (0, api_resource_ts_1.int)(row, 'paid_charges'),
82
+ sharePercent: (0, api_resource_ts_1.number)(row, 'share_percent'),
83
+ }));
84
+ this.topPaymentLinks = (0, api_resource_ts_1.records)(attributes, 'top_payment_links').map((link) => ({
85
+ id: (0, api_resource_ts_1.nullableString)(link, 'id'),
86
+ title: (0, api_resource_ts_1.nullableString)(link, 'title'),
87
+ paidCharges: (0, api_resource_ts_1.int)(link, 'paid_charges'),
88
+ }));
89
+ this.setup = {
90
+ payoutAddress: (0, api_resource_ts_1.bool)(setup, 'payout_address'),
91
+ paymentLink: (0, api_resource_ts_1.bool)(setup, 'payment_link'),
92
+ paidCharge: (0, api_resource_ts_1.bool)(setup, 'paid_charge'),
93
+ webhookEndpoint: (0, api_resource_ts_1.bool)(setup, 'webhook_endpoint'),
94
+ publicProfile: (0, api_resource_ts_1.bool)(setup, 'public_profile'),
95
+ };
96
+ this.daily = (0, api_resource_ts_1.records)(attributes, 'daily').map((day) => ({
97
+ date: (0, api_resource_ts_1.date)(day, 'date'),
98
+ volume: (0, api_resource_ts_1.string)(day, 'volume', '0'),
99
+ sentVolume: (0, api_resource_ts_1.string)(day, 'sent_volume', '0'),
100
+ paidCharges: (0, api_resource_ts_1.int)(day, 'paid_charges'),
101
+ }));
102
+ this.mode = (0, api_resource_ts_1.nullableString)(meta, 'mode');
39
103
  }
40
104
  }
41
105
  exports.Overview = Overview;
106
+ /** Read a charge that needs a person. */
107
+ function chargeAmount(row) {
108
+ return {
109
+ id: (0, api_resource_ts_1.string)(row, 'id'),
110
+ asset: (0, api_resource_ts_1.string)(row, 'asset'),
111
+ amount: (0, api_resource_ts_1.string)(row, 'amount', '0'),
112
+ receivedAmount: (0, api_resource_ts_1.string)(row, 'received_amount', '0'),
113
+ };
114
+ }
@@ -1,4 +1,4 @@
1
- import { PaymentLinkStatus, PricingType, type OrString } from '../enums.ts';
1
+ import { PaymentLinkStatus, PricingType, type Asset, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** A question a payment link's checkout asks. */
4
4
  export interface CheckoutQuestion {
@@ -24,9 +24,9 @@ export declare class PaymentLink extends ApiResource {
24
24
  /** The most a customer may pay on an open-price link. */
25
25
  readonly maxAmount: string | null;
26
26
  /** The fiat currency the link is priced in. */
27
- readonly currency: string;
27
+ readonly currency: OrString<Currency>;
28
28
  /** The coins the link takes, or null for every coin the account can receive. */
29
- readonly acceptedAssets: string[] | null;
29
+ readonly acceptedAssets: OrString<Asset>[] | null;
30
30
  /** One of the PaymentLinkStatus values: active or archived. */
31
31
  readonly status: OrString<PaymentLinkStatus>;
32
32
  /** Where the customer is sent after paying. */
@@ -1,4 +1,4 @@
1
- import { PayoutStatus, type Asset, type OrString } from '../enums.ts';
1
+ import { PayoutStatus, type AddressNetwork, type Asset, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** What became of one paid charge: what came in, what was kept, what was sent and the transaction that carried it. */
4
4
  export declare class Payout extends ApiResource {
@@ -19,7 +19,7 @@ export declare class Payout extends ApiResource {
19
19
  /** What the fee was worth in fiat, at the rate the charge was locked at. */
20
20
  readonly feeFiatAmount: string | null;
21
21
  /** The fiat currency of feeFiatAmount and exchangeRate. */
22
- readonly fiatCurrency: string | null;
22
+ readonly fiatCurrency: OrString<Currency> | null;
23
23
  /** The rate the charge was locked at. */
24
24
  readonly exchangeRate: string | null;
25
25
  /** What the merchant is owed, before the chain's own fee. */
@@ -76,14 +76,14 @@ export declare class PayoutSummary extends ApiResource {
76
76
  }
77
77
  /** Where the account's payouts on one network go. */
78
78
  export declare class PayoutAddress extends ApiResource {
79
- /** The network, such as "bitcoin" or "evm", which is also its id in the paths. */
80
- readonly network: string;
79
+ /** One of the AddressNetwork values, such as "bitcoin" or "evm", which is also its id in the paths. */
80
+ readonly network: OrString<AddressNetwork>;
81
81
  /** The network's name. */
82
82
  readonly name: string;
83
83
  /** Where payouts go, null while there is no address: payouts in its coins then wait for one. */
84
84
  readonly address: string | null;
85
85
  /** The coins on offer on this network. */
86
- readonly assets: string[];
86
+ readonly assets: OrString<Asset>[];
87
87
  /** Until when payouts to a newly saved address wait. */
88
88
  readonly payoutsHeldUntil: Date | null;
89
89
  /** When the address was last saved. */
@@ -120,7 +120,7 @@ class PayoutSummary extends api_resource_ts_1.ApiResource {
120
120
  exports.PayoutSummary = PayoutSummary;
121
121
  /** Where the account's payouts on one network go. */
122
122
  class PayoutAddress extends api_resource_ts_1.ApiResource {
123
- /** The network, such as "bitcoin" or "evm", which is also its id in the paths. */
123
+ /** One of the AddressNetwork values, such as "bitcoin" or "evm", which is also its id in the paths. */
124
124
  network;
125
125
  /** The network's name. */
126
126
  name;
@@ -1,3 +1,4 @@
1
+ import type { Asset, Currency, OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** A crypto payment for a month of Pro: where to pay it and what to send. */
3
4
  export declare class ProPayment extends ApiResource {
@@ -6,9 +7,9 @@ export declare class ProPayment extends ApiResource {
6
7
  /** What it costs, in currency. */
7
8
  readonly price: string;
8
9
  /** The currency of the price. */
9
- readonly currency: string;
10
+ readonly currency: OrString<Currency>;
10
11
  /** The coin it is paid in. */
11
- readonly asset: string;
12
+ readonly asset: OrString<Asset>;
12
13
  /** What to send, in the coin. */
13
14
  readonly assetAmount: string;
14
15
  /** The page to pay it on. */
@@ -1,4 +1,4 @@
1
- import { Asset, type OrString } from '../enums.ts';
1
+ import { Asset, type Currency, type OrString } from '../enums.ts';
2
2
  import { ApiResource, type Attributes } from './api-resource.ts';
3
3
  /** A coin that can be paid in the API key's mode, with the lowest price a charge in it can have. */
4
4
  export declare class SupportedAsset extends ApiResource {
@@ -21,7 +21,7 @@ export declare class SupportedAsset extends ApiResource {
21
21
  /** Whether the account takes it right now, which needs a payout address for that network. */
22
22
  readonly accepted: boolean | null;
23
23
  /** The currency exchangeRate and minimumPrice are in. */
24
- readonly currency: string;
24
+ readonly currency: OrString<Currency>;
25
25
  /** What one unit of the coin is worth in that currency right now, or null while no rate is available. */
26
26
  readonly exchangeRate: string | null;
27
27
  /** The least a charge in it can come to, in the coin itself, or null when it has no minimum of its own. */
@@ -1,3 +1,4 @@
1
+ import { WebhookDeliveryStatus, type EventType, type OrString } from '../enums.ts';
1
2
  import { ApiResource, type Attributes } from './api-resource.ts';
2
3
  /** Where webhooks are delivered, and whether it can receive them. Its signing secret is only returned when it is added or rotated. */
3
4
  export declare class WebhookEndpoint extends ApiResource {
@@ -8,7 +9,7 @@ export declare class WebhookEndpoint extends ApiResource {
8
9
  /** What the merchant noted about it. */
9
10
  readonly description: string | null;
10
11
  /** The EventType values it subscribes to. */
11
- readonly events: string[];
12
+ readonly events: OrString<EventType>[];
12
13
  /** Whether it is switched on. */
13
14
  readonly active: boolean;
14
15
  /** Whether it has answered the verification challenge; it receives nothing until it has. */
@@ -36,13 +37,13 @@ export declare class WebhookDelivery extends ApiResource {
36
37
  /** The delivery's id, the X-VeliraPay-Delivery header it was sent with. */
37
38
  readonly id: string;
38
39
  /** The EventType value it carried. */
39
- readonly event: string;
40
+ readonly event: OrString<EventType>;
40
41
  /** The id of the event it carried, null for a test delivery. */
41
42
  readonly eventId: string | null;
42
43
  /** Whether it was a test event, which describes no real payment. */
43
44
  readonly test: boolean;
44
- /** "pending", "succeeded" or "failed". */
45
- readonly status: string;
45
+ /** One of the WebhookDeliveryStatus values: pending, succeeded or failed. */
46
+ readonly status: OrString<WebhookDeliveryStatus>;
46
47
  /** How many times it was sent. */
47
48
  readonly attempts: number;
48
49
  /** The HTTP status the endpoint last answered with. */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookDeliveryAttempt = exports.WebhookDelivery = exports.WebhookEndpoint = void 0;
4
+ const enums_ts_1 = require("../enums.js");
4
5
  const api_resource_ts_1 = require("./api-resource.js");
5
6
  /** Where webhooks are delivered, and whether it can receive them. Its signing secret is only returned when it is added or rotated. */
6
7
  class WebhookEndpoint extends api_resource_ts_1.ApiResource {
@@ -62,7 +63,7 @@ class WebhookDelivery extends api_resource_ts_1.ApiResource {
62
63
  eventId;
63
64
  /** Whether it was a test event, which describes no real payment. */
64
65
  test;
65
- /** "pending", "succeeded" or "failed". */
66
+ /** One of the WebhookDeliveryStatus values: pending, succeeded or failed. */
66
67
  status;
67
68
  /** How many times it was sent. */
68
69
  attempts;
@@ -105,7 +106,7 @@ class WebhookDelivery extends api_resource_ts_1.ApiResource {
105
106
  }
106
107
  /** Whether the endpoint accepted the delivery. */
107
108
  succeeded() {
108
- return this.status === 'succeeded';
109
+ return this.status === enums_ts_1.WebhookDeliveryStatus.Succeeded;
109
110
  }
110
111
  }
111
112
  exports.WebhookDelivery = WebhookDelivery;
@@ -15,7 +15,7 @@ class AccountService extends service_ts_1.Service {
15
15
  }
16
16
  /** Change the default currency, the payment tolerances, the checkout language or invoice reminders. Needs payment_settings:write. */
17
17
  async updatePaymentSettings(params, options) {
18
- return account(await this.respond('PATCH', '/v1/payment-settings', params, options));
18
+ return account(await this.respond('PATCH', '/v1/payment-settings', (0, service_ts_1.withDecimalAmounts)(params, 'underpayment_tolerance', 'overpayment_threshold'), options));
19
19
  }
20
20
  }
21
21
  exports.AccountService = AccountService;
@@ -8,7 +8,13 @@ export declare class ApiKeyService extends Service {
8
8
  list(params?: PageParams): Promise<Page<ApiKey>>;
9
9
  /** Iterate over every active key, newest first, fetching pages as they are reached. */
10
10
  iterator(params?: Omit<PageParams, 'page'>): AsyncGenerator<ApiKey, void, undefined>;
11
- /** Create a key in the API key's mode. Its key property holds the key itself, shown this once; leaving permissions out gives full access. */
11
+ /**
12
+ * Create a key in the API key's mode. Its key property holds the key itself, shown this once; leaving permissions out gives full access.
13
+ *
14
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
15
+ * wasReplayed() is true: the key was made, but cannot be shown again. Find it with list() by its name and createdAt, revoke() it,
16
+ * and create another with a fresh idempotency key.
17
+ */
12
18
  create(params: ApiKeyCreateParams, options?: RequestOptions): Promise<ApiKey>;
13
19
  /** Change a key's name, permissions or allowed_ips, only those given; null permissions gives full access and null allowed_ips anywhere. */
14
20
  update(id: string, params: ApiKeyUpdateParams, options?: RequestOptions): Promise<ApiKey>;
@@ -13,7 +13,13 @@ class ApiKeyService extends service_ts_1.Service {
13
13
  async *iterator(params = {}) {
14
14
  yield* (await this.list(params)).autoPagingIterator();
15
15
  }
16
- /** Create a key in the API key's mode. Its key property holds the key itself, shown this once; leaving permissions out gives full access. */
16
+ /**
17
+ * Create a key in the API key's mode. Its key property holds the key itself, shown this once; leaving permissions out gives full access.
18
+ *
19
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
20
+ * wasReplayed() is true: the key was made, but cannot be shown again. Find it with list() by its name and createdAt, revoke() it,
21
+ * and create another with a fresh idempotency key.
22
+ */
17
23
  async create(params, options) {
18
24
  return new api_key_ts_1.ApiKey(await this.request('POST', '/v1/api-keys', params, options));
19
25
  }
@@ -1,9 +1,8 @@
1
- import type { Page } from '../page.ts';
1
+ import { AssetPage } from '../page.ts';
2
2
  import type { AssetListParams } from '../params.ts';
3
- import { SupportedAsset } from '../resources/supported-asset.ts';
4
3
  import { Service } from './service.ts';
5
4
  /** The /v1/assets endpoint. */
6
5
  export declare class AssetService extends Service {
7
- /** List the coins that can be paid in the API key's mode, with the lowest price each can be charged at, in one page. */
8
- list(params?: AssetListParams): Promise<Page<SupportedAsset>>;
6
+ /** List the coins that can be paid in the API key's mode, with the lowest price each can be charged at, in one page that also gives the currencies prices can be asked in. */
7
+ list(params?: AssetListParams): Promise<AssetPage>;
9
8
  }
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AssetService = void 0;
4
+ const page_ts_1 = require("../page.js");
4
5
  const supported_asset_ts_1 = require("../resources/supported-asset.js");
5
6
  const service_ts_1 = require("./service.js");
6
7
  /** The /v1/assets endpoint. */
7
8
  class AssetService extends service_ts_1.Service {
8
- /** List the coins that can be paid in the API key's mode, with the lowest price each can be charged at, in one page. */
9
+ /** List the coins that can be paid in the API key's mode, with the lowest price each can be charged at, in one page that also gives the currencies prices can be asked in. */
9
10
  async list(params = {}) {
10
- return this.page('/v1/assets', params, (asset) => new supported_asset_ts_1.SupportedAsset(asset));
11
+ return this.page('/v1/assets', params, (asset) => new supported_asset_ts_1.SupportedAsset(asset), page_ts_1.AssetPage);
11
12
  }
12
13
  }
13
14
  exports.AssetService = AssetService;
@@ -1,25 +1,25 @@
1
1
  import type { Page } from '../page.ts';
2
2
  import type { ChargeCreateParams, ChargeListParams, RefundParams, RequestOptions, SimulateParams } from '../params.ts';
3
- import { Charge } from '../resources/charge.ts';
3
+ import { type ApiCharge } from '../resources/charge.ts';
4
4
  import { Service } from './service.ts';
5
5
  /** The /v1/charges endpoints. */
6
6
  export declare class ChargeService extends Service {
7
7
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
8
- create(params: ChargeCreateParams, options?: RequestOptions): Promise<Charge>;
8
+ create(params: ChargeCreateParams, options?: RequestOptions): Promise<ApiCharge>;
9
9
  /** Retrieve a charge by its id. */
10
- retrieve(id: string): Promise<Charge>;
10
+ retrieve(id: string): Promise<ApiCharge>;
11
11
  /** List charges, newest first. */
12
- list(params?: ChargeListParams): Promise<Page<Charge>>;
12
+ list(params?: ChargeListParams): Promise<Page<ApiCharge>>;
13
13
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
14
- iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<Charge, void, undefined>;
14
+ iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<ApiCharge, void, undefined>;
15
15
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
16
- cancel(id: string, options?: RequestOptions): Promise<Charge>;
16
+ cancel(id: string, options?: RequestOptions): Promise<ApiCharge>;
17
17
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
18
- recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<Charge>;
18
+ recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<ApiCharge>;
19
19
  /** Email the customer the payment page of a pending charge. */
20
- send(id: string, options?: RequestOptions): Promise<Charge>;
20
+ send(id: string, options?: RequestOptions): Promise<ApiCharge>;
21
21
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
22
- accept(id: string, options?: RequestOptions): Promise<Charge>;
22
+ accept(id: string, options?: RequestOptions): Promise<ApiCharge>;
23
23
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
24
- simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<Charge>;
24
+ simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<ApiCharge>;
25
25
  }
@@ -7,15 +7,15 @@ const service_ts_1 = require("./service.js");
7
7
  class ChargeService extends service_ts_1.Service {
8
8
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
9
9
  async create(params, options) {
10
- return new charge_ts_1.Charge(await this.request('POST', '/v1/charges', params, options));
10
+ return apiCharge(await this.request('POST', '/v1/charges', (0, service_ts_1.withDecimalAmounts)(params, 'amount'), options));
11
11
  }
12
12
  /** Retrieve a charge by its id. */
13
13
  async retrieve(id) {
14
- return new charge_ts_1.Charge(await this.request('GET', (0, service_ts_1.path)('/v1/charges/%s', id)));
14
+ return apiCharge(await this.request('GET', (0, service_ts_1.path)('/v1/charges/%s', id)));
15
15
  }
16
16
  /** List charges, newest first. */
17
17
  async list(params = {}) {
18
- return this.page('/v1/charges', params, (charge) => new charge_ts_1.Charge(charge));
18
+ return this.page('/v1/charges', params, apiCharge);
19
19
  }
20
20
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
21
21
  async *iterator(params = {}) {
@@ -23,23 +23,27 @@ class ChargeService extends service_ts_1.Service {
23
23
  }
24
24
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
25
25
  async cancel(id, options) {
26
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/cancel', id), undefined, options));
26
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/cancel', id), undefined, options));
27
27
  }
28
28
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
29
29
  async recordRefund(id, params, options) {
30
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/refunds', id), params, options));
30
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/refunds', id), (0, service_ts_1.withDecimalAmounts)(params, 'amount'), options));
31
31
  }
32
32
  /** Email the customer the payment page of a pending charge. */
33
33
  async send(id, options) {
34
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/send', id), undefined, options));
34
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/send', id), undefined, options));
35
35
  }
36
36
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
37
37
  async accept(id, options) {
38
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/accept', id), undefined, options));
38
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/accept', id), undefined, options));
39
39
  }
40
40
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
41
41
  async simulate(id, params = {}, options) {
42
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : params, options));
42
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : (0, service_ts_1.withDecimalAmounts)(params, 'amount'), options));
43
43
  }
44
44
  }
45
45
  exports.ChargeService = ChargeService;
46
+ /** Read a charge the API answered with, which always carries its checkout page. */
47
+ function apiCharge(attributes) {
48
+ return new charge_ts_1.Charge(attributes);
49
+ }
@@ -7,7 +7,7 @@ const service_ts_1 = require("./service.js");
7
7
  class CouponService extends service_ts_1.Service {
8
8
  /** Create a coupon taking either percent_off or amount_off; currency is required with amount_off or min_amount. */
9
9
  async create(params, options) {
10
- return new coupon_ts_1.Coupon(await this.request('POST', '/v1/coupons', params, options));
10
+ return new coupon_ts_1.Coupon(await this.request('POST', '/v1/coupons', (0, service_ts_1.withDecimalAmounts)(params, 'percent_off', 'amount_off', 'min_amount'), options));
11
11
  }
12
12
  /** Retrieve a coupon by its code, in any case. */
13
13
  async retrieve(id) {
@@ -7,7 +7,11 @@ const service_ts_1 = require("./service.js");
7
7
  class InvoiceService extends service_ts_1.Service {
8
8
  /** Create an invoice, for a total or a list of items, and optionally email it to the customer. */
9
9
  async create(params, options) {
10
- return new invoice_ts_1.Invoice(await this.request('POST', '/v1/invoices', params, options));
10
+ const body = (0, service_ts_1.withDecimalAmounts)(params, 'amount');
11
+ if (Array.isArray(params.items)) {
12
+ body.items = params.items.map((item) => (0, service_ts_1.withDecimalAmounts)(item, 'quantity', 'unit_amount'));
13
+ }
14
+ return new invoice_ts_1.Invoice(await this.request('POST', '/v1/invoices', body, options));
11
15
  }
12
16
  /** Retrieve an invoice by its id. */
13
17
  async retrieve(id) {
@@ -8,7 +8,7 @@ export declare class MemberService extends Service {
8
8
  list(params?: PageParams): Promise<Page<Member>>;
9
9
  /** Iterate over every member, oldest first, fetching pages as they are reached. */
10
10
  iterator(params?: Omit<PageParams, 'page'>): AsyncGenerator<Member, void, undefined>;
11
- /** Give a member another role: "admin", "finance", "support" or "viewer". An owner is never changed this way. */
11
+ /** Give a member another role: admin, finance, support or viewer, as the MemberRole values name them. An owner is never changed this way. */
12
12
  update(id: string, params: MemberUpdateParams, options?: RequestOptions): Promise<Member>;
13
13
  /** Remove a member, which also revokes the API keys they made. An owner is never removed this way. */
14
14
  remove(id: string, options?: RequestOptions): Promise<void>;
@@ -19,7 +19,7 @@ export declare class InvitationService extends Service {
19
19
  list(params?: PageParams): Promise<Page<Invitation>>;
20
20
  /** Iterate over every waiting invitation, newest first, fetching pages as they are reached. */
21
21
  iterator(params?: Omit<PageParams, 'page'>): AsyncGenerator<Invitation, void, undefined>;
22
- /** Email someone an invitation to join as an "admin", "finance", "support" or "viewer", in the name of whoever made the API key. */
22
+ /** Email someone an invitation to join as an admin, finance, support or viewer, in the name of whoever made the API key. */
23
23
  create(params: InvitationCreateParams, options?: RequestOptions): Promise<Invitation>;
24
24
  /** Withdraw an invitation, so its link stops working. */
25
25
  cancel(id: string, options?: RequestOptions): Promise<void>;
@@ -13,7 +13,7 @@ class MemberService extends service_ts_1.Service {
13
13
  async *iterator(params = {}) {
14
14
  yield* (await this.list(params)).autoPagingIterator();
15
15
  }
16
- /** Give a member another role: "admin", "finance", "support" or "viewer". An owner is never changed this way. */
16
+ /** Give a member another role: admin, finance, support or viewer, as the MemberRole values name them. An owner is never changed this way. */
17
17
  async update(id, params, options) {
18
18
  return new member_ts_1.Member(await this.request('PATCH', (0, service_ts_1.path)('/v1/members/%s', id), params, options));
19
19
  }
@@ -33,7 +33,7 @@ class InvitationService extends service_ts_1.Service {
33
33
  async *iterator(params = {}) {
34
34
  yield* (await this.list(params)).autoPagingIterator();
35
35
  }
36
- /** Email someone an invitation to join as an "admin", "finance", "support" or "viewer", in the name of whoever made the API key. */
36
+ /** Email someone an invitation to join as an admin, finance, support or viewer, in the name of whoever made the API key. */
37
37
  async create(params, options) {
38
38
  return new member_ts_1.Invitation(await this.request('POST', '/v1/invitations', params, options));
39
39
  }
@@ -2,6 +2,6 @@ import { Overview } from '../resources/overview.ts';
2
2
  import { Service } from './service.ts';
3
3
  /** The /v1/overview endpoint. Needs overview:read. */
4
4
  export declare class OverviewService extends Service {
5
- /** Retrieve the dashboard's figures for the last 30 days, in the API key's mode. */
5
+ /** Retrieve the dashboard's figures for the last 30 days, in the API key's mode, and what needs attention now. */
6
6
  retrieve(): Promise<Overview>;
7
7
  }