diff --git a/api.md b/api.md index e20fe54..e154010 100644 --- a/api.md +++ b/api.md @@ -9,7 +9,7 @@ awaited, a `Page` that dereferences to the body (`page.field`) and lists `page.i `next_page()`; `.items()` streams every item across pages and `.pages()` every page. Models are in [`src/models`](src/models), and the options structs next to their resource. -[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Licenses](#licenses) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) +[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Invoices payments](#invoices-payments) · [Licenses](#licenses) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) ## Add ons @@ -230,9 +230,20 @@ in [`src/models`](src/models), and the options structs next to their resource. | `client.invoices().retrieve(invoice_id: &str) -> Call` | `GET /api/v1/invoices/{invoice_id}` | [`Invoice`](src/models/invoice.rs) | | `client.invoices().update_custom_properties(invoice_id: &str, invoice_custom_properties_request: InvoiceCustomPropertiesRequest) -> Call` | `PATCH /api/v1/invoices/{invoice_id}/custom-properties` | [`Invoice`](src/models/invoice.rs) | | `client.invoices().download(invoice_id: &str) -> Call` | `GET /api/v1/invoices/{invoice_id}/download` | bytes | +| `client.invoices().mark_paid(invoice_id: &str, record_invoice_payment_request: RecordInvoicePaymentRequest, options: InvoicesMarkPaidOptions) -> Call` | `POST /api/v1/invoices/{invoice_id}/mark-paid` | [`Transaction`](src/models/transaction.rs) | +| `client.invoices().mark_uncollectible(invoice_id: &str, options: InvoicesMarkUncollectibleOptions) -> Call<()>` | `POST /api/v1/invoices/{invoice_id}/mark-uncollectible` | nothing | | `client.invoices().refresh(invoice_id: &str) -> Call` | `POST /api/v1/invoices/{invoice_id}/refresh` | [`Invoice`](src/models/invoice.rs) | | `client.invoices().download_xml(invoice_id: &str) -> Call` | `GET /api/v1/invoices/{invoice_id}/xml` | bytes | +### Invoices payments + +[`client.invoices().payments()`](src/api/invoices_payments.rs) + +| Method | Request | Returns | +| --- | --- | --- | +| `client.invoices().payments().create(invoice_id: &str, record_invoice_payment_request: RecordInvoicePaymentRequest, options: InvoicesPaymentsCreateOptions) -> Call` | `POST /api/v1/invoices/{invoice_id}/payments` | [`Transaction`](src/models/transaction.rs) | +| `client.invoices().payments().reverse(invoice_id: &str, transaction_id: &str, reverse_invoice_payment_request: ReverseInvoicePaymentRequest, options: InvoicesPaymentsReverseOptions) -> Call` | `POST /api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse` | [`Transaction`](src/models/transaction.rs) | + ## Licenses [`client.licenses()`](src/api/licenses.rs) diff --git a/src/api/invoices.rs b/src/api/invoices.rs index 9c5d35d..d1894b7 100644 --- a/src/api/invoices.rs +++ b/src/api/invoices.rs @@ -139,6 +139,44 @@ impl InvoicesListOptions { } } +/// Query and header parameters of [`Invoices::mark_paid`], built +/// with the required ones by [`new`](Self::new). +#[derive(Clone, Debug)] +#[non_exhaustive] +pub struct InvoicesMarkPaidOptions { + /// The `Idempotency-Key` header parameter. + pub idempotency_key: String, +} + +impl InvoicesMarkPaidOptions { + /// Options with the required parameters set. + #[must_use] + pub fn new(idempotency_key: impl Into) -> Self { + Self { + idempotency_key: idempotency_key.into(), + } + } +} + +/// Query and header parameters of [`Invoices::mark_uncollectible`], built +/// with the required ones by [`new`](Self::new). +#[derive(Clone, Debug)] +#[non_exhaustive] +pub struct InvoicesMarkUncollectibleOptions { + /// The `Idempotency-Key` header parameter. + pub idempotency_key: String, +} + +impl InvoicesMarkUncollectibleOptions { + /// Options with the required parameters set. + #[must_use] + pub fn new(idempotency_key: impl Into) -> Self { + Self { + idempotency_key: idempotency_key.into(), + } + } +} + /// The invoices API, from the client's /// [`invoices`](crate::api::Meteroid::invoices). #[derive(Clone)] @@ -171,6 +209,12 @@ impl Invoices { self } + /// The payments API, with the options of this one. + #[must_use] + pub fn payments(&self) -> super::InvoicesPayments { + super::InvoicesPayments::new(self.cfg.clone()).with_options(self.options.clone()) + } + fn list_request( &self, options: impl Into>, @@ -301,6 +345,67 @@ impl Invoices { .binary(&self.cfg) } + /// Mark an invoice as paid + /// + /// Record an external payment for the entire remaining balance of a finalized invoice. The amount + /// must match the remaining balance. + /// + /// `POST /api/v1/invoices/{invoice_id}/mark-paid`. + /// + /// # Errors + /// + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500). + pub fn mark_paid( + &self, + invoice_id: impl Into, + record_invoice_payment_request: crate::models::RecordInvoicePaymentRequest, + options: InvoicesMarkPaidOptions, + ) -> crate::api::Call { + let InvoicesMarkPaidOptions { idempotency_key } = options; + + crate::request::Request::new( + http::Method::POST, + "/api/v1/invoices/{invoice_id}/mark-paid", + ) + .with_path_param( + "invoice_id", + Into::::into(invoice_id), + ) + .with_header_param("Idempotency-Key", &idempotency_key) + .with_body_param(record_invoice_payment_request) + .with_options(&self.options) + .json(&self.cfg) + } + + /// Mark an invoice as uncollectible + /// + /// Transition a finalized invoice to uncollectible and stop its payment reminders. + /// + /// `POST /api/v1/invoices/{invoice_id}/mark-uncollectible`. + /// + /// # Errors + /// + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500). + pub fn mark_uncollectible( + &self, + invoice_id: impl Into, + options: InvoicesMarkUncollectibleOptions, + ) -> crate::api::Call<()> { + let InvoicesMarkUncollectibleOptions { idempotency_key } = options; + + crate::request::Request::new( + http::Method::POST, + "/api/v1/invoices/{invoice_id}/mark-uncollectible", + ) + .with_path_param( + "invoice_id", + Into::::into(invoice_id), + ) + .with_header_param("Idempotency-Key", &idempotency_key) + .with_options(&self.options) + .empty(&self.cfg) + } + /// Refresh invoice /// /// Recompute a draft invoice against current usage, credits, coupons and tax, and return it. diff --git a/src/api/invoices_payments.rs b/src/api/invoices_payments.rs new file mode 100644 index 0000000..f1b3694 --- /dev/null +++ b/src/api/invoices_payments.rs @@ -0,0 +1,141 @@ +// this file is @generated +#![allow(clippy::doc_markdown, clippy::default_trait_access)] + +#[allow(unused_imports, clippy::wildcard_imports)] +use crate::{error::Result, models::*, Configuration}; + +/// Query and header parameters of [`InvoicesPayments::create`], built +/// with the required ones by [`new`](Self::new). +#[derive(Clone, Debug)] +#[non_exhaustive] +pub struct InvoicesPaymentsCreateOptions { + /// The `Idempotency-Key` header parameter. + pub idempotency_key: String, +} + +impl InvoicesPaymentsCreateOptions { + /// Options with the required parameters set. + #[must_use] + pub fn new(idempotency_key: impl Into) -> Self { + Self { + idempotency_key: idempotency_key.into(), + } + } +} + +/// Query and header parameters of [`InvoicesPayments::reverse`], built +/// with the required ones by [`new`](Self::new). +#[derive(Clone, Debug)] +#[non_exhaustive] +pub struct InvoicesPaymentsReverseOptions { + /// The `Idempotency-Key` header parameter. + pub idempotency_key: String, +} + +impl InvoicesPaymentsReverseOptions { + /// Options with the required parameters set. + #[must_use] + pub fn new(idempotency_key: impl Into) -> Self { + Self { + idempotency_key: idempotency_key.into(), + } + } +} + +/// The invoices payments API, from +/// [`Invoices::payments`](crate::api::Invoices::payments). +#[derive(Clone)] +pub struct InvoicesPayments { + cfg: std::sync::Arc, + options: crate::api::RequestOptions, +} + +impl std::fmt::Debug for InvoicesPayments { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("InvoicesPayments") + .field("options", &self.options) + .finish_non_exhaustive() + } +} + +impl InvoicesPayments { + pub(super) fn new(cfg: std::sync::Arc) -> Self { + Self { + cfg, + options: crate::api::RequestOptions::default(), + } + } + + /// Applies `options` (headers, timeout, retries, idempotency key) to the calls made + /// through the returned value. + #[must_use] + pub fn with_options(mut self, options: crate::api::RequestOptions) -> Self { + self.options = options; + self + } + + /// Record an invoice payment + /// + /// Record a partial or full payment received outside Meteroid against a finalized invoice. + /// Paying the remaining balance marks the invoice paid. + /// + /// `POST /api/v1/invoices/{invoice_id}/payments`. + /// + /// # Errors + /// + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500). + pub fn create( + &self, + invoice_id: impl Into, + record_invoice_payment_request: crate::models::RecordInvoicePaymentRequest, + options: InvoicesPaymentsCreateOptions, + ) -> crate::api::Call { + let InvoicesPaymentsCreateOptions { idempotency_key } = options; + + crate::request::Request::new(http::Method::POST, "/api/v1/invoices/{invoice_id}/payments") + .with_path_param( + "invoice_id", + Into::::into(invoice_id), + ) + .with_header_param("Idempotency-Key", &idempotency_key) + .with_body_param(record_invoice_payment_request) + .with_options(&self.options) + .json(&self.cfg) + } + + /// Reverse an invoice payment + /// + /// Record the full reversal of a settled manual payment. + /// + /// `POST /api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse`. + /// + /// # Errors + /// + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500). + pub fn reverse( + &self, + invoice_id: impl Into, + transaction_id: impl Into, + reverse_invoice_payment_request: crate::models::ReverseInvoicePaymentRequest, + options: InvoicesPaymentsReverseOptions, + ) -> crate::api::Call { + let InvoicesPaymentsReverseOptions { idempotency_key } = options; + + crate::request::Request::new( + http::Method::POST, + "/api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse", + ) + .with_path_param( + "invoice_id", + Into::::into(invoice_id), + ) + .with_path_param( + "transaction_id", + Into::::into(transaction_id), + ) + .with_header_param("Idempotency-Key", &idempotency_key) + .with_body_param(reverse_invoice_payment_request) + .with_options(&self.options) + .json(&self.cfg) + } +} diff --git a/src/api/metrics.rs b/src/api/metrics.rs index 9df5711..2c14172 100644 --- a/src/api/metrics.rs +++ b/src/api/metrics.rs @@ -194,7 +194,7 @@ impl Metrics { /// /// # Errors /// - /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 429). + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 429). pub fn create( &self, create_metric_request: crate::models::CreateMetricRequest, @@ -233,7 +233,7 @@ impl Metrics { /// /// # Errors /// - /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 404, 429). + /// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 429). pub fn update( &self, metric_id: impl Into, diff --git a/src/api/mod.rs b/src/api/mod.rs index 19eb539..f8462da 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -50,6 +50,7 @@ mod entitlements; mod events; mod features; mod invoices; +mod invoices_payments; mod licenses; mod metrics; mod oauth; @@ -95,7 +96,12 @@ pub use self::{ entitlements::Entitlements, events::Events, features::{Features, FeaturesListOptions}, - invoices::{Invoices, InvoicesListOptions}, + invoices::{ + Invoices, InvoicesListOptions, InvoicesMarkPaidOptions, InvoicesMarkUncollectibleOptions, + }, + invoices_payments::{ + InvoicesPayments, InvoicesPaymentsCreateOptions, InvoicesPaymentsReverseOptions, + }, licenses::{Licenses, LicensesListOptions}, metrics::{Metrics, MetricsListOptions}, oauth::Oauth, diff --git a/src/models/create_metric_request.rs b/src/models/create_metric_request.rs index c615bca..e8848ee 100644 --- a/src/models/create_metric_request.rs +++ b/src/models/create_metric_request.rs @@ -47,6 +47,13 @@ pub struct CreateMetricRequest { #[serde(skip_serializing_if = "Option::is_none")] pub unit_singular: Option, + /// Event property, e.g. `project_id`, that breaks each invoice line down by value. The line is + /// still priced on its total usage, and each value shows its quantity and share of the amount. + #[serde(skip_serializing_if = "Option::is_none")] + pub usage_breakdown_key: Option, + + /// Event property, e.g. `cluster_id`, whose values are billed as separate invoice lines, each + /// priced on its own usage. #[serde(skip_serializing_if = "Option::is_none")] pub usage_group_key: Option, @@ -77,6 +84,7 @@ impl CreateMetricRequest { unit_conversion: None, unit_plural: None, unit_singular: None, + usage_breakdown_key: None, usage_group_key: None, extra: serde_json::Map::new(), } @@ -141,6 +149,13 @@ impl CreateMetricRequest { self } + /// Sets `usage_breakdown_key`. + #[must_use] + pub fn usage_breakdown_key(mut self, usage_breakdown_key: impl Into) -> Self { + self.usage_breakdown_key = Some(usage_breakdown_key.into()); + self + } + /// Sets `usage_group_key`. #[must_use] pub fn usage_group_key(mut self, usage_group_key: impl Into) -> Self { diff --git a/src/models/event.rs b/src/models/event.rs index 8423c31..334907d 100644 --- a/src/models/event.rs +++ b/src/models/event.rs @@ -17,7 +17,7 @@ pub struct Event { pub properties: Option>, /// RFC 3339 timestamp. Defaults to ingestion time if omitted. - /// Must be between 24 hours ago and 1 hour from now. Set `allow_backfilling` to remove the past limit. + /// Must be between 24 hours ago and 1 hour from now. Set `allow_backfilling` to accept timestamps up to 13 months in the past. #[serde(skip_serializing_if = "Option::is_none")] pub timestamp: Option>, diff --git a/src/models/ingest_events_request.rs b/src/models/ingest_events_request.rs index a95a8b5..c4a0c26 100644 --- a/src/models/ingest_events_request.rs +++ b/src/models/ingest_events_request.rs @@ -5,7 +5,7 @@ use super::event::Event; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct IngestEventsRequest { - /// Allow events with timestamps more than 1 day in the past. Defaults to `false`. + /// Allow events with timestamps more than 1 day in the past, up to 13 months. Defaults to `false`. #[serde(skip_serializing_if = "Option::is_none")] pub allow_backfilling: Option, diff --git a/src/models/invoice_line_item.rs b/src/models/invoice_line_item.rs index 339587b..a8d5e2c 100644 --- a/src/models/invoice_line_item.rs +++ b/src/models/invoice_line_item.rs @@ -1,7 +1,10 @@ // this file is @generated use serde::{Deserialize, Serialize}; -use super::{invoice_line_credit_unit::InvoiceLineCreditUnit, sub_line_item::SubLineItem}; +use super::{ + invoice_line_credit_unit::InvoiceLineCreditUnit, + invoice_line_usage_breakdown::InvoiceLineUsageBreakdown, sub_line_item::SubLineItem, +}; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[non_exhaustive] @@ -35,6 +38,9 @@ pub struct InvoiceLineItem { #[serde(skip_serializing_if = "Option::is_none")] pub unit_price: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage_breakdown: Option, + /// Properties this version of the SDK does not know, sent back as received. #[serde(flatten)] pub extra: serde_json::Map, @@ -63,6 +69,7 @@ impl InvoiceLineItem { sub_line_items, tax_rate, unit_price: None, + usage_breakdown: None, extra: serde_json::Map::new(), } } diff --git a/src/models/invoice_line_usage_breakdown.rs b/src/models/invoice_line_usage_breakdown.rs new file mode 100644 index 0000000..f4a9d74 --- /dev/null +++ b/src/models/invoice_line_usage_breakdown.rs @@ -0,0 +1,30 @@ +// this file is @generated +use serde::{Deserialize, Serialize}; + +use super::invoice_line_usage_breakdown_item::InvoiceLineUsageBreakdownItem; + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[non_exhaustive] +pub struct InvoiceLineUsageBreakdown { + /// Largest amount first. Past 99 values, the rest are summed in one last item flagged `others`. + pub items: Vec, + + /// The event property the usage is broken down by, e.g. `project_id`. + pub key: String, + + /// Properties this version of the SDK does not know, sent back as received. + #[serde(flatten)] + pub extra: serde_json::Map, +} + +impl InvoiceLineUsageBreakdown { + /// Creates a value from its required fields. + #[must_use] + pub fn new(items: Vec, key: impl Into) -> Self { + Self { + items, + key: key.into(), + extra: serde_json::Map::new(), + } + } +} diff --git a/src/models/invoice_line_usage_breakdown_item.rs b/src/models/invoice_line_usage_breakdown_item.rs new file mode 100644 index 0000000..7157240 --- /dev/null +++ b/src/models/invoice_line_usage_breakdown_item.rs @@ -0,0 +1,48 @@ +// this file is @generated +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[non_exhaustive] +pub struct InvoiceLineUsageBreakdownItem { + /// Its part of the line's amount before discounts and tax, in minor units. + pub amount_subtotal: i64, + + /// Its part of `credit_unit.consumed`, on a line priced in a credit unit. + #[serde(skip_serializing_if = "Option::is_none")] + pub credits_consumed: Option, + + /// Set on the last item when there are more than 99 values: it sums the rest. + #[serde(skip_serializing_if = "Option::is_none")] + pub others: Option, + + /// Usage of this value, in the units the line is priced in. + pub quantity: rust_decimal::Decimal, + + /// Its part of the tax-included amount quoted, on a line billed from tax-inclusive prices. + #[serde(skip_serializing_if = "Option::is_none")] + pub quoted_amount_subtotal: Option, + + /// The property's value; absent for events without it, and for `others`. + #[serde(skip_serializing_if = "Option::is_none")] + pub value: Option, + + /// Properties this version of the SDK does not know, sent back as received. + #[serde(flatten)] + pub extra: serde_json::Map, +} + +impl InvoiceLineUsageBreakdownItem { + /// Creates a value from its required fields. + #[must_use] + pub fn new(amount_subtotal: i64, quantity: rust_decimal::Decimal) -> Self { + Self { + amount_subtotal, + credits_consumed: None, + others: None, + quantity, + quoted_amount_subtotal: None, + value: None, + extra: serde_json::Map::new(), + } + } +} diff --git a/src/models/metric.rs b/src/models/metric.rs index 08b0de9..9db87ca 100644 --- a/src/models/metric.rs +++ b/src/models/metric.rs @@ -52,6 +52,13 @@ pub struct Metric { #[serde(skip_serializing_if = "Option::is_none")] pub unit_singular: Option, + /// Event property, e.g. `project_id`, that breaks each invoice line down by value. The line is + /// still priced on its total usage, and each value shows its quantity and share of the amount. + #[serde(skip_serializing_if = "Option::is_none")] + pub usage_breakdown_key: Option, + + /// Event property, e.g. `cluster_id`, whose values are billed as separate invoice lines, each + /// priced on its own usage. #[serde(skip_serializing_if = "Option::is_none")] pub usage_group_key: Option, @@ -87,6 +94,7 @@ impl Metric { unit_conversion: None, unit_plural: None, unit_singular: None, + usage_breakdown_key: None, usage_group_key: None, extra: serde_json::Map::new(), } diff --git a/src/models/metric_event.rs b/src/models/metric_event.rs index cc6303c..2c2c4d4 100644 --- a/src/models/metric_event.rs +++ b/src/models/metric_event.rs @@ -50,6 +50,9 @@ pub struct MetricEvent { #[serde(skip_serializing_if = "Option::is_none")] pub unit_singular: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage_breakdown_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub usage_group_key: Option, @@ -93,6 +96,7 @@ impl MetricEvent { unit_conversion_rounding: None, unit_plural: None, unit_singular: None, + usage_breakdown_key: None, usage_group_key: None, id: id.into(), timestamp, diff --git a/src/models/metric_event_data.rs b/src/models/metric_event_data.rs index e3064d5..20f29d2 100644 --- a/src/models/metric_event_data.rs +++ b/src/models/metric_event_data.rs @@ -49,6 +49,9 @@ pub struct MetricEventData { #[serde(skip_serializing_if = "Option::is_none")] pub unit_singular: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage_breakdown_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub usage_group_key: Option, @@ -83,6 +86,7 @@ impl MetricEventData { unit_conversion_rounding: None, unit_plural: None, unit_singular: None, + usage_breakdown_key: None, usage_group_key: None, extra: serde_json::Map::new(), } diff --git a/src/models/mod.rs b/src/models/mod.rs index afc7eaf..83657b2 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -243,6 +243,8 @@ pub mod invoice_event_data; pub mod invoice_id; pub mod invoice_line_credit_unit; pub mod invoice_line_item; +pub mod invoice_line_usage_breakdown; +pub mod invoice_line_usage_breakdown_item; pub mod invoice_list_response; pub mod invoice_payment_status; pub mod invoice_status; @@ -370,6 +372,7 @@ pub mod rate_fee; pub mod rate_fee_structure; pub mod rate_plan_fee; pub mod rate_pricing; +pub mod record_invoice_payment_request; pub mod recurring_fee; pub mod refund_event_data; pub mod refund_mode; @@ -380,6 +383,7 @@ pub mod resolved_entitlement_list_response; pub mod resolved_entitlement_value; pub mod rest_error_response; pub mod reversal_kind; +pub mod reverse_invoice_payment_request; pub mod revocation_request; pub mod revoke_license_request; pub mod rotated_secret; @@ -626,6 +630,8 @@ pub use self::{ invoice_documents_event_data::InvoiceDocumentsEventData, invoice_event::InvoiceEvent, invoice_event_data::InvoiceEventData, invoice_id::InvoiceId, invoice_line_credit_unit::InvoiceLineCreditUnit, invoice_line_item::InvoiceLineItem, + invoice_line_usage_breakdown::InvoiceLineUsageBreakdown, + invoice_line_usage_breakdown_item::InvoiceLineUsageBreakdownItem, invoice_list_response::InvoiceListResponse, invoice_payment_status::InvoicePaymentStatus, invoice_status::InvoiceStatus, invoice_type::InvoiceType, invoicing_entity_id::InvoicingEntityId, issue_license_request::IssueLicenseRequest, @@ -689,14 +695,15 @@ pub use self::{ products_scope::ProductsScope, property_config::PropertyConfig, quote_event::QuoteEvent, quote_event_data::QuoteEventData, quote_id::QuoteId, rate_fee::RateFee, rate_fee_structure::RateFeeStructure, rate_plan_fee::RatePlanFee, rate_pricing::RatePricing, - recurring_fee::RecurringFee, refund_event_data::RefundEventData, refund_mode::RefundMode, + record_invoice_payment_request::RecordInvoicePaymentRequest, recurring_fee::RecurringFee, + refund_event_data::RefundEventData, refund_mode::RefundMode, replace_plan_request::ReplacePlanRequest, reset_period::ResetPeriod, resolved_entitlement::ResolvedEntitlement, resolved_entitlement_list_response::ResolvedEntitlementListResponse, resolved_entitlement_value::ResolvedEntitlementValue, rest_error_response::RestErrorResponse, - reversal_kind::ReversalKind, revocation_request::RevocationRequest, - revoke_license_request::RevokeLicenseRequest, rotated_secret::RotatedSecret, - select_option::SelectOption, shipping_address::ShippingAddress, + reversal_kind::ReversalKind, reverse_invoice_payment_request::ReverseInvoicePaymentRequest, + revocation_request::RevocationRequest, revoke_license_request::RevokeLicenseRequest, + rotated_secret::RotatedSecret, select_option::SelectOption, shipping_address::ShippingAddress, sliding_window_reset_period::SlidingWindowResetPeriod, slot_downgrade_policy_enum::SlotDowngradePolicyEnum, slot_fee::SlotFee, slot_fee_structure::SlotFeeStructure, slot_plan_fee::SlotPlanFee, slot_pricing::SlotPricing, diff --git a/src/models/record_invoice_payment_request.rs b/src/models/record_invoice_payment_request.rs new file mode 100644 index 0000000..5ea029c --- /dev/null +++ b/src/models/record_invoice_payment_request.rs @@ -0,0 +1,47 @@ +// this file is @generated +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct RecordInvoicePaymentRequest { + /// The positive amount received, in minor units of the invoice currency (e.g. cents). + pub amount: i64, + + /// When the payment was received, at most a day ahead. Defaults to the current time. + #[serde(skip_serializing_if = "Option::is_none")] + pub paid_at: Option>, + + /// Reference for the external payment, such as a bank transfer ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub reference: Option, + + /// Properties this version of the SDK does not know, sent back as received. + #[serde(flatten)] + pub extra: serde_json::Map, +} + +impl RecordInvoicePaymentRequest { + /// Creates a value from its required fields. + #[must_use] + pub fn new(amount: i64) -> Self { + Self { + amount, + paid_at: None, + reference: None, + extra: serde_json::Map::new(), + } + } + + /// Sets `paid_at`. + #[must_use] + pub fn paid_at(mut self, paid_at: impl Into>) -> Self { + self.paid_at = Some(paid_at.into()); + self + } + + /// Sets `reference`. + #[must_use] + pub fn reference(mut self, reference: impl Into) -> Self { + self.reference = Some(reference.into()); + self + } +} diff --git a/src/models/reverse_invoice_payment_request.rs b/src/models/reverse_invoice_payment_request.rs new file mode 100644 index 0000000..2fad13b --- /dev/null +++ b/src/models/reverse_invoice_payment_request.rs @@ -0,0 +1,50 @@ +// this file is @generated +use serde::{Deserialize, Serialize}; + +use super::reversal_kind::ReversalKind; + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ReverseInvoicePaymentRequest { + /// `CHARGEBACK`, `DEBTOR_RECALL` and `DISPUTE` leave the invoice paid and mark the payment + /// disputed. Any other kind makes the amount due again. + pub kind: ReversalKind, + + /// Additional details about the reversal. + #[serde(skip_serializing_if = "Option::is_none")] + pub reason: Option, + + /// When the reversal occurred, at most a day ahead. Defaults to the current time. + #[serde(skip_serializing_if = "Option::is_none")] + pub reversed_at: Option>, + + /// Properties this version of the SDK does not know, sent back as received. + #[serde(flatten)] + pub extra: serde_json::Map, +} + +impl ReverseInvoicePaymentRequest { + /// Creates a value from its required fields. + #[must_use] + pub fn new(kind: ReversalKind) -> Self { + Self { + kind, + reason: None, + reversed_at: None, + extra: serde_json::Map::new(), + } + } + + /// Sets `reason`. + #[must_use] + pub fn reason(mut self, reason: impl Into) -> Self { + self.reason = Some(reason.into()); + self + } + + /// Sets `reversed_at`. + #[must_use] + pub fn reversed_at(mut self, reversed_at: impl Into>) -> Self { + self.reversed_at = Some(reversed_at.into()); + self + } +} diff --git a/src/models/subscription_status_enum.rs b/src/models/subscription_status_enum.rs index ba86f7f..5b22a80 100644 --- a/src/models/subscription_status_enum.rs +++ b/src/models/subscription_status_enum.rs @@ -3,6 +3,8 @@ use std::fmt; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +/// `PendingCharge`, `Paused`, `Suspended`, `Superseded` and `Errored` stay in the published +/// schema; no subscription holds them any more, and a filter on them lists none. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum SubscriptionStatusEnum { diff --git a/src/models/update_metric_request.rs b/src/models/update_metric_request.rs index 6961f48..b7c6f09 100644 --- a/src/models/update_metric_request.rs +++ b/src/models/update_metric_request.rs @@ -62,6 +62,14 @@ pub struct UpdateMetricRequest { )] pub unit_singular: Option>, + /// Omit to leave the breakdown key unchanged; send `null` to remove it. + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "crate::models::codec::nullable" + )] + pub usage_breakdown_key: Option>, + /// Properties this version of the SDK does not know, sent back as received. #[serde(flatten)] pub extra: serde_json::Map, @@ -79,6 +87,7 @@ impl UpdateMetricRequest { unit_conversion: None, unit_plural: None, unit_singular: None, + usage_breakdown_key: None, extra: serde_json::Map::new(), } } @@ -183,4 +192,18 @@ impl UpdateMetricRequest { self.unit_singular = Some(None); self } + + /// Sets `usage_breakdown_key`. + #[must_use] + pub fn usage_breakdown_key(mut self, usage_breakdown_key: impl Into) -> Self { + self.usage_breakdown_key = Some(Some(usage_breakdown_key.into())); + self + } + + /// Sends `usage_breakdown_key` as `null`, clearing it. + #[must_use] + pub fn clear_usage_breakdown_key(mut self) -> Self { + self.usage_breakdown_key = Some(None); + self + } }