- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
update to v1001
Showing
295 changed files
with
32,923 additions
and
5,817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
members = [ | ||
"stripe_types", | ||
"stripe_webhook", | ||
"openapi", | ||
"tests", | ||
"generated/*", | ||
"examples/*", | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "async_stripe_forwarding" | ||
version.workspace = true | ||
description.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
|
||
[lib] | ||
path = "src/mod.rs" | ||
|
||
[dependencies] | ||
serde.workspace = true | ||
serde_json = { workspace = true, optional = true } | ||
smol_str.workspace = true | ||
miniserde.workspace = true | ||
stripe_types = {path = "../../stripe_types"} | ||
stripe_client_core = {path = "../../stripe_client_core"} | ||
|
||
stripe_shared = {path = "../../generated/stripe_shared"} | ||
|
||
|
||
[features] | ||
serialize = ["stripe_types/serialize","stripe_shared/serialize"] | ||
deserialize = ["stripe_types/deserialize","stripe_shared/deserialize", "dep:serde_json"] | ||
forwarding_request = [] | ||
|
||
full = ["forwarding_request"] | ||
|
||
|
||
[package.metadata.docs.rs] | ||
features = ["full"] | ||
|
109 changes: 109 additions & 0 deletions
109
generated/async_stripe_forwarding/src/forwarded_request_context.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/// Metadata about the forwarded request. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct ForwardedRequestContext { | ||
/// The time it took in milliseconds for the destination endpoint to respond. | ||
pub destination_duration: i64, | ||
/// The IP address of the destination. | ||
pub destination_ip_address: String, | ||
} | ||
#[doc(hidden)] | ||
pub struct ForwardedRequestContextBuilder { | ||
destination_duration: Option<i64>, | ||
destination_ip_address: Option<String>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for ForwardedRequestContext { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<ForwardedRequestContext>, | ||
builder: ForwardedRequestContextBuilder, | ||
} | ||
|
||
impl Visitor for Place<ForwardedRequestContext> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: ForwardedRequestContextBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for ForwardedRequestContextBuilder { | ||
type Out = ForwardedRequestContext; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"destination_duration" => Deserialize::begin(&mut self.destination_duration), | ||
"destination_ip_address" => Deserialize::begin(&mut self.destination_ip_address), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
destination_duration: Deserialize::default(), | ||
destination_ip_address: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
destination_duration: self.destination_duration?, | ||
destination_ip_address: self.destination_ip_address.take()?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for ForwardedRequestContext { | ||
type Builder = ForwardedRequestContextBuilder; | ||
} | ||
|
||
impl FromValueOpt for ForwardedRequestContext { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = ForwardedRequestContextBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"destination_duration" => { | ||
b.destination_duration = Some(FromValueOpt::from_value(v)?) | ||
} | ||
"destination_ip_address" => { | ||
b.destination_ip_address = Some(FromValueOpt::from_value(v)?) | ||
} | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
183 changes: 183 additions & 0 deletions
183
generated/async_stripe_forwarding/src/forwarded_request_details.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
/// Details about the request forwarded to the destination endpoint. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct ForwardedRequestDetails { | ||
/// The body payload to send to the destination endpoint. | ||
pub body: String, | ||
/// The headers to include in the forwarded request. | ||
/// Can be omitted if no additional headers (excluding Stripe-generated ones such as the Content-Type header) should be included. | ||
pub headers: Vec<async_stripe_forwarding::ForwardedRequestHeader>, | ||
/// The HTTP method used to call the destination endpoint. | ||
pub http_method: ForwardedRequestDetailsHttpMethod, | ||
} | ||
#[doc(hidden)] | ||
pub struct ForwardedRequestDetailsBuilder { | ||
body: Option<String>, | ||
headers: Option<Vec<async_stripe_forwarding::ForwardedRequestHeader>>, | ||
http_method: Option<ForwardedRequestDetailsHttpMethod>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for ForwardedRequestDetails { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<ForwardedRequestDetails>, | ||
builder: ForwardedRequestDetailsBuilder, | ||
} | ||
|
||
impl Visitor for Place<ForwardedRequestDetails> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: ForwardedRequestDetailsBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for ForwardedRequestDetailsBuilder { | ||
type Out = ForwardedRequestDetails; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"body" => Deserialize::begin(&mut self.body), | ||
"headers" => Deserialize::begin(&mut self.headers), | ||
"http_method" => Deserialize::begin(&mut self.http_method), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
body: Deserialize::default(), | ||
headers: Deserialize::default(), | ||
http_method: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
body: self.body.take()?, | ||
headers: self.headers.take()?, | ||
http_method: self.http_method?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for ForwardedRequestDetails { | ||
type Builder = ForwardedRequestDetailsBuilder; | ||
} | ||
|
||
impl FromValueOpt for ForwardedRequestDetails { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = ForwardedRequestDetailsBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"body" => b.body = Some(FromValueOpt::from_value(v)?), | ||
"headers" => b.headers = Some(FromValueOpt::from_value(v)?), | ||
"http_method" => b.http_method = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
/// The HTTP method used to call the destination endpoint. | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum ForwardedRequestDetailsHttpMethod { | ||
Post, | ||
} | ||
impl ForwardedRequestDetailsHttpMethod { | ||
pub fn as_str(self) -> &'static str { | ||
use ForwardedRequestDetailsHttpMethod::*; | ||
match self { | ||
Post => "POST", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for ForwardedRequestDetailsHttpMethod { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use ForwardedRequestDetailsHttpMethod::*; | ||
match s { | ||
"POST" => Ok(Post), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for ForwardedRequestDetailsHttpMethod { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for ForwardedRequestDetailsHttpMethod { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for ForwardedRequestDetailsHttpMethod { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for ForwardedRequestDetailsHttpMethod { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<ForwardedRequestDetailsHttpMethod> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = | ||
Some(ForwardedRequestDetailsHttpMethod::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(ForwardedRequestDetailsHttpMethod); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for ForwardedRequestDetailsHttpMethod { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom("Unknown value for ForwardedRequestDetailsHttpMethod") | ||
}) | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
generated/async_stripe_forwarding/src/forwarded_request_header.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/// Header data. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct ForwardedRequestHeader { | ||
/// The header name. | ||
pub name: String, | ||
/// The header value. | ||
pub value: String, | ||
} | ||
#[doc(hidden)] | ||
pub struct ForwardedRequestHeaderBuilder { | ||
name: Option<String>, | ||
value: Option<String>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for ForwardedRequestHeader { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<ForwardedRequestHeader>, | ||
builder: ForwardedRequestHeaderBuilder, | ||
} | ||
|
||
impl Visitor for Place<ForwardedRequestHeader> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: ForwardedRequestHeaderBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for ForwardedRequestHeaderBuilder { | ||
type Out = ForwardedRequestHeader; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"name" => Deserialize::begin(&mut self.name), | ||
"value" => Deserialize::begin(&mut self.value), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { name: Deserialize::default(), value: Deserialize::default() } | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { name: self.name.take()?, value: self.value.take()? }) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for ForwardedRequestHeader { | ||
type Builder = ForwardedRequestHeaderBuilder; | ||
} | ||
|
||
impl FromValueOpt for ForwardedRequestHeader { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = ForwardedRequestHeaderBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"name" => b.name = Some(FromValueOpt::from_value(v)?), | ||
"value" => b.value = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
112 changes: 112 additions & 0 deletions
112
generated/async_stripe_forwarding/src/forwarded_response_details.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/// Details about the response from the destination endpoint. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct ForwardedResponseDetails { | ||
/// The response body from the destination endpoint to Stripe. | ||
pub body: String, | ||
/// HTTP headers that the destination endpoint returned. | ||
pub headers: Vec<async_stripe_forwarding::ForwardedRequestHeader>, | ||
/// The HTTP status code that the destination endpoint returned. | ||
pub status: i64, | ||
} | ||
#[doc(hidden)] | ||
pub struct ForwardedResponseDetailsBuilder { | ||
body: Option<String>, | ||
headers: Option<Vec<async_stripe_forwarding::ForwardedRequestHeader>>, | ||
status: Option<i64>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for ForwardedResponseDetails { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<ForwardedResponseDetails>, | ||
builder: ForwardedResponseDetailsBuilder, | ||
} | ||
|
||
impl Visitor for Place<ForwardedResponseDetails> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: ForwardedResponseDetailsBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for ForwardedResponseDetailsBuilder { | ||
type Out = ForwardedResponseDetails; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"body" => Deserialize::begin(&mut self.body), | ||
"headers" => Deserialize::begin(&mut self.headers), | ||
"status" => Deserialize::begin(&mut self.status), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
body: Deserialize::default(), | ||
headers: Deserialize::default(), | ||
status: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
body: self.body.take()?, | ||
headers: self.headers.take()?, | ||
status: self.status?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for ForwardedResponseDetails { | ||
type Builder = ForwardedResponseDetailsBuilder; | ||
} | ||
|
||
impl FromValueOpt for ForwardedResponseDetails { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = ForwardedResponseDetailsBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"body" => b.body = Some(FromValueOpt::from_value(v)?), | ||
"headers" => b.headers = Some(FromValueOpt::from_value(v)?), | ||
"status" => b.status = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
generated/async_stripe_forwarding/src/forwarding_request/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "forwarding_request")] | ||
mod requests; | ||
pub(crate) mod types; | ||
#[cfg(feature = "forwarding_request")] | ||
pub use requests::*; |
284 changes: 284 additions & 0 deletions
284
generated/async_stripe_forwarding/src/forwarding_request/requests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
use stripe_client_core::{ | ||
RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest, | ||
}; | ||
|
||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct ListForwardingRequestBuilder<'a> { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
created: Option<ListForwardingRequestCreated>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
ending_before: Option<&'a str>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
limit: Option<i64>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
starting_after: Option<&'a str>, | ||
} | ||
impl<'a> ListForwardingRequestBuilder<'a> { | ||
fn new() -> Self { | ||
Self { created: None, ending_before: None, expand: None, limit: None, starting_after: None } | ||
} | ||
} | ||
/// Similar to other List endpoints, filters results based on created timestamp. | ||
/// You can pass gt, gte, lt, and lte timestamp values. | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
pub struct ListForwardingRequestCreated { | ||
/// Return results where the `created` field is greater than this value. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub gt: Option<i64>, | ||
/// Return results where the `created` field is greater than or equal to this value. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub gte: Option<i64>, | ||
/// Return results where the `created` field is less than this value. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub lt: Option<i64>, | ||
/// Return results where the `created` field is less than or equal to this value. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub lte: Option<i64>, | ||
} | ||
impl ListForwardingRequestCreated { | ||
pub fn new() -> Self { | ||
Self { gt: None, gte: None, lt: None, lte: None } | ||
} | ||
} | ||
impl Default for ListForwardingRequestCreated { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
/// Lists all ForwardingRequest objects. | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct ListForwardingRequest<'a> { | ||
inner: ListForwardingRequestBuilder<'a>, | ||
} | ||
impl<'a> ListForwardingRequest<'a> { | ||
/// Construct a new `ListForwardingRequest`. | ||
pub fn new() -> Self { | ||
Self { inner: ListForwardingRequestBuilder::new() } | ||
} | ||
/// Similar to other List endpoints, filters results based on created timestamp. | ||
/// You can pass gt, gte, lt, and lte timestamp values. | ||
pub fn created(mut self, created: ListForwardingRequestCreated) -> Self { | ||
self.inner.created = Some(created); | ||
self | ||
} | ||
/// A pagination cursor to fetch the previous page of the list. | ||
/// The value must be a ForwardingRequest ID. | ||
pub fn ending_before(mut self, ending_before: &'a str) -> Self { | ||
self.inner.ending_before = Some(ending_before); | ||
self | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
/// A limit on the number of objects to be returned. | ||
/// Limit can range between 1 and 100, and the default is 10. | ||
pub fn limit(mut self, limit: i64) -> Self { | ||
self.inner.limit = Some(limit); | ||
self | ||
} | ||
/// A pagination cursor to fetch the next page of the list. The value must be a ForwardingRequest ID. | ||
pub fn starting_after(mut self, starting_after: &'a str) -> Self { | ||
self.inner.starting_after = Some(starting_after); | ||
self | ||
} | ||
} | ||
impl<'a> Default for ListForwardingRequest<'a> { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
impl ListForwardingRequest<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
|
||
pub fn paginate( | ||
&self, | ||
) -> stripe_client_core::ListPaginator< | ||
stripe_types::List<async_stripe_forwarding::ForwardingRequest>, | ||
> { | ||
stripe_client_core::ListPaginator::new_list("/forwarding/requests", self.inner) | ||
} | ||
} | ||
|
||
impl StripeRequest for ListForwardingRequest<'_> { | ||
type Output = stripe_types::List<async_stripe_forwarding::ForwardingRequest>; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
RequestBuilder::new(StripeMethod::Get, "/forwarding/requests").query(&self.inner) | ||
} | ||
} | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct RetrieveForwardingRequestBuilder<'a> { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
} | ||
impl<'a> RetrieveForwardingRequestBuilder<'a> { | ||
fn new() -> Self { | ||
Self { expand: None } | ||
} | ||
} | ||
/// Retrieves a ForwardingRequest object. | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct RetrieveForwardingRequest<'a> { | ||
inner: RetrieveForwardingRequestBuilder<'a>, | ||
id: &'a async_stripe_forwarding::ForwardingRequestId, | ||
} | ||
impl<'a> RetrieveForwardingRequest<'a> { | ||
/// Construct a new `RetrieveForwardingRequest`. | ||
pub fn new(id: &'a async_stripe_forwarding::ForwardingRequestId) -> Self { | ||
Self { id, inner: RetrieveForwardingRequestBuilder::new() } | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
} | ||
impl RetrieveForwardingRequest<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
} | ||
|
||
impl StripeRequest for RetrieveForwardingRequest<'_> { | ||
type Output = async_stripe_forwarding::ForwardingRequest; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
let id = self.id; | ||
RequestBuilder::new(StripeMethod::Get, format!("/forwarding/requests/{id}")) | ||
.query(&self.inner) | ||
} | ||
} | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct CreateForwardingRequestBuilder<'a> { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
payment_method: &'a str, | ||
replacements: &'a [async_stripe_forwarding::ForwardingRequestReplacements], | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
request: Option<CreateForwardingRequestRequest<'a>>, | ||
url: &'a str, | ||
} | ||
impl<'a> CreateForwardingRequestBuilder<'a> { | ||
fn new( | ||
payment_method: &'a str, | ||
replacements: &'a [async_stripe_forwarding::ForwardingRequestReplacements], | ||
url: &'a str, | ||
) -> Self { | ||
Self { expand: None, payment_method, replacements, request: None, url } | ||
} | ||
} | ||
/// The request body and headers to be sent to the destination endpoint. | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
pub struct CreateForwardingRequestRequest<'a> { | ||
/// The body payload to send to the destination endpoint. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub body: Option<&'a str>, | ||
/// The headers to include in the forwarded request. | ||
/// Can be omitted if no additional headers (excluding Stripe-generated ones such as the Content-Type header) should be included. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub headers: Option<&'a [CreateForwardingRequestRequestHeaders<'a>]>, | ||
} | ||
impl<'a> CreateForwardingRequestRequest<'a> { | ||
pub fn new() -> Self { | ||
Self { body: None, headers: None } | ||
} | ||
} | ||
impl<'a> Default for CreateForwardingRequestRequest<'a> { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
/// The headers to include in the forwarded request. | ||
/// Can be omitted if no additional headers (excluding Stripe-generated ones such as the Content-Type header) should be included. | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
pub struct CreateForwardingRequestRequestHeaders<'a> { | ||
/// The header name. | ||
pub name: &'a str, | ||
/// The header value. | ||
pub value: &'a str, | ||
} | ||
impl<'a> CreateForwardingRequestRequestHeaders<'a> { | ||
pub fn new(name: &'a str, value: &'a str) -> Self { | ||
Self { name, value } | ||
} | ||
} | ||
/// Creates a ForwardingRequest object. | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct CreateForwardingRequest<'a> { | ||
inner: CreateForwardingRequestBuilder<'a>, | ||
} | ||
impl<'a> CreateForwardingRequest<'a> { | ||
/// Construct a new `CreateForwardingRequest`. | ||
pub fn new( | ||
payment_method: &'a str, | ||
replacements: &'a [async_stripe_forwarding::ForwardingRequestReplacements], | ||
url: &'a str, | ||
) -> Self { | ||
Self { inner: CreateForwardingRequestBuilder::new(payment_method, replacements, url) } | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
/// The request body and headers to be sent to the destination endpoint. | ||
pub fn request(mut self, request: CreateForwardingRequestRequest<'a>) -> Self { | ||
self.inner.request = Some(request); | ||
self | ||
} | ||
} | ||
impl CreateForwardingRequest<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
} | ||
|
||
impl StripeRequest for CreateForwardingRequest<'_> { | ||
type Output = async_stripe_forwarding::ForwardingRequest; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
RequestBuilder::new(StripeMethod::Post, "/forwarding/requests").form(&self.inner) | ||
} | ||
} |
272 changes: 272 additions & 0 deletions
272
generated/async_stripe_forwarding/src/forwarding_request/types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,272 @@ | ||
/// Instructs Stripe to make a request on your behalf using the destination URL. The destination URL | ||
/// is activated by Stripe at the time of onboarding. Stripe verifies requests with your credentials | ||
/// provided during onboarding, and injects card details from the payment_method into the request. | ||
/// | ||
/// Stripe redacts all sensitive fields and headers, including authentication credentials and card numbers,. | ||
/// before storing the request and response data in the forwarding Request object, which are subject to a. | ||
/// 30-day retention period. | ||
/// | ||
/// You can provide a Stripe idempotency key to make sure that requests with the same key result in only one. | ||
/// outbound request. | ||
/// The Stripe idempotency key provided should be unique and different from any idempotency. | ||
/// keys provided on the underlying third-party request. | ||
/// | ||
/// Forwarding Requests are synchronous requests that return a response or time out according to | ||
/// Stripe’s limits. | ||
/// | ||
/// Related guide: [Forward card details to third-party API endpoints](https://docs.stripe.com/payments/forwarding). | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct ForwardingRequest { | ||
/// Time at which the object was created. Measured in seconds since the Unix epoch. | ||
pub created: stripe_types::Timestamp, | ||
/// Unique identifier for the object. | ||
pub id: async_stripe_forwarding::ForwardingRequestId, | ||
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
pub livemode: bool, | ||
/// The PaymentMethod to insert into the forwarded request. | ||
/// Forwarding previously consumed PaymentMethods is allowed. | ||
pub payment_method: String, | ||
/// The field kinds to be replaced in the forwarded request. | ||
pub replacements: Vec<async_stripe_forwarding::ForwardingRequestReplacements>, | ||
/// Context about the request from Stripe's servers to the destination endpoint. | ||
pub request_context: Option<async_stripe_forwarding::ForwardedRequestContext>, | ||
/// The request that was sent to the destination endpoint. We redact any sensitive fields. | ||
pub request_details: Option<async_stripe_forwarding::ForwardedRequestDetails>, | ||
/// The response that the destination endpoint returned to us. We redact any sensitive fields. | ||
pub response_details: Option<async_stripe_forwarding::ForwardedResponseDetails>, | ||
/// The destination URL for the forwarded request. Must be supported by the config. | ||
pub url: Option<String>, | ||
} | ||
#[doc(hidden)] | ||
pub struct ForwardingRequestBuilder { | ||
created: Option<stripe_types::Timestamp>, | ||
id: Option<async_stripe_forwarding::ForwardingRequestId>, | ||
livemode: Option<bool>, | ||
payment_method: Option<String>, | ||
replacements: Option<Vec<async_stripe_forwarding::ForwardingRequestReplacements>>, | ||
request_context: Option<Option<async_stripe_forwarding::ForwardedRequestContext>>, | ||
request_details: Option<Option<async_stripe_forwarding::ForwardedRequestDetails>>, | ||
response_details: Option<Option<async_stripe_forwarding::ForwardedResponseDetails>>, | ||
url: Option<Option<String>>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for ForwardingRequest { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<ForwardingRequest>, | ||
builder: ForwardingRequestBuilder, | ||
} | ||
|
||
impl Visitor for Place<ForwardingRequest> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: ForwardingRequestBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for ForwardingRequestBuilder { | ||
type Out = ForwardingRequest; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"created" => Deserialize::begin(&mut self.created), | ||
"id" => Deserialize::begin(&mut self.id), | ||
"livemode" => Deserialize::begin(&mut self.livemode), | ||
"payment_method" => Deserialize::begin(&mut self.payment_method), | ||
"replacements" => Deserialize::begin(&mut self.replacements), | ||
"request_context" => Deserialize::begin(&mut self.request_context), | ||
"request_details" => Deserialize::begin(&mut self.request_details), | ||
"response_details" => Deserialize::begin(&mut self.response_details), | ||
"url" => Deserialize::begin(&mut self.url), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
created: Deserialize::default(), | ||
id: Deserialize::default(), | ||
livemode: Deserialize::default(), | ||
payment_method: Deserialize::default(), | ||
replacements: Deserialize::default(), | ||
request_context: Deserialize::default(), | ||
request_details: Deserialize::default(), | ||
response_details: Deserialize::default(), | ||
url: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
created: self.created?, | ||
id: self.id.take()?, | ||
livemode: self.livemode?, | ||
payment_method: self.payment_method.take()?, | ||
replacements: self.replacements.take()?, | ||
request_context: self.request_context.take()?, | ||
request_details: self.request_details.take()?, | ||
response_details: self.response_details.take()?, | ||
url: self.url.take()?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for ForwardingRequest { | ||
type Builder = ForwardingRequestBuilder; | ||
} | ||
|
||
impl FromValueOpt for ForwardingRequest { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = ForwardingRequestBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"created" => b.created = Some(FromValueOpt::from_value(v)?), | ||
"id" => b.id = Some(FromValueOpt::from_value(v)?), | ||
"livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), | ||
"payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), | ||
"replacements" => b.replacements = Some(FromValueOpt::from_value(v)?), | ||
"request_context" => b.request_context = Some(FromValueOpt::from_value(v)?), | ||
"request_details" => b.request_details = Some(FromValueOpt::from_value(v)?), | ||
"response_details" => b.response_details = Some(FromValueOpt::from_value(v)?), | ||
"url" => b.url = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for ForwardingRequest { | ||
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { | ||
use serde::ser::SerializeStruct; | ||
let mut s = s.serialize_struct("ForwardingRequest", 10)?; | ||
s.serialize_field("created", &self.created)?; | ||
s.serialize_field("id", &self.id)?; | ||
s.serialize_field("livemode", &self.livemode)?; | ||
s.serialize_field("payment_method", &self.payment_method)?; | ||
s.serialize_field("replacements", &self.replacements)?; | ||
s.serialize_field("request_context", &self.request_context)?; | ||
s.serialize_field("request_details", &self.request_details)?; | ||
s.serialize_field("response_details", &self.response_details)?; | ||
s.serialize_field("url", &self.url)?; | ||
|
||
s.serialize_field("object", "forwarding.request")?; | ||
s.end() | ||
} | ||
} | ||
impl stripe_types::Object for ForwardingRequest { | ||
type Id = async_stripe_forwarding::ForwardingRequestId; | ||
fn id(&self) -> &Self::Id { | ||
&self.id | ||
} | ||
} | ||
stripe_types::def_id!(ForwardingRequestId); | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum ForwardingRequestReplacements { | ||
CardCvc, | ||
CardExpiry, | ||
CardNumber, | ||
CardholderName, | ||
} | ||
impl ForwardingRequestReplacements { | ||
pub fn as_str(self) -> &'static str { | ||
use ForwardingRequestReplacements::*; | ||
match self { | ||
CardCvc => "card_cvc", | ||
CardExpiry => "card_expiry", | ||
CardNumber => "card_number", | ||
CardholderName => "cardholder_name", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for ForwardingRequestReplacements { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use ForwardingRequestReplacements::*; | ||
match s { | ||
"card_cvc" => Ok(CardCvc), | ||
"card_expiry" => Ok(CardExpiry), | ||
"card_number" => Ok(CardNumber), | ||
"cardholder_name" => Ok(CardholderName), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for ForwardingRequestReplacements { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for ForwardingRequestReplacements { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
impl serde::Serialize for ForwardingRequestReplacements { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for ForwardingRequestReplacements { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<ForwardingRequestReplacements> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = Some(ForwardingRequestReplacements::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(ForwardingRequestReplacements); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for ForwardingRequestReplacements { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom("Unknown value for ForwardingRequestReplacements") | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![recursion_limit = "256"] | ||
#![allow(clippy::large_enum_variant)] | ||
#![allow(rustdoc::broken_intra_doc_links)] | ||
#![allow(rustdoc::invalid_html_tags)] | ||
|
||
//! | ||
extern crate self as async_stripe_forwarding; | ||
|
||
miniserde::make_place!(Place); | ||
#[doc(hidden)] | ||
pub mod forwarded_request_context; | ||
#[doc(inline)] | ||
pub use forwarded_request_context::*; | ||
#[doc(hidden)] | ||
pub mod forwarded_request_details; | ||
#[doc(inline)] | ||
pub use forwarded_request_details::*; | ||
#[doc(hidden)] | ||
pub mod forwarded_request_header; | ||
#[doc(inline)] | ||
pub use forwarded_request_header::*; | ||
#[doc(hidden)] | ||
pub mod forwarded_response_details; | ||
#[doc(inline)] | ||
pub use forwarded_response_details::*; | ||
pub use forwarding_request::types::*; | ||
pub mod forwarding_request; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "billing_meter")] | ||
mod requests; | ||
pub(crate) mod types; | ||
#[cfg(feature = "billing_meter")] | ||
pub use requests::*; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
/// A billing meter is a resource that allows you to track usage of a particular event. | ||
/// For example, you might create a billing meter to track the number of API calls made by a particular user. | ||
/// You can then attach the billing meter to a price and attach the price to a subscription to charge the user for the number of API calls they make. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeter { | ||
/// Time at which the object was created. Measured in seconds since the Unix epoch. | ||
pub created: stripe_types::Timestamp, | ||
pub customer_mapping: stripe_billing::BillingMeterResourceCustomerMappingSettings, | ||
pub default_aggregation: stripe_billing::BillingMeterResourceAggregationSettings, | ||
/// The meter's name. | ||
pub display_name: String, | ||
/// The name of the meter event to record usage for. | ||
/// Corresponds with the `event_name` field on meter events. | ||
pub event_name: String, | ||
/// The time window to pre-aggregate meter events for, if any. | ||
pub event_time_window: Option<stripe_billing::BillingMeterEventTimeWindow>, | ||
/// Unique identifier for the object. | ||
pub id: stripe_billing::BillingMeterId, | ||
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
pub livemode: bool, | ||
/// The meter's status. | ||
pub status: stripe_billing::BillingMeterStatus, | ||
pub status_transitions: stripe_billing::BillingMeterResourceBillingMeterStatusTransitions, | ||
/// Time at which the object was last updated. Measured in seconds since the Unix epoch. | ||
pub updated: stripe_types::Timestamp, | ||
pub value_settings: stripe_billing::BillingMeterResourceBillingMeterValue, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterBuilder { | ||
created: Option<stripe_types::Timestamp>, | ||
customer_mapping: Option<stripe_billing::BillingMeterResourceCustomerMappingSettings>, | ||
default_aggregation: Option<stripe_billing::BillingMeterResourceAggregationSettings>, | ||
display_name: Option<String>, | ||
event_name: Option<String>, | ||
event_time_window: Option<Option<stripe_billing::BillingMeterEventTimeWindow>>, | ||
id: Option<stripe_billing::BillingMeterId>, | ||
livemode: Option<bool>, | ||
status: Option<stripe_billing::BillingMeterStatus>, | ||
status_transitions: Option<stripe_billing::BillingMeterResourceBillingMeterStatusTransitions>, | ||
updated: Option<stripe_types::Timestamp>, | ||
value_settings: Option<stripe_billing::BillingMeterResourceBillingMeterValue>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeter { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeter>, | ||
builder: BillingMeterBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeter> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterBuilder { | ||
type Out = BillingMeter; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"created" => Deserialize::begin(&mut self.created), | ||
"customer_mapping" => Deserialize::begin(&mut self.customer_mapping), | ||
"default_aggregation" => Deserialize::begin(&mut self.default_aggregation), | ||
"display_name" => Deserialize::begin(&mut self.display_name), | ||
"event_name" => Deserialize::begin(&mut self.event_name), | ||
"event_time_window" => Deserialize::begin(&mut self.event_time_window), | ||
"id" => Deserialize::begin(&mut self.id), | ||
"livemode" => Deserialize::begin(&mut self.livemode), | ||
"status" => Deserialize::begin(&mut self.status), | ||
"status_transitions" => Deserialize::begin(&mut self.status_transitions), | ||
"updated" => Deserialize::begin(&mut self.updated), | ||
"value_settings" => Deserialize::begin(&mut self.value_settings), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
created: Deserialize::default(), | ||
customer_mapping: Deserialize::default(), | ||
default_aggregation: Deserialize::default(), | ||
display_name: Deserialize::default(), | ||
event_name: Deserialize::default(), | ||
event_time_window: Deserialize::default(), | ||
id: Deserialize::default(), | ||
livemode: Deserialize::default(), | ||
status: Deserialize::default(), | ||
status_transitions: Deserialize::default(), | ||
updated: Deserialize::default(), | ||
value_settings: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
created: self.created?, | ||
customer_mapping: self.customer_mapping.take()?, | ||
default_aggregation: self.default_aggregation?, | ||
display_name: self.display_name.take()?, | ||
event_name: self.event_name.take()?, | ||
event_time_window: self.event_time_window?, | ||
id: self.id.take()?, | ||
livemode: self.livemode?, | ||
status: self.status?, | ||
status_transitions: self.status_transitions?, | ||
updated: self.updated?, | ||
value_settings: self.value_settings.take()?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeter { | ||
type Builder = BillingMeterBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeter { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"created" => b.created = Some(FromValueOpt::from_value(v)?), | ||
"customer_mapping" => b.customer_mapping = Some(FromValueOpt::from_value(v)?), | ||
"default_aggregation" => { | ||
b.default_aggregation = Some(FromValueOpt::from_value(v)?) | ||
} | ||
"display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), | ||
"event_name" => b.event_name = Some(FromValueOpt::from_value(v)?), | ||
"event_time_window" => b.event_time_window = Some(FromValueOpt::from_value(v)?), | ||
"id" => b.id = Some(FromValueOpt::from_value(v)?), | ||
"livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), | ||
"status" => b.status = Some(FromValueOpt::from_value(v)?), | ||
"status_transitions" => { | ||
b.status_transitions = Some(FromValueOpt::from_value(v)?) | ||
} | ||
"updated" => b.updated = Some(FromValueOpt::from_value(v)?), | ||
"value_settings" => b.value_settings = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeter { | ||
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { | ||
use serde::ser::SerializeStruct; | ||
let mut s = s.serialize_struct("BillingMeter", 13)?; | ||
s.serialize_field("created", &self.created)?; | ||
s.serialize_field("customer_mapping", &self.customer_mapping)?; | ||
s.serialize_field("default_aggregation", &self.default_aggregation)?; | ||
s.serialize_field("display_name", &self.display_name)?; | ||
s.serialize_field("event_name", &self.event_name)?; | ||
s.serialize_field("event_time_window", &self.event_time_window)?; | ||
s.serialize_field("id", &self.id)?; | ||
s.serialize_field("livemode", &self.livemode)?; | ||
s.serialize_field("status", &self.status)?; | ||
s.serialize_field("status_transitions", &self.status_transitions)?; | ||
s.serialize_field("updated", &self.updated)?; | ||
s.serialize_field("value_settings", &self.value_settings)?; | ||
|
||
s.serialize_field("object", "billing.meter")?; | ||
s.end() | ||
} | ||
} | ||
impl stripe_types::Object for BillingMeter { | ||
type Id = stripe_billing::BillingMeterId; | ||
fn id(&self) -> &Self::Id { | ||
&self.id | ||
} | ||
} | ||
stripe_types::def_id!(BillingMeterId); | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum BillingMeterEventTimeWindow { | ||
Day, | ||
Hour, | ||
} | ||
impl BillingMeterEventTimeWindow { | ||
pub fn as_str(self) -> &'static str { | ||
use BillingMeterEventTimeWindow::*; | ||
match self { | ||
Day => "day", | ||
Hour => "hour", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for BillingMeterEventTimeWindow { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use BillingMeterEventTimeWindow::*; | ||
match s { | ||
"day" => Ok(Day), | ||
"hour" => Ok(Hour), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for BillingMeterEventTimeWindow { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for BillingMeterEventTimeWindow { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
impl serde::Serialize for BillingMeterEventTimeWindow { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for BillingMeterEventTimeWindow { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<BillingMeterEventTimeWindow> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = Some(BillingMeterEventTimeWindow::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(BillingMeterEventTimeWindow); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for BillingMeterEventTimeWindow { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s) | ||
.map_err(|_| serde::de::Error::custom("Unknown value for BillingMeterEventTimeWindow")) | ||
} | ||
} | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum BillingMeterStatus { | ||
Active, | ||
Inactive, | ||
} | ||
impl BillingMeterStatus { | ||
pub fn as_str(self) -> &'static str { | ||
use BillingMeterStatus::*; | ||
match self { | ||
Active => "active", | ||
Inactive => "inactive", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for BillingMeterStatus { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use BillingMeterStatus::*; | ||
match s { | ||
"active" => Ok(Active), | ||
"inactive" => Ok(Inactive), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for BillingMeterStatus { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for BillingMeterStatus { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
impl serde::Serialize for BillingMeterStatus { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for BillingMeterStatus { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<BillingMeterStatus> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = Some(BillingMeterStatus::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(BillingMeterStatus); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for BillingMeterStatus { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s) | ||
.map_err(|_| serde::de::Error::custom("Unknown value for BillingMeterStatus")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "billing_meter_event")] | ||
mod requests; | ||
pub(crate) mod types; | ||
#[cfg(feature = "billing_meter_event")] | ||
pub use requests::*; |
80 changes: 80 additions & 0 deletions
80
generated/stripe_billing/src/billing_meter_event/requests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use stripe_client_core::{ | ||
RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest, | ||
}; | ||
|
||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct CreateBillingMeterEventBuilder<'a> { | ||
event_name: &'a str, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
identifier: Option<&'a str>, | ||
payload: &'a std::collections::HashMap<String, String>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
timestamp: Option<stripe_types::Timestamp>, | ||
} | ||
impl<'a> CreateBillingMeterEventBuilder<'a> { | ||
fn new(event_name: &'a str, payload: &'a std::collections::HashMap<String, String>) -> Self { | ||
Self { event_name, expand: None, identifier: None, payload, timestamp: None } | ||
} | ||
} | ||
/// Creates a billing meter event | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct CreateBillingMeterEvent<'a> { | ||
inner: CreateBillingMeterEventBuilder<'a>, | ||
} | ||
impl<'a> CreateBillingMeterEvent<'a> { | ||
/// Construct a new `CreateBillingMeterEvent`. | ||
pub fn new( | ||
event_name: &'a str, | ||
payload: &'a std::collections::HashMap<String, String>, | ||
) -> Self { | ||
Self { inner: CreateBillingMeterEventBuilder::new(event_name, payload) } | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
/// A unique identifier for the event. | ||
/// If not provided, one will be generated. | ||
/// We recommend using a globally unique identifier for this. | ||
/// We'll enforce uniqueness within a rolling 24 hour period. | ||
pub fn identifier(mut self, identifier: &'a str) -> Self { | ||
self.inner.identifier = Some(identifier); | ||
self | ||
} | ||
/// The time of the event. | ||
/// Measured in seconds since the Unix epoch. | ||
/// Must be within the past 35 calendar days or up to 5 minutes in the future. | ||
/// Defaults to current timestamp if not specified. | ||
pub fn timestamp(mut self, timestamp: stripe_types::Timestamp) -> Self { | ||
self.inner.timestamp = Some(timestamp); | ||
self | ||
} | ||
} | ||
impl CreateBillingMeterEvent<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
} | ||
|
||
impl StripeRequest for CreateBillingMeterEvent<'_> { | ||
type Output = stripe_billing::BillingMeterEvent; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
RequestBuilder::new(StripeMethod::Post, "/billing/meter_events").form(&self.inner) | ||
} | ||
} |
152 changes: 152 additions & 0 deletions
152
generated/stripe_billing/src/billing_meter_event/types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/// A billing meter event represents a customer's usage of a product. | ||
/// Meter events are used to bill a customer based on their usage. | ||
/// Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterEvent { | ||
/// Time at which the object was created. Measured in seconds since the Unix epoch. | ||
pub created: stripe_types::Timestamp, | ||
/// The name of the meter event. Corresponds with the `event_name` field on a meter. | ||
pub event_name: String, | ||
/// A unique identifier for the event. | ||
pub identifier: String, | ||
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
pub livemode: bool, | ||
/// The payload of the event. | ||
/// This contains the fields corresponding to a meter's `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and `value_settings.event_payload_key` (default is `value`). | ||
/// Read more about the [payload](https://stripe.com/docs/billing/subscriptions/usage-based/recording-usage#payload-key-overrides). | ||
pub payload: std::collections::HashMap<String, String>, | ||
/// The timestamp passed in when creating the event. Measured in seconds since the Unix epoch. | ||
pub timestamp: stripe_types::Timestamp, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterEventBuilder { | ||
created: Option<stripe_types::Timestamp>, | ||
event_name: Option<String>, | ||
identifier: Option<String>, | ||
livemode: Option<bool>, | ||
payload: Option<std::collections::HashMap<String, String>>, | ||
timestamp: Option<stripe_types::Timestamp>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterEvent { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterEvent>, | ||
builder: BillingMeterEventBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterEvent> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterEventBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterEventBuilder { | ||
type Out = BillingMeterEvent; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"created" => Deserialize::begin(&mut self.created), | ||
"event_name" => Deserialize::begin(&mut self.event_name), | ||
"identifier" => Deserialize::begin(&mut self.identifier), | ||
"livemode" => Deserialize::begin(&mut self.livemode), | ||
"payload" => Deserialize::begin(&mut self.payload), | ||
"timestamp" => Deserialize::begin(&mut self.timestamp), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
created: Deserialize::default(), | ||
event_name: Deserialize::default(), | ||
identifier: Deserialize::default(), | ||
livemode: Deserialize::default(), | ||
payload: Deserialize::default(), | ||
timestamp: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
created: self.created?, | ||
event_name: self.event_name.take()?, | ||
identifier: self.identifier.take()?, | ||
livemode: self.livemode?, | ||
payload: self.payload.take()?, | ||
timestamp: self.timestamp?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterEvent { | ||
type Builder = BillingMeterEventBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterEvent { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterEventBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"created" => b.created = Some(FromValueOpt::from_value(v)?), | ||
"event_name" => b.event_name = Some(FromValueOpt::from_value(v)?), | ||
"identifier" => b.identifier = Some(FromValueOpt::from_value(v)?), | ||
"livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), | ||
"payload" => b.payload = Some(FromValueOpt::from_value(v)?), | ||
"timestamp" => b.timestamp = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeterEvent { | ||
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { | ||
use serde::ser::SerializeStruct; | ||
let mut s = s.serialize_struct("BillingMeterEvent", 7)?; | ||
s.serialize_field("created", &self.created)?; | ||
s.serialize_field("event_name", &self.event_name)?; | ||
s.serialize_field("identifier", &self.identifier)?; | ||
s.serialize_field("livemode", &self.livemode)?; | ||
s.serialize_field("payload", &self.payload)?; | ||
s.serialize_field("timestamp", &self.timestamp)?; | ||
|
||
s.serialize_field("object", "billing.meter_event")?; | ||
s.end() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
generated/stripe_billing/src/billing_meter_event_adjustment/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "billing_meter_event_adjustment")] | ||
mod requests; | ||
pub(crate) mod types; | ||
#[cfg(feature = "billing_meter_event_adjustment")] | ||
pub use requests::*; |
87 changes: 87 additions & 0 deletions
87
generated/stripe_billing/src/billing_meter_event_adjustment/requests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use stripe_client_core::{ | ||
RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest, | ||
}; | ||
|
||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct CreateBillingMeterEventAdjustmentBuilder<'a> { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
cancel: Option<CreateBillingMeterEventAdjustmentCancel<'a>>, | ||
event_name: &'a str, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
#[serde(rename = "type")] | ||
type_: stripe_billing::BillingMeterEventAdjustmentType, | ||
} | ||
impl<'a> CreateBillingMeterEventAdjustmentBuilder<'a> { | ||
fn new(event_name: &'a str, type_: stripe_billing::BillingMeterEventAdjustmentType) -> Self { | ||
Self { cancel: None, event_name, expand: None, type_ } | ||
} | ||
} | ||
/// Specifies which event to cancel. | ||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
pub struct CreateBillingMeterEventAdjustmentCancel<'a> { | ||
/// Unique identifier for the event. | ||
/// You can only cancel events within 24 hours of Stripe receiving them. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub identifier: Option<&'a str>, | ||
} | ||
impl<'a> CreateBillingMeterEventAdjustmentCancel<'a> { | ||
pub fn new() -> Self { | ||
Self { identifier: None } | ||
} | ||
} | ||
impl<'a> Default for CreateBillingMeterEventAdjustmentCancel<'a> { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
/// Creates a billing meter event adjustment | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct CreateBillingMeterEventAdjustment<'a> { | ||
inner: CreateBillingMeterEventAdjustmentBuilder<'a>, | ||
} | ||
impl<'a> CreateBillingMeterEventAdjustment<'a> { | ||
/// Construct a new `CreateBillingMeterEventAdjustment`. | ||
pub fn new( | ||
event_name: &'a str, | ||
type_: stripe_billing::BillingMeterEventAdjustmentType, | ||
) -> Self { | ||
Self { inner: CreateBillingMeterEventAdjustmentBuilder::new(event_name, type_) } | ||
} | ||
/// Specifies which event to cancel. | ||
pub fn cancel(mut self, cancel: CreateBillingMeterEventAdjustmentCancel<'a>) -> Self { | ||
self.inner.cancel = Some(cancel); | ||
self | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
} | ||
impl CreateBillingMeterEventAdjustment<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
} | ||
|
||
impl StripeRequest for CreateBillingMeterEventAdjustment<'_> { | ||
type Output = stripe_billing::BillingMeterEventAdjustment; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
RequestBuilder::new(StripeMethod::Post, "/billing/meter_event_adjustments") | ||
.form(&self.inner) | ||
} | ||
} |
284 changes: 284 additions & 0 deletions
284
generated/stripe_billing/src/billing_meter_event_adjustment/types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
/// A billing meter event adjustment is a resource that allows you to cancel a meter event. | ||
/// For example, you might create a billing meter event adjustment to cancel a meter event that was created in error or attached to the wrong customer. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterEventAdjustment { | ||
/// Specifies which event to cancel. | ||
pub cancel: Option<stripe_billing::BillingMeterResourceBillingMeterEventAdjustmentCancel>, | ||
/// The name of the meter event. Corresponds with the `event_name` field on a meter. | ||
pub event_name: String, | ||
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
pub livemode: bool, | ||
/// The meter event adjustment's status. | ||
pub status: BillingMeterEventAdjustmentStatus, | ||
/// Specifies whether to cancel a single event or a range of events for a time period. | ||
/// Time period cancellation is not supported yet. | ||
#[cfg_attr(feature = "deserialize", serde(rename = "type"))] | ||
pub type_: stripe_billing::BillingMeterEventAdjustmentType, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterEventAdjustmentBuilder { | ||
cancel: Option<Option<stripe_billing::BillingMeterResourceBillingMeterEventAdjustmentCancel>>, | ||
event_name: Option<String>, | ||
livemode: Option<bool>, | ||
status: Option<BillingMeterEventAdjustmentStatus>, | ||
type_: Option<stripe_billing::BillingMeterEventAdjustmentType>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterEventAdjustment { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterEventAdjustment>, | ||
builder: BillingMeterEventAdjustmentBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterEventAdjustment> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterEventAdjustmentBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterEventAdjustmentBuilder { | ||
type Out = BillingMeterEventAdjustment; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"cancel" => Deserialize::begin(&mut self.cancel), | ||
"event_name" => Deserialize::begin(&mut self.event_name), | ||
"livemode" => Deserialize::begin(&mut self.livemode), | ||
"status" => Deserialize::begin(&mut self.status), | ||
"type" => Deserialize::begin(&mut self.type_), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
cancel: Deserialize::default(), | ||
event_name: Deserialize::default(), | ||
livemode: Deserialize::default(), | ||
status: Deserialize::default(), | ||
type_: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
cancel: self.cancel.take()?, | ||
event_name: self.event_name.take()?, | ||
livemode: self.livemode?, | ||
status: self.status?, | ||
type_: self.type_?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterEventAdjustment { | ||
type Builder = BillingMeterEventAdjustmentBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterEventAdjustment { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterEventAdjustmentBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"cancel" => b.cancel = Some(FromValueOpt::from_value(v)?), | ||
"event_name" => b.event_name = Some(FromValueOpt::from_value(v)?), | ||
"livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), | ||
"status" => b.status = Some(FromValueOpt::from_value(v)?), | ||
"type" => b.type_ = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeterEventAdjustment { | ||
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { | ||
use serde::ser::SerializeStruct; | ||
let mut s = s.serialize_struct("BillingMeterEventAdjustment", 6)?; | ||
s.serialize_field("cancel", &self.cancel)?; | ||
s.serialize_field("event_name", &self.event_name)?; | ||
s.serialize_field("livemode", &self.livemode)?; | ||
s.serialize_field("status", &self.status)?; | ||
s.serialize_field("type", &self.type_)?; | ||
|
||
s.serialize_field("object", "billing.meter_event_adjustment")?; | ||
s.end() | ||
} | ||
} | ||
/// The meter event adjustment's status. | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum BillingMeterEventAdjustmentStatus { | ||
Complete, | ||
Pending, | ||
} | ||
impl BillingMeterEventAdjustmentStatus { | ||
pub fn as_str(self) -> &'static str { | ||
use BillingMeterEventAdjustmentStatus::*; | ||
match self { | ||
Complete => "complete", | ||
Pending => "pending", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for BillingMeterEventAdjustmentStatus { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use BillingMeterEventAdjustmentStatus::*; | ||
match s { | ||
"complete" => Ok(Complete), | ||
"pending" => Ok(Pending), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for BillingMeterEventAdjustmentStatus { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for BillingMeterEventAdjustmentStatus { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeterEventAdjustmentStatus { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for BillingMeterEventAdjustmentStatus { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<BillingMeterEventAdjustmentStatus> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = | ||
Some(BillingMeterEventAdjustmentStatus::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(BillingMeterEventAdjustmentStatus); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for BillingMeterEventAdjustmentStatus { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom("Unknown value for BillingMeterEventAdjustmentStatus") | ||
}) | ||
} | ||
} | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum BillingMeterEventAdjustmentType { | ||
Cancel, | ||
} | ||
impl BillingMeterEventAdjustmentType { | ||
pub fn as_str(self) -> &'static str { | ||
use BillingMeterEventAdjustmentType::*; | ||
match self { | ||
Cancel => "cancel", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for BillingMeterEventAdjustmentType { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use BillingMeterEventAdjustmentType::*; | ||
match s { | ||
"cancel" => Ok(Cancel), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for BillingMeterEventAdjustmentType { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for BillingMeterEventAdjustmentType { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
impl serde::Serialize for BillingMeterEventAdjustmentType { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for BillingMeterEventAdjustmentType { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<BillingMeterEventAdjustmentType> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = | ||
Some(BillingMeterEventAdjustmentType::from_str(s).map_err(|_| miniserde::Error)?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(BillingMeterEventAdjustmentType); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for BillingMeterEventAdjustmentType { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom("Unknown value for BillingMeterEventAdjustmentType") | ||
}) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
generated/stripe_billing/src/billing_meter_event_summary/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(feature = "billing_meter_event_summary")] | ||
mod requests; | ||
pub(crate) mod types; | ||
#[cfg(feature = "billing_meter_event_summary")] | ||
pub use requests::*; |
188 changes: 188 additions & 0 deletions
188
generated/stripe_billing/src/billing_meter_event_summary/requests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
use stripe_client_core::{ | ||
RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest, | ||
}; | ||
|
||
#[derive(Copy, Clone, Debug, serde::Serialize)] | ||
struct ListIdBillingMeterEventSummaryBuilder<'a> { | ||
customer: &'a str, | ||
end_time: stripe_types::Timestamp, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
ending_before: Option<&'a str>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
expand: Option<&'a [&'a str]>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
limit: Option<i64>, | ||
start_time: stripe_types::Timestamp, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
starting_after: Option<&'a str>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
value_grouping_window: Option<ListIdBillingMeterEventSummaryValueGroupingWindow>, | ||
} | ||
impl<'a> ListIdBillingMeterEventSummaryBuilder<'a> { | ||
fn new( | ||
customer: &'a str, | ||
end_time: stripe_types::Timestamp, | ||
start_time: stripe_types::Timestamp, | ||
) -> Self { | ||
Self { | ||
customer, | ||
end_time, | ||
ending_before: None, | ||
expand: None, | ||
limit: None, | ||
start_time, | ||
starting_after: None, | ||
value_grouping_window: None, | ||
} | ||
} | ||
} | ||
/// Specifies what granularity to use when generating event summaries. | ||
/// If not specified, a single event summary would be returned for the specified time range. | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
Hour, | ||
} | ||
impl ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
pub fn as_str(self) -> &'static str { | ||
use ListIdBillingMeterEventSummaryValueGroupingWindow::*; | ||
match self { | ||
Hour => "hour", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use ListIdBillingMeterEventSummaryValueGroupingWindow::*; | ||
match s { | ||
"hour" => Ok(Hour), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
impl serde::Serialize for ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for ListIdBillingMeterEventSummaryValueGroupingWindow { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom( | ||
"Unknown value for ListIdBillingMeterEventSummaryValueGroupingWindow", | ||
) | ||
}) | ||
} | ||
} | ||
/// Retrieve a list of billing meter event summaries. | ||
#[derive(Clone, Debug, serde::Serialize)] | ||
pub struct ListIdBillingMeterEventSummary<'a> { | ||
inner: ListIdBillingMeterEventSummaryBuilder<'a>, | ||
id: &'a stripe_billing::BillingMeterId, | ||
} | ||
impl<'a> ListIdBillingMeterEventSummary<'a> { | ||
/// Construct a new `ListIdBillingMeterEventSummary`. | ||
pub fn new( | ||
id: &'a stripe_billing::BillingMeterId, | ||
customer: &'a str, | ||
end_time: stripe_types::Timestamp, | ||
start_time: stripe_types::Timestamp, | ||
) -> Self { | ||
Self { | ||
id, | ||
inner: ListIdBillingMeterEventSummaryBuilder::new(customer, end_time, start_time), | ||
} | ||
} | ||
/// A cursor for use in pagination. | ||
/// `ending_before` is an object ID that defines your place in the list. | ||
/// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. | ||
pub fn ending_before(mut self, ending_before: &'a str) -> Self { | ||
self.inner.ending_before = Some(ending_before); | ||
self | ||
} | ||
/// Specifies which fields in the response should be expanded. | ||
pub fn expand(mut self, expand: &'a [&'a str]) -> Self { | ||
self.inner.expand = Some(expand); | ||
self | ||
} | ||
/// A limit on the number of objects to be returned. | ||
/// Limit can range between 1 and 100, and the default is 10. | ||
pub fn limit(mut self, limit: i64) -> Self { | ||
self.inner.limit = Some(limit); | ||
self | ||
} | ||
/// A cursor for use in pagination. | ||
/// `starting_after` is an object ID that defines your place in the list. | ||
/// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. | ||
pub fn starting_after(mut self, starting_after: &'a str) -> Self { | ||
self.inner.starting_after = Some(starting_after); | ||
self | ||
} | ||
/// Specifies what granularity to use when generating event summaries. | ||
/// If not specified, a single event summary would be returned for the specified time range. | ||
pub fn value_grouping_window( | ||
mut self, | ||
value_grouping_window: ListIdBillingMeterEventSummaryValueGroupingWindow, | ||
) -> Self { | ||
self.inner.value_grouping_window = Some(value_grouping_window); | ||
self | ||
} | ||
} | ||
impl ListIdBillingMeterEventSummary<'_> { | ||
/// Send the request and return the deserialized response. | ||
pub async fn send<C: StripeClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send(client).await | ||
} | ||
|
||
/// Send the request and return the deserialized response, blocking until completion. | ||
pub fn send_blocking<C: StripeBlockingClient>( | ||
&self, | ||
client: &C, | ||
) -> Result<<Self as StripeRequest>::Output, C::Err> { | ||
self.customize().send_blocking(client) | ||
} | ||
|
||
pub fn paginate( | ||
&self, | ||
) -> stripe_client_core::ListPaginator< | ||
stripe_types::List<stripe_billing::BillingMeterEventSummary>, | ||
> { | ||
let id = self.id; | ||
|
||
stripe_client_core::ListPaginator::new_list( | ||
format!("/billing/meters/{id}/event_summaries"), | ||
self.inner, | ||
) | ||
} | ||
} | ||
|
||
impl StripeRequest for ListIdBillingMeterEventSummary<'_> { | ||
type Output = stripe_types::List<stripe_billing::BillingMeterEventSummary>; | ||
|
||
fn build(&self) -> RequestBuilder { | ||
let id = self.id; | ||
RequestBuilder::new(StripeMethod::Get, format!("/billing/meters/{id}/event_summaries")) | ||
.query(&self.inner) | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
generated/stripe_billing/src/billing_meter_event_summary/types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/// A billing meter event summary represents an aggregated view of a customer's billing meter events within a specified timeframe. | ||
/// It indicates how much. | ||
/// usage was accrued by a customer for that period. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterEventSummary { | ||
/// Aggregated value of all the events within `start_time` (inclusive) and `end_time` (inclusive). | ||
/// The aggregation strategy is defined on meter via `default_aggregation`. | ||
pub aggregated_value: f64, | ||
/// End timestamp for this event summary (inclusive). | ||
pub end_time: stripe_types::Timestamp, | ||
/// Unique identifier for the object. | ||
pub id: stripe_billing::BillingMeterEventSummaryId, | ||
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
pub livemode: bool, | ||
/// The meter associated with this event summary. | ||
pub meter: String, | ||
/// Start timestamp for this event summary (inclusive). | ||
pub start_time: stripe_types::Timestamp, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterEventSummaryBuilder { | ||
aggregated_value: Option<f64>, | ||
end_time: Option<stripe_types::Timestamp>, | ||
id: Option<stripe_billing::BillingMeterEventSummaryId>, | ||
livemode: Option<bool>, | ||
meter: Option<String>, | ||
start_time: Option<stripe_types::Timestamp>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterEventSummary { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterEventSummary>, | ||
builder: BillingMeterEventSummaryBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterEventSummary> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterEventSummaryBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterEventSummaryBuilder { | ||
type Out = BillingMeterEventSummary; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"aggregated_value" => Deserialize::begin(&mut self.aggregated_value), | ||
"end_time" => Deserialize::begin(&mut self.end_time), | ||
"id" => Deserialize::begin(&mut self.id), | ||
"livemode" => Deserialize::begin(&mut self.livemode), | ||
"meter" => Deserialize::begin(&mut self.meter), | ||
"start_time" => Deserialize::begin(&mut self.start_time), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { | ||
aggregated_value: Deserialize::default(), | ||
end_time: Deserialize::default(), | ||
id: Deserialize::default(), | ||
livemode: Deserialize::default(), | ||
meter: Deserialize::default(), | ||
start_time: Deserialize::default(), | ||
} | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { | ||
aggregated_value: self.aggregated_value?, | ||
end_time: self.end_time?, | ||
id: self.id.take()?, | ||
livemode: self.livemode?, | ||
meter: self.meter.take()?, | ||
start_time: self.start_time?, | ||
}) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterEventSummary { | ||
type Builder = BillingMeterEventSummaryBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterEventSummary { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterEventSummaryBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"aggregated_value" => b.aggregated_value = Some(FromValueOpt::from_value(v)?), | ||
"end_time" => b.end_time = Some(FromValueOpt::from_value(v)?), | ||
"id" => b.id = Some(FromValueOpt::from_value(v)?), | ||
"livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), | ||
"meter" => b.meter = Some(FromValueOpt::from_value(v)?), | ||
"start_time" => b.start_time = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeterEventSummary { | ||
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { | ||
use serde::ser::SerializeStruct; | ||
let mut s = s.serialize_struct("BillingMeterEventSummary", 7)?; | ||
s.serialize_field("aggregated_value", &self.aggregated_value)?; | ||
s.serialize_field("end_time", &self.end_time)?; | ||
s.serialize_field("id", &self.id)?; | ||
s.serialize_field("livemode", &self.livemode)?; | ||
s.serialize_field("meter", &self.meter)?; | ||
s.serialize_field("start_time", &self.start_time)?; | ||
|
||
s.serialize_field("object", "billing.meter_event_summary")?; | ||
s.end() | ||
} | ||
} | ||
impl stripe_types::Object for BillingMeterEventSummary { | ||
type Id = stripe_billing::BillingMeterEventSummaryId; | ||
fn id(&self) -> &Self::Id { | ||
&self.id | ||
} | ||
} | ||
stripe_types::def_id!(BillingMeterEventSummaryId); |
170 changes: 170 additions & 0 deletions
170
generated/stripe_billing/src/billing_meter_resource_aggregation_settings.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
#[derive(Copy, Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterResourceAggregationSettings { | ||
/// Specifies how events are aggregated. | ||
pub formula: BillingMeterResourceAggregationSettingsFormula, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterResourceAggregationSettingsBuilder { | ||
formula: Option<BillingMeterResourceAggregationSettingsFormula>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterResourceAggregationSettings { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterResourceAggregationSettings>, | ||
builder: BillingMeterResourceAggregationSettingsBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterResourceAggregationSettings> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterResourceAggregationSettingsBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterResourceAggregationSettingsBuilder { | ||
type Out = BillingMeterResourceAggregationSettings; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"formula" => Deserialize::begin(&mut self.formula), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { formula: Deserialize::default() } | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { formula: self.formula? }) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterResourceAggregationSettings { | ||
type Builder = BillingMeterResourceAggregationSettingsBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterResourceAggregationSettings { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterResourceAggregationSettingsBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"formula" => b.formula = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; | ||
/// Specifies how events are aggregated. | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub enum BillingMeterResourceAggregationSettingsFormula { | ||
Count, | ||
Sum, | ||
} | ||
impl BillingMeterResourceAggregationSettingsFormula { | ||
pub fn as_str(self) -> &'static str { | ||
use BillingMeterResourceAggregationSettingsFormula::*; | ||
match self { | ||
Count => "count", | ||
Sum => "sum", | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for BillingMeterResourceAggregationSettingsFormula { | ||
type Err = (); | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
use BillingMeterResourceAggregationSettingsFormula::*; | ||
match s { | ||
"count" => Ok(Count), | ||
"sum" => Ok(Sum), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
impl std::fmt::Display for BillingMeterResourceAggregationSettingsFormula { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for BillingMeterResourceAggregationSettingsFormula { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
#[cfg(feature = "serialize")] | ||
impl serde::Serialize for BillingMeterResourceAggregationSettingsFormula { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
serializer.serialize_str(self.as_str()) | ||
} | ||
} | ||
impl miniserde::Deserialize for BillingMeterResourceAggregationSettingsFormula { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { | ||
crate::Place::new(out) | ||
} | ||
} | ||
|
||
impl miniserde::de::Visitor for crate::Place<BillingMeterResourceAggregationSettingsFormula> { | ||
fn string(&mut self, s: &str) -> miniserde::Result<()> { | ||
use std::str::FromStr; | ||
self.out = Some( | ||
BillingMeterResourceAggregationSettingsFormula::from_str(s) | ||
.map_err(|_| miniserde::Error)?, | ||
); | ||
Ok(()) | ||
} | ||
} | ||
|
||
stripe_types::impl_from_val_with_from_str!(BillingMeterResourceAggregationSettingsFormula); | ||
#[cfg(feature = "deserialize")] | ||
impl<'de> serde::Deserialize<'de> for BillingMeterResourceAggregationSettingsFormula { | ||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
use std::str::FromStr; | ||
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; | ||
Self::from_str(&s).map_err(|_| { | ||
serde::de::Error::custom( | ||
"Unknown value for BillingMeterResourceAggregationSettingsFormula", | ||
) | ||
}) | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
generated/stripe_billing/src/billing_meter_resource_billing_meter_event_adjustment_cancel.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterResourceBillingMeterEventAdjustmentCancel { | ||
/// Unique identifier for the event. | ||
pub identifier: Option<String>, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder { | ||
identifier: Option<Option<String>>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterResourceBillingMeterEventAdjustmentCancel { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterResourceBillingMeterEventAdjustmentCancel>, | ||
builder: BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterResourceBillingMeterEventAdjustmentCancel> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: | ||
BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder { | ||
type Out = BillingMeterResourceBillingMeterEventAdjustmentCancel; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"identifier" => Deserialize::begin(&mut self.identifier), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { identifier: Deserialize::default() } | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { identifier: self.identifier.take()? }) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterResourceBillingMeterEventAdjustmentCancel { | ||
type Builder = BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterResourceBillingMeterEventAdjustmentCancel { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = | ||
BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"identifier" => b.identifier = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
93 changes: 93 additions & 0 deletions
93
generated/stripe_billing/src/billing_meter_resource_billing_meter_status_transitions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#[derive(Copy, Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterResourceBillingMeterStatusTransitions { | ||
/// The time the meter was deactivated, if any. Measured in seconds since Unix epoch. | ||
pub deactivated_at: Option<stripe_types::Timestamp>, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterResourceBillingMeterStatusTransitionsBuilder { | ||
deactivated_at: Option<Option<stripe_types::Timestamp>>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterResourceBillingMeterStatusTransitions { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterResourceBillingMeterStatusTransitions>, | ||
builder: BillingMeterResourceBillingMeterStatusTransitionsBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterResourceBillingMeterStatusTransitions> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterResourceBillingMeterStatusTransitionsBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterResourceBillingMeterStatusTransitionsBuilder { | ||
type Out = BillingMeterResourceBillingMeterStatusTransitions; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"deactivated_at" => Deserialize::begin(&mut self.deactivated_at), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { deactivated_at: Deserialize::default() } | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { deactivated_at: self.deactivated_at? }) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterResourceBillingMeterStatusTransitions { | ||
type Builder = BillingMeterResourceBillingMeterStatusTransitionsBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterResourceBillingMeterStatusTransitions { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterResourceBillingMeterStatusTransitionsBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"deactivated_at" => b.deactivated_at = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
93 changes: 93 additions & 0 deletions
93
generated/stripe_billing/src/billing_meter_resource_billing_meter_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] | ||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
pub struct BillingMeterResourceBillingMeterValue { | ||
/// The key in the meter event payload to use as the value for this meter. | ||
pub event_payload_key: String, | ||
} | ||
#[doc(hidden)] | ||
pub struct BillingMeterResourceBillingMeterValueBuilder { | ||
event_payload_key: Option<String>, | ||
} | ||
|
||
#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] | ||
const _: () = { | ||
use miniserde::de::{Map, Visitor}; | ||
use miniserde::json::Value; | ||
use miniserde::{make_place, Deserialize, Result}; | ||
use stripe_types::miniserde_helpers::FromValueOpt; | ||
use stripe_types::{MapBuilder, ObjectDeser}; | ||
|
||
make_place!(Place); | ||
|
||
impl Deserialize for BillingMeterResourceBillingMeterValue { | ||
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { | ||
Place::new(out) | ||
} | ||
} | ||
|
||
struct Builder<'a> { | ||
out: &'a mut Option<BillingMeterResourceBillingMeterValue>, | ||
builder: BillingMeterResourceBillingMeterValueBuilder, | ||
} | ||
|
||
impl Visitor for Place<BillingMeterResourceBillingMeterValue> { | ||
fn map(&mut self) -> Result<Box<dyn Map + '_>> { | ||
Ok(Box::new(Builder { | ||
out: &mut self.out, | ||
builder: BillingMeterResourceBillingMeterValueBuilder::deser_default(), | ||
})) | ||
} | ||
} | ||
|
||
impl MapBuilder for BillingMeterResourceBillingMeterValueBuilder { | ||
type Out = BillingMeterResourceBillingMeterValue; | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
Ok(match k { | ||
"event_payload_key" => Deserialize::begin(&mut self.event_payload_key), | ||
|
||
_ => <dyn Visitor>::ignore(), | ||
}) | ||
} | ||
|
||
fn deser_default() -> Self { | ||
Self { event_payload_key: Deserialize::default() } | ||
} | ||
|
||
fn take_out(&mut self) -> Option<Self::Out> { | ||
Some(Self::Out { event_payload_key: self.event_payload_key.take()? }) | ||
} | ||
} | ||
|
||
impl<'a> Map for Builder<'a> { | ||
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { | ||
self.builder.key(k) | ||
} | ||
|
||
fn finish(&mut self) -> Result<()> { | ||
*self.out = self.builder.take_out(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl ObjectDeser for BillingMeterResourceBillingMeterValue { | ||
type Builder = BillingMeterResourceBillingMeterValueBuilder; | ||
} | ||
|
||
impl FromValueOpt for BillingMeterResourceBillingMeterValue { | ||
fn from_value(v: Value) -> Option<Self> { | ||
let Value::Object(obj) = v else { | ||
return None; | ||
}; | ||
let mut b = BillingMeterResourceBillingMeterValueBuilder::deser_default(); | ||
for (k, v) in obj { | ||
match k.as_str() { | ||
"event_payload_key" => b.event_payload_key = Some(FromValueOpt::from_value(v)?), | ||
|
||
_ => {} | ||
} | ||
} | ||
b.take_out() | ||
} | ||
} | ||
}; |
Oops, something went wrong.