Skip to content

Commit

Permalink
Merge pull request #602 from mzeitlin11/comp-time
Browse files Browse the repository at this point in the history
Be careful with ? in generated code
  • Loading branch information
arlyon authored Sep 3, 2024
2 parents 48d4653 + fba30c3 commit d14a43b
Show file tree
Hide file tree
Showing 963 changed files with 26,608 additions and 11,890 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/async-stripe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
]
services:
stripe-mock:
image: stripe/stripe-mock
image: stripe/stripe-mock:v0.185.0
ports:
- 12111:12111
- 12112:12112
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ To run the tests, you will need
to run a [`stripe-mock`](https://github.com/stripe/stripe-mock) server and select a runtime. CI runs tests against all runtimes, but it is encouraged you test your changes locally against a few runtimes first.

```sh
docker run --rm -d -it -p 12111-12112:12111-12112 stripe/stripe-mock:latest
docker run --rm -d -it -p 12111-12112:12111-12112 stripe/stripe-mock:v0.185.0
cargo test --features runtime-blocking
```

Expand Down
90 changes: 61 additions & 29 deletions generated/async-stripe-billing/src/billing_meter/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ pub struct BillingMeterBuilder {
value_settings: Option<stripe_billing::BillingMeterResourceBillingMeterValue>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -111,19 +117,49 @@ const _: () = {
}

fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(created),
Some(customer_mapping),
Some(default_aggregation),
Some(display_name),
Some(event_name),
Some(event_time_window),
Some(id),
Some(livemode),
Some(status),
Some(status_transitions),
Some(updated),
Some(value_settings),
) = (
self.created,
self.customer_mapping.take(),
self.default_aggregation,
self.display_name.take(),
self.event_name.take(),
self.event_time_window,
self.id.take(),
self.livemode,
self.status,
self.status_transitions,
self.updated,
self.value_settings.take(),
)
else {
return None;
};
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()?,
created,
customer_mapping,
default_aggregation,
display_name,
event_name,
event_time_window,
id,
livemode,
status,
status_transitions,
updated,
value_settings,
})
}
}
Expand Down Expand Up @@ -151,22 +187,18 @@ const _: () = {
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)?),
"created" => b.created = FromValueOpt::from_value(v),
"customer_mapping" => b.customer_mapping = FromValueOpt::from_value(v),
"default_aggregation" => b.default_aggregation = FromValueOpt::from_value(v),
"display_name" => b.display_name = FromValueOpt::from_value(v),
"event_name" => b.event_name = FromValueOpt::from_value(v),
"event_time_window" => b.event_time_window = FromValueOpt::from_value(v),
"id" => b.id = FromValueOpt::from_value(v),
"livemode" => b.livemode = FromValueOpt::from_value(v),
"status" => b.status = FromValueOpt::from_value(v),
"status_transitions" => b.status_transitions = FromValueOpt::from_value(v),
"updated" => b.updated = FromValueOpt::from_value(v),
"value_settings" => b.value_settings = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
47 changes: 32 additions & 15 deletions generated/async-stripe-billing/src/billing_meter_event/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ pub struct BillingMeterEventBuilder {
timestamp: Option<stripe_types::Timestamp>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -86,14 +92,25 @@ const _: () = {
}

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?,
})
let (
Some(created),
Some(event_name),
Some(identifier),
Some(livemode),
Some(payload),
Some(timestamp),
) = (
self.created,
self.event_name.take(),
self.identifier.take(),
self.livemode,
self.payload.take(),
self.timestamp,
)
else {
return None;
};
Some(Self::Out { created, event_name, identifier, livemode, payload, timestamp })
}
}

Expand All @@ -120,12 +137,12 @@ const _: () = {
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)?),
"created" => b.created = FromValueOpt::from_value(v),
"event_name" => b.event_name = FromValueOpt::from_value(v),
"identifier" => b.identifier = FromValueOpt::from_value(v),
"livemode" => b.livemode = FromValueOpt::from_value(v),
"payload" => b.payload = FromValueOpt::from_value(v),
"timestamp" => b.timestamp = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ pub struct BillingMeterEventAdjustmentBuilder {
type_: Option<stripe_billing::BillingMeterEventAdjustmentType>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -80,13 +86,16 @@ const _: () = {
}

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_?,
})
let (Some(cancel), Some(event_name), Some(livemode), Some(status), Some(type_)) = (
self.cancel.take(),
self.event_name.take(),
self.livemode,
self.status,
self.type_,
) else {
return None;
};
Some(Self::Out { cancel, event_name, livemode, status, type_ })
}
}

Expand All @@ -113,11 +122,11 @@ const _: () = {
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)?),
"cancel" => b.cancel = FromValueOpt::from_value(v),
"event_name" => b.event_name = FromValueOpt::from_value(v),
"livemode" => b.livemode = FromValueOpt::from_value(v),
"status" => b.status = FromValueOpt::from_value(v),
"type" => b.type_ = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ pub struct BillingMeterEventSummaryBuilder {
start_time: Option<stripe_types::Timestamp>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -85,14 +91,25 @@ const _: () = {
}

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?,
})
let (
Some(aggregated_value),
Some(end_time),
Some(id),
Some(livemode),
Some(meter),
Some(start_time),
) = (
self.aggregated_value,
self.end_time,
self.id.take(),
self.livemode,
self.meter.take(),
self.start_time,
)
else {
return None;
};
Some(Self::Out { aggregated_value, end_time, id, livemode, meter, start_time })
}
}

Expand All @@ -119,12 +136,12 @@ const _: () = {
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)?),
"aggregated_value" => b.aggregated_value = FromValueOpt::from_value(v),
"end_time" => b.end_time = FromValueOpt::from_value(v),
"id" => b.id = FromValueOpt::from_value(v),
"livemode" => b.livemode = FromValueOpt::from_value(v),
"meter" => b.meter = FromValueOpt::from_value(v),
"start_time" => b.start_time = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pub struct BillingMeterResourceAggregationSettingsBuilder {
formula: Option<BillingMeterResourceAggregationSettingsFormula>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -55,7 +61,10 @@ const _: () = {
}

fn take_out(&mut self) -> Option<Self::Out> {
Some(Self::Out { formula: self.formula? })
let (Some(formula),) = (self.formula,) else {
return None;
};
Some(Self::Out { formula })
}
}

Expand All @@ -82,7 +91,7 @@ const _: () = {
let mut b = BillingMeterResourceAggregationSettingsBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"formula" => b.formula = Some(FromValueOpt::from_value(v)?),
"formula" => b.formula = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pub struct BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder {
identifier: Option<Option<String>>,
}

#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)]
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
Expand Down Expand Up @@ -56,7 +62,10 @@ const _: () = {
}

fn take_out(&mut self) -> Option<Self::Out> {
Some(Self::Out { identifier: self.identifier.take()? })
let (Some(identifier),) = (self.identifier.take(),) else {
return None;
};
Some(Self::Out { identifier })
}
}

Expand Down Expand Up @@ -84,7 +93,7 @@ const _: () = {
BillingMeterResourceBillingMeterEventAdjustmentCancelBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"identifier" => b.identifier = Some(FromValueOpt::from_value(v)?),
"identifier" => b.identifier = FromValueOpt::from_value(v),

_ => {}
}
Expand Down
Loading

0 comments on commit d14a43b

Please sign in to comment.