paypal_rust/resources/
amount_breakdown.rs1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3
4use crate::resources::money::Money;
5
6#[skip_serializing_none]
7#[derive(Clone, Debug, Default, Deserialize, Serialize)]
8pub struct AmountBreakdown {
9 pub item_total: Option<Money>,
12
13 pub shipping: Option<Money>,
15
16 pub handling: Option<Money>,
18
19 pub tax_total: Option<Money>,
22
23 pub insurance: Option<Money>,
25
26 pub shipping_discount: Option<Money>,
28
29 pub discount: Option<Money>,
31}
32
33impl AmountBreakdown {
34 #[must_use]
35 pub const fn new() -> Self {
36 Self {
37 item_total: None,
38 shipping: None,
39 handling: None,
40 tax_total: None,
41 insurance: None,
42 shipping_discount: None,
43 discount: None,
44 }
45 }
46
47 #[must_use]
48 pub fn item_total(mut self, item_total: Money) -> Self {
49 self.item_total = Some(item_total);
50 self
51 }
52
53 #[must_use]
54 pub fn shipping(mut self, shipping: Money) -> Self {
55 self.shipping = Some(shipping);
56 self
57 }
58
59 #[must_use]
60 pub fn handling(mut self, handling: Money) -> Self {
61 self.handling = Some(handling);
62 self
63 }
64
65 #[must_use]
66 pub fn tax_total(mut self, tax_total: Money) -> Self {
67 self.tax_total = Some(tax_total);
68 self
69 }
70
71 #[must_use]
72 pub fn insurance(mut self, insurance: Money) -> Self {
73 self.insurance = Some(insurance);
74 self
75 }
76
77 #[must_use]
78 pub fn shipping_discount(mut self, shipping_discount: Money) -> Self {
79 self.shipping_discount = Some(shipping_discount);
80 self
81 }
82
83 #[must_use]
84 pub fn discount(mut self, discount: Money) -> Self {
85 self.discount = Some(discount);
86 self
87 }
88}