1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct RetrieveTaxCalculationBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 expand: Option<Vec<String>>,
9}
10impl RetrieveTaxCalculationBuilder {
11 fn new() -> Self {
12 Self { expand: None }
13 }
14}
15#[derive(Clone, Debug, serde::Serialize)]
17pub struct RetrieveTaxCalculation {
18 inner: RetrieveTaxCalculationBuilder,
19 calculation: stripe_misc::TaxCalculationId,
20}
21impl RetrieveTaxCalculation {
22 pub fn new(calculation: impl Into<stripe_misc::TaxCalculationId>) -> Self {
24 Self { calculation: calculation.into(), inner: RetrieveTaxCalculationBuilder::new() }
25 }
26 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
28 self.inner.expand = Some(expand.into());
29 self
30 }
31}
32impl RetrieveTaxCalculation {
33 pub async fn send<C: StripeClient>(
35 &self,
36 client: &C,
37 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
38 self.customize().send(client).await
39 }
40
41 pub fn send_blocking<C: StripeBlockingClient>(
43 &self,
44 client: &C,
45 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
46 self.customize().send_blocking(client)
47 }
48}
49
50impl StripeRequest for RetrieveTaxCalculation {
51 type Output = stripe_misc::TaxCalculation;
52
53 fn build(&self) -> RequestBuilder {
54 let calculation = &self.calculation;
55 RequestBuilder::new(StripeMethod::Get, format!("/tax/calculations/{calculation}"))
56 .query(&self.inner)
57 }
58}
59#[derive(Clone, Debug, serde::Serialize)]
60struct ListLineItemsTaxCalculationBuilder {
61 #[serde(skip_serializing_if = "Option::is_none")]
62 ending_before: Option<String>,
63 #[serde(skip_serializing_if = "Option::is_none")]
64 expand: Option<Vec<String>>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 limit: Option<i64>,
67 #[serde(skip_serializing_if = "Option::is_none")]
68 starting_after: Option<String>,
69}
70impl ListLineItemsTaxCalculationBuilder {
71 fn new() -> Self {
72 Self { ending_before: None, expand: None, limit: None, starting_after: None }
73 }
74}
75#[derive(Clone, Debug, serde::Serialize)]
77pub struct ListLineItemsTaxCalculation {
78 inner: ListLineItemsTaxCalculationBuilder,
79 calculation: stripe_misc::TaxCalculationId,
80}
81impl ListLineItemsTaxCalculation {
82 pub fn new(calculation: impl Into<stripe_misc::TaxCalculationId>) -> Self {
84 Self { calculation: calculation.into(), inner: ListLineItemsTaxCalculationBuilder::new() }
85 }
86 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
90 self.inner.ending_before = Some(ending_before.into());
91 self
92 }
93 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
95 self.inner.expand = Some(expand.into());
96 self
97 }
98 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
101 self.inner.limit = Some(limit.into());
102 self
103 }
104 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
108 self.inner.starting_after = Some(starting_after.into());
109 self
110 }
111}
112impl ListLineItemsTaxCalculation {
113 pub async fn send<C: StripeClient>(
115 &self,
116 client: &C,
117 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
118 self.customize().send(client).await
119 }
120
121 pub fn send_blocking<C: StripeBlockingClient>(
123 &self,
124 client: &C,
125 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
126 self.customize().send_blocking(client)
127 }
128
129 pub fn paginate(
130 &self,
131 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_misc::TaxCalculationLineItem>>
132 {
133 let calculation = &self.calculation;
134
135 stripe_client_core::ListPaginator::new_list(
136 format!("/tax/calculations/{calculation}/line_items"),
137 &self.inner,
138 )
139 }
140}
141
142impl StripeRequest for ListLineItemsTaxCalculation {
143 type Output = stripe_types::List<stripe_misc::TaxCalculationLineItem>;
144
145 fn build(&self) -> RequestBuilder {
146 let calculation = &self.calculation;
147 RequestBuilder::new(
148 StripeMethod::Get,
149 format!("/tax/calculations/{calculation}/line_items"),
150 )
151 .query(&self.inner)
152 }
153}
154#[derive(Clone, Debug, serde::Serialize)]
155struct CreateTaxCalculationBuilder {
156 currency: stripe_types::Currency,
157 #[serde(skip_serializing_if = "Option::is_none")]
158 customer: Option<String>,
159 #[serde(skip_serializing_if = "Option::is_none")]
160 customer_details: Option<CreateTaxCalculationCustomerDetails>,
161 #[serde(skip_serializing_if = "Option::is_none")]
162 expand: Option<Vec<String>>,
163 line_items: Vec<CreateTaxCalculationLineItems>,
164 #[serde(skip_serializing_if = "Option::is_none")]
165 ship_from_details: Option<CreateTaxCalculationShipFromDetails>,
166 #[serde(skip_serializing_if = "Option::is_none")]
167 shipping_cost: Option<CreateTaxCalculationShippingCost>,
168 #[serde(skip_serializing_if = "Option::is_none")]
169 tax_date: Option<stripe_types::Timestamp>,
170}
171impl CreateTaxCalculationBuilder {
172 fn new(
173 currency: impl Into<stripe_types::Currency>,
174 line_items: impl Into<Vec<CreateTaxCalculationLineItems>>,
175 ) -> Self {
176 Self {
177 currency: currency.into(),
178 customer: None,
179 customer_details: None,
180 expand: None,
181 line_items: line_items.into(),
182 ship_from_details: None,
183 shipping_cost: None,
184 tax_date: None,
185 }
186 }
187}
188#[derive(Clone, Debug, serde::Serialize)]
190pub struct CreateTaxCalculationCustomerDetails {
191 #[serde(skip_serializing_if = "Option::is_none")]
193 pub address: Option<CreateTaxCalculationCustomerDetailsAddress>,
194 #[serde(skip_serializing_if = "Option::is_none")]
196 pub address_source: Option<CreateTaxCalculationCustomerDetailsAddressSource>,
197 #[serde(skip_serializing_if = "Option::is_none")]
199 pub ip_address: Option<String>,
200 #[serde(skip_serializing_if = "Option::is_none")]
204 pub tax_ids: Option<Vec<CreateTaxCalculationCustomerDetailsTaxIds>>,
205 #[serde(skip_serializing_if = "Option::is_none")]
209 pub taxability_override: Option<CreateTaxCalculationCustomerDetailsTaxabilityOverride>,
210}
211impl CreateTaxCalculationCustomerDetails {
212 pub fn new() -> Self {
213 Self {
214 address: None,
215 address_source: None,
216 ip_address: None,
217 tax_ids: None,
218 taxability_override: None,
219 }
220 }
221}
222impl Default for CreateTaxCalculationCustomerDetails {
223 fn default() -> Self {
224 Self::new()
225 }
226}
227#[derive(Clone, Debug, serde::Serialize)]
229pub struct CreateTaxCalculationCustomerDetailsAddress {
230 #[serde(skip_serializing_if = "Option::is_none")]
232 pub city: Option<String>,
233 pub country: String,
235 #[serde(skip_serializing_if = "Option::is_none")]
237 pub line1: Option<String>,
238 #[serde(skip_serializing_if = "Option::is_none")]
240 pub line2: Option<String>,
241 #[serde(skip_serializing_if = "Option::is_none")]
243 pub postal_code: Option<String>,
244 #[serde(skip_serializing_if = "Option::is_none")]
247 pub state: Option<String>,
248}
249impl CreateTaxCalculationCustomerDetailsAddress {
250 pub fn new(country: impl Into<String>) -> Self {
251 Self {
252 city: None,
253 country: country.into(),
254 line1: None,
255 line2: None,
256 postal_code: None,
257 state: None,
258 }
259 }
260}
261#[derive(Clone, Eq, PartialEq)]
263#[non_exhaustive]
264pub enum CreateTaxCalculationCustomerDetailsAddressSource {
265 Billing,
266 Shipping,
267 Unknown(String),
269}
270impl CreateTaxCalculationCustomerDetailsAddressSource {
271 pub fn as_str(&self) -> &str {
272 use CreateTaxCalculationCustomerDetailsAddressSource::*;
273 match self {
274 Billing => "billing",
275 Shipping => "shipping",
276 Unknown(v) => v,
277 }
278 }
279}
280
281impl std::str::FromStr for CreateTaxCalculationCustomerDetailsAddressSource {
282 type Err = std::convert::Infallible;
283 fn from_str(s: &str) -> Result<Self, Self::Err> {
284 use CreateTaxCalculationCustomerDetailsAddressSource::*;
285 match s {
286 "billing" => Ok(Billing),
287 "shipping" => Ok(Shipping),
288 v => {
289 tracing::warn!(
290 "Unknown value '{}' for enum '{}'",
291 v,
292 "CreateTaxCalculationCustomerDetailsAddressSource"
293 );
294 Ok(Unknown(v.to_owned()))
295 }
296 }
297 }
298}
299impl std::fmt::Display for CreateTaxCalculationCustomerDetailsAddressSource {
300 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
301 f.write_str(self.as_str())
302 }
303}
304
305impl std::fmt::Debug for CreateTaxCalculationCustomerDetailsAddressSource {
306 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
307 f.write_str(self.as_str())
308 }
309}
310impl serde::Serialize for CreateTaxCalculationCustomerDetailsAddressSource {
311 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
312 where
313 S: serde::Serializer,
314 {
315 serializer.serialize_str(self.as_str())
316 }
317}
318#[cfg(feature = "deserialize")]
319impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsAddressSource {
320 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
321 use std::str::FromStr;
322 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
323 Ok(Self::from_str(&s).expect("infallible"))
324 }
325}
326#[derive(Clone, Debug, serde::Serialize)]
330pub struct CreateTaxCalculationCustomerDetailsTaxIds {
331 #[serde(rename = "type")]
333 pub type_: CreateTaxCalculationCustomerDetailsTaxIdsType,
334 pub value: String,
336}
337impl CreateTaxCalculationCustomerDetailsTaxIds {
338 pub fn new(
339 type_: impl Into<CreateTaxCalculationCustomerDetailsTaxIdsType>,
340 value: impl Into<String>,
341 ) -> Self {
342 Self { type_: type_.into(), value: value.into() }
343 }
344}
345#[derive(Clone, Eq, PartialEq)]
347#[non_exhaustive]
348pub enum CreateTaxCalculationCustomerDetailsTaxIdsType {
349 AdNrt,
350 AeTrn,
351 AlTin,
352 AmTin,
353 AoTin,
354 ArCuit,
355 AuAbn,
356 AuArn,
357 AwTin,
358 AzTin,
359 BaTin,
360 BbTin,
361 BdBin,
362 BfIfu,
363 BgUic,
364 BhVat,
365 BjIfu,
366 BoTin,
367 BrCnpj,
368 BrCpf,
369 BsTin,
370 ByTin,
371 CaBn,
372 CaGstHst,
373 CaPstBc,
374 CaPstMb,
375 CaPstSk,
376 CaQst,
377 CdNif,
378 ChUid,
379 ChVat,
380 ClTin,
381 CmNiu,
382 CnTin,
383 CoNit,
384 CrTin,
385 CvNif,
386 DeStn,
387 DoRcn,
388 EcRuc,
389 EgTin,
390 EsCif,
391 EtTin,
392 EuOssVat,
393 EuVat,
394 GbVat,
395 GeVat,
396 GnNif,
397 HkBr,
398 HrOib,
399 HuTin,
400 IdNpwp,
401 IlVat,
402 InGst,
403 IsVat,
404 JpCn,
405 JpRn,
406 JpTrn,
407 KePin,
408 KgTin,
409 KhTin,
410 KrBrn,
411 KzBin,
412 LaTin,
413 LiUid,
414 LiVat,
415 MaVat,
416 MdVat,
417 MePib,
418 MkVat,
419 MrNif,
420 MxRfc,
421 MyFrp,
422 MyItn,
423 MySst,
424 NgTin,
425 NoVat,
426 NoVoec,
427 NpPan,
428 NzGst,
429 OmVat,
430 PeRuc,
431 PhTin,
432 RoTin,
433 RsPib,
434 RuInn,
435 RuKpp,
436 SaVat,
437 SgGst,
438 SgUen,
439 SiTin,
440 SnNinea,
441 SrFin,
442 SvNit,
443 ThVat,
444 TjTin,
445 TrTin,
446 TwVat,
447 TzVat,
448 UaVat,
449 UgTin,
450 UsEin,
451 UyRuc,
452 UzTin,
453 UzVat,
454 VeRif,
455 VnTin,
456 ZaVat,
457 ZmTin,
458 ZwTin,
459 Unknown(String),
461}
462impl CreateTaxCalculationCustomerDetailsTaxIdsType {
463 pub fn as_str(&self) -> &str {
464 use CreateTaxCalculationCustomerDetailsTaxIdsType::*;
465 match self {
466 AdNrt => "ad_nrt",
467 AeTrn => "ae_trn",
468 AlTin => "al_tin",
469 AmTin => "am_tin",
470 AoTin => "ao_tin",
471 ArCuit => "ar_cuit",
472 AuAbn => "au_abn",
473 AuArn => "au_arn",
474 AwTin => "aw_tin",
475 AzTin => "az_tin",
476 BaTin => "ba_tin",
477 BbTin => "bb_tin",
478 BdBin => "bd_bin",
479 BfIfu => "bf_ifu",
480 BgUic => "bg_uic",
481 BhVat => "bh_vat",
482 BjIfu => "bj_ifu",
483 BoTin => "bo_tin",
484 BrCnpj => "br_cnpj",
485 BrCpf => "br_cpf",
486 BsTin => "bs_tin",
487 ByTin => "by_tin",
488 CaBn => "ca_bn",
489 CaGstHst => "ca_gst_hst",
490 CaPstBc => "ca_pst_bc",
491 CaPstMb => "ca_pst_mb",
492 CaPstSk => "ca_pst_sk",
493 CaQst => "ca_qst",
494 CdNif => "cd_nif",
495 ChUid => "ch_uid",
496 ChVat => "ch_vat",
497 ClTin => "cl_tin",
498 CmNiu => "cm_niu",
499 CnTin => "cn_tin",
500 CoNit => "co_nit",
501 CrTin => "cr_tin",
502 CvNif => "cv_nif",
503 DeStn => "de_stn",
504 DoRcn => "do_rcn",
505 EcRuc => "ec_ruc",
506 EgTin => "eg_tin",
507 EsCif => "es_cif",
508 EtTin => "et_tin",
509 EuOssVat => "eu_oss_vat",
510 EuVat => "eu_vat",
511 GbVat => "gb_vat",
512 GeVat => "ge_vat",
513 GnNif => "gn_nif",
514 HkBr => "hk_br",
515 HrOib => "hr_oib",
516 HuTin => "hu_tin",
517 IdNpwp => "id_npwp",
518 IlVat => "il_vat",
519 InGst => "in_gst",
520 IsVat => "is_vat",
521 JpCn => "jp_cn",
522 JpRn => "jp_rn",
523 JpTrn => "jp_trn",
524 KePin => "ke_pin",
525 KgTin => "kg_tin",
526 KhTin => "kh_tin",
527 KrBrn => "kr_brn",
528 KzBin => "kz_bin",
529 LaTin => "la_tin",
530 LiUid => "li_uid",
531 LiVat => "li_vat",
532 MaVat => "ma_vat",
533 MdVat => "md_vat",
534 MePib => "me_pib",
535 MkVat => "mk_vat",
536 MrNif => "mr_nif",
537 MxRfc => "mx_rfc",
538 MyFrp => "my_frp",
539 MyItn => "my_itn",
540 MySst => "my_sst",
541 NgTin => "ng_tin",
542 NoVat => "no_vat",
543 NoVoec => "no_voec",
544 NpPan => "np_pan",
545 NzGst => "nz_gst",
546 OmVat => "om_vat",
547 PeRuc => "pe_ruc",
548 PhTin => "ph_tin",
549 RoTin => "ro_tin",
550 RsPib => "rs_pib",
551 RuInn => "ru_inn",
552 RuKpp => "ru_kpp",
553 SaVat => "sa_vat",
554 SgGst => "sg_gst",
555 SgUen => "sg_uen",
556 SiTin => "si_tin",
557 SnNinea => "sn_ninea",
558 SrFin => "sr_fin",
559 SvNit => "sv_nit",
560 ThVat => "th_vat",
561 TjTin => "tj_tin",
562 TrTin => "tr_tin",
563 TwVat => "tw_vat",
564 TzVat => "tz_vat",
565 UaVat => "ua_vat",
566 UgTin => "ug_tin",
567 UsEin => "us_ein",
568 UyRuc => "uy_ruc",
569 UzTin => "uz_tin",
570 UzVat => "uz_vat",
571 VeRif => "ve_rif",
572 VnTin => "vn_tin",
573 ZaVat => "za_vat",
574 ZmTin => "zm_tin",
575 ZwTin => "zw_tin",
576 Unknown(v) => v,
577 }
578 }
579}
580
581impl std::str::FromStr for CreateTaxCalculationCustomerDetailsTaxIdsType {
582 type Err = std::convert::Infallible;
583 fn from_str(s: &str) -> Result<Self, Self::Err> {
584 use CreateTaxCalculationCustomerDetailsTaxIdsType::*;
585 match s {
586 "ad_nrt" => Ok(AdNrt),
587 "ae_trn" => Ok(AeTrn),
588 "al_tin" => Ok(AlTin),
589 "am_tin" => Ok(AmTin),
590 "ao_tin" => Ok(AoTin),
591 "ar_cuit" => Ok(ArCuit),
592 "au_abn" => Ok(AuAbn),
593 "au_arn" => Ok(AuArn),
594 "aw_tin" => Ok(AwTin),
595 "az_tin" => Ok(AzTin),
596 "ba_tin" => Ok(BaTin),
597 "bb_tin" => Ok(BbTin),
598 "bd_bin" => Ok(BdBin),
599 "bf_ifu" => Ok(BfIfu),
600 "bg_uic" => Ok(BgUic),
601 "bh_vat" => Ok(BhVat),
602 "bj_ifu" => Ok(BjIfu),
603 "bo_tin" => Ok(BoTin),
604 "br_cnpj" => Ok(BrCnpj),
605 "br_cpf" => Ok(BrCpf),
606 "bs_tin" => Ok(BsTin),
607 "by_tin" => Ok(ByTin),
608 "ca_bn" => Ok(CaBn),
609 "ca_gst_hst" => Ok(CaGstHst),
610 "ca_pst_bc" => Ok(CaPstBc),
611 "ca_pst_mb" => Ok(CaPstMb),
612 "ca_pst_sk" => Ok(CaPstSk),
613 "ca_qst" => Ok(CaQst),
614 "cd_nif" => Ok(CdNif),
615 "ch_uid" => Ok(ChUid),
616 "ch_vat" => Ok(ChVat),
617 "cl_tin" => Ok(ClTin),
618 "cm_niu" => Ok(CmNiu),
619 "cn_tin" => Ok(CnTin),
620 "co_nit" => Ok(CoNit),
621 "cr_tin" => Ok(CrTin),
622 "cv_nif" => Ok(CvNif),
623 "de_stn" => Ok(DeStn),
624 "do_rcn" => Ok(DoRcn),
625 "ec_ruc" => Ok(EcRuc),
626 "eg_tin" => Ok(EgTin),
627 "es_cif" => Ok(EsCif),
628 "et_tin" => Ok(EtTin),
629 "eu_oss_vat" => Ok(EuOssVat),
630 "eu_vat" => Ok(EuVat),
631 "gb_vat" => Ok(GbVat),
632 "ge_vat" => Ok(GeVat),
633 "gn_nif" => Ok(GnNif),
634 "hk_br" => Ok(HkBr),
635 "hr_oib" => Ok(HrOib),
636 "hu_tin" => Ok(HuTin),
637 "id_npwp" => Ok(IdNpwp),
638 "il_vat" => Ok(IlVat),
639 "in_gst" => Ok(InGst),
640 "is_vat" => Ok(IsVat),
641 "jp_cn" => Ok(JpCn),
642 "jp_rn" => Ok(JpRn),
643 "jp_trn" => Ok(JpTrn),
644 "ke_pin" => Ok(KePin),
645 "kg_tin" => Ok(KgTin),
646 "kh_tin" => Ok(KhTin),
647 "kr_brn" => Ok(KrBrn),
648 "kz_bin" => Ok(KzBin),
649 "la_tin" => Ok(LaTin),
650 "li_uid" => Ok(LiUid),
651 "li_vat" => Ok(LiVat),
652 "ma_vat" => Ok(MaVat),
653 "md_vat" => Ok(MdVat),
654 "me_pib" => Ok(MePib),
655 "mk_vat" => Ok(MkVat),
656 "mr_nif" => Ok(MrNif),
657 "mx_rfc" => Ok(MxRfc),
658 "my_frp" => Ok(MyFrp),
659 "my_itn" => Ok(MyItn),
660 "my_sst" => Ok(MySst),
661 "ng_tin" => Ok(NgTin),
662 "no_vat" => Ok(NoVat),
663 "no_voec" => Ok(NoVoec),
664 "np_pan" => Ok(NpPan),
665 "nz_gst" => Ok(NzGst),
666 "om_vat" => Ok(OmVat),
667 "pe_ruc" => Ok(PeRuc),
668 "ph_tin" => Ok(PhTin),
669 "ro_tin" => Ok(RoTin),
670 "rs_pib" => Ok(RsPib),
671 "ru_inn" => Ok(RuInn),
672 "ru_kpp" => Ok(RuKpp),
673 "sa_vat" => Ok(SaVat),
674 "sg_gst" => Ok(SgGst),
675 "sg_uen" => Ok(SgUen),
676 "si_tin" => Ok(SiTin),
677 "sn_ninea" => Ok(SnNinea),
678 "sr_fin" => Ok(SrFin),
679 "sv_nit" => Ok(SvNit),
680 "th_vat" => Ok(ThVat),
681 "tj_tin" => Ok(TjTin),
682 "tr_tin" => Ok(TrTin),
683 "tw_vat" => Ok(TwVat),
684 "tz_vat" => Ok(TzVat),
685 "ua_vat" => Ok(UaVat),
686 "ug_tin" => Ok(UgTin),
687 "us_ein" => Ok(UsEin),
688 "uy_ruc" => Ok(UyRuc),
689 "uz_tin" => Ok(UzTin),
690 "uz_vat" => Ok(UzVat),
691 "ve_rif" => Ok(VeRif),
692 "vn_tin" => Ok(VnTin),
693 "za_vat" => Ok(ZaVat),
694 "zm_tin" => Ok(ZmTin),
695 "zw_tin" => Ok(ZwTin),
696 v => {
697 tracing::warn!(
698 "Unknown value '{}' for enum '{}'",
699 v,
700 "CreateTaxCalculationCustomerDetailsTaxIdsType"
701 );
702 Ok(Unknown(v.to_owned()))
703 }
704 }
705 }
706}
707impl std::fmt::Display for CreateTaxCalculationCustomerDetailsTaxIdsType {
708 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
709 f.write_str(self.as_str())
710 }
711}
712
713impl std::fmt::Debug for CreateTaxCalculationCustomerDetailsTaxIdsType {
714 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
715 f.write_str(self.as_str())
716 }
717}
718impl serde::Serialize for CreateTaxCalculationCustomerDetailsTaxIdsType {
719 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
720 where
721 S: serde::Serializer,
722 {
723 serializer.serialize_str(self.as_str())
724 }
725}
726#[cfg(feature = "deserialize")]
727impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsTaxIdsType {
728 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
729 use std::str::FromStr;
730 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
731 Ok(Self::from_str(&s).expect("infallible"))
732 }
733}
734#[derive(Clone, Eq, PartialEq)]
738#[non_exhaustive]
739pub enum CreateTaxCalculationCustomerDetailsTaxabilityOverride {
740 CustomerExempt,
741 None,
742 ReverseCharge,
743 Unknown(String),
745}
746impl CreateTaxCalculationCustomerDetailsTaxabilityOverride {
747 pub fn as_str(&self) -> &str {
748 use CreateTaxCalculationCustomerDetailsTaxabilityOverride::*;
749 match self {
750 CustomerExempt => "customer_exempt",
751 None => "none",
752 ReverseCharge => "reverse_charge",
753 Unknown(v) => v,
754 }
755 }
756}
757
758impl std::str::FromStr for CreateTaxCalculationCustomerDetailsTaxabilityOverride {
759 type Err = std::convert::Infallible;
760 fn from_str(s: &str) -> Result<Self, Self::Err> {
761 use CreateTaxCalculationCustomerDetailsTaxabilityOverride::*;
762 match s {
763 "customer_exempt" => Ok(CustomerExempt),
764 "none" => Ok(None),
765 "reverse_charge" => Ok(ReverseCharge),
766 v => {
767 tracing::warn!(
768 "Unknown value '{}' for enum '{}'",
769 v,
770 "CreateTaxCalculationCustomerDetailsTaxabilityOverride"
771 );
772 Ok(Unknown(v.to_owned()))
773 }
774 }
775 }
776}
777impl std::fmt::Display for CreateTaxCalculationCustomerDetailsTaxabilityOverride {
778 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
779 f.write_str(self.as_str())
780 }
781}
782
783impl std::fmt::Debug for CreateTaxCalculationCustomerDetailsTaxabilityOverride {
784 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
785 f.write_str(self.as_str())
786 }
787}
788impl serde::Serialize for CreateTaxCalculationCustomerDetailsTaxabilityOverride {
789 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
790 where
791 S: serde::Serializer,
792 {
793 serializer.serialize_str(self.as_str())
794 }
795}
796#[cfg(feature = "deserialize")]
797impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsTaxabilityOverride {
798 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
799 use std::str::FromStr;
800 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
801 Ok(Self::from_str(&s).expect("infallible"))
802 }
803}
804#[derive(Clone, Debug, serde::Serialize)]
806pub struct CreateTaxCalculationLineItems {
807 pub amount: i64,
811 #[serde(skip_serializing_if = "Option::is_none")]
814 pub metadata: Option<std::collections::HashMap<String, String>>,
815 #[serde(skip_serializing_if = "Option::is_none")]
817 pub product: Option<String>,
818 #[serde(skip_serializing_if = "Option::is_none")]
822 pub quantity: Option<u64>,
823 #[serde(skip_serializing_if = "Option::is_none")]
826 pub reference: Option<String>,
827 #[serde(skip_serializing_if = "Option::is_none")]
829 pub tax_behavior: Option<CreateTaxCalculationLineItemsTaxBehavior>,
830 #[serde(skip_serializing_if = "Option::is_none")]
834 pub tax_code: Option<String>,
835}
836impl CreateTaxCalculationLineItems {
837 pub fn new(amount: impl Into<i64>) -> Self {
838 Self {
839 amount: amount.into(),
840 metadata: None,
841 product: None,
842 quantity: None,
843 reference: None,
844 tax_behavior: None,
845 tax_code: None,
846 }
847 }
848}
849#[derive(Clone, Eq, PartialEq)]
851#[non_exhaustive]
852pub enum CreateTaxCalculationLineItemsTaxBehavior {
853 Exclusive,
854 Inclusive,
855 Unknown(String),
857}
858impl CreateTaxCalculationLineItemsTaxBehavior {
859 pub fn as_str(&self) -> &str {
860 use CreateTaxCalculationLineItemsTaxBehavior::*;
861 match self {
862 Exclusive => "exclusive",
863 Inclusive => "inclusive",
864 Unknown(v) => v,
865 }
866 }
867}
868
869impl std::str::FromStr for CreateTaxCalculationLineItemsTaxBehavior {
870 type Err = std::convert::Infallible;
871 fn from_str(s: &str) -> Result<Self, Self::Err> {
872 use CreateTaxCalculationLineItemsTaxBehavior::*;
873 match s {
874 "exclusive" => Ok(Exclusive),
875 "inclusive" => Ok(Inclusive),
876 v => {
877 tracing::warn!(
878 "Unknown value '{}' for enum '{}'",
879 v,
880 "CreateTaxCalculationLineItemsTaxBehavior"
881 );
882 Ok(Unknown(v.to_owned()))
883 }
884 }
885 }
886}
887impl std::fmt::Display for CreateTaxCalculationLineItemsTaxBehavior {
888 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
889 f.write_str(self.as_str())
890 }
891}
892
893impl std::fmt::Debug for CreateTaxCalculationLineItemsTaxBehavior {
894 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
895 f.write_str(self.as_str())
896 }
897}
898impl serde::Serialize for CreateTaxCalculationLineItemsTaxBehavior {
899 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
900 where
901 S: serde::Serializer,
902 {
903 serializer.serialize_str(self.as_str())
904 }
905}
906#[cfg(feature = "deserialize")]
907impl<'de> serde::Deserialize<'de> for CreateTaxCalculationLineItemsTaxBehavior {
908 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
909 use std::str::FromStr;
910 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
911 Ok(Self::from_str(&s).expect("infallible"))
912 }
913}
914#[derive(Clone, Debug, serde::Serialize)]
916pub struct CreateTaxCalculationShipFromDetails {
917 pub address: CreateTaxCalculationShipFromDetailsAddress,
919}
920impl CreateTaxCalculationShipFromDetails {
921 pub fn new(address: impl Into<CreateTaxCalculationShipFromDetailsAddress>) -> Self {
922 Self { address: address.into() }
923 }
924}
925#[derive(Clone, Debug, serde::Serialize)]
927pub struct CreateTaxCalculationShipFromDetailsAddress {
928 #[serde(skip_serializing_if = "Option::is_none")]
930 pub city: Option<String>,
931 pub country: String,
933 #[serde(skip_serializing_if = "Option::is_none")]
935 pub line1: Option<String>,
936 #[serde(skip_serializing_if = "Option::is_none")]
938 pub line2: Option<String>,
939 #[serde(skip_serializing_if = "Option::is_none")]
941 pub postal_code: Option<String>,
942 #[serde(skip_serializing_if = "Option::is_none")]
944 pub state: Option<String>,
945}
946impl CreateTaxCalculationShipFromDetailsAddress {
947 pub fn new(country: impl Into<String>) -> Self {
948 Self {
949 city: None,
950 country: country.into(),
951 line1: None,
952 line2: None,
953 postal_code: None,
954 state: None,
955 }
956 }
957}
958#[derive(Clone, Debug, serde::Serialize)]
960pub struct CreateTaxCalculationShippingCost {
961 #[serde(skip_serializing_if = "Option::is_none")]
965 pub amount: Option<i64>,
966 #[serde(skip_serializing_if = "Option::is_none")]
969 pub shipping_rate: Option<String>,
970 #[serde(skip_serializing_if = "Option::is_none")]
974 pub tax_behavior: Option<CreateTaxCalculationShippingCostTaxBehavior>,
975 #[serde(skip_serializing_if = "Option::is_none")]
978 pub tax_code: Option<String>,
979}
980impl CreateTaxCalculationShippingCost {
981 pub fn new() -> Self {
982 Self { amount: None, shipping_rate: None, tax_behavior: None, tax_code: None }
983 }
984}
985impl Default for CreateTaxCalculationShippingCost {
986 fn default() -> Self {
987 Self::new()
988 }
989}
990#[derive(Clone, Eq, PartialEq)]
994#[non_exhaustive]
995pub enum CreateTaxCalculationShippingCostTaxBehavior {
996 Exclusive,
997 Inclusive,
998 Unknown(String),
1000}
1001impl CreateTaxCalculationShippingCostTaxBehavior {
1002 pub fn as_str(&self) -> &str {
1003 use CreateTaxCalculationShippingCostTaxBehavior::*;
1004 match self {
1005 Exclusive => "exclusive",
1006 Inclusive => "inclusive",
1007 Unknown(v) => v,
1008 }
1009 }
1010}
1011
1012impl std::str::FromStr for CreateTaxCalculationShippingCostTaxBehavior {
1013 type Err = std::convert::Infallible;
1014 fn from_str(s: &str) -> Result<Self, Self::Err> {
1015 use CreateTaxCalculationShippingCostTaxBehavior::*;
1016 match s {
1017 "exclusive" => Ok(Exclusive),
1018 "inclusive" => Ok(Inclusive),
1019 v => {
1020 tracing::warn!(
1021 "Unknown value '{}' for enum '{}'",
1022 v,
1023 "CreateTaxCalculationShippingCostTaxBehavior"
1024 );
1025 Ok(Unknown(v.to_owned()))
1026 }
1027 }
1028 }
1029}
1030impl std::fmt::Display for CreateTaxCalculationShippingCostTaxBehavior {
1031 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1032 f.write_str(self.as_str())
1033 }
1034}
1035
1036impl std::fmt::Debug for CreateTaxCalculationShippingCostTaxBehavior {
1037 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1038 f.write_str(self.as_str())
1039 }
1040}
1041impl serde::Serialize for CreateTaxCalculationShippingCostTaxBehavior {
1042 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1043 where
1044 S: serde::Serializer,
1045 {
1046 serializer.serialize_str(self.as_str())
1047 }
1048}
1049#[cfg(feature = "deserialize")]
1050impl<'de> serde::Deserialize<'de> for CreateTaxCalculationShippingCostTaxBehavior {
1051 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1052 use std::str::FromStr;
1053 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1054 Ok(Self::from_str(&s).expect("infallible"))
1055 }
1056}
1057#[derive(Clone, Debug, serde::Serialize)]
1059pub struct CreateTaxCalculation {
1060 inner: CreateTaxCalculationBuilder,
1061}
1062impl CreateTaxCalculation {
1063 pub fn new(
1065 currency: impl Into<stripe_types::Currency>,
1066 line_items: impl Into<Vec<CreateTaxCalculationLineItems>>,
1067 ) -> Self {
1068 Self { inner: CreateTaxCalculationBuilder::new(currency.into(), line_items.into()) }
1069 }
1070 pub fn customer(mut self, customer: impl Into<String>) -> Self {
1073 self.inner.customer = Some(customer.into());
1074 self
1075 }
1076 pub fn customer_details(
1078 mut self,
1079 customer_details: impl Into<CreateTaxCalculationCustomerDetails>,
1080 ) -> Self {
1081 self.inner.customer_details = Some(customer_details.into());
1082 self
1083 }
1084 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
1086 self.inner.expand = Some(expand.into());
1087 self
1088 }
1089 pub fn ship_from_details(
1091 mut self,
1092 ship_from_details: impl Into<CreateTaxCalculationShipFromDetails>,
1093 ) -> Self {
1094 self.inner.ship_from_details = Some(ship_from_details.into());
1095 self
1096 }
1097 pub fn shipping_cost(
1099 mut self,
1100 shipping_cost: impl Into<CreateTaxCalculationShippingCost>,
1101 ) -> Self {
1102 self.inner.shipping_cost = Some(shipping_cost.into());
1103 self
1104 }
1105 pub fn tax_date(mut self, tax_date: impl Into<stripe_types::Timestamp>) -> Self {
1109 self.inner.tax_date = Some(tax_date.into());
1110 self
1111 }
1112}
1113impl CreateTaxCalculation {
1114 pub async fn send<C: StripeClient>(
1116 &self,
1117 client: &C,
1118 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1119 self.customize().send(client).await
1120 }
1121
1122 pub fn send_blocking<C: StripeBlockingClient>(
1124 &self,
1125 client: &C,
1126 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1127 self.customize().send_blocking(client)
1128 }
1129}
1130
1131impl StripeRequest for CreateTaxCalculation {
1132 type Output = stripe_misc::TaxCalculation;
1133
1134 fn build(&self) -> RequestBuilder {
1135 RequestBuilder::new(StripeMethod::Post, "/tax/calculations").form(&self.inner)
1136 }
1137}