1#[derive(Clone, Debug)]
7#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
8pub struct IssuingDispute {
9 pub amount: i64,
12 pub balance_transactions: Option<Vec<stripe_shared::BalanceTransaction>>,
14 pub created: stripe_types::Timestamp,
16 pub currency: stripe_types::Currency,
18 pub evidence: stripe_shared::IssuingDisputeEvidence,
19 pub id: stripe_shared::IssuingDisputeId,
21 pub livemode: bool,
23 pub loss_reason: Option<IssuingDisputeLossReason>,
27 pub metadata: std::collections::HashMap<String, String>,
30 pub status: stripe_shared::IssuingDisputeStatus,
32 pub transaction: stripe_types::Expandable<stripe_shared::IssuingTransaction>,
34 pub treasury: Option<stripe_shared::IssuingDisputeTreasury>,
36}
37#[doc(hidden)]
38pub struct IssuingDisputeBuilder {
39 amount: Option<i64>,
40 balance_transactions: Option<Option<Vec<stripe_shared::BalanceTransaction>>>,
41 created: Option<stripe_types::Timestamp>,
42 currency: Option<stripe_types::Currency>,
43 evidence: Option<stripe_shared::IssuingDisputeEvidence>,
44 id: Option<stripe_shared::IssuingDisputeId>,
45 livemode: Option<bool>,
46 loss_reason: Option<Option<IssuingDisputeLossReason>>,
47 metadata: Option<std::collections::HashMap<String, String>>,
48 status: Option<stripe_shared::IssuingDisputeStatus>,
49 transaction: Option<stripe_types::Expandable<stripe_shared::IssuingTransaction>>,
50 treasury: Option<Option<stripe_shared::IssuingDisputeTreasury>>,
51}
52
53#[allow(
54 unused_variables,
55 irrefutable_let_patterns,
56 clippy::let_unit_value,
57 clippy::match_single_binding,
58 clippy::single_match
59)]
60const _: () = {
61 use miniserde::de::{Map, Visitor};
62 use miniserde::json::Value;
63 use miniserde::{Deserialize, Result, make_place};
64 use stripe_types::miniserde_helpers::FromValueOpt;
65 use stripe_types::{MapBuilder, ObjectDeser};
66
67 make_place!(Place);
68
69 impl Deserialize for IssuingDispute {
70 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
71 Place::new(out)
72 }
73 }
74
75 struct Builder<'a> {
76 out: &'a mut Option<IssuingDispute>,
77 builder: IssuingDisputeBuilder,
78 }
79
80 impl Visitor for Place<IssuingDispute> {
81 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
82 Ok(Box::new(Builder {
83 out: &mut self.out,
84 builder: IssuingDisputeBuilder::deser_default(),
85 }))
86 }
87 }
88
89 impl MapBuilder for IssuingDisputeBuilder {
90 type Out = IssuingDispute;
91 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
92 Ok(match k {
93 "amount" => Deserialize::begin(&mut self.amount),
94 "balance_transactions" => Deserialize::begin(&mut self.balance_transactions),
95 "created" => Deserialize::begin(&mut self.created),
96 "currency" => Deserialize::begin(&mut self.currency),
97 "evidence" => Deserialize::begin(&mut self.evidence),
98 "id" => Deserialize::begin(&mut self.id),
99 "livemode" => Deserialize::begin(&mut self.livemode),
100 "loss_reason" => Deserialize::begin(&mut self.loss_reason),
101 "metadata" => Deserialize::begin(&mut self.metadata),
102 "status" => Deserialize::begin(&mut self.status),
103 "transaction" => Deserialize::begin(&mut self.transaction),
104 "treasury" => Deserialize::begin(&mut self.treasury),
105 _ => <dyn Visitor>::ignore(),
106 })
107 }
108
109 fn deser_default() -> Self {
110 Self {
111 amount: Deserialize::default(),
112 balance_transactions: Deserialize::default(),
113 created: Deserialize::default(),
114 currency: Deserialize::default(),
115 evidence: Deserialize::default(),
116 id: Deserialize::default(),
117 livemode: Deserialize::default(),
118 loss_reason: Deserialize::default(),
119 metadata: Deserialize::default(),
120 status: Deserialize::default(),
121 transaction: Deserialize::default(),
122 treasury: Deserialize::default(),
123 }
124 }
125
126 fn take_out(&mut self) -> Option<Self::Out> {
127 let (
128 Some(amount),
129 Some(balance_transactions),
130 Some(created),
131 Some(currency),
132 Some(evidence),
133 Some(id),
134 Some(livemode),
135 Some(loss_reason),
136 Some(metadata),
137 Some(status),
138 Some(transaction),
139 Some(treasury),
140 ) = (
141 self.amount,
142 self.balance_transactions.take(),
143 self.created,
144 self.currency.take(),
145 self.evidence.take(),
146 self.id.take(),
147 self.livemode,
148 self.loss_reason.take(),
149 self.metadata.take(),
150 self.status.take(),
151 self.transaction.take(),
152 self.treasury.take(),
153 )
154 else {
155 return None;
156 };
157 Some(Self::Out {
158 amount,
159 balance_transactions,
160 created,
161 currency,
162 evidence,
163 id,
164 livemode,
165 loss_reason,
166 metadata,
167 status,
168 transaction,
169 treasury,
170 })
171 }
172 }
173
174 impl Map for Builder<'_> {
175 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
176 self.builder.key(k)
177 }
178
179 fn finish(&mut self) -> Result<()> {
180 *self.out = self.builder.take_out();
181 Ok(())
182 }
183 }
184
185 impl ObjectDeser for IssuingDispute {
186 type Builder = IssuingDisputeBuilder;
187 }
188
189 impl FromValueOpt for IssuingDispute {
190 fn from_value(v: Value) -> Option<Self> {
191 let Value::Object(obj) = v else {
192 return None;
193 };
194 let mut b = IssuingDisputeBuilder::deser_default();
195 for (k, v) in obj {
196 match k.as_str() {
197 "amount" => b.amount = FromValueOpt::from_value(v),
198 "balance_transactions" => b.balance_transactions = FromValueOpt::from_value(v),
199 "created" => b.created = FromValueOpt::from_value(v),
200 "currency" => b.currency = FromValueOpt::from_value(v),
201 "evidence" => b.evidence = FromValueOpt::from_value(v),
202 "id" => b.id = FromValueOpt::from_value(v),
203 "livemode" => b.livemode = FromValueOpt::from_value(v),
204 "loss_reason" => b.loss_reason = FromValueOpt::from_value(v),
205 "metadata" => b.metadata = FromValueOpt::from_value(v),
206 "status" => b.status = FromValueOpt::from_value(v),
207 "transaction" => b.transaction = FromValueOpt::from_value(v),
208 "treasury" => b.treasury = FromValueOpt::from_value(v),
209 _ => {}
210 }
211 }
212 b.take_out()
213 }
214 }
215};
216#[cfg(feature = "serialize")]
217impl serde::Serialize for IssuingDispute {
218 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
219 use serde::ser::SerializeStruct;
220 let mut s = s.serialize_struct("IssuingDispute", 13)?;
221 s.serialize_field("amount", &self.amount)?;
222 s.serialize_field("balance_transactions", &self.balance_transactions)?;
223 s.serialize_field("created", &self.created)?;
224 s.serialize_field("currency", &self.currency)?;
225 s.serialize_field("evidence", &self.evidence)?;
226 s.serialize_field("id", &self.id)?;
227 s.serialize_field("livemode", &self.livemode)?;
228 s.serialize_field("loss_reason", &self.loss_reason)?;
229 s.serialize_field("metadata", &self.metadata)?;
230 s.serialize_field("status", &self.status)?;
231 s.serialize_field("transaction", &self.transaction)?;
232 s.serialize_field("treasury", &self.treasury)?;
233
234 s.serialize_field("object", "issuing.dispute")?;
235 s.end()
236 }
237}
238#[derive(Clone, Eq, PartialEq)]
242#[non_exhaustive]
243pub enum IssuingDisputeLossReason {
244 CardholderAuthenticationIssuerLiability,
245 Eci5TokenTransactionWithTavv,
246 ExcessDisputesInTimeframe,
247 HasNotMetTheMinimumDisputeAmountRequirements,
248 InvalidDuplicateDispute,
249 InvalidIncorrectAmountDispute,
250 InvalidNoAuthorization,
251 InvalidUseOfDisputes,
252 MerchandiseDeliveredOrShipped,
253 MerchandiseOrServiceAsDescribed,
254 NotCancelled,
255 Other,
256 RefundIssued,
257 SubmittedBeyondAllowableTimeLimit,
258 Transaction3dsRequired,
259 TransactionApprovedAfterPriorFraudDispute,
260 TransactionAuthorized,
261 TransactionElectronicallyRead,
262 TransactionQualifiesForVisaEasyPaymentService,
263 TransactionUnattended,
264 Unknown(String),
266}
267impl IssuingDisputeLossReason {
268 pub fn as_str(&self) -> &str {
269 use IssuingDisputeLossReason::*;
270 match self {
271 CardholderAuthenticationIssuerLiability => "cardholder_authentication_issuer_liability",
272 Eci5TokenTransactionWithTavv => "eci5_token_transaction_with_tavv",
273 ExcessDisputesInTimeframe => "excess_disputes_in_timeframe",
274 HasNotMetTheMinimumDisputeAmountRequirements => {
275 "has_not_met_the_minimum_dispute_amount_requirements"
276 }
277 InvalidDuplicateDispute => "invalid_duplicate_dispute",
278 InvalidIncorrectAmountDispute => "invalid_incorrect_amount_dispute",
279 InvalidNoAuthorization => "invalid_no_authorization",
280 InvalidUseOfDisputes => "invalid_use_of_disputes",
281 MerchandiseDeliveredOrShipped => "merchandise_delivered_or_shipped",
282 MerchandiseOrServiceAsDescribed => "merchandise_or_service_as_described",
283 NotCancelled => "not_cancelled",
284 Other => "other",
285 RefundIssued => "refund_issued",
286 SubmittedBeyondAllowableTimeLimit => "submitted_beyond_allowable_time_limit",
287 Transaction3dsRequired => "transaction_3ds_required",
288 TransactionApprovedAfterPriorFraudDispute => {
289 "transaction_approved_after_prior_fraud_dispute"
290 }
291 TransactionAuthorized => "transaction_authorized",
292 TransactionElectronicallyRead => "transaction_electronically_read",
293 TransactionQualifiesForVisaEasyPaymentService => {
294 "transaction_qualifies_for_visa_easy_payment_service"
295 }
296 TransactionUnattended => "transaction_unattended",
297 Unknown(v) => v,
298 }
299 }
300}
301
302impl std::str::FromStr for IssuingDisputeLossReason {
303 type Err = std::convert::Infallible;
304 fn from_str(s: &str) -> Result<Self, Self::Err> {
305 use IssuingDisputeLossReason::*;
306 match s {
307 "cardholder_authentication_issuer_liability" => {
308 Ok(CardholderAuthenticationIssuerLiability)
309 }
310 "eci5_token_transaction_with_tavv" => Ok(Eci5TokenTransactionWithTavv),
311 "excess_disputes_in_timeframe" => Ok(ExcessDisputesInTimeframe),
312 "has_not_met_the_minimum_dispute_amount_requirements" => {
313 Ok(HasNotMetTheMinimumDisputeAmountRequirements)
314 }
315 "invalid_duplicate_dispute" => Ok(InvalidDuplicateDispute),
316 "invalid_incorrect_amount_dispute" => Ok(InvalidIncorrectAmountDispute),
317 "invalid_no_authorization" => Ok(InvalidNoAuthorization),
318 "invalid_use_of_disputes" => Ok(InvalidUseOfDisputes),
319 "merchandise_delivered_or_shipped" => Ok(MerchandiseDeliveredOrShipped),
320 "merchandise_or_service_as_described" => Ok(MerchandiseOrServiceAsDescribed),
321 "not_cancelled" => Ok(NotCancelled),
322 "other" => Ok(Other),
323 "refund_issued" => Ok(RefundIssued),
324 "submitted_beyond_allowable_time_limit" => Ok(SubmittedBeyondAllowableTimeLimit),
325 "transaction_3ds_required" => Ok(Transaction3dsRequired),
326 "transaction_approved_after_prior_fraud_dispute" => {
327 Ok(TransactionApprovedAfterPriorFraudDispute)
328 }
329 "transaction_authorized" => Ok(TransactionAuthorized),
330 "transaction_electronically_read" => Ok(TransactionElectronicallyRead),
331 "transaction_qualifies_for_visa_easy_payment_service" => {
332 Ok(TransactionQualifiesForVisaEasyPaymentService)
333 }
334 "transaction_unattended" => Ok(TransactionUnattended),
335 v => {
336 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingDisputeLossReason");
337 Ok(Unknown(v.to_owned()))
338 }
339 }
340 }
341}
342impl std::fmt::Display for IssuingDisputeLossReason {
343 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
344 f.write_str(self.as_str())
345 }
346}
347
348impl std::fmt::Debug for IssuingDisputeLossReason {
349 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
350 f.write_str(self.as_str())
351 }
352}
353#[cfg(feature = "serialize")]
354impl serde::Serialize for IssuingDisputeLossReason {
355 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
356 where
357 S: serde::Serializer,
358 {
359 serializer.serialize_str(self.as_str())
360 }
361}
362impl miniserde::Deserialize for IssuingDisputeLossReason {
363 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
364 crate::Place::new(out)
365 }
366}
367
368impl miniserde::de::Visitor for crate::Place<IssuingDisputeLossReason> {
369 fn string(&mut self, s: &str) -> miniserde::Result<()> {
370 use std::str::FromStr;
371 self.out = Some(IssuingDisputeLossReason::from_str(s).expect("infallible"));
372 Ok(())
373 }
374}
375
376stripe_types::impl_from_val_with_from_str!(IssuingDisputeLossReason);
377#[cfg(feature = "deserialize")]
378impl<'de> serde::Deserialize<'de> for IssuingDisputeLossReason {
379 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
380 use std::str::FromStr;
381 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
382 Ok(Self::from_str(&s).expect("infallible"))
383 }
384}
385impl stripe_types::Object for IssuingDispute {
386 type Id = stripe_shared::IssuingDisputeId;
387 fn id(&self) -> &Self::Id {
388 &self.id
389 }
390
391 fn into_id(self) -> Self::Id {
392 self.id
393 }
394}
395stripe_types::def_id!(IssuingDisputeId);
396#[derive(Clone, Eq, PartialEq)]
397#[non_exhaustive]
398pub enum IssuingDisputeStatus {
399 Expired,
400 Lost,
401 Submitted,
402 Unsubmitted,
403 Won,
404 Unknown(String),
406}
407impl IssuingDisputeStatus {
408 pub fn as_str(&self) -> &str {
409 use IssuingDisputeStatus::*;
410 match self {
411 Expired => "expired",
412 Lost => "lost",
413 Submitted => "submitted",
414 Unsubmitted => "unsubmitted",
415 Won => "won",
416 Unknown(v) => v,
417 }
418 }
419}
420
421impl std::str::FromStr for IssuingDisputeStatus {
422 type Err = std::convert::Infallible;
423 fn from_str(s: &str) -> Result<Self, Self::Err> {
424 use IssuingDisputeStatus::*;
425 match s {
426 "expired" => Ok(Expired),
427 "lost" => Ok(Lost),
428 "submitted" => Ok(Submitted),
429 "unsubmitted" => Ok(Unsubmitted),
430 "won" => Ok(Won),
431 v => {
432 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingDisputeStatus");
433 Ok(Unknown(v.to_owned()))
434 }
435 }
436 }
437}
438impl std::fmt::Display for IssuingDisputeStatus {
439 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
440 f.write_str(self.as_str())
441 }
442}
443
444impl std::fmt::Debug for IssuingDisputeStatus {
445 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
446 f.write_str(self.as_str())
447 }
448}
449impl serde::Serialize for IssuingDisputeStatus {
450 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
451 where
452 S: serde::Serializer,
453 {
454 serializer.serialize_str(self.as_str())
455 }
456}
457impl miniserde::Deserialize for IssuingDisputeStatus {
458 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
459 crate::Place::new(out)
460 }
461}
462
463impl miniserde::de::Visitor for crate::Place<IssuingDisputeStatus> {
464 fn string(&mut self, s: &str) -> miniserde::Result<()> {
465 use std::str::FromStr;
466 self.out = Some(IssuingDisputeStatus::from_str(s).expect("infallible"));
467 Ok(())
468 }
469}
470
471stripe_types::impl_from_val_with_from_str!(IssuingDisputeStatus);
472#[cfg(feature = "deserialize")]
473impl<'de> serde::Deserialize<'de> for IssuingDisputeStatus {
474 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
475 use std::str::FromStr;
476 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
477 Ok(Self::from_str(&s).expect("infallible"))
478 }
479}