Skip to main content

quicknode_sdk/admin/
billing.rs

1#[cfg(feature = "node")]
2use napi_derive::napi;
3#[cfg(feature = "python")]
4use pyo3::pyclass;
5#[cfg(feature = "python")]
6use pyo3_stub_gen::derive::gen_stub_pyclass;
7use serde::{Deserialize, Serialize};
8
9/// A single line item on an invoice.
10#[cfg_attr(feature = "python", gen_stub_pyclass)]
11#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
12#[cfg_attr(feature = "node", napi(object))]
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct InvoiceLine {
15    /// Human-readable description of the line item.
16    pub description: String,
17    /// Line item amount in the smallest currency unit.
18    pub amount: i64,
19}
20
21/// An invoice issued to the account.
22#[cfg_attr(feature = "python", gen_stub_pyclass)]
23#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
24#[cfg_attr(feature = "node", napi(object))]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct Invoice {
27    /// Unique invoice identifier.
28    pub id: String,
29    /// Payment status (e.g. `paid`, `open`).
30    pub status: String,
31    /// Reason the invoice was generated (e.g. `subscription_cycle`).
32    pub billing_reason: String,
33    /// Line items contributing to the invoice total.
34    #[serde(default)]
35    pub lines: Vec<InvoiceLine>,
36    /// Amount due in the smallest currency unit.
37    pub amount_due: i64,
38    /// Amount already paid in the smallest currency unit.
39    pub amount_paid: i64,
40    /// Start of the billing period (Unix timestamp).
41    pub period_start: i64,
42    /// End of the billing period (Unix timestamp).
43    pub period_end: i64,
44    /// Timestamp when the invoice was created (Unix timestamp).
45    pub created: i64,
46    /// Subtotal before taxes and adjustments.
47    pub subtotal: i64,
48}
49
50/// Response from `list_invoices`.
51#[cfg_attr(feature = "python", gen_stub_pyclass)]
52#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
53#[cfg_attr(feature = "node", napi(object))]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ListInvoicesResponse {
56    /// Invoice data payload.
57    pub data: Option<ListInvoicesData>,
58    /// Error message when the request did not succeed.
59    pub error: Option<String>,
60}
61
62/// Invoice list wrapper.
63#[cfg_attr(feature = "python", gen_stub_pyclass)]
64#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
65#[cfg_attr(feature = "node", napi(object))]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct ListInvoicesData {
68    /// Invoices on the account.
69    #[serde(default)]
70    pub invoices: Vec<Invoice>,
71}
72
73/// A payment recorded on the account.
74#[cfg_attr(feature = "python", gen_stub_pyclass)]
75#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
76#[cfg_attr(feature = "node", napi(object))]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct Payment {
79    /// Payment amount as a string in the account's currency.
80    pub amount: String,
81    /// Last four digits of the card used for the payment.
82    pub card_last_4: Option<String>,
83    /// Timestamp when the payment was recorded.
84    pub created_at: String,
85    /// Currency code (e.g. `usd`).
86    pub currency: String,
87    /// Payment status.
88    pub status: String,
89    /// Portion of the payment attributed to marketplace spending.
90    pub marketplace_amount: Option<String>,
91}
92
93/// Response from `list_payments`.
94#[cfg_attr(feature = "python", gen_stub_pyclass)]
95#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
96#[cfg_attr(feature = "node", napi(object))]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct ListPaymentsResponse {
99    /// Payment data payload.
100    pub data: Option<ListPaymentsData>,
101    /// Error message when the request did not succeed.
102    pub error: Option<String>,
103}
104
105/// Payment list wrapper.
106#[cfg_attr(feature = "python", gen_stub_pyclass)]
107#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
108#[cfg_attr(feature = "node", napi(object))]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct ListPaymentsData {
111    /// Payments on the account.
112    #[serde(default)]
113    pub payments: Vec<Payment>,
114}