@leaflow/sdk 0.115.1 → 0.117.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 (71) hide show
  1. package/dist/billing/v1/generated/functions.d.ts +172 -35
  2. package/dist/billing/v1/generated/functions.js +199 -29
  3. package/dist/billing/v1/generated/models.d.ts +252 -112
  4. package/dist/billing/v1/generated/models.js +16 -8
  5. package/dist/billing/v1/generated/schemas.zod.d.ts +125 -31
  6. package/dist/billing/v1/generated/schemas.zod.js +128 -22
  7. package/dist/billing/v1/generated/validators/accountBalance.zod.d.ts +5 -4
  8. package/dist/billing/v1/generated/validators/accountBalance.zod.js +5 -3
  9. package/dist/billing/v1/generated/validators/applicability.zod.d.ts +2 -3
  10. package/dist/billing/v1/generated/validators/billingAccount.zod.d.ts +1 -9
  11. package/dist/billing/v1/generated/validators/billingAccount.zod.js +4 -12
  12. package/dist/billing/v1/generated/validators/billingAccountCreate.zod.d.ts +0 -4
  13. package/dist/billing/v1/generated/validators/billingAccountCreate.zod.js +0 -4
  14. package/dist/billing/v1/generated/validators/billingAccountList.zod.d.ts +1 -9
  15. package/dist/billing/v1/generated/validators/billingAccountUpdate.zod.d.ts +1 -19
  16. package/dist/billing/v1/generated/validators/billingAccountUpdate.zod.js +4 -23
  17. package/dist/billing/v1/generated/validators/contact.zod.d.ts +37 -0
  18. package/dist/billing/v1/generated/validators/contact.zod.js +37 -0
  19. package/dist/billing/v1/generated/validators/contactCreate.zod.d.ts +32 -0
  20. package/dist/billing/v1/generated/validators/contactCreate.zod.js +30 -0
  21. package/dist/billing/v1/generated/validators/contactList.zod.d.ts +34 -0
  22. package/dist/billing/v1/generated/validators/contactList.zod.js +14 -0
  23. package/dist/billing/v1/generated/validators/contactUpdate.zod.d.ts +33 -0
  24. package/dist/billing/v1/generated/validators/contactUpdate.zod.js +31 -0
  25. package/dist/billing/v1/generated/validators/creditGrant.zod.d.ts +2 -3
  26. package/dist/billing/v1/generated/validators/creditGrantList.zod.d.ts +2 -3
  27. package/dist/billing/v1/generated/validators/creditGroup.zod.d.ts +2 -3
  28. package/dist/billing/v1/generated/validators/discount.zod.d.ts +2 -3
  29. package/dist/billing/v1/generated/validators/discountList.zod.d.ts +2 -3
  30. package/dist/billing/v1/generated/validators/getStatementUsageParams.zod.d.ts +29 -0
  31. package/dist/billing/v1/generated/validators/getStatementUsageParams.zod.js +33 -0
  32. package/dist/billing/v1/generated/validators/invoice.zod.d.ts +1 -6
  33. package/dist/billing/v1/generated/validators/invoice.zod.js +4 -8
  34. package/dist/billing/v1/generated/validators/invoiceItem.zod.d.ts +0 -2
  35. package/dist/billing/v1/generated/validators/invoiceItem.zod.js +0 -5
  36. package/dist/billing/v1/generated/validators/invoiceItemList.zod.d.ts +0 -2
  37. package/dist/billing/v1/generated/validators/invoiceList.zod.d.ts +1 -6
  38. package/dist/billing/v1/generated/validators/invoiceStatus.zod.js +1 -1
  39. package/dist/billing/v1/generated/validators/listContactsParams.zod.d.ts +18 -0
  40. package/dist/billing/v1/generated/validators/listContactsParams.zod.js +20 -0
  41. package/dist/billing/v1/generated/validators/listStatementsParams.zod.d.ts +25 -0
  42. package/dist/billing/v1/generated/validators/listStatementsParams.zod.js +25 -0
  43. package/dist/billing/v1/generated/validators/listUsageChargesParams.zod.d.ts +1 -0
  44. package/dist/billing/v1/generated/validators/listUsageChargesParams.zod.js +1 -0
  45. package/dist/billing/v1/generated/validators/order.zod.d.ts +2 -1
  46. package/dist/billing/v1/generated/validators/orderItem.zod.d.ts +1 -0
  47. package/dist/billing/v1/generated/validators/orderItem.zod.js +4 -0
  48. package/dist/billing/v1/generated/validators/orderItemList.zod.d.ts +1 -0
  49. package/dist/billing/v1/generated/validators/orderList.zod.d.ts +2 -1
  50. package/dist/billing/v1/generated/validators/purchaseOperation.zod.d.ts +2 -3
  51. package/dist/billing/v1/generated/validators/purchaseOperation.zod.js +2 -2
  52. package/dist/billing/v1/generated/validators/statement.zod.d.ts +34 -0
  53. package/dist/billing/v1/generated/validators/statement.zod.js +36 -0
  54. package/dist/billing/v1/generated/validators/statementAmounts.zod.d.ts +16 -0
  55. package/dist/billing/v1/generated/validators/statementAmounts.zod.js +15 -0
  56. package/dist/billing/v1/generated/validators/statementItem.zod.d.ts +20 -0
  57. package/dist/billing/v1/generated/validators/statementItem.zod.js +25 -0
  58. package/dist/billing/v1/generated/validators/statementList.zod.d.ts +41 -0
  59. package/dist/billing/v1/generated/validators/statementList.zod.js +14 -0
  60. package/dist/billing/v1/generated/validators/statementStatus.zod.d.ts +14 -0
  61. package/dist/billing/v1/generated/validators/statementStatus.zod.js +9 -0
  62. package/dist/billing/v1/generated/validators/statementSummary.zod.d.ts +36 -0
  63. package/dist/billing/v1/generated/validators/statementSummary.zod.js +19 -0
  64. package/dist/billing/v1/generated/validators/usageCharge.zod.d.ts +1 -0
  65. package/dist/billing/v1/generated/validators/usageCharge.zod.js +1 -0
  66. package/dist/billing/v1/generated/validators/usageChargeList.zod.d.ts +1 -0
  67. package/dist/routes.d.ts +64 -8
  68. package/dist/routes.js +72 -9
  69. package/package.json +1 -1
  70. package/dist/billing/v1/generated/validators/meteredUsage.zod.d.ts +0 -20
  71. package/dist/billing/v1/generated/validators/meteredUsage.zod.js +0 -27
@@ -5,13 +5,114 @@
5
5
  * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
6
  * OpenAPI spec version: v1
7
7
  */
8
- import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList, CheckoutOrderRequest, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListInvoiceItemsParams, ListInvoicesParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, MeteredUsage, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList } from "./models.js";
8
+ import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList, CheckoutOrderRequest, Contact, ContactCreate, ContactList, ContactUpdate, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, GetStatementUsageParams, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListContactsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListInvoiceItemsParams, ListInvoicesParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListStatementsParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Statement, StatementList, StatementSummary, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList } from "./models.js";
9
9
  export type HTTPStatusCode1xx = 100 | 101 | 102 | 103;
10
10
  export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;
11
11
  export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
12
12
  export type HTTPStatusCode4xx = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451;
13
13
  export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
14
14
  export type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;
15
+ export type listContactsResponse200 = {
16
+ data: ContactList;
17
+ status: 200;
18
+ };
19
+ export type listContactsResponseDefault = {
20
+ data: ErrorResponse;
21
+ status: Exclude<HTTPStatusCodes, 200>;
22
+ };
23
+ export type listContactsResponseSuccess = listContactsResponse200 & {
24
+ headers: Headers;
25
+ };
26
+ export type listContactsResponseError = listContactsResponseDefault & {
27
+ headers: Headers;
28
+ };
29
+ export type listContactsResponse = listContactsResponseSuccess | listContactsResponseError;
30
+ export declare const getListContactsUrl: (accountId: number, params?: ListContactsParams) => string;
31
+ /**
32
+ * @summary List contacts
33
+ */
34
+ export declare const listContacts: (accountId: number, params?: ListContactsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listContactsResponse>;
35
+ export type createContactResponse201 = {
36
+ data: Contact;
37
+ status: 201;
38
+ };
39
+ export type createContactResponseDefault = {
40
+ data: ErrorResponse;
41
+ status: Exclude<HTTPStatusCodes, 201>;
42
+ };
43
+ export type createContactResponseSuccess = createContactResponse201 & {
44
+ headers: Headers;
45
+ };
46
+ export type createContactResponseError = createContactResponseDefault & {
47
+ headers: Headers;
48
+ };
49
+ export type createContactResponse = createContactResponseSuccess | createContactResponseError;
50
+ export declare const getCreateContactUrl: (accountId: number) => string;
51
+ /**
52
+ * @summary Create contact
53
+ */
54
+ export declare const createContact: (accountId: number, contactCreate: ContactCreate, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<createContactResponse>;
55
+ export type getContactResponse200 = {
56
+ data: Contact;
57
+ status: 200;
58
+ };
59
+ export type getContactResponseDefault = {
60
+ data: ErrorResponse;
61
+ status: Exclude<HTTPStatusCodes, 200>;
62
+ };
63
+ export type getContactResponseSuccess = getContactResponse200 & {
64
+ headers: Headers;
65
+ };
66
+ export type getContactResponseError = getContactResponseDefault & {
67
+ headers: Headers;
68
+ };
69
+ export type getContactResponse = getContactResponseSuccess | getContactResponseError;
70
+ export declare const getGetContactUrl: (contactId: string) => string;
71
+ /**
72
+ * @summary Get contact
73
+ */
74
+ export declare const getContact: (contactId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getContactResponse>;
75
+ export type updateContactResponse200 = {
76
+ data: Contact;
77
+ status: 200;
78
+ };
79
+ export type updateContactResponseDefault = {
80
+ data: ErrorResponse;
81
+ status: Exclude<HTTPStatusCodes, 200>;
82
+ };
83
+ export type updateContactResponseSuccess = updateContactResponse200 & {
84
+ headers: Headers;
85
+ };
86
+ export type updateContactResponseError = updateContactResponseDefault & {
87
+ headers: Headers;
88
+ };
89
+ export type updateContactResponse = updateContactResponseSuccess | updateContactResponseError;
90
+ export declare const getUpdateContactUrl: (contactId: string) => string;
91
+ /**
92
+ * @summary Update contact
93
+ */
94
+ export declare const updateContact: (contactId: string, contactUpdate: ContactUpdate, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<updateContactResponse>;
95
+ export type deleteContactResponse204 = {
96
+ data: void;
97
+ status: 204;
98
+ };
99
+ export type deleteContactResponseDefault = {
100
+ data: ErrorResponse;
101
+ status: Exclude<HTTPStatusCodes, 204>;
102
+ };
103
+ export type deleteContactResponseSuccess = deleteContactResponse204 & {
104
+ headers: Headers;
105
+ };
106
+ export type deleteContactResponseError = deleteContactResponseDefault & {
107
+ headers: Headers;
108
+ };
109
+ export type deleteContactResponse = deleteContactResponseSuccess | deleteContactResponseError;
110
+ export declare const getDeleteContactUrl: (contactId: string) => string;
111
+ /**
112
+ * The selected invoice contact must be cleared or replaced before deletion. Issued invoice snapshots are retained.
113
+ * @summary Delete contact
114
+ */
115
+ export declare const deleteContact: (contactId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<deleteContactResponse>;
15
116
  export type listCurrenciesResponse200 = {
16
117
  data: CurrencyList;
17
118
  status: 200;
@@ -115,10 +216,9 @@ export type updateBillingAccountResponseError = updateBillingAccountResponseDefa
115
216
  export type updateBillingAccountResponse = updateBillingAccountResponseSuccess | updateBillingAccountResponseError;
116
217
  export declare const getUpdateBillingAccountUrl: (accountId: number) => string;
117
218
  /**
118
- * The legal name, address and tax identifier are copied onto each invoice when it is
119
- * issued. Changing them here affects invoices issued afterwards, not those already sent.
120
- *
121
- * The currency cannot be changed.
219
+ * Select an active contact belonging to this account for future invoices. Its legal name,
220
+ * address and tax identifier are copied when an invoice is issued; issued snapshots are
221
+ * retained. Set invoice_contact_id to null to clear the selection. The currency cannot change.
122
222
  * @summary Update billing account
123
223
  */
124
224
  export declare const updateBillingAccount: (accountId: number, billingAccountUpdate: BillingAccountUpdate, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<updateBillingAccountResponse>;
@@ -142,29 +242,6 @@ export declare const getGetAccountBalanceUrl: (accountId: number) => string;
142
242
  * @summary Get account balance
143
243
  */
144
244
  export declare const getAccountBalance: (accountId: number, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getAccountBalanceResponse>;
145
- export type getAccountMeteredUsageResponse200 = {
146
- data: MeteredUsage;
147
- status: 200;
148
- };
149
- export type getAccountMeteredUsageResponseDefault = {
150
- data: ErrorResponse;
151
- status: Exclude<HTTPStatusCodes, 200>;
152
- };
153
- export type getAccountMeteredUsageResponseSuccess = getAccountMeteredUsageResponse200 & {
154
- headers: Headers;
155
- };
156
- export type getAccountMeteredUsageResponseError = getAccountMeteredUsageResponseDefault & {
157
- headers: Headers;
158
- };
159
- export type getAccountMeteredUsageResponse = getAccountMeteredUsageResponseSuccess | getAccountMeteredUsageResponseError;
160
- export declare const getGetAccountMeteredUsageUrl: (accountId: number) => string;
161
- /**
162
- * Whether the account has anything billed by usage, and what that usage has cost over the last
163
- * seven days. Usage is paid from the balance, so this tells how much of the balance it is likely
164
- * to need: the balance divided by `average_daily_amount` is roughly how many days it lasts.
165
- * @summary Get account metered usage
166
- */
167
- export declare const getAccountMeteredUsage: (accountId: number, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getAccountMeteredUsageResponse>;
168
245
  export type listPaymentOptionsResponse200 = {
169
246
  data: PaymentOptionList;
170
247
  status: 200;
@@ -830,9 +907,7 @@ export type listUsageChargesResponseError = listUsageChargesResponseDefault & {
830
907
  export type listUsageChargesResponse = listUsageChargesResponseSuccess | listUsageChargesResponseError;
831
908
  export declare const getListUsageChargesUrl: (params?: ListUsageChargesParams) => string;
832
909
  /**
833
- * Each charge is added to the month's usage invoice as it is priced, summed into one line per
834
- * subscription, project, resource, meter and rate. Filter by `invoice_item_id` to see the
835
- * charges behind a line. Charges still waiting to be priced are included too.
910
+ * Lists priced and pending usage charges. Requires `statement_id`, `invoice_item_id`, or both `from` and `to` spanning at most 31 days; use the statement summary or spend report for longer periods. Charges are summed into one line per subscription, project, resource, meter and rate when their statement closes; filter by `invoice_item_id` to see the charges behind a line. Charges still waiting to be priced are included too.
836
911
  *
837
912
  * Only charges recorded against your billing accounts are included, before filtering, counting and pagination. Reassigning a project does not move previously recorded charges to its new account.
838
913
  * @summary List usage charges
@@ -1671,10 +1746,72 @@ export type listSpendResponseError = listSpendResponseDefault & {
1671
1746
  export type listSpendResponse = listSpendResponseSuccess | listSpendResponseError;
1672
1747
  export declare const getListSpendUrl: (params: ListSpendParams) => string;
1673
1748
  /**
1674
- * Aggregates rated and invoiced usage charges in the specified time range for one billing account.
1675
- * Includes usage not yet invoiced. Project filters use the account recorded on each charge, including
1676
- * charges for projects later assigned to another account. The total covers all matching groups, not
1677
- * just the returned page.
1749
+ * Sums priced usage for one billing account by UTC day, including usage not yet invoiced. Amounts are
1750
+ * before tax and before the tier adjustments made when a statement closes; minimum charges added at
1751
+ * closing are included. `from` and `to` must fall on UTC day boundaries and span at most 92 days.
1752
+ * Project filters use the account recorded on each charge, including charges for projects later
1753
+ * assigned to another account. The total covers all matching groups, not just the returned page.
1678
1754
  * @summary List account spend
1679
1755
  */
1680
1756
  export declare const listSpend: (params: ListSpendParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listSpendResponse>;
1757
+ export type listStatementsResponse200 = {
1758
+ data: StatementList;
1759
+ status: 200;
1760
+ };
1761
+ export type listStatementsResponseDefault = {
1762
+ data: ErrorResponse;
1763
+ status: Exclude<HTTPStatusCodes, 200>;
1764
+ };
1765
+ export type listStatementsResponseSuccess = listStatementsResponse200 & {
1766
+ headers: Headers;
1767
+ };
1768
+ export type listStatementsResponseError = listStatementsResponseDefault & {
1769
+ headers: Headers;
1770
+ };
1771
+ export type listStatementsResponse = listStatementsResponseSuccess | listStatementsResponseError;
1772
+ export declare const getListStatementsUrl: (params?: ListStatementsParams) => string;
1773
+ /**
1774
+ * @summary List statements
1775
+ */
1776
+ export declare const listStatements: (params?: ListStatementsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listStatementsResponse>;
1777
+ export type getStatementResponse200 = {
1778
+ data: Statement;
1779
+ status: 200;
1780
+ };
1781
+ export type getStatementResponseDefault = {
1782
+ data: ErrorResponse;
1783
+ status: Exclude<HTTPStatusCodes, 200>;
1784
+ };
1785
+ export type getStatementResponseSuccess = getStatementResponse200 & {
1786
+ headers: Headers;
1787
+ };
1788
+ export type getStatementResponseError = getStatementResponseDefault & {
1789
+ headers: Headers;
1790
+ };
1791
+ export type getStatementResponse = getStatementResponseSuccess | getStatementResponseError;
1792
+ export declare const getGetStatementUrl: (statementId: string) => string;
1793
+ /**
1794
+ * @summary Get statement
1795
+ */
1796
+ export declare const getStatement: (statementId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getStatementResponse>;
1797
+ export type getStatementUsageResponse200 = {
1798
+ data: StatementSummary;
1799
+ status: 200;
1800
+ };
1801
+ export type getStatementUsageResponseDefault = {
1802
+ data: ErrorResponse;
1803
+ status: Exclude<HTTPStatusCodes, 200>;
1804
+ };
1805
+ export type getStatementUsageResponseSuccess = getStatementUsageResponse200 & {
1806
+ headers: Headers;
1807
+ };
1808
+ export type getStatementUsageResponseError = getStatementUsageResponseDefault & {
1809
+ headers: Headers;
1810
+ };
1811
+ export type getStatementUsageResponse = getStatementUsageResponseSuccess | getStatementUsageResponseError;
1812
+ export declare const getGetStatementUsageUrl: (statementId: string, params?: GetStatementUsageParams) => string;
1813
+ /**
1814
+ * Reads the consumption summary that is updated in the same transaction as usage is priced. Group by project, product or meter and filter within the statement. Quantities are included only for meter groups so different units are never combined.
1815
+ * @summary Get grouped consumption
1816
+ */
1817
+ export declare const getStatementUsage: (statementId: string, params?: GetStatementUsageParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getStatementUsageResponse>;
@@ -1,3 +1,122 @@
1
+ export const getListContactsUrl = (accountId, params) => {
2
+ const normalizedParams = new URLSearchParams();
3
+ Object.entries(params || {}).forEach(([key, value]) => {
4
+ if (value !== undefined) {
5
+ normalizedParams.append(key, value === null ? "null" : String(value));
6
+ }
7
+ });
8
+ const stringifiedParams = normalizedParams.toString();
9
+ return stringifiedParams.length > 0
10
+ ? `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/contacts?${stringifiedParams}`
11
+ : `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/contacts`;
12
+ };
13
+ /**
14
+ * @summary List contacts
15
+ */
16
+ export const listContacts = async (accountId, params, options, fetchFn) => {
17
+ const res = await (fetchFn ?? fetch)(getListContactsUrl(accountId, params), {
18
+ ...options,
19
+ method: "GET",
20
+ });
21
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
22
+ const data = body ? JSON.parse(body) : {};
23
+ return { data, status: res.status, headers: res.headers };
24
+ };
25
+ export const getCreateContactUrl = (accountId) => {
26
+ return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/contacts`;
27
+ };
28
+ /**
29
+ * @summary Create contact
30
+ */
31
+ export const createContact = async (accountId, contactCreate, options, fetchFn) => {
32
+ const getHeaders = (h) => {
33
+ if (!h)
34
+ return {};
35
+ if (h instanceof Headers)
36
+ return Object.fromEntries(h.entries());
37
+ if (Symbol.iterator in h) {
38
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
39
+ }
40
+ const headers = {};
41
+ for (const [name, value] of Object.entries(h)) {
42
+ if (value !== undefined)
43
+ headers[name] = value;
44
+ }
45
+ return headers;
46
+ };
47
+ const res = await (fetchFn ?? fetch)(getCreateContactUrl(accountId), {
48
+ ...options,
49
+ method: "POST",
50
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
51
+ body: JSON.stringify(contactCreate),
52
+ });
53
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
54
+ const data = body ? JSON.parse(body) : {};
55
+ return { data, status: res.status, headers: res.headers };
56
+ };
57
+ export const getGetContactUrl = (contactId) => {
58
+ return `https://billing.leaflow.cloud/api/v1/contacts/${encodeURIComponent(String(contactId))}`;
59
+ };
60
+ /**
61
+ * @summary Get contact
62
+ */
63
+ export const getContact = async (contactId, options, fetchFn) => {
64
+ const res = await (fetchFn ?? fetch)(getGetContactUrl(contactId), {
65
+ ...options,
66
+ method: "GET",
67
+ });
68
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
69
+ const data = body ? JSON.parse(body) : {};
70
+ return { data, status: res.status, headers: res.headers };
71
+ };
72
+ export const getUpdateContactUrl = (contactId) => {
73
+ return `https://billing.leaflow.cloud/api/v1/contacts/${encodeURIComponent(String(contactId))}`;
74
+ };
75
+ /**
76
+ * @summary Update contact
77
+ */
78
+ export const updateContact = async (contactId, contactUpdate, options, fetchFn) => {
79
+ const getHeaders = (h) => {
80
+ if (!h)
81
+ return {};
82
+ if (h instanceof Headers)
83
+ return Object.fromEntries(h.entries());
84
+ if (Symbol.iterator in h) {
85
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
86
+ }
87
+ const headers = {};
88
+ for (const [name, value] of Object.entries(h)) {
89
+ if (value !== undefined)
90
+ headers[name] = value;
91
+ }
92
+ return headers;
93
+ };
94
+ const res = await (fetchFn ?? fetch)(getUpdateContactUrl(contactId), {
95
+ ...options,
96
+ method: "PATCH",
97
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
98
+ body: JSON.stringify(contactUpdate),
99
+ });
100
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
101
+ const data = body ? JSON.parse(body) : {};
102
+ return { data, status: res.status, headers: res.headers };
103
+ };
104
+ export const getDeleteContactUrl = (contactId) => {
105
+ return `https://billing.leaflow.cloud/api/v1/contacts/${encodeURIComponent(String(contactId))}`;
106
+ };
107
+ /**
108
+ * The selected invoice contact must be cleared or replaced before deletion. Issued invoice snapshots are retained.
109
+ * @summary Delete contact
110
+ */
111
+ export const deleteContact = async (contactId, options, fetchFn) => {
112
+ const res = await (fetchFn ?? fetch)(getDeleteContactUrl(contactId), {
113
+ ...options,
114
+ method: "DELETE",
115
+ });
116
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
117
+ const data = body ? JSON.parse(body) : undefined;
118
+ return { data, status: res.status, headers: res.headers };
119
+ };
1
120
  export const getListCurrenciesUrl = (params) => {
2
121
  const normalizedParams = new URLSearchParams();
3
122
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -103,10 +222,9 @@ export const getUpdateBillingAccountUrl = (accountId) => {
103
222
  return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}`;
104
223
  };
105
224
  /**
106
- * The legal name, address and tax identifier are copied onto each invoice when it is
107
- * issued. Changing them here affects invoices issued afterwards, not those already sent.
108
- *
109
- * The currency cannot be changed.
225
+ * Select an active contact belonging to this account for future invoices. Its legal name,
226
+ * address and tax identifier are copied when an invoice is issued; issued snapshots are
227
+ * retained. Set invoice_contact_id to null to clear the selection. The currency cannot change.
110
228
  * @summary Update billing account
111
229
  */
112
230
  export const updateBillingAccount = async (accountId, billingAccountUpdate, options, fetchFn) => {
@@ -150,24 +268,6 @@ export const getAccountBalance = async (accountId, options, fetchFn) => {
150
268
  const data = body ? JSON.parse(body) : {};
151
269
  return { data, status: res.status, headers: res.headers };
152
270
  };
153
- export const getGetAccountMeteredUsageUrl = (accountId) => {
154
- return `https://billing.leaflow.cloud/api/v1/billing-accounts/${encodeURIComponent(String(accountId))}/metered-usage`;
155
- };
156
- /**
157
- * Whether the account has anything billed by usage, and what that usage has cost over the last
158
- * seven days. Usage is paid from the balance, so this tells how much of the balance it is likely
159
- * to need: the balance divided by `average_daily_amount` is roughly how many days it lasts.
160
- * @summary Get account metered usage
161
- */
162
- export const getAccountMeteredUsage = async (accountId, options, fetchFn) => {
163
- const res = await (fetchFn ?? fetch)(getGetAccountMeteredUsageUrl(accountId), {
164
- ...options,
165
- method: "GET",
166
- });
167
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
168
- const data = body ? JSON.parse(body) : {};
169
- return { data, status: res.status, headers: res.headers };
170
- };
171
271
  export const getListPaymentOptionsUrl = (accountId, params) => {
172
272
  const normalizedParams = new URLSearchParams();
173
273
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -909,9 +1009,7 @@ export const getListUsageChargesUrl = (params) => {
909
1009
  : `https://billing.leaflow.cloud/api/v1/usage-charges`;
910
1010
  };
911
1011
  /**
912
- * Each charge is added to the month's usage invoice as it is priced, summed into one line per
913
- * subscription, project, resource, meter and rate. Filter by `invoice_item_id` to see the
914
- * charges behind a line. Charges still waiting to be priced are included too.
1012
+ * Lists priced and pending usage charges. Requires `statement_id`, `invoice_item_id`, or both `from` and `to` spanning at most 31 days; use the statement summary or spend report for longer periods. Charges are summed into one line per subscription, project, resource, meter and rate when their statement closes; filter by `invoice_item_id` to see the charges behind a line. Charges still waiting to be priced are included too.
915
1013
  *
916
1014
  * Only charges recorded against your billing accounts are included, before filtering, counting and pagination. Reassigning a project does not move previously recorded charges to its new account.
917
1015
  * @summary List usage charges
@@ -1938,10 +2036,11 @@ export const getListSpendUrl = (params) => {
1938
2036
  : `https://billing.leaflow.cloud/api/v1/spend`;
1939
2037
  };
1940
2038
  /**
1941
- * Aggregates rated and invoiced usage charges in the specified time range for one billing account.
1942
- * Includes usage not yet invoiced. Project filters use the account recorded on each charge, including
1943
- * charges for projects later assigned to another account. The total covers all matching groups, not
1944
- * just the returned page.
2039
+ * Sums priced usage for one billing account by UTC day, including usage not yet invoiced. Amounts are
2040
+ * before tax and before the tier adjustments made when a statement closes; minimum charges added at
2041
+ * closing are included. `from` and `to` must fall on UTC day boundaries and span at most 92 days.
2042
+ * Project filters use the account recorded on each charge, including charges for projects later
2043
+ * assigned to another account. The total covers all matching groups, not just the returned page.
1945
2044
  * @summary List account spend
1946
2045
  */
1947
2046
  export const listSpend = async (params, options, fetchFn) => {
@@ -1953,3 +2052,74 @@ export const listSpend = async (params, options, fetchFn) => {
1953
2052
  const data = body ? JSON.parse(body) : {};
1954
2053
  return { data, status: res.status, headers: res.headers };
1955
2054
  };
2055
+ export const getListStatementsUrl = (params) => {
2056
+ const normalizedParams = new URLSearchParams();
2057
+ Object.entries(params || {}).forEach(([key, value]) => {
2058
+ if (value !== undefined) {
2059
+ normalizedParams.append(key, value === null ? "null" : String(value));
2060
+ }
2061
+ });
2062
+ const stringifiedParams = normalizedParams.toString();
2063
+ return stringifiedParams.length > 0
2064
+ ? `https://billing.leaflow.cloud/api/v1/statements?${stringifiedParams}`
2065
+ : `https://billing.leaflow.cloud/api/v1/statements`;
2066
+ };
2067
+ /**
2068
+ * @summary List statements
2069
+ */
2070
+ export const listStatements = async (params, options, fetchFn) => {
2071
+ const res = await (fetchFn ?? fetch)(getListStatementsUrl(params), {
2072
+ ...options,
2073
+ method: "GET",
2074
+ });
2075
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
2076
+ const data = body ? JSON.parse(body) : {};
2077
+ return { data, status: res.status, headers: res.headers };
2078
+ };
2079
+ export const getGetStatementUrl = (statementId) => {
2080
+ return `https://billing.leaflow.cloud/api/v1/statements/${encodeURIComponent(String(statementId))}`;
2081
+ };
2082
+ /**
2083
+ * @summary Get statement
2084
+ */
2085
+ export const getStatement = async (statementId, options, fetchFn) => {
2086
+ const res = await (fetchFn ?? fetch)(getGetStatementUrl(statementId), {
2087
+ ...options,
2088
+ method: "GET",
2089
+ });
2090
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
2091
+ const data = body ? JSON.parse(body) : {};
2092
+ return { data, status: res.status, headers: res.headers };
2093
+ };
2094
+ export const getGetStatementUsageUrl = (statementId, params) => {
2095
+ const normalizedParams = new URLSearchParams();
2096
+ Object.entries(params || {}).forEach(([key, value]) => {
2097
+ const explodeParameters = ["project_ids"];
2098
+ if (Array.isArray(value) && explodeParameters.includes(key)) {
2099
+ value.forEach((v) => {
2100
+ normalizedParams.append(key, v === null ? "null" : String(v));
2101
+ });
2102
+ return;
2103
+ }
2104
+ if (value !== undefined) {
2105
+ normalizedParams.append(key, value === null ? "null" : String(value));
2106
+ }
2107
+ });
2108
+ const stringifiedParams = normalizedParams.toString();
2109
+ return stringifiedParams.length > 0
2110
+ ? `https://billing.leaflow.cloud/api/v1/statements/${encodeURIComponent(String(statementId))}/usage-summary?${stringifiedParams}`
2111
+ : `https://billing.leaflow.cloud/api/v1/statements/${encodeURIComponent(String(statementId))}/usage-summary`;
2112
+ };
2113
+ /**
2114
+ * Reads the consumption summary that is updated in the same transaction as usage is priced. Group by project, product or meter and filter within the statement. Quantities are included only for meter groups so different units are never combined.
2115
+ * @summary Get grouped consumption
2116
+ */
2117
+ export const getStatementUsage = async (statementId, params, options, fetchFn) => {
2118
+ const res = await (fetchFn ?? fetch)(getGetStatementUsageUrl(statementId, params), {
2119
+ ...options,
2120
+ method: "GET",
2121
+ });
2122
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
2123
+ const data = body ? JSON.parse(body) : {};
2124
+ return { data, status: res.status, headers: res.headers };
2125
+ };