1pub mod error {
3 pub struct ConversionError(::std::borrow::Cow<'static, str>);
5 impl ::std::error::Error for ConversionError {}
6 impl ::std::fmt::Display for ConversionError {
7 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
8 ::std::fmt::Display::fmt(&self.0, f)
9 }
10 }
11 impl ::std::fmt::Debug for ConversionError {
12 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
13 ::std::fmt::Debug::fmt(&self.0, f)
14 }
15 }
16 impl From<&'static str> for ConversionError {
17 fn from(value: &'static str) -> Self {
18 Self(value.into())
19 }
20 }
21 impl From<String> for ConversionError {
22 fn from(value: String) -> Self {
23 Self(value.into())
24 }
25 }
26}
27#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
49#[serde(deny_unknown_fields)]
50pub struct AchPayment {
51 pub routing_number: AchPaymentRoutingNumber,
52}
53impl From<&AchPayment> for AchPayment {
54 fn from(value: &AchPayment) -> Self {
55 value.clone()
56 }
57}
58impl AchPayment {
59 pub fn builder() -> builder::AchPayment {
60 Default::default()
61 }
62}
63#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75pub struct AchPaymentRoutingNumber(String);
76impl ::std::ops::Deref for AchPaymentRoutingNumber {
77 type Target = String;
78 fn deref(&self) -> &String {
79 &self.0
80 }
81}
82impl From<AchPaymentRoutingNumber> for String {
83 fn from(value: AchPaymentRoutingNumber) -> Self {
84 value.0
85 }
86}
87impl From<&AchPaymentRoutingNumber> for AchPaymentRoutingNumber {
88 fn from(value: &AchPaymentRoutingNumber) -> Self {
89 value.clone()
90 }
91}
92impl ::std::str::FromStr for AchPaymentRoutingNumber {
93 type Err = self::error::ConversionError;
94 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
95 if regress::Regex::new("^\\d{9}$")
96 .unwrap()
97 .find(value)
98 .is_none()
99 {
100 return Err("doesn't match pattern \"^\\d{9}$\"".into());
101 }
102 Ok(Self(value.to_string()))
103 }
104}
105impl ::std::convert::TryFrom<&str> for AchPaymentRoutingNumber {
106 type Error = self::error::ConversionError;
107 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
108 value.parse()
109 }
110}
111impl ::std::convert::TryFrom<&String> for AchPaymentRoutingNumber {
112 type Error = self::error::ConversionError;
113 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
114 value.parse()
115 }
116}
117impl ::std::convert::TryFrom<String> for AchPaymentRoutingNumber {
118 type Error = self::error::ConversionError;
119 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
120 value.parse()
121 }
122}
123impl<'de> ::serde::Deserialize<'de> for AchPaymentRoutingNumber {
124 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
125 where
126 D: ::serde::Deserializer<'de>,
127 {
128 String::deserialize(deserializer)?
129 .parse()
130 .map_err(|e: self::error::ConversionError| {
131 <D::Error as ::serde::de::Error>::custom(e.to_string())
132 })
133 }
134}
135#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
161#[serde(deny_unknown_fields)]
162pub struct Action {
163 pub name: String,
164 pub url: String,
165}
166impl From<&Action> for Action {
167 fn from(value: &Action) -> Self {
168 value.clone()
169 }
170}
171impl Action {
172 pub fn builder() -> builder::Action {
173 Default::default()
174 }
175}
176#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
262#[serde(deny_unknown_fields)]
263pub struct Address {
264 #[serde(default, skip_serializing_if = "Option::is_none")]
265 pub city: Option<String>,
266 #[serde(default, skip_serializing_if = "Option::is_none")]
267 pub country: Option<AddressCountry>,
268 #[serde(default, skip_serializing_if = "Option::is_none")]
269 pub lat: Option<f64>,
270 #[serde(default, skip_serializing_if = "Option::is_none")]
271 pub lon: Option<f64>,
272 #[serde(default, skip_serializing_if = "Option::is_none")]
273 pub postal_code: Option<String>,
274 #[serde(default, skip_serializing_if = "Option::is_none")]
275 pub region: Option<AddressRegion>,
276 #[serde(default, skip_serializing_if = "Option::is_none")]
277 pub street_address: Option<String>,
278 #[serde(default, skip_serializing_if = "Option::is_none")]
279 pub tz: Option<String>,
280}
281impl From<&Address> for Address {
282 fn from(value: &Address) -> Self {
283 value.clone()
284 }
285}
286impl Address {
287 pub fn builder() -> builder::Address {
288 Default::default()
289 }
290}
291#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
304pub struct AddressCountry(String);
305impl ::std::ops::Deref for AddressCountry {
306 type Target = String;
307 fn deref(&self) -> &String {
308 &self.0
309 }
310}
311impl From<AddressCountry> for String {
312 fn from(value: AddressCountry) -> Self {
313 value.0
314 }
315}
316impl From<&AddressCountry> for AddressCountry {
317 fn from(value: &AddressCountry) -> Self {
318 value.clone()
319 }
320}
321impl ::std::str::FromStr for AddressCountry {
322 type Err = self::error::ConversionError;
323 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
324 if value.len() > 2usize {
325 return Err("longer than 2 characters".into());
326 }
327 if value.len() < 2usize {
328 return Err("shorter than 2 characters".into());
329 }
330 Ok(Self(value.to_string()))
331 }
332}
333impl ::std::convert::TryFrom<&str> for AddressCountry {
334 type Error = self::error::ConversionError;
335 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
336 value.parse()
337 }
338}
339impl ::std::convert::TryFrom<&String> for AddressCountry {
340 type Error = self::error::ConversionError;
341 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
342 value.parse()
343 }
344}
345impl ::std::convert::TryFrom<String> for AddressCountry {
346 type Error = self::error::ConversionError;
347 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
348 value.parse()
349 }
350}
351impl<'de> ::serde::Deserialize<'de> for AddressCountry {
352 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
353 where
354 D: ::serde::Deserializer<'de>,
355 {
356 String::deserialize(deserializer)?
357 .parse()
358 .map_err(|e: self::error::ConversionError| {
359 <D::Error as ::serde::de::Error>::custom(e.to_string())
360 })
361 }
362}
363#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
375pub struct AddressRegion(String);
376impl ::std::ops::Deref for AddressRegion {
377 type Target = String;
378 fn deref(&self) -> &String {
379 &self.0
380 }
381}
382impl From<AddressRegion> for String {
383 fn from(value: AddressRegion) -> Self {
384 value.0
385 }
386}
387impl From<&AddressRegion> for AddressRegion {
388 fn from(value: &AddressRegion) -> Self {
389 value.clone()
390 }
391}
392impl ::std::str::FromStr for AddressRegion {
393 type Err = self::error::ConversionError;
394 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
395 if regress::Regex::new("^[a-zA-Z0-9]{1,3}$")
396 .unwrap()
397 .find(value)
398 .is_none()
399 {
400 return Err("doesn't match pattern \"^[a-zA-Z0-9]{1,3}$\"".into());
401 }
402 Ok(Self(value.to_string()))
403 }
404}
405impl ::std::convert::TryFrom<&str> for AddressRegion {
406 type Error = self::error::ConversionError;
407 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
408 value.parse()
409 }
410}
411impl ::std::convert::TryFrom<&String> for AddressRegion {
412 type Error = self::error::ConversionError;
413 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
414 value.parse()
415 }
416}
417impl ::std::convert::TryFrom<String> for AddressRegion {
418 type Error = self::error::ConversionError;
419 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
420 value.parse()
421 }
422}
423impl<'de> ::serde::Deserialize<'de> for AddressRegion {
424 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
425 where
426 D: ::serde::Deserializer<'de>,
427 {
428 String::deserialize(deserializer)?
429 .parse()
430 .map_err(|e: self::error::ConversionError| {
431 <D::Error as ::serde::de::Error>::custom(e.to_string())
432 })
433 }
434}
435#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
480#[serde(deny_unknown_fields)]
481pub struct Adjustment {
482 pub adjustment_type: AdjustmentType,
483 pub amount: i64,
484 #[serde(default, skip_serializing_if = "Option::is_none")]
485 pub name: Option<String>,
486 #[serde(default, skip_serializing_if = "Option::is_none")]
487 pub rate: Option<f64>,
488}
489impl From<&Adjustment> for Adjustment {
490 fn from(value: &Adjustment) -> Self {
491 value.clone()
492 }
493}
494impl Adjustment {
495 pub fn builder() -> builder::Adjustment {
496 Default::default()
497 }
498}
499#[derive(
518 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
519)]
520pub enum AdjustmentType {
521 #[serde(rename = "add_on")]
522 AddOn,
523 #[serde(rename = "discount")]
524 Discount,
525 #[serde(rename = "fee")]
526 Fee,
527 #[serde(rename = "other")]
528 Other,
529 #[serde(rename = "tip")]
530 Tip,
531}
532impl From<&AdjustmentType> for AdjustmentType {
533 fn from(value: &AdjustmentType) -> Self {
534 value.clone()
535 }
536}
537impl ::std::fmt::Display for AdjustmentType {
538 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
539 match *self {
540 Self::AddOn => write!(f, "add_on"),
541 Self::Discount => write!(f, "discount"),
542 Self::Fee => write!(f, "fee"),
543 Self::Other => write!(f, "other"),
544 Self::Tip => write!(f, "tip"),
545 }
546 }
547}
548impl std::str::FromStr for AdjustmentType {
549 type Err = self::error::ConversionError;
550 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
551 match value {
552 "add_on" => Ok(Self::AddOn),
553 "discount" => Ok(Self::Discount),
554 "fee" => Ok(Self::Fee),
555 "other" => Ok(Self::Other),
556 "tip" => Ok(Self::Tip),
557 _ => Err("invalid value".into()),
558 }
559 }
560}
561impl std::convert::TryFrom<&str> for AdjustmentType {
562 type Error = self::error::ConversionError;
563 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
564 value.parse()
565 }
566}
567impl std::convert::TryFrom<&String> for AdjustmentType {
568 type Error = self::error::ConversionError;
569 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
570 value.parse()
571 }
572}
573impl std::convert::TryFrom<String> for AdjustmentType {
574 type Error = self::error::ConversionError;
575 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
576 value.parse()
577 }
578}
579#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
725#[serde(deny_unknown_fields)]
726pub struct CarRental {
727 #[serde(default, skip_serializing_if = "Option::is_none")]
728 pub confirmation_number: Option<String>,
729 #[serde(default, skip_serializing_if = "Option::is_none")]
730 pub drivers: Option<Vec<Person>>,
731 #[serde(default, skip_serializing_if = "Option::is_none")]
732 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
733 pub items: Vec<Item>,
734 #[serde(default, skip_serializing_if = "Option::is_none")]
735 pub metadata: Option<Vec<Metadatum>>,
736 pub odometer_reading_in: i64,
737 pub odometer_reading_out: i64,
738 #[serde(default, skip_serializing_if = "Option::is_none")]
739 pub record_locator: Option<String>,
740 pub rental_at: i64,
741 pub rental_location: Place,
742 pub return_at: i64,
743 pub return_location: Place,
744 #[serde(default, skip_serializing_if = "Option::is_none")]
745 pub vehicle: Option<CarRentalVehicle>,
746 #[serde(default, skip_serializing_if = "Option::is_none")]
747 pub vendor_code: Option<CarRentalVendorCode>,
748}
749impl From<&CarRental> for CarRental {
750 fn from(value: &CarRental) -> Self {
751 value.clone()
752 }
753}
754impl CarRental {
755 pub fn builder() -> builder::CarRental {
756 Default::default()
757 }
758}
759#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
799#[serde(deny_unknown_fields)]
800pub struct CarRentalVehicle {
801 pub description: String,
802 #[serde(default, skip_serializing_if = "Option::is_none")]
803 pub image: Option<String>,
804 #[serde(default, skip_serializing_if = "Option::is_none")]
805 pub license_plate_number: Option<String>,
806 #[serde(default, skip_serializing_if = "Option::is_none")]
807 pub vehicle_class: Option<CarRentalVehicleVehicleClass>,
808}
809impl From<&CarRentalVehicle> for CarRentalVehicle {
810 fn from(value: &CarRentalVehicle) -> Self {
811 value.clone()
812 }
813}
814impl CarRentalVehicle {
815 pub fn builder() -> builder::CarRentalVehicle {
816 Default::default()
817 }
818}
819#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
831pub struct CarRentalVehicleVehicleClass(String);
832impl ::std::ops::Deref for CarRentalVehicleVehicleClass {
833 type Target = String;
834 fn deref(&self) -> &String {
835 &self.0
836 }
837}
838impl From<CarRentalVehicleVehicleClass> for String {
839 fn from(value: CarRentalVehicleVehicleClass) -> Self {
840 value.0
841 }
842}
843impl From<&CarRentalVehicleVehicleClass> for CarRentalVehicleVehicleClass {
844 fn from(value: &CarRentalVehicleVehicleClass) -> Self {
845 value.clone()
846 }
847}
848impl ::std::str::FromStr for CarRentalVehicleVehicleClass {
849 type Err = self::error::ConversionError;
850 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
851 if regress::Regex::new("^[a-zA-Z]{4}$")
852 .unwrap()
853 .find(value)
854 .is_none()
855 {
856 return Err("doesn't match pattern \"^[a-zA-Z]{4}$\"".into());
857 }
858 Ok(Self(value.to_string()))
859 }
860}
861impl ::std::convert::TryFrom<&str> for CarRentalVehicleVehicleClass {
862 type Error = self::error::ConversionError;
863 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
864 value.parse()
865 }
866}
867impl ::std::convert::TryFrom<&String> for CarRentalVehicleVehicleClass {
868 type Error = self::error::ConversionError;
869 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
870 value.parse()
871 }
872}
873impl ::std::convert::TryFrom<String> for CarRentalVehicleVehicleClass {
874 type Error = self::error::ConversionError;
875 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
876 value.parse()
877 }
878}
879impl<'de> ::serde::Deserialize<'de> for CarRentalVehicleVehicleClass {
880 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
881 where
882 D: ::serde::Deserializer<'de>,
883 {
884 String::deserialize(deserializer)?
885 .parse()
886 .map_err(|e: self::error::ConversionError| {
887 <D::Error as ::serde::de::Error>::custom(e.to_string())
888 })
889 }
890}
891#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
903pub struct CarRentalVendorCode(String);
904impl ::std::ops::Deref for CarRentalVendorCode {
905 type Target = String;
906 fn deref(&self) -> &String {
907 &self.0
908 }
909}
910impl From<CarRentalVendorCode> for String {
911 fn from(value: CarRentalVendorCode) -> Self {
912 value.0
913 }
914}
915impl From<&CarRentalVendorCode> for CarRentalVendorCode {
916 fn from(value: &CarRentalVendorCode) -> Self {
917 value.clone()
918 }
919}
920impl ::std::str::FromStr for CarRentalVendorCode {
921 type Err = self::error::ConversionError;
922 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
923 if regress::Regex::new("^[A-Z]{2}$")
924 .unwrap()
925 .find(value)
926 .is_none()
927 {
928 return Err("doesn't match pattern \"^[A-Z]{2}$\"".into());
929 }
930 Ok(Self(value.to_string()))
931 }
932}
933impl ::std::convert::TryFrom<&str> for CarRentalVendorCode {
934 type Error = self::error::ConversionError;
935 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
936 value.parse()
937 }
938}
939impl ::std::convert::TryFrom<&String> for CarRentalVendorCode {
940 type Error = self::error::ConversionError;
941 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
942 value.parse()
943 }
944}
945impl ::std::convert::TryFrom<String> for CarRentalVendorCode {
946 type Error = self::error::ConversionError;
947 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
948 value.parse()
949 }
950}
951impl<'de> ::serde::Deserialize<'de> for CarRentalVendorCode {
952 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
953 where
954 D: ::serde::Deserializer<'de>,
955 {
956 String::deserialize(deserializer)?
957 .parse()
958 .map_err(|e: self::error::ConversionError| {
959 <D::Error as ::serde::de::Error>::custom(e.to_string())
960 })
961 }
962}
963#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1005#[serde(deny_unknown_fields)]
1006pub struct CardPayment {
1007 pub last_four: CardPaymentLastFour,
1008 #[serde(default, skip_serializing_if = "Option::is_none")]
1009 pub network: Option<CardPaymentNetwork>,
1010}
1011impl From<&CardPayment> for CardPayment {
1012 fn from(value: &CardPayment) -> Self {
1013 value.clone()
1014 }
1015}
1016impl CardPayment {
1017 pub fn builder() -> builder::CardPayment {
1018 Default::default()
1019 }
1020}
1021#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1033pub struct CardPaymentLastFour(String);
1034impl ::std::ops::Deref for CardPaymentLastFour {
1035 type Target = String;
1036 fn deref(&self) -> &String {
1037 &self.0
1038 }
1039}
1040impl From<CardPaymentLastFour> for String {
1041 fn from(value: CardPaymentLastFour) -> Self {
1042 value.0
1043 }
1044}
1045impl From<&CardPaymentLastFour> for CardPaymentLastFour {
1046 fn from(value: &CardPaymentLastFour) -> Self {
1047 value.clone()
1048 }
1049}
1050impl ::std::str::FromStr for CardPaymentLastFour {
1051 type Err = self::error::ConversionError;
1052 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1053 if regress::Regex::new("^\\d{4}$")
1054 .unwrap()
1055 .find(value)
1056 .is_none()
1057 {
1058 return Err("doesn't match pattern \"^\\d{4}$\"".into());
1059 }
1060 Ok(Self(value.to_string()))
1061 }
1062}
1063impl ::std::convert::TryFrom<&str> for CardPaymentLastFour {
1064 type Error = self::error::ConversionError;
1065 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1066 value.parse()
1067 }
1068}
1069impl ::std::convert::TryFrom<&String> for CardPaymentLastFour {
1070 type Error = self::error::ConversionError;
1071 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1072 value.parse()
1073 }
1074}
1075impl ::std::convert::TryFrom<String> for CardPaymentLastFour {
1076 type Error = self::error::ConversionError;
1077 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1078 value.parse()
1079 }
1080}
1081impl<'de> ::serde::Deserialize<'de> for CardPaymentLastFour {
1082 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1083 where
1084 D: ::serde::Deserializer<'de>,
1085 {
1086 String::deserialize(deserializer)?
1087 .parse()
1088 .map_err(|e: self::error::ConversionError| {
1089 <D::Error as ::serde::de::Error>::custom(e.to_string())
1090 })
1091 }
1092}
1093#[derive(
1114 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
1115)]
1116pub enum CardPaymentNetwork {
1117 #[serde(rename = "amex")]
1118 Amex,
1119 #[serde(rename = "diners")]
1120 Diners,
1121 #[serde(rename = "discover")]
1122 Discover,
1123 #[serde(rename = "eftpos_au")]
1124 EftposAu,
1125 #[serde(rename = "jcb")]
1126 Jcb,
1127 #[serde(rename = "mastercard")]
1128 Mastercard,
1129 #[serde(rename = "unionpay")]
1130 Unionpay,
1131 #[serde(rename = "visa")]
1132 Visa,
1133}
1134impl From<&CardPaymentNetwork> for CardPaymentNetwork {
1135 fn from(value: &CardPaymentNetwork) -> Self {
1136 value.clone()
1137 }
1138}
1139impl ::std::fmt::Display for CardPaymentNetwork {
1140 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1141 match *self {
1142 Self::Amex => write!(f, "amex"),
1143 Self::Diners => write!(f, "diners"),
1144 Self::Discover => write!(f, "discover"),
1145 Self::EftposAu => write!(f, "eftpos_au"),
1146 Self::Jcb => write!(f, "jcb"),
1147 Self::Mastercard => write!(f, "mastercard"),
1148 Self::Unionpay => write!(f, "unionpay"),
1149 Self::Visa => write!(f, "visa"),
1150 }
1151 }
1152}
1153impl std::str::FromStr for CardPaymentNetwork {
1154 type Err = self::error::ConversionError;
1155 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1156 match value {
1157 "amex" => Ok(Self::Amex),
1158 "diners" => Ok(Self::Diners),
1159 "discover" => Ok(Self::Discover),
1160 "eftpos_au" => Ok(Self::EftposAu),
1161 "jcb" => Ok(Self::Jcb),
1162 "mastercard" => Ok(Self::Mastercard),
1163 "unionpay" => Ok(Self::Unionpay),
1164 "visa" => Ok(Self::Visa),
1165 _ => Err("invalid value".into()),
1166 }
1167 }
1168}
1169impl std::convert::TryFrom<&str> for CardPaymentNetwork {
1170 type Error = self::error::ConversionError;
1171 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1172 value.parse()
1173 }
1174}
1175impl std::convert::TryFrom<&String> for CardPaymentNetwork {
1176 type Error = self::error::ConversionError;
1177 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1178 value.parse()
1179 }
1180}
1181impl std::convert::TryFrom<String> for CardPaymentNetwork {
1182 type Error = self::error::ConversionError;
1183 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1184 value.parse()
1185 }
1186}
1187#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1201pub struct Currency(String);
1202impl ::std::ops::Deref for Currency {
1203 type Target = String;
1204 fn deref(&self) -> &String {
1205 &self.0
1206 }
1207}
1208impl From<Currency> for String {
1209 fn from(value: Currency) -> Self {
1210 value.0
1211 }
1212}
1213impl From<&Currency> for Currency {
1214 fn from(value: &Currency) -> Self {
1215 value.clone()
1216 }
1217}
1218impl ::std::str::FromStr for Currency {
1219 type Err = self::error::ConversionError;
1220 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1221 if regress::Regex::new("^[a-z]{3}$")
1222 .unwrap()
1223 .find(value)
1224 .is_none()
1225 {
1226 return Err("doesn't match pattern \"^[a-z]{3}$\"".into());
1227 }
1228 Ok(Self(value.to_string()))
1229 }
1230}
1231impl ::std::convert::TryFrom<&str> for Currency {
1232 type Error = self::error::ConversionError;
1233 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1234 value.parse()
1235 }
1236}
1237impl ::std::convert::TryFrom<&String> for Currency {
1238 type Error = self::error::ConversionError;
1239 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1240 value.parse()
1241 }
1242}
1243impl ::std::convert::TryFrom<String> for Currency {
1244 type Error = self::error::ConversionError;
1245 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1246 value.parse()
1247 }
1248}
1249impl<'de> ::serde::Deserialize<'de> for Currency {
1250 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1251 where
1252 D: ::serde::Deserializer<'de>,
1253 {
1254 String::deserialize(deserializer)?
1255 .parse()
1256 .map_err(|e: self::error::ConversionError| {
1257 <D::Error as ::serde::de::Error>::custom(e.to_string())
1258 })
1259 }
1260}
1261#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1338#[serde(deny_unknown_fields)]
1339pub struct Customer {
1340 #[serde(default, skip_serializing_if = "Option::is_none")]
1341 pub address: Option<Address>,
1342 #[serde(default, skip_serializing_if = "Option::is_none")]
1343 pub booker: Option<Person>,
1344 #[serde(default, skip_serializing_if = "Option::is_none")]
1345 pub email: Option<String>,
1346 #[serde(default, skip_serializing_if = "Option::is_none")]
1347 pub metadata: Option<Vec<Metadatum>>,
1348 pub name: String,
1349 #[serde(default, skip_serializing_if = "Option::is_none")]
1350 pub phone: Option<CustomerPhone>,
1351 #[serde(default, skip_serializing_if = "Option::is_none")]
1352 pub website: Option<String>,
1353}
1354impl From<&Customer> for Customer {
1355 fn from(value: &Customer) -> Self {
1356 value.clone()
1357 }
1358}
1359impl Customer {
1360 pub fn builder() -> builder::Customer {
1361 Default::default()
1362 }
1363}
1364#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1376pub struct CustomerPhone(String);
1377impl ::std::ops::Deref for CustomerPhone {
1378 type Target = String;
1379 fn deref(&self) -> &String {
1380 &self.0
1381 }
1382}
1383impl From<CustomerPhone> for String {
1384 fn from(value: CustomerPhone) -> Self {
1385 value.0
1386 }
1387}
1388impl From<&CustomerPhone> for CustomerPhone {
1389 fn from(value: &CustomerPhone) -> Self {
1390 value.clone()
1391 }
1392}
1393impl ::std::str::FromStr for CustomerPhone {
1394 type Err = self::error::ConversionError;
1395 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1396 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
1397 .unwrap()
1398 .find(value)
1399 .is_none()
1400 {
1401 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
1402 }
1403 Ok(Self(value.to_string()))
1404 }
1405}
1406impl ::std::convert::TryFrom<&str> for CustomerPhone {
1407 type Error = self::error::ConversionError;
1408 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1409 value.parse()
1410 }
1411}
1412impl ::std::convert::TryFrom<&String> for CustomerPhone {
1413 type Error = self::error::ConversionError;
1414 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1415 value.parse()
1416 }
1417}
1418impl ::std::convert::TryFrom<String> for CustomerPhone {
1419 type Error = self::error::ConversionError;
1420 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1421 value.parse()
1422 }
1423}
1424impl<'de> ::serde::Deserialize<'de> for CustomerPhone {
1425 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1426 where
1427 D: ::serde::Deserializer<'de>,
1428 {
1429 String::deserialize(deserializer)?
1430 .parse()
1431 .map_err(|e: self::error::ConversionError| {
1432 <D::Error as ::serde::de::Error>::custom(e.to_string())
1433 })
1434 }
1435}
1436#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1461#[serde(deny_unknown_fields)]
1462pub struct Doc {
1463 pub body: String,
1464 pub title: String,
1465}
1466impl From<&Doc> for Doc {
1467 fn from(value: &Doc) -> Self {
1468 value.clone()
1469 }
1470}
1471impl Doc {
1472 pub fn builder() -> builder::Doc {
1473 Default::default()
1474 }
1475}
1476#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1526#[serde(deny_unknown_fields)]
1527pub struct Ecommerce {
1528 #[serde(default, skip_serializing_if = "Option::is_none")]
1529 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
1530 #[serde(default, skip_serializing_if = "Option::is_none")]
1531 pub invoice_level_line_items: Option<Vec<Item>>,
1532 pub shipments: Vec<Shipment>,
1533}
1534impl From<&Ecommerce> for Ecommerce {
1535 fn from(value: &Ecommerce) -> Self {
1536 value.clone()
1537 }
1538}
1539impl Ecommerce {
1540 pub fn builder() -> builder::Ecommerce {
1541 Default::default()
1542 }
1543}
1544#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1588#[serde(deny_unknown_fields)]
1589pub struct Flight {
1590 #[serde(default, skip_serializing_if = "Option::is_none")]
1591 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
1592 #[serde(default, skip_serializing_if = "Option::is_none")]
1593 pub itinerary_locator: Option<String>,
1594 pub tickets: Vec<FlightTicket>,
1595}
1596impl From<&Flight> for Flight {
1597 fn from(value: &Flight) -> Self {
1598 value.clone()
1599 }
1600}
1601impl Flight {
1602 pub fn builder() -> builder::Flight {
1603 Default::default()
1604 }
1605}
1606#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1731#[serde(deny_unknown_fields)]
1732pub struct FlightSegment {
1733 #[serde(default, skip_serializing_if = "Option::is_none")]
1734 pub adjustments: Option<Vec<Adjustment>>,
1735 #[serde(default, skip_serializing_if = "Option::is_none")]
1736 pub aircraft_type: Option<FlightSegmentAircraftType>,
1737 pub arrival_airport_code: FlightSegmentArrivalAirportCode,
1738 #[serde(default, skip_serializing_if = "Option::is_none")]
1739 pub arrival_at: Option<i64>,
1740 #[serde(default, skip_serializing_if = "Option::is_none")]
1741 pub arrival_tz: Option<String>,
1742 #[serde(default, skip_serializing_if = "Option::is_none")]
1743 pub class_of_service: Option<String>,
1744 pub departure_airport_code: FlightSegmentDepartureAirportCode,
1745 #[serde(default, skip_serializing_if = "Option::is_none")]
1746 pub departure_at: Option<i64>,
1747 #[serde(default, skip_serializing_if = "Option::is_none")]
1748 pub departure_tz: Option<String>,
1749 #[serde(default, skip_serializing_if = "Option::is_none")]
1750 pub fare: Option<i64>,
1751 #[serde(default, skip_serializing_if = "Option::is_none")]
1752 pub flight_number: Option<String>,
1753 #[serde(default, skip_serializing_if = "Option::is_none")]
1754 pub metadata: Option<Vec<Metadatum>>,
1755 #[serde(default, skip_serializing_if = "Option::is_none")]
1756 pub seat: Option<String>,
1757 #[serde(default, skip_serializing_if = "Option::is_none")]
1758 pub taxes: Option<Vec<Tax>>,
1759}
1760impl From<&FlightSegment> for FlightSegment {
1761 fn from(value: &FlightSegment) -> Self {
1762 value.clone()
1763 }
1764}
1765impl FlightSegment {
1766 pub fn builder() -> builder::FlightSegment {
1767 Default::default()
1768 }
1769}
1770#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1782pub struct FlightSegmentAircraftType(String);
1783impl ::std::ops::Deref for FlightSegmentAircraftType {
1784 type Target = String;
1785 fn deref(&self) -> &String {
1786 &self.0
1787 }
1788}
1789impl From<FlightSegmentAircraftType> for String {
1790 fn from(value: FlightSegmentAircraftType) -> Self {
1791 value.0
1792 }
1793}
1794impl From<&FlightSegmentAircraftType> for FlightSegmentAircraftType {
1795 fn from(value: &FlightSegmentAircraftType) -> Self {
1796 value.clone()
1797 }
1798}
1799impl ::std::str::FromStr for FlightSegmentAircraftType {
1800 type Err = self::error::ConversionError;
1801 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1802 if regress::Regex::new("^[a-zA-Z0-9]{2,4}$")
1803 .unwrap()
1804 .find(value)
1805 .is_none()
1806 {
1807 return Err("doesn't match pattern \"^[a-zA-Z0-9]{2,4}$\"".into());
1808 }
1809 Ok(Self(value.to_string()))
1810 }
1811}
1812impl ::std::convert::TryFrom<&str> for FlightSegmentAircraftType {
1813 type Error = self::error::ConversionError;
1814 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1815 value.parse()
1816 }
1817}
1818impl ::std::convert::TryFrom<&String> for FlightSegmentAircraftType {
1819 type Error = self::error::ConversionError;
1820 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1821 value.parse()
1822 }
1823}
1824impl ::std::convert::TryFrom<String> for FlightSegmentAircraftType {
1825 type Error = self::error::ConversionError;
1826 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1827 value.parse()
1828 }
1829}
1830impl<'de> ::serde::Deserialize<'de> for FlightSegmentAircraftType {
1831 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1832 where
1833 D: ::serde::Deserializer<'de>,
1834 {
1835 String::deserialize(deserializer)?
1836 .parse()
1837 .map_err(|e: self::error::ConversionError| {
1838 <D::Error as ::serde::de::Error>::custom(e.to_string())
1839 })
1840 }
1841}
1842#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1854pub struct FlightSegmentArrivalAirportCode(String);
1855impl ::std::ops::Deref for FlightSegmentArrivalAirportCode {
1856 type Target = String;
1857 fn deref(&self) -> &String {
1858 &self.0
1859 }
1860}
1861impl From<FlightSegmentArrivalAirportCode> for String {
1862 fn from(value: FlightSegmentArrivalAirportCode) -> Self {
1863 value.0
1864 }
1865}
1866impl From<&FlightSegmentArrivalAirportCode> for FlightSegmentArrivalAirportCode {
1867 fn from(value: &FlightSegmentArrivalAirportCode) -> Self {
1868 value.clone()
1869 }
1870}
1871impl ::std::str::FromStr for FlightSegmentArrivalAirportCode {
1872 type Err = self::error::ConversionError;
1873 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1874 if regress::Regex::new("^[a-zA-Z]{3}$")
1875 .unwrap()
1876 .find(value)
1877 .is_none()
1878 {
1879 return Err("doesn't match pattern \"^[a-zA-Z]{3}$\"".into());
1880 }
1881 Ok(Self(value.to_string()))
1882 }
1883}
1884impl ::std::convert::TryFrom<&str> for FlightSegmentArrivalAirportCode {
1885 type Error = self::error::ConversionError;
1886 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1887 value.parse()
1888 }
1889}
1890impl ::std::convert::TryFrom<&String> for FlightSegmentArrivalAirportCode {
1891 type Error = self::error::ConversionError;
1892 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1893 value.parse()
1894 }
1895}
1896impl ::std::convert::TryFrom<String> for FlightSegmentArrivalAirportCode {
1897 type Error = self::error::ConversionError;
1898 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1899 value.parse()
1900 }
1901}
1902impl<'de> ::serde::Deserialize<'de> for FlightSegmentArrivalAirportCode {
1903 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1904 where
1905 D: ::serde::Deserializer<'de>,
1906 {
1907 String::deserialize(deserializer)?
1908 .parse()
1909 .map_err(|e: self::error::ConversionError| {
1910 <D::Error as ::serde::de::Error>::custom(e.to_string())
1911 })
1912 }
1913}
1914#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1926pub struct FlightSegmentDepartureAirportCode(String);
1927impl ::std::ops::Deref for FlightSegmentDepartureAirportCode {
1928 type Target = String;
1929 fn deref(&self) -> &String {
1930 &self.0
1931 }
1932}
1933impl From<FlightSegmentDepartureAirportCode> for String {
1934 fn from(value: FlightSegmentDepartureAirportCode) -> Self {
1935 value.0
1936 }
1937}
1938impl From<&FlightSegmentDepartureAirportCode> for FlightSegmentDepartureAirportCode {
1939 fn from(value: &FlightSegmentDepartureAirportCode) -> Self {
1940 value.clone()
1941 }
1942}
1943impl ::std::str::FromStr for FlightSegmentDepartureAirportCode {
1944 type Err = self::error::ConversionError;
1945 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1946 if regress::Regex::new("^[a-zA-Z]{3}$")
1947 .unwrap()
1948 .find(value)
1949 .is_none()
1950 {
1951 return Err("doesn't match pattern \"^[a-zA-Z]{3}$\"".into());
1952 }
1953 Ok(Self(value.to_string()))
1954 }
1955}
1956impl ::std::convert::TryFrom<&str> for FlightSegmentDepartureAirportCode {
1957 type Error = self::error::ConversionError;
1958 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1959 value.parse()
1960 }
1961}
1962impl ::std::convert::TryFrom<&String> for FlightSegmentDepartureAirportCode {
1963 type Error = self::error::ConversionError;
1964 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1965 value.parse()
1966 }
1967}
1968impl ::std::convert::TryFrom<String> for FlightSegmentDepartureAirportCode {
1969 type Error = self::error::ConversionError;
1970 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1971 value.parse()
1972 }
1973}
1974impl<'de> ::serde::Deserialize<'de> for FlightSegmentDepartureAirportCode {
1975 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1976 where
1977 D: ::serde::Deserializer<'de>,
1978 {
1979 String::deserialize(deserializer)?
1980 .parse()
1981 .map_err(|e: self::error::ConversionError| {
1982 <D::Error as ::serde::de::Error>::custom(e.to_string())
1983 })
1984 }
1985}
1986#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2053#[serde(deny_unknown_fields)]
2054pub struct FlightTicket {
2055 #[serde(default, skip_serializing_if = "Option::is_none")]
2057 pub fare: Option<i64>,
2058 #[serde(default, skip_serializing_if = "Option::is_none")]
2059 pub number: Option<String>,
2060 #[serde(default, skip_serializing_if = "Option::is_none")]
2061 pub passenger: Option<Person>,
2062 #[serde(default, skip_serializing_if = "Option::is_none")]
2063 pub record_locator: Option<String>,
2064 pub segments: Vec<FlightSegment>,
2065 #[serde(default, skip_serializing_if = "Option::is_none")]
2066 pub taxes: Option<Vec<Tax>>,
2067}
2068impl From<&FlightTicket> for FlightTicket {
2069 fn from(value: &FlightTicket) -> Self {
2070 value.clone()
2071 }
2072}
2073impl FlightTicket {
2074 pub fn builder() -> builder::FlightTicket {
2075 Default::default()
2076 }
2077}
2078#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2112#[serde(deny_unknown_fields)]
2113pub struct Footer {
2114 #[serde(default, skip_serializing_if = "Option::is_none")]
2115 pub actions: Option<Vec<Action>>,
2116 #[serde(default, skip_serializing_if = "Option::is_none")]
2117 pub supplemental_text: Option<String>,
2118}
2119impl From<&Footer> for Footer {
2120 fn from(value: &Footer) -> Self {
2121 value.clone()
2122 }
2123}
2124impl Footer {
2125 pub fn builder() -> builder::Footer {
2126 Default::default()
2127 }
2128}
2129#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2167#[serde(deny_unknown_fields)]
2168pub struct GeneralItemization {
2169 #[serde(default, skip_serializing_if = "Option::is_none")]
2170 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
2171 pub items: Vec<Item>,
2172}
2173impl From<&GeneralItemization> for GeneralItemization {
2174 fn from(value: &GeneralItemization) -> Self {
2175 value.clone()
2176 }
2177}
2178impl GeneralItemization {
2179 pub fn builder() -> builder::GeneralItemization {
2180 Default::default()
2181 }
2182}
2183#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2308#[serde(deny_unknown_fields)]
2309pub struct Header {
2310 pub currency: Currency,
2312 #[serde(default, skip_serializing_if = "Option::is_none")]
2313 pub customer: Option<Customer>,
2314 #[serde(default, skip_serializing_if = "Option::is_none")]
2315 pub invoice_asset_id: Option<String>,
2316 #[serde(default, skip_serializing_if = "Option::is_none")]
2317 pub invoice_number: Option<String>,
2318 pub invoiced_at: i64,
2319 #[serde(default, skip_serializing_if = "Option::is_none")]
2320 pub location: Option<Place>,
2321 #[serde(default, skip_serializing_if = "Option::is_none")]
2322 pub mcc: Option<HeaderMcc>,
2323 pub paid: i64,
2324 #[serde(default, skip_serializing_if = "Option::is_none")]
2325 pub receipt_asset_id: Option<String>,
2326 pub subtotal: i64,
2327 #[serde(default, skip_serializing_if = "Option::is_none")]
2328 pub third_party: Option<HeaderThirdParty>,
2329 pub total: i64,
2330}
2331impl From<&Header> for Header {
2332 fn from(value: &Header) -> Self {
2333 value.clone()
2334 }
2335}
2336impl Header {
2337 pub fn builder() -> builder::Header {
2338 Default::default()
2339 }
2340}
2341#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2353pub struct HeaderMcc(String);
2354impl ::std::ops::Deref for HeaderMcc {
2355 type Target = String;
2356 fn deref(&self) -> &String {
2357 &self.0
2358 }
2359}
2360impl From<HeaderMcc> for String {
2361 fn from(value: HeaderMcc) -> Self {
2362 value.0
2363 }
2364}
2365impl From<&HeaderMcc> for HeaderMcc {
2366 fn from(value: &HeaderMcc) -> Self {
2367 value.clone()
2368 }
2369}
2370impl ::std::str::FromStr for HeaderMcc {
2371 type Err = self::error::ConversionError;
2372 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2373 if regress::Regex::new("^\\d{4}$")
2374 .unwrap()
2375 .find(value)
2376 .is_none()
2377 {
2378 return Err("doesn't match pattern \"^\\d{4}$\"".into());
2379 }
2380 Ok(Self(value.to_string()))
2381 }
2382}
2383impl ::std::convert::TryFrom<&str> for HeaderMcc {
2384 type Error = self::error::ConversionError;
2385 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2386 value.parse()
2387 }
2388}
2389impl ::std::convert::TryFrom<&String> for HeaderMcc {
2390 type Error = self::error::ConversionError;
2391 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2392 value.parse()
2393 }
2394}
2395impl ::std::convert::TryFrom<String> for HeaderMcc {
2396 type Error = self::error::ConversionError;
2397 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2398 value.parse()
2399 }
2400}
2401impl<'de> ::serde::Deserialize<'de> for HeaderMcc {
2402 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2403 where
2404 D: ::serde::Deserializer<'de>,
2405 {
2406 String::deserialize(deserializer)?
2407 .parse()
2408 .map_err(|e: self::error::ConversionError| {
2409 <D::Error as ::serde::de::Error>::custom(e.to_string())
2410 })
2411 }
2412}
2413#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2456#[serde(deny_unknown_fields)]
2457pub struct HeaderThirdParty {
2458 pub make_primary: bool,
2460 #[serde(default, skip_serializing_if = "Option::is_none")]
2461 pub merchant: Option<Org>,
2462 pub relation: HeaderThirdPartyRelation,
2463}
2464impl From<&HeaderThirdParty> for HeaderThirdParty {
2465 fn from(value: &HeaderThirdParty) -> Self {
2466 value.clone()
2467 }
2468}
2469impl HeaderThirdParty {
2470 pub fn builder() -> builder::HeaderThirdParty {
2471 Default::default()
2472 }
2473}
2474#[derive(
2493 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
2494)]
2495pub enum HeaderThirdPartyRelation {
2496 #[serde(rename = "bnpl")]
2497 Bnpl,
2498 #[serde(rename = "delivery_service")]
2499 DeliveryService,
2500 #[serde(rename = "marketplace")]
2501 Marketplace,
2502 #[serde(rename = "payment_processor")]
2503 PaymentProcessor,
2504 #[serde(rename = "platform")]
2505 Platform,
2506 #[serde(rename = "point_of_sale")]
2507 PointOfSale,
2508}
2509impl From<&HeaderThirdPartyRelation> for HeaderThirdPartyRelation {
2510 fn from(value: &HeaderThirdPartyRelation) -> Self {
2511 value.clone()
2512 }
2513}
2514impl ::std::fmt::Display for HeaderThirdPartyRelation {
2515 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2516 match *self {
2517 Self::Bnpl => write!(f, "bnpl"),
2518 Self::DeliveryService => write!(f, "delivery_service"),
2519 Self::Marketplace => write!(f, "marketplace"),
2520 Self::PaymentProcessor => write!(f, "payment_processor"),
2521 Self::Platform => write!(f, "platform"),
2522 Self::PointOfSale => write!(f, "point_of_sale"),
2523 }
2524 }
2525}
2526impl std::str::FromStr for HeaderThirdPartyRelation {
2527 type Err = self::error::ConversionError;
2528 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2529 match value {
2530 "bnpl" => Ok(Self::Bnpl),
2531 "delivery_service" => Ok(Self::DeliveryService),
2532 "marketplace" => Ok(Self::Marketplace),
2533 "payment_processor" => Ok(Self::PaymentProcessor),
2534 "platform" => Ok(Self::Platform),
2535 "point_of_sale" => Ok(Self::PointOfSale),
2536 _ => Err("invalid value".into()),
2537 }
2538 }
2539}
2540impl std::convert::TryFrom<&str> for HeaderThirdPartyRelation {
2541 type Error = self::error::ConversionError;
2542 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2543 value.parse()
2544 }
2545}
2546impl std::convert::TryFrom<&String> for HeaderThirdPartyRelation {
2547 type Error = self::error::ConversionError;
2548 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2549 value.parse()
2550 }
2551}
2552impl std::convert::TryFrom<String> for HeaderThirdPartyRelation {
2553 type Error = self::error::ConversionError;
2554 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2555 value.parse()
2556 }
2557}
2558#[derive(
2576 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
2577)]
2578pub enum Interval {
2579 #[serde(rename = "day")]
2580 Day,
2581 #[serde(rename = "week")]
2582 Week,
2583 #[serde(rename = "month")]
2584 Month,
2585 #[serde(rename = "year")]
2586 Year,
2587}
2588impl From<&Interval> for Interval {
2589 fn from(value: &Interval) -> Self {
2590 value.clone()
2591 }
2592}
2593impl ::std::fmt::Display for Interval {
2594 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2595 match *self {
2596 Self::Day => write!(f, "day"),
2597 Self::Week => write!(f, "week"),
2598 Self::Month => write!(f, "month"),
2599 Self::Year => write!(f, "year"),
2600 }
2601 }
2602}
2603impl std::str::FromStr for Interval {
2604 type Err = self::error::ConversionError;
2605 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2606 match value {
2607 "day" => Ok(Self::Day),
2608 "week" => Ok(Self::Week),
2609 "month" => Ok(Self::Month),
2610 "year" => Ok(Self::Year),
2611 _ => Err("invalid value".into()),
2612 }
2613 }
2614}
2615impl std::convert::TryFrom<&str> for Interval {
2616 type Error = self::error::ConversionError;
2617 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2618 value.parse()
2619 }
2620}
2621impl std::convert::TryFrom<&String> for Interval {
2622 type Error = self::error::ConversionError;
2623 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2624 value.parse()
2625 }
2626}
2627impl std::convert::TryFrom<String> for Interval {
2628 type Error = self::error::ConversionError;
2629 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2630 value.parse()
2631 }
2632}
2633#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2760#[serde(deny_unknown_fields)]
2761pub struct Item {
2762 #[serde(default, skip_serializing_if = "Option::is_none")]
2763 pub adjustments: Option<Vec<Adjustment>>,
2764 pub amount: i64,
2765 #[serde(default, skip_serializing_if = "Option::is_none")]
2766 pub date: Option<String>,
2767 pub description: String,
2768 #[serde(default, skip_serializing_if = "Option::is_none")]
2769 pub group: Option<String>,
2770 #[serde(default, skip_serializing_if = "Option::is_none")]
2771 pub metadata: Option<Vec<Metadatum>>,
2772 #[serde(default, skip_serializing_if = "Option::is_none")]
2773 pub product_image_asset_id: Option<String>,
2774 #[serde(default, skip_serializing_if = "Option::is_none")]
2775 pub quantity: Option<f64>,
2776 #[serde(default, skip_serializing_if = "Option::is_none")]
2777 pub taxes: Option<Vec<Tax>>,
2778 #[serde(default, skip_serializing_if = "Option::is_none")]
2779 pub unit: Option<String>,
2780 #[serde(default, skip_serializing_if = "Option::is_none")]
2781 pub unit_cost: Option<i64>,
2782 #[serde(default, skip_serializing_if = "Option::is_none")]
2783 pub unspsc: Option<ItemUnspsc>,
2784 #[serde(default, skip_serializing_if = "Option::is_none")]
2785 pub url: Option<String>,
2786}
2787impl From<&Item> for Item {
2788 fn from(value: &Item) -> Self {
2789 value.clone()
2790 }
2791}
2792impl Item {
2793 pub fn builder() -> builder::Item {
2794 Default::default()
2795 }
2796}
2797#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2809pub struct ItemUnspsc(String);
2810impl ::std::ops::Deref for ItemUnspsc {
2811 type Target = String;
2812 fn deref(&self) -> &String {
2813 &self.0
2814 }
2815}
2816impl From<ItemUnspsc> for String {
2817 fn from(value: ItemUnspsc) -> Self {
2818 value.0
2819 }
2820}
2821impl From<&ItemUnspsc> for ItemUnspsc {
2822 fn from(value: &ItemUnspsc) -> Self {
2823 value.clone()
2824 }
2825}
2826impl ::std::str::FromStr for ItemUnspsc {
2827 type Err = self::error::ConversionError;
2828 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2829 if regress::Regex::new("^\\d{8}$")
2830 .unwrap()
2831 .find(value)
2832 .is_none()
2833 {
2834 return Err("doesn't match pattern \"^\\d{8}$\"".into());
2835 }
2836 Ok(Self(value.to_string()))
2837 }
2838}
2839impl ::std::convert::TryFrom<&str> for ItemUnspsc {
2840 type Error = self::error::ConversionError;
2841 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2842 value.parse()
2843 }
2844}
2845impl ::std::convert::TryFrom<&String> for ItemUnspsc {
2846 type Error = self::error::ConversionError;
2847 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2848 value.parse()
2849 }
2850}
2851impl ::std::convert::TryFrom<String> for ItemUnspsc {
2852 type Error = self::error::ConversionError;
2853 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2854 value.parse()
2855 }
2856}
2857impl<'de> ::serde::Deserialize<'de> for ItemUnspsc {
2858 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2859 where
2860 D: ::serde::Deserializer<'de>,
2861 {
2862 String::deserialize(deserializer)?
2863 .parse()
2864 .map_err(|e: self::error::ConversionError| {
2865 <D::Error as ::serde::de::Error>::custom(e.to_string())
2866 })
2867 }
2868}
2869#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2964#[serde(deny_unknown_fields)]
2965pub struct Itemization {
2966 #[serde(default, skip_serializing_if = "Option::is_none")]
2967 pub car_rental: Option<CarRental>,
2968 #[serde(default, skip_serializing_if = "Option::is_none")]
2969 pub ecommerce: Option<Ecommerce>,
2970 #[serde(default, skip_serializing_if = "Option::is_none")]
2971 pub flight: Option<Flight>,
2972 #[serde(default, skip_serializing_if = "Option::is_none")]
2973 pub general: Option<GeneralItemization>,
2974 #[serde(default, skip_serializing_if = "Option::is_none")]
2975 pub lodging: Option<Lodging>,
2976 #[serde(default, skip_serializing_if = "Option::is_none")]
2977 pub service: Option<Service>,
2978 #[serde(default, skip_serializing_if = "Option::is_none")]
2979 pub subscription: Option<Subscription>,
2980 #[serde(default, skip_serializing_if = "Option::is_none")]
2981 pub transit_route: Option<TransitRoute>,
2982}
2983impl From<&Itemization> for Itemization {
2984 fn from(value: &Itemization) -> Self {
2985 value.clone()
2986 }
2987}
2988impl Itemization {
2989 pub fn builder() -> builder::Itemization {
2990 Default::default()
2991 }
2992}
2993#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3101#[serde(deny_unknown_fields)]
3102pub struct Lodging {
3103 #[serde(default, skip_serializing_if = "Option::is_none")]
3104 pub chain_code: Option<LodgingChainCode>,
3105 pub check_in: i64,
3106 pub check_out: i64,
3107 #[serde(default, skip_serializing_if = "Option::is_none")]
3108 pub confirmation_number: Option<String>,
3109 #[serde(default, skip_serializing_if = "Option::is_none")]
3110 pub guests: Option<Vec<Person>>,
3111 #[serde(default, skip_serializing_if = "Option::is_none")]
3112 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
3113 pub items: Vec<Item>,
3114 pub location: Place,
3115 #[serde(default, skip_serializing_if = "Option::is_none")]
3116 pub metadata: Option<Vec<Metadatum>>,
3117 #[serde(default, skip_serializing_if = "Option::is_none")]
3118 pub property_id: Option<LodgingPropertyId>,
3119 #[serde(default, skip_serializing_if = "Option::is_none")]
3120 pub record_locator: Option<String>,
3121 #[serde(default, skip_serializing_if = "Option::is_none")]
3122 pub room: Option<String>,
3123}
3124impl From<&Lodging> for Lodging {
3125 fn from(value: &Lodging) -> Self {
3126 value.clone()
3127 }
3128}
3129impl Lodging {
3130 pub fn builder() -> builder::Lodging {
3131 Default::default()
3132 }
3133}
3134#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3146pub struct LodgingChainCode(String);
3147impl ::std::ops::Deref for LodgingChainCode {
3148 type Target = String;
3149 fn deref(&self) -> &String {
3150 &self.0
3151 }
3152}
3153impl From<LodgingChainCode> for String {
3154 fn from(value: LodgingChainCode) -> Self {
3155 value.0
3156 }
3157}
3158impl From<&LodgingChainCode> for LodgingChainCode {
3159 fn from(value: &LodgingChainCode) -> Self {
3160 value.clone()
3161 }
3162}
3163impl ::std::str::FromStr for LodgingChainCode {
3164 type Err = self::error::ConversionError;
3165 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3166 if regress::Regex::new("^[A-Z]{2}$")
3167 .unwrap()
3168 .find(value)
3169 .is_none()
3170 {
3171 return Err("doesn't match pattern \"^[A-Z]{2}$\"".into());
3172 }
3173 Ok(Self(value.to_string()))
3174 }
3175}
3176impl ::std::convert::TryFrom<&str> for LodgingChainCode {
3177 type Error = self::error::ConversionError;
3178 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3179 value.parse()
3180 }
3181}
3182impl ::std::convert::TryFrom<&String> for LodgingChainCode {
3183 type Error = self::error::ConversionError;
3184 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3185 value.parse()
3186 }
3187}
3188impl ::std::convert::TryFrom<String> for LodgingChainCode {
3189 type Error = self::error::ConversionError;
3190 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3191 value.parse()
3192 }
3193}
3194impl<'de> ::serde::Deserialize<'de> for LodgingChainCode {
3195 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3196 where
3197 D: ::serde::Deserializer<'de>,
3198 {
3199 String::deserialize(deserializer)?
3200 .parse()
3201 .map_err(|e: self::error::ConversionError| {
3202 <D::Error as ::serde::de::Error>::custom(e.to_string())
3203 })
3204 }
3205}
3206#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3218pub struct LodgingPropertyId(String);
3219impl ::std::ops::Deref for LodgingPropertyId {
3220 type Target = String;
3221 fn deref(&self) -> &String {
3222 &self.0
3223 }
3224}
3225impl From<LodgingPropertyId> for String {
3226 fn from(value: LodgingPropertyId) -> Self {
3227 value.0
3228 }
3229}
3230impl From<&LodgingPropertyId> for LodgingPropertyId {
3231 fn from(value: &LodgingPropertyId) -> Self {
3232 value.clone()
3233 }
3234}
3235impl ::std::str::FromStr for LodgingPropertyId {
3236 type Err = self::error::ConversionError;
3237 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3238 if regress::Regex::new("^(gds\\.[a-z]+|chain\\.[a-z]+|giata):[a-zA-Z0-9]+$")
3239 .unwrap()
3240 .find(value)
3241 .is_none()
3242 {
3243 return Err(
3244 "doesn't match pattern \"^(gds\\.[a-z]+|chain\\.[a-z]+|giata):[a-zA-Z0-9]+$\"".into(),
3245 );
3246 }
3247 Ok(Self(value.to_string()))
3248 }
3249}
3250impl ::std::convert::TryFrom<&str> for LodgingPropertyId {
3251 type Error = self::error::ConversionError;
3252 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3253 value.parse()
3254 }
3255}
3256impl ::std::convert::TryFrom<&String> for LodgingPropertyId {
3257 type Error = self::error::ConversionError;
3258 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3259 value.parse()
3260 }
3261}
3262impl ::std::convert::TryFrom<String> for LodgingPropertyId {
3263 type Error = self::error::ConversionError;
3264 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3265 value.parse()
3266 }
3267}
3268impl<'de> ::serde::Deserialize<'de> for LodgingPropertyId {
3269 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3270 where
3271 D: ::serde::Deserializer<'de>,
3272 {
3273 String::deserialize(deserializer)?
3274 .parse()
3275 .map_err(|e: self::error::ConversionError| {
3276 <D::Error as ::serde::de::Error>::custom(e.to_string())
3277 })
3278 }
3279}
3280#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3305#[serde(deny_unknown_fields)]
3306pub struct Metadatum {
3307 pub key: String,
3308 pub value: String,
3309}
3310impl From<&Metadatum> for Metadatum {
3311 fn from(value: &Metadatum) -> Self {
3312 value.clone()
3313 }
3314}
3315impl Metadatum {
3316 pub fn builder() -> builder::Metadatum {
3317 Default::default()
3318 }
3319}
3320#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3391#[serde(deny_unknown_fields)]
3392pub struct Org {
3393 #[serde(default, skip_serializing_if = "Option::is_none")]
3394 pub address: Option<Address>,
3395 #[serde(default, skip_serializing_if = "Option::is_none")]
3397 pub brand_color: Option<OrgBrandColor>,
3398 #[serde(default, skip_serializing_if = "Option::is_none")]
3399 pub legal_name: Option<String>,
3400 #[serde(default, skip_serializing_if = "Option::is_none")]
3401 pub logo: Option<String>,
3402 #[serde(default, skip_serializing_if = "Option::is_none")]
3403 pub logo_asset_id: Option<String>,
3404 pub name: String,
3405 #[serde(default, skip_serializing_if = "Option::is_none")]
3406 pub vat_number: Option<String>,
3407 #[serde(default, skip_serializing_if = "Option::is_none")]
3408 pub website: Option<String>,
3409}
3410impl From<&Org> for Org {
3411 fn from(value: &Org) -> Self {
3412 value.clone()
3413 }
3414}
3415impl Org {
3416 pub fn builder() -> builder::Org {
3417 Default::default()
3418 }
3419}
3420#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3433pub struct OrgBrandColor(String);
3434impl ::std::ops::Deref for OrgBrandColor {
3435 type Target = String;
3436 fn deref(&self) -> &String {
3437 &self.0
3438 }
3439}
3440impl From<OrgBrandColor> for String {
3441 fn from(value: OrgBrandColor) -> Self {
3442 value.0
3443 }
3444}
3445impl From<&OrgBrandColor> for OrgBrandColor {
3446 fn from(value: &OrgBrandColor) -> Self {
3447 value.clone()
3448 }
3449}
3450impl ::std::str::FromStr for OrgBrandColor {
3451 type Err = self::error::ConversionError;
3452 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3453 if regress::Regex::new("^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$")
3454 .unwrap()
3455 .find(value)
3456 .is_none()
3457 {
3458 return Err("doesn't match pattern \"^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\"".into());
3459 }
3460 Ok(Self(value.to_string()))
3461 }
3462}
3463impl ::std::convert::TryFrom<&str> for OrgBrandColor {
3464 type Error = self::error::ConversionError;
3465 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3466 value.parse()
3467 }
3468}
3469impl ::std::convert::TryFrom<&String> for OrgBrandColor {
3470 type Error = self::error::ConversionError;
3471 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3472 value.parse()
3473 }
3474}
3475impl ::std::convert::TryFrom<String> for OrgBrandColor {
3476 type Error = self::error::ConversionError;
3477 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3478 value.parse()
3479 }
3480}
3481impl<'de> ::serde::Deserialize<'de> for OrgBrandColor {
3482 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3483 where
3484 D: ::serde::Deserializer<'de>,
3485 {
3486 String::deserialize(deserializer)?
3487 .parse()
3488 .map_err(|e: self::error::ConversionError| {
3489 <D::Error as ::serde::de::Error>::custom(e.to_string())
3490 })
3491 }
3492}
3493#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3554#[serde(deny_unknown_fields)]
3555pub struct Payment {
3556 #[serde(default, skip_serializing_if = "Option::is_none")]
3557 pub ach_payment: Option<AchPayment>,
3558 pub amount: i64,
3559 #[serde(default, skip_serializing_if = "Option::is_none")]
3560 pub card_payment: Option<CardPayment>,
3561 pub paid_at: i64,
3562 #[serde(default, skip_serializing_if = "Option::is_none")]
3563 pub payment_type: Option<PaymentPaymentType>,
3564}
3565impl From<&Payment> for Payment {
3566 fn from(value: &Payment) -> Self {
3567 value.clone()
3568 }
3569}
3570impl Payment {
3571 pub fn builder() -> builder::Payment {
3572 Default::default()
3573 }
3574}
3575#[derive(
3590 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
3591)]
3592pub enum PaymentPaymentType {
3593 #[serde(rename = "card")]
3594 Card,
3595 #[serde(rename = "ach")]
3596 Ach,
3597}
3598impl From<&PaymentPaymentType> for PaymentPaymentType {
3599 fn from(value: &PaymentPaymentType) -> Self {
3600 value.clone()
3601 }
3602}
3603impl ::std::fmt::Display for PaymentPaymentType {
3604 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3605 match *self {
3606 Self::Card => write!(f, "card"),
3607 Self::Ach => write!(f, "ach"),
3608 }
3609 }
3610}
3611impl std::str::FromStr for PaymentPaymentType {
3612 type Err = self::error::ConversionError;
3613 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3614 match value {
3615 "card" => Ok(Self::Card),
3616 "ach" => Ok(Self::Ach),
3617 _ => Err("invalid value".into()),
3618 }
3619 }
3620}
3621impl std::convert::TryFrom<&str> for PaymentPaymentType {
3622 type Error = self::error::ConversionError;
3623 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3624 value.parse()
3625 }
3626}
3627impl std::convert::TryFrom<&String> for PaymentPaymentType {
3628 type Error = self::error::ConversionError;
3629 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3630 value.parse()
3631 }
3632}
3633impl std::convert::TryFrom<String> for PaymentPaymentType {
3634 type Error = self::error::ConversionError;
3635 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3636 value.parse()
3637 }
3638}
3639#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3701#[serde(deny_unknown_fields)]
3702pub struct Person {
3703 #[serde(default, skip_serializing_if = "Option::is_none")]
3704 pub email: Option<String>,
3705 #[serde(default, skip_serializing_if = "Option::is_none")]
3706 pub first_name: Option<String>,
3707 #[serde(default, skip_serializing_if = "Option::is_none")]
3708 pub last_name: Option<String>,
3709 #[serde(default, skip_serializing_if = "Option::is_none")]
3710 pub metadata: Option<Vec<Metadatum>>,
3711 #[serde(default, skip_serializing_if = "Option::is_none")]
3712 pub phone: Option<PersonPhone>,
3713 #[serde(default, skip_serializing_if = "Option::is_none")]
3714 pub preferred_first_name: Option<String>,
3715}
3716impl From<&Person> for Person {
3717 fn from(value: &Person) -> Self {
3718 value.clone()
3719 }
3720}
3721impl Person {
3722 pub fn builder() -> builder::Person {
3723 Default::default()
3724 }
3725}
3726#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3738pub struct PersonPhone(String);
3739impl ::std::ops::Deref for PersonPhone {
3740 type Target = String;
3741 fn deref(&self) -> &String {
3742 &self.0
3743 }
3744}
3745impl From<PersonPhone> for String {
3746 fn from(value: PersonPhone) -> Self {
3747 value.0
3748 }
3749}
3750impl From<&PersonPhone> for PersonPhone {
3751 fn from(value: &PersonPhone) -> Self {
3752 value.clone()
3753 }
3754}
3755impl ::std::str::FromStr for PersonPhone {
3756 type Err = self::error::ConversionError;
3757 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3758 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
3759 .unwrap()
3760 .find(value)
3761 .is_none()
3762 {
3763 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
3764 }
3765 Ok(Self(value.to_string()))
3766 }
3767}
3768impl ::std::convert::TryFrom<&str> for PersonPhone {
3769 type Error = self::error::ConversionError;
3770 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3771 value.parse()
3772 }
3773}
3774impl ::std::convert::TryFrom<&String> for PersonPhone {
3775 type Error = self::error::ConversionError;
3776 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3777 value.parse()
3778 }
3779}
3780impl ::std::convert::TryFrom<String> for PersonPhone {
3781 type Error = self::error::ConversionError;
3782 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3783 value.parse()
3784 }
3785}
3786impl<'de> ::serde::Deserialize<'de> for PersonPhone {
3787 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3788 where
3789 D: ::serde::Deserializer<'de>,
3790 {
3791 String::deserialize(deserializer)?
3792 .parse()
3793 .map_err(|e: self::error::ConversionError| {
3794 <D::Error as ::serde::de::Error>::custom(e.to_string())
3795 })
3796 }
3797}
3798#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3865#[serde(deny_unknown_fields)]
3866pub struct Place {
3867 #[serde(default, skip_serializing_if = "Option::is_none")]
3868 pub address: Option<Address>,
3869 #[serde(default, skip_serializing_if = "Option::is_none")]
3870 pub google_place_id: Option<String>,
3871 #[serde(default, skip_serializing_if = "Option::is_none")]
3872 pub image: Option<String>,
3873 #[serde(default, skip_serializing_if = "Option::is_none")]
3874 pub name: Option<String>,
3875 #[serde(default, skip_serializing_if = "Option::is_none")]
3876 pub phone: Option<PlacePhone>,
3877 #[serde(default, skip_serializing_if = "Option::is_none")]
3878 pub url: Option<String>,
3879}
3880impl From<&Place> for Place {
3881 fn from(value: &Place) -> Self {
3882 value.clone()
3883 }
3884}
3885impl Place {
3886 pub fn builder() -> builder::Place {
3887 Default::default()
3888 }
3889}
3890#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3902pub struct PlacePhone(String);
3903impl ::std::ops::Deref for PlacePhone {
3904 type Target = String;
3905 fn deref(&self) -> &String {
3906 &self.0
3907 }
3908}
3909impl From<PlacePhone> for String {
3910 fn from(value: PlacePhone) -> Self {
3911 value.0
3912 }
3913}
3914impl From<&PlacePhone> for PlacePhone {
3915 fn from(value: &PlacePhone) -> Self {
3916 value.clone()
3917 }
3918}
3919impl ::std::str::FromStr for PlacePhone {
3920 type Err = self::error::ConversionError;
3921 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3922 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
3923 .unwrap()
3924 .find(value)
3925 .is_none()
3926 {
3927 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
3928 }
3929 Ok(Self(value.to_string()))
3930 }
3931}
3932impl ::std::convert::TryFrom<&str> for PlacePhone {
3933 type Error = self::error::ConversionError;
3934 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3935 value.parse()
3936 }
3937}
3938impl ::std::convert::TryFrom<&String> for PlacePhone {
3939 type Error = self::error::ConversionError;
3940 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3941 value.parse()
3942 }
3943}
3944impl ::std::convert::TryFrom<String> for PlacePhone {
3945 type Error = self::error::ConversionError;
3946 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3947 value.parse()
3948 }
3949}
3950impl<'de> ::serde::Deserialize<'de> for PlacePhone {
3951 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3952 where
3953 D: ::serde::Deserializer<'de>,
3954 {
3955 String::deserialize(deserializer)?
3956 .parse()
3957 .map_err(|e: self::error::ConversionError| {
3958 <D::Error as ::serde::de::Error>::custom(e.to_string())
3959 })
3960 }
3961}
3962#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4008#[serde(deny_unknown_fields)]
4009pub struct Receipt {
4010 pub footer: Footer,
4011 pub header: Header,
4012 pub itemization: Itemization,
4013 pub payments: Vec<Payment>,
4014 pub schema_version: SchemaVersion,
4015}
4016impl From<&Receipt> for Receipt {
4017 fn from(value: &Receipt) -> Self {
4018 value.clone()
4019 }
4020}
4021impl Receipt {
4022 pub fn builder() -> builder::Receipt {
4023 Default::default()
4024 }
4025}
4026#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4041pub struct SchemaVersion(String);
4042impl ::std::ops::Deref for SchemaVersion {
4043 type Target = String;
4044 fn deref(&self) -> &String {
4045 &self.0
4046 }
4047}
4048impl From<SchemaVersion> for String {
4049 fn from(value: SchemaVersion) -> Self {
4050 value.0
4051 }
4052}
4053impl From<&SchemaVersion> for SchemaVersion {
4054 fn from(value: &SchemaVersion) -> Self {
4055 value.clone()
4056 }
4057}
4058impl ::std::str::FromStr for SchemaVersion {
4059 type Err = self::error::ConversionError;
4060 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4061 if value.len() > 14usize {
4062 return Err("longer than 14 characters".into());
4063 }
4064 if value.len() < 5usize {
4065 return Err("shorter than 5 characters".into());
4066 }
4067 if regress::Regex::new("^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$")
4068 .unwrap()
4069 .find(value)
4070 .is_none()
4071 {
4072 return Err(
4073 "doesn't match pattern \"^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$\"".into(),
4074 );
4075 }
4076 Ok(Self(value.to_string()))
4077 }
4078}
4079impl ::std::convert::TryFrom<&str> for SchemaVersion {
4080 type Error = self::error::ConversionError;
4081 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4082 value.parse()
4083 }
4084}
4085impl ::std::convert::TryFrom<&String> for SchemaVersion {
4086 type Error = self::error::ConversionError;
4087 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4088 value.parse()
4089 }
4090}
4091impl ::std::convert::TryFrom<String> for SchemaVersion {
4092 type Error = self::error::ConversionError;
4093 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4094 value.parse()
4095 }
4096}
4097impl<'de> ::serde::Deserialize<'de> for SchemaVersion {
4098 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4099 where
4100 D: ::serde::Deserializer<'de>,
4101 {
4102 String::deserialize(deserializer)?
4103 .parse()
4104 .map_err(|e: self::error::ConversionError| {
4105 <D::Error as ::serde::de::Error>::custom(e.to_string())
4106 })
4107 }
4108}
4109#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4147#[serde(deny_unknown_fields)]
4148pub struct Service {
4149 #[serde(default, skip_serializing_if = "Option::is_none")]
4150 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4151 pub service_items: Vec<ServiceItem>,
4152}
4153impl From<&Service> for Service {
4154 fn from(value: &Service) -> Self {
4155 value.clone()
4156 }
4157}
4158impl Service {
4159 pub fn builder() -> builder::Service {
4160 Default::default()
4161 }
4162}
4163#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4292#[serde(deny_unknown_fields)]
4293pub struct ServiceItem {
4294 #[serde(default, skip_serializing_if = "Option::is_none")]
4295 pub adjustments: Option<Vec<Adjustment>>,
4296 pub amount: i64,
4297 #[serde(default, skip_serializing_if = "Option::is_none")]
4298 pub current_period_end_at: Option<i64>,
4299 #[serde(default, skip_serializing_if = "Option::is_none")]
4300 pub current_period_start_at: Option<i64>,
4301 pub description: String,
4302 #[serde(default, skip_serializing_if = "Option::is_none")]
4303 pub interval: Option<Interval>,
4304 #[serde(default, skip_serializing_if = "Option::is_none")]
4305 pub interval_count: Option<i64>,
4306 #[serde(default, skip_serializing_if = "Option::is_none")]
4307 pub metadata: Option<Vec<Metadatum>>,
4308 #[serde(default, skip_serializing_if = "Option::is_none")]
4309 pub quantity: Option<f64>,
4310 pub recurring: bool,
4311 #[serde(default, skip_serializing_if = "Option::is_none")]
4312 pub service_location: Option<Place>,
4313 #[serde(default, skip_serializing_if = "Option::is_none")]
4314 pub taxes: Option<Vec<Tax>>,
4315 #[serde(default, skip_serializing_if = "Option::is_none")]
4316 pub unit_cost: Option<f64>,
4317}
4318impl From<&ServiceItem> for ServiceItem {
4319 fn from(value: &ServiceItem) -> Self {
4320 value.clone()
4321 }
4322}
4323impl ServiceItem {
4324 pub fn builder() -> builder::ServiceItem {
4325 Default::default()
4326 }
4327}
4328#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4398#[serde(deny_unknown_fields)]
4399pub struct Shipment {
4400 #[serde(default, skip_serializing_if = "Option::is_none")]
4401 pub carrier: Option<String>,
4402 #[serde(default, skip_serializing_if = "Option::is_none")]
4403 pub destination_address: Option<Address>,
4404 #[serde(default, skip_serializing_if = "Option::is_none")]
4405 pub expected_delivery_at: Option<i64>,
4406 pub items: Vec<Item>,
4407 #[serde(default, skip_serializing_if = "Option::is_none")]
4408 pub shipment_status: Option<ShipmentShipmentStatus>,
4409 #[serde(default, skip_serializing_if = "Option::is_none")]
4410 pub tracking_number: Option<String>,
4411}
4412impl From<&Shipment> for Shipment {
4413 fn from(value: &Shipment) -> Self {
4414 value.clone()
4415 }
4416}
4417impl Shipment {
4418 pub fn builder() -> builder::Shipment {
4419 Default::default()
4420 }
4421}
4422#[derive(
4438 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
4439)]
4440pub enum ShipmentShipmentStatus {
4441 #[serde(rename = "prep")]
4442 Prep,
4443 #[serde(rename = "in_transit")]
4444 InTransit,
4445 #[serde(rename = "delivered")]
4446 Delivered,
4447}
4448impl From<&ShipmentShipmentStatus> for ShipmentShipmentStatus {
4449 fn from(value: &ShipmentShipmentStatus) -> Self {
4450 value.clone()
4451 }
4452}
4453impl ::std::fmt::Display for ShipmentShipmentStatus {
4454 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4455 match *self {
4456 Self::Prep => write!(f, "prep"),
4457 Self::InTransit => write!(f, "in_transit"),
4458 Self::Delivered => write!(f, "delivered"),
4459 }
4460 }
4461}
4462impl std::str::FromStr for ShipmentShipmentStatus {
4463 type Err = self::error::ConversionError;
4464 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4465 match value {
4466 "prep" => Ok(Self::Prep),
4467 "in_transit" => Ok(Self::InTransit),
4468 "delivered" => Ok(Self::Delivered),
4469 _ => Err("invalid value".into()),
4470 }
4471 }
4472}
4473impl std::convert::TryFrom<&str> for ShipmentShipmentStatus {
4474 type Error = self::error::ConversionError;
4475 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4476 value.parse()
4477 }
4478}
4479impl std::convert::TryFrom<&String> for ShipmentShipmentStatus {
4480 type Error = self::error::ConversionError;
4481 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4482 value.parse()
4483 }
4484}
4485impl std::convert::TryFrom<String> for ShipmentShipmentStatus {
4486 type Error = self::error::ConversionError;
4487 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4488 value.parse()
4489 }
4490}
4491#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4529#[serde(deny_unknown_fields)]
4530pub struct Subscription {
4531 #[serde(default, skip_serializing_if = "Option::is_none")]
4532 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4533 pub subscription_items: Vec<SubscriptionItem>,
4534}
4535impl From<&Subscription> for Subscription {
4536 fn from(value: &Subscription) -> Self {
4537 value.clone()
4538 }
4539}
4540impl Subscription {
4541 pub fn builder() -> builder::Subscription {
4542 Default::default()
4543 }
4544}
4545#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4669#[serde(deny_unknown_fields)]
4670pub struct SubscriptionItem {
4671 #[serde(default, skip_serializing_if = "Option::is_none")]
4672 pub adjustments: Option<Vec<Adjustment>>,
4673 pub amount: i64,
4674 #[serde(default, skip_serializing_if = "Option::is_none")]
4675 pub current_period_end_at: Option<i64>,
4676 #[serde(default, skip_serializing_if = "Option::is_none")]
4677 pub current_period_start_at: Option<i64>,
4678 pub description: String,
4679 #[serde(default, skip_serializing_if = "Option::is_none")]
4680 pub interval: Option<Interval>,
4681 #[serde(default, skip_serializing_if = "Option::is_none")]
4682 pub interval_count: Option<i64>,
4683 #[serde(default, skip_serializing_if = "Option::is_none")]
4684 pub metadata: Option<Vec<Metadatum>>,
4685 #[serde(default, skip_serializing_if = "Option::is_none")]
4686 pub quantity: Option<f64>,
4687 pub subscription_type: SubscriptionType,
4688 #[serde(default, skip_serializing_if = "Option::is_none")]
4689 pub taxes: Option<Vec<Tax>>,
4690 #[serde(default, skip_serializing_if = "Option::is_none")]
4691 pub unit_cost: Option<f64>,
4692}
4693impl From<&SubscriptionItem> for SubscriptionItem {
4694 fn from(value: &SubscriptionItem) -> Self {
4695 value.clone()
4696 }
4697}
4698impl SubscriptionItem {
4699 pub fn builder() -> builder::SubscriptionItem {
4700 Default::default()
4701 }
4702}
4703#[derive(
4719 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
4720)]
4721pub enum SubscriptionType {
4722 #[serde(rename = "one_time")]
4723 OneTime,
4724 #[serde(rename = "recurring")]
4725 Recurring,
4726}
4727impl From<&SubscriptionType> for SubscriptionType {
4728 fn from(value: &SubscriptionType) -> Self {
4729 value.clone()
4730 }
4731}
4732impl ::std::fmt::Display for SubscriptionType {
4733 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4734 match *self {
4735 Self::OneTime => write!(f, "one_time"),
4736 Self::Recurring => write!(f, "recurring"),
4737 }
4738 }
4739}
4740impl std::str::FromStr for SubscriptionType {
4741 type Err = self::error::ConversionError;
4742 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4743 match value {
4744 "one_time" => Ok(Self::OneTime),
4745 "recurring" => Ok(Self::Recurring),
4746 _ => Err("invalid value".into()),
4747 }
4748 }
4749}
4750impl std::convert::TryFrom<&str> for SubscriptionType {
4751 type Error = self::error::ConversionError;
4752 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4753 value.parse()
4754 }
4755}
4756impl std::convert::TryFrom<&String> for SubscriptionType {
4757 type Error = self::error::ConversionError;
4758 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4759 value.parse()
4760 }
4761}
4762impl std::convert::TryFrom<String> for SubscriptionType {
4763 type Error = self::error::ConversionError;
4764 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4765 value.parse()
4766 }
4767}
4768#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4799#[serde(deny_unknown_fields)]
4800pub struct Tax {
4801 pub amount: i64,
4802 pub name: String,
4803 #[serde(default, skip_serializing_if = "Option::is_none")]
4804 pub rate: Option<f64>,
4805}
4806impl From<&Tax> for Tax {
4807 fn from(value: &Tax) -> Self {
4808 value.clone()
4809 }
4810}
4811impl Tax {
4812 pub fn builder() -> builder::Tax {
4813 Default::default()
4814 }
4815}
4816#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4854#[serde(deny_unknown_fields)]
4855pub struct TransitRoute {
4856 #[serde(default, skip_serializing_if = "Option::is_none")]
4857 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4858 pub transit_route_items: Vec<TransitRouteItem>,
4859}
4860impl From<&TransitRoute> for TransitRoute {
4861 fn from(value: &TransitRoute) -> Self {
4862 value.clone()
4863 }
4864}
4865impl TransitRoute {
4866 pub fn builder() -> builder::TransitRoute {
4867 Default::default()
4868 }
4869}
4870#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
5006#[serde(deny_unknown_fields)]
5007pub struct TransitRouteItem {
5008 #[serde(default, skip_serializing_if = "Option::is_none")]
5009 pub adjustments: Option<Vec<Adjustment>>,
5010 #[serde(default, skip_serializing_if = "Option::is_none")]
5011 pub arrival_at: Option<i64>,
5012 #[serde(default, skip_serializing_if = "Option::is_none")]
5013 pub arrival_location: Option<Place>,
5014 #[serde(default, skip_serializing_if = "Option::is_none")]
5015 pub departure_at: Option<i64>,
5016 #[serde(default, skip_serializing_if = "Option::is_none")]
5017 pub departure_location: Option<Place>,
5018 pub fare: i64,
5019 #[serde(default, skip_serializing_if = "Option::is_none")]
5020 pub metadata: Option<Vec<Metadatum>>,
5021 #[serde(default, skip_serializing_if = "Option::is_none")]
5022 pub mode: Option<TransitRouteItemMode>,
5023 #[serde(default, skip_serializing_if = "Option::is_none")]
5024 pub passenger: Option<Person>,
5025 #[serde(default, skip_serializing_if = "Option::is_none")]
5026 pub polyline: Option<String>,
5027 #[serde(default, skip_serializing_if = "Option::is_none")]
5028 pub taxes: Option<Vec<Tax>>,
5029}
5030impl From<&TransitRouteItem> for TransitRouteItem {
5031 fn from(value: &TransitRouteItem) -> Self {
5032 value.clone()
5033 }
5034}
5035impl TransitRouteItem {
5036 pub fn builder() -> builder::TransitRouteItem {
5037 Default::default()
5038 }
5039}
5040#[derive(
5059 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
5060)]
5061pub enum TransitRouteItemMode {
5062 #[serde(rename = "car")]
5063 Car,
5064 #[serde(rename = "taxi")]
5065 Taxi,
5066 #[serde(rename = "rail")]
5067 Rail,
5068 #[serde(rename = "bus")]
5069 Bus,
5070 #[serde(rename = "ferry")]
5071 Ferry,
5072 #[serde(rename = "other")]
5073 Other,
5074}
5075impl From<&TransitRouteItemMode> for TransitRouteItemMode {
5076 fn from(value: &TransitRouteItemMode) -> Self {
5077 value.clone()
5078 }
5079}
5080impl ::std::fmt::Display for TransitRouteItemMode {
5081 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5082 match *self {
5083 Self::Car => write!(f, "car"),
5084 Self::Taxi => write!(f, "taxi"),
5085 Self::Rail => write!(f, "rail"),
5086 Self::Bus => write!(f, "bus"),
5087 Self::Ferry => write!(f, "ferry"),
5088 Self::Other => write!(f, "other"),
5089 }
5090 }
5091}
5092impl std::str::FromStr for TransitRouteItemMode {
5093 type Err = self::error::ConversionError;
5094 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
5095 match value {
5096 "car" => Ok(Self::Car),
5097 "taxi" => Ok(Self::Taxi),
5098 "rail" => Ok(Self::Rail),
5099 "bus" => Ok(Self::Bus),
5100 "ferry" => Ok(Self::Ferry),
5101 "other" => Ok(Self::Other),
5102 _ => Err("invalid value".into()),
5103 }
5104 }
5105}
5106impl std::convert::TryFrom<&str> for TransitRouteItemMode {
5107 type Error = self::error::ConversionError;
5108 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
5109 value.parse()
5110 }
5111}
5112impl std::convert::TryFrom<&String> for TransitRouteItemMode {
5113 type Error = self::error::ConversionError;
5114 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
5115 value.parse()
5116 }
5117}
5118impl std::convert::TryFrom<String> for TransitRouteItemMode {
5119 type Error = self::error::ConversionError;
5120 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
5121 value.parse()
5122 }
5123}
5124pub mod builder {
5126 #[derive(Clone, Debug)]
5127 pub struct AchPayment {
5128 routing_number: Result<super::AchPaymentRoutingNumber, String>,
5129 }
5130 impl Default for AchPayment {
5131 fn default() -> Self {
5132 Self {
5133 routing_number: Err("no value supplied for routing_number".to_string()),
5134 }
5135 }
5136 }
5137 impl AchPayment {
5138 pub fn routing_number<T>(mut self, value: T) -> Self
5139 where
5140 T: std::convert::TryInto<super::AchPaymentRoutingNumber>,
5141 T::Error: std::fmt::Display,
5142 {
5143 self.routing_number = value
5144 .try_into()
5145 .map_err(|e| format!("error converting supplied value for routing_number: {}", e));
5146 self
5147 }
5148 }
5149 impl std::convert::TryFrom<AchPayment> for super::AchPayment {
5150 type Error = super::error::ConversionError;
5151 fn try_from(value: AchPayment) -> Result<Self, super::error::ConversionError> {
5152 Ok(Self {
5153 routing_number: value.routing_number?,
5154 })
5155 }
5156 }
5157 impl From<super::AchPayment> for AchPayment {
5158 fn from(value: super::AchPayment) -> Self {
5159 Self {
5160 routing_number: Ok(value.routing_number),
5161 }
5162 }
5163 }
5164 #[derive(Clone, Debug)]
5165 pub struct Action {
5166 name: Result<String, String>,
5167 url: Result<String, String>,
5168 }
5169 impl Default for Action {
5170 fn default() -> Self {
5171 Self {
5172 name: Err("no value supplied for name".to_string()),
5173 url: Err("no value supplied for url".to_string()),
5174 }
5175 }
5176 }
5177 impl Action {
5178 pub fn name<T>(mut self, value: T) -> Self
5179 where
5180 T: std::convert::TryInto<String>,
5181 T::Error: std::fmt::Display,
5182 {
5183 self.name = value
5184 .try_into()
5185 .map_err(|e| format!("error converting supplied value for name: {}", e));
5186 self
5187 }
5188 pub fn url<T>(mut self, value: T) -> Self
5189 where
5190 T: std::convert::TryInto<String>,
5191 T::Error: std::fmt::Display,
5192 {
5193 self.url = value
5194 .try_into()
5195 .map_err(|e| format!("error converting supplied value for url: {}", e));
5196 self
5197 }
5198 }
5199 impl std::convert::TryFrom<Action> for super::Action {
5200 type Error = super::error::ConversionError;
5201 fn try_from(value: Action) -> Result<Self, super::error::ConversionError> {
5202 Ok(Self {
5203 name: value.name?,
5204 url: value.url?,
5205 })
5206 }
5207 }
5208 impl From<super::Action> for Action {
5209 fn from(value: super::Action) -> Self {
5210 Self {
5211 name: Ok(value.name),
5212 url: Ok(value.url),
5213 }
5214 }
5215 }
5216 #[derive(Clone, Debug)]
5217 pub struct Address {
5218 city: Result<Option<String>, String>,
5219 country: Result<Option<super::AddressCountry>, String>,
5220 lat: Result<Option<f64>, String>,
5221 lon: Result<Option<f64>, String>,
5222 postal_code: Result<Option<String>, String>,
5223 region: Result<Option<super::AddressRegion>, String>,
5224 street_address: Result<Option<String>, String>,
5225 tz: Result<Option<String>, String>,
5226 }
5227 impl Default for Address {
5228 fn default() -> Self {
5229 Self {
5230 city: Ok(Default::default()),
5231 country: Ok(Default::default()),
5232 lat: Ok(Default::default()),
5233 lon: Ok(Default::default()),
5234 postal_code: Ok(Default::default()),
5235 region: Ok(Default::default()),
5236 street_address: Ok(Default::default()),
5237 tz: Ok(Default::default()),
5238 }
5239 }
5240 }
5241 impl Address {
5242 pub fn city<T>(mut self, value: T) -> Self
5243 where
5244 T: std::convert::TryInto<Option<String>>,
5245 T::Error: std::fmt::Display,
5246 {
5247 self.city = value
5248 .try_into()
5249 .map_err(|e| format!("error converting supplied value for city: {}", e));
5250 self
5251 }
5252 pub fn country<T>(mut self, value: T) -> Self
5253 where
5254 T: std::convert::TryInto<Option<super::AddressCountry>>,
5255 T::Error: std::fmt::Display,
5256 {
5257 self.country = value
5258 .try_into()
5259 .map_err(|e| format!("error converting supplied value for country: {}", e));
5260 self
5261 }
5262 pub fn lat<T>(mut self, value: T) -> Self
5263 where
5264 T: std::convert::TryInto<Option<f64>>,
5265 T::Error: std::fmt::Display,
5266 {
5267 self.lat = value
5268 .try_into()
5269 .map_err(|e| format!("error converting supplied value for lat: {}", e));
5270 self
5271 }
5272 pub fn lon<T>(mut self, value: T) -> Self
5273 where
5274 T: std::convert::TryInto<Option<f64>>,
5275 T::Error: std::fmt::Display,
5276 {
5277 self.lon = value
5278 .try_into()
5279 .map_err(|e| format!("error converting supplied value for lon: {}", e));
5280 self
5281 }
5282 pub fn postal_code<T>(mut self, value: T) -> Self
5283 where
5284 T: std::convert::TryInto<Option<String>>,
5285 T::Error: std::fmt::Display,
5286 {
5287 self.postal_code = value
5288 .try_into()
5289 .map_err(|e| format!("error converting supplied value for postal_code: {}", e));
5290 self
5291 }
5292 pub fn region<T>(mut self, value: T) -> Self
5293 where
5294 T: std::convert::TryInto<Option<super::AddressRegion>>,
5295 T::Error: std::fmt::Display,
5296 {
5297 self.region = value
5298 .try_into()
5299 .map_err(|e| format!("error converting supplied value for region: {}", e));
5300 self
5301 }
5302 pub fn street_address<T>(mut self, value: T) -> Self
5303 where
5304 T: std::convert::TryInto<Option<String>>,
5305 T::Error: std::fmt::Display,
5306 {
5307 self.street_address = value
5308 .try_into()
5309 .map_err(|e| format!("error converting supplied value for street_address: {}", e));
5310 self
5311 }
5312 pub fn tz<T>(mut self, value: T) -> Self
5313 where
5314 T: std::convert::TryInto<Option<String>>,
5315 T::Error: std::fmt::Display,
5316 {
5317 self.tz = value
5318 .try_into()
5319 .map_err(|e| format!("error converting supplied value for tz: {}", e));
5320 self
5321 }
5322 }
5323 impl std::convert::TryFrom<Address> for super::Address {
5324 type Error = super::error::ConversionError;
5325 fn try_from(value: Address) -> Result<Self, super::error::ConversionError> {
5326 Ok(Self {
5327 city: value.city?,
5328 country: value.country?,
5329 lat: value.lat?,
5330 lon: value.lon?,
5331 postal_code: value.postal_code?,
5332 region: value.region?,
5333 street_address: value.street_address?,
5334 tz: value.tz?,
5335 })
5336 }
5337 }
5338 impl From<super::Address> for Address {
5339 fn from(value: super::Address) -> Self {
5340 Self {
5341 city: Ok(value.city),
5342 country: Ok(value.country),
5343 lat: Ok(value.lat),
5344 lon: Ok(value.lon),
5345 postal_code: Ok(value.postal_code),
5346 region: Ok(value.region),
5347 street_address: Ok(value.street_address),
5348 tz: Ok(value.tz),
5349 }
5350 }
5351 }
5352 #[derive(Clone, Debug)]
5353 pub struct Adjustment {
5354 adjustment_type: Result<super::AdjustmentType, String>,
5355 amount: Result<i64, String>,
5356 name: Result<Option<String>, String>,
5357 rate: Result<Option<f64>, String>,
5358 }
5359 impl Default for Adjustment {
5360 fn default() -> Self {
5361 Self {
5362 adjustment_type: Err("no value supplied for adjustment_type".to_string()),
5363 amount: Err("no value supplied for amount".to_string()),
5364 name: Ok(Default::default()),
5365 rate: Ok(Default::default()),
5366 }
5367 }
5368 }
5369 impl Adjustment {
5370 pub fn adjustment_type<T>(mut self, value: T) -> Self
5371 where
5372 T: std::convert::TryInto<super::AdjustmentType>,
5373 T::Error: std::fmt::Display,
5374 {
5375 self.adjustment_type = value
5376 .try_into()
5377 .map_err(|e| format!("error converting supplied value for adjustment_type: {}", e));
5378 self
5379 }
5380 pub fn amount<T>(mut self, value: T) -> Self
5381 where
5382 T: std::convert::TryInto<i64>,
5383 T::Error: std::fmt::Display,
5384 {
5385 self.amount = value
5386 .try_into()
5387 .map_err(|e| format!("error converting supplied value for amount: {}", e));
5388 self
5389 }
5390 pub fn name<T>(mut self, value: T) -> Self
5391 where
5392 T: std::convert::TryInto<Option<String>>,
5393 T::Error: std::fmt::Display,
5394 {
5395 self.name = value
5396 .try_into()
5397 .map_err(|e| format!("error converting supplied value for name: {}", e));
5398 self
5399 }
5400 pub fn rate<T>(mut self, value: T) -> Self
5401 where
5402 T: std::convert::TryInto<Option<f64>>,
5403 T::Error: std::fmt::Display,
5404 {
5405 self.rate = value
5406 .try_into()
5407 .map_err(|e| format!("error converting supplied value for rate: {}", e));
5408 self
5409 }
5410 }
5411 impl std::convert::TryFrom<Adjustment> for super::Adjustment {
5412 type Error = super::error::ConversionError;
5413 fn try_from(value: Adjustment) -> Result<Self, super::error::ConversionError> {
5414 Ok(Self {
5415 adjustment_type: value.adjustment_type?,
5416 amount: value.amount?,
5417 name: value.name?,
5418 rate: value.rate?,
5419 })
5420 }
5421 }
5422 impl From<super::Adjustment> for Adjustment {
5423 fn from(value: super::Adjustment) -> Self {
5424 Self {
5425 adjustment_type: Ok(value.adjustment_type),
5426 amount: Ok(value.amount),
5427 name: Ok(value.name),
5428 rate: Ok(value.rate),
5429 }
5430 }
5431 }
5432 #[derive(Clone, Debug)]
5433 pub struct CarRental {
5434 confirmation_number: Result<Option<String>, String>,
5435 drivers: Result<Option<Vec<super::Person>>, String>,
5436 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
5437 items: Result<Vec<super::Item>, String>,
5438 metadata: Result<Option<Vec<super::Metadatum>>, String>,
5439 odometer_reading_in: Result<i64, String>,
5440 odometer_reading_out: Result<i64, String>,
5441 record_locator: Result<Option<String>, String>,
5442 rental_at: Result<i64, String>,
5443 rental_location: Result<super::Place, String>,
5444 return_at: Result<i64, String>,
5445 return_location: Result<super::Place, String>,
5446 vehicle: Result<Option<super::CarRentalVehicle>, String>,
5447 vendor_code: Result<Option<super::CarRentalVendorCode>, String>,
5448 }
5449 impl Default for CarRental {
5450 fn default() -> Self {
5451 Self {
5452 confirmation_number: Ok(Default::default()),
5453 drivers: Ok(Default::default()),
5454 invoice_level_adjustments: Ok(Default::default()),
5455 items: Err("no value supplied for items".to_string()),
5456 metadata: Ok(Default::default()),
5457 odometer_reading_in: Err("no value supplied for odometer_reading_in".to_string()),
5458 odometer_reading_out: Err("no value supplied for odometer_reading_out".to_string()),
5459 record_locator: Ok(Default::default()),
5460 rental_at: Err("no value supplied for rental_at".to_string()),
5461 rental_location: Err("no value supplied for rental_location".to_string()),
5462 return_at: Err("no value supplied for return_at".to_string()),
5463 return_location: Err("no value supplied for return_location".to_string()),
5464 vehicle: Ok(Default::default()),
5465 vendor_code: Ok(Default::default()),
5466 }
5467 }
5468 }
5469 impl CarRental {
5470 pub fn confirmation_number<T>(mut self, value: T) -> Self
5471 where
5472 T: std::convert::TryInto<Option<String>>,
5473 T::Error: std::fmt::Display,
5474 {
5475 self.confirmation_number = value.try_into().map_err(|e| {
5476 format!(
5477 "error converting supplied value for confirmation_number: {}",
5478 e
5479 )
5480 });
5481 self
5482 }
5483 pub fn drivers<T>(mut self, value: T) -> Self
5484 where
5485 T: std::convert::TryInto<Option<Vec<super::Person>>>,
5486 T::Error: std::fmt::Display,
5487 {
5488 self.drivers = value
5489 .try_into()
5490 .map_err(|e| format!("error converting supplied value for drivers: {}", e));
5491 self
5492 }
5493 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
5494 where
5495 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
5496 T::Error: std::fmt::Display,
5497 {
5498 self.invoice_level_adjustments = value.try_into().map_err(|e| {
5499 format!(
5500 "error converting supplied value for invoice_level_adjustments: {}",
5501 e
5502 )
5503 });
5504 self
5505 }
5506 pub fn items<T>(mut self, value: T) -> Self
5507 where
5508 T: std::convert::TryInto<Vec<super::Item>>,
5509 T::Error: std::fmt::Display,
5510 {
5511 self.items = value
5512 .try_into()
5513 .map_err(|e| format!("error converting supplied value for items: {}", e));
5514 self
5515 }
5516 pub fn metadata<T>(mut self, value: T) -> Self
5517 where
5518 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
5519 T::Error: std::fmt::Display,
5520 {
5521 self.metadata = value
5522 .try_into()
5523 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
5524 self
5525 }
5526 pub fn odometer_reading_in<T>(mut self, value: T) -> Self
5527 where
5528 T: std::convert::TryInto<i64>,
5529 T::Error: std::fmt::Display,
5530 {
5531 self.odometer_reading_in = value.try_into().map_err(|e| {
5532 format!(
5533 "error converting supplied value for odometer_reading_in: {}",
5534 e
5535 )
5536 });
5537 self
5538 }
5539 pub fn odometer_reading_out<T>(mut self, value: T) -> Self
5540 where
5541 T: std::convert::TryInto<i64>,
5542 T::Error: std::fmt::Display,
5543 {
5544 self.odometer_reading_out = value.try_into().map_err(|e| {
5545 format!(
5546 "error converting supplied value for odometer_reading_out: {}",
5547 e
5548 )
5549 });
5550 self
5551 }
5552 pub fn record_locator<T>(mut self, value: T) -> Self
5553 where
5554 T: std::convert::TryInto<Option<String>>,
5555 T::Error: std::fmt::Display,
5556 {
5557 self.record_locator = value
5558 .try_into()
5559 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
5560 self
5561 }
5562 pub fn rental_at<T>(mut self, value: T) -> Self
5563 where
5564 T: std::convert::TryInto<i64>,
5565 T::Error: std::fmt::Display,
5566 {
5567 self.rental_at = value
5568 .try_into()
5569 .map_err(|e| format!("error converting supplied value for rental_at: {}", e));
5570 self
5571 }
5572 pub fn rental_location<T>(mut self, value: T) -> Self
5573 where
5574 T: std::convert::TryInto<super::Place>,
5575 T::Error: std::fmt::Display,
5576 {
5577 self.rental_location = value
5578 .try_into()
5579 .map_err(|e| format!("error converting supplied value for rental_location: {}", e));
5580 self
5581 }
5582 pub fn return_at<T>(mut self, value: T) -> Self
5583 where
5584 T: std::convert::TryInto<i64>,
5585 T::Error: std::fmt::Display,
5586 {
5587 self.return_at = value
5588 .try_into()
5589 .map_err(|e| format!("error converting supplied value for return_at: {}", e));
5590 self
5591 }
5592 pub fn return_location<T>(mut self, value: T) -> Self
5593 where
5594 T: std::convert::TryInto<super::Place>,
5595 T::Error: std::fmt::Display,
5596 {
5597 self.return_location = value
5598 .try_into()
5599 .map_err(|e| format!("error converting supplied value for return_location: {}", e));
5600 self
5601 }
5602 pub fn vehicle<T>(mut self, value: T) -> Self
5603 where
5604 T: std::convert::TryInto<Option<super::CarRentalVehicle>>,
5605 T::Error: std::fmt::Display,
5606 {
5607 self.vehicle = value
5608 .try_into()
5609 .map_err(|e| format!("error converting supplied value for vehicle: {}", e));
5610 self
5611 }
5612 pub fn vendor_code<T>(mut self, value: T) -> Self
5613 where
5614 T: std::convert::TryInto<Option<super::CarRentalVendorCode>>,
5615 T::Error: std::fmt::Display,
5616 {
5617 self.vendor_code = value
5618 .try_into()
5619 .map_err(|e| format!("error converting supplied value for vendor_code: {}", e));
5620 self
5621 }
5622 }
5623 impl std::convert::TryFrom<CarRental> for super::CarRental {
5624 type Error = super::error::ConversionError;
5625 fn try_from(value: CarRental) -> Result<Self, super::error::ConversionError> {
5626 Ok(Self {
5627 confirmation_number: value.confirmation_number?,
5628 drivers: value.drivers?,
5629 invoice_level_adjustments: value.invoice_level_adjustments?,
5630 items: value.items?,
5631 metadata: value.metadata?,
5632 odometer_reading_in: value.odometer_reading_in?,
5633 odometer_reading_out: value.odometer_reading_out?,
5634 record_locator: value.record_locator?,
5635 rental_at: value.rental_at?,
5636 rental_location: value.rental_location?,
5637 return_at: value.return_at?,
5638 return_location: value.return_location?,
5639 vehicle: value.vehicle?,
5640 vendor_code: value.vendor_code?,
5641 })
5642 }
5643 }
5644 impl From<super::CarRental> for CarRental {
5645 fn from(value: super::CarRental) -> Self {
5646 Self {
5647 confirmation_number: Ok(value.confirmation_number),
5648 drivers: Ok(value.drivers),
5649 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
5650 items: Ok(value.items),
5651 metadata: Ok(value.metadata),
5652 odometer_reading_in: Ok(value.odometer_reading_in),
5653 odometer_reading_out: Ok(value.odometer_reading_out),
5654 record_locator: Ok(value.record_locator),
5655 rental_at: Ok(value.rental_at),
5656 rental_location: Ok(value.rental_location),
5657 return_at: Ok(value.return_at),
5658 return_location: Ok(value.return_location),
5659 vehicle: Ok(value.vehicle),
5660 vendor_code: Ok(value.vendor_code),
5661 }
5662 }
5663 }
5664 #[derive(Clone, Debug)]
5665 pub struct CarRentalVehicle {
5666 description: Result<String, String>,
5667 image: Result<Option<String>, String>,
5668 license_plate_number: Result<Option<String>, String>,
5669 vehicle_class: Result<Option<super::CarRentalVehicleVehicleClass>, String>,
5670 }
5671 impl Default for CarRentalVehicle {
5672 fn default() -> Self {
5673 Self {
5674 description: Err("no value supplied for description".to_string()),
5675 image: Ok(Default::default()),
5676 license_plate_number: Ok(Default::default()),
5677 vehicle_class: Ok(Default::default()),
5678 }
5679 }
5680 }
5681 impl CarRentalVehicle {
5682 pub fn description<T>(mut self, value: T) -> Self
5683 where
5684 T: std::convert::TryInto<String>,
5685 T::Error: std::fmt::Display,
5686 {
5687 self.description = value
5688 .try_into()
5689 .map_err(|e| format!("error converting supplied value for description: {}", e));
5690 self
5691 }
5692 pub fn image<T>(mut self, value: T) -> Self
5693 where
5694 T: std::convert::TryInto<Option<String>>,
5695 T::Error: std::fmt::Display,
5696 {
5697 self.image = value
5698 .try_into()
5699 .map_err(|e| format!("error converting supplied value for image: {}", e));
5700 self
5701 }
5702 pub fn license_plate_number<T>(mut self, value: T) -> Self
5703 where
5704 T: std::convert::TryInto<Option<String>>,
5705 T::Error: std::fmt::Display,
5706 {
5707 self.license_plate_number = value.try_into().map_err(|e| {
5708 format!(
5709 "error converting supplied value for license_plate_number: {}",
5710 e
5711 )
5712 });
5713 self
5714 }
5715 pub fn vehicle_class<T>(mut self, value: T) -> Self
5716 where
5717 T: std::convert::TryInto<Option<super::CarRentalVehicleVehicleClass>>,
5718 T::Error: std::fmt::Display,
5719 {
5720 self.vehicle_class = value
5721 .try_into()
5722 .map_err(|e| format!("error converting supplied value for vehicle_class: {}", e));
5723 self
5724 }
5725 }
5726 impl std::convert::TryFrom<CarRentalVehicle> for super::CarRentalVehicle {
5727 type Error = super::error::ConversionError;
5728 fn try_from(value: CarRentalVehicle) -> Result<Self, super::error::ConversionError> {
5729 Ok(Self {
5730 description: value.description?,
5731 image: value.image?,
5732 license_plate_number: value.license_plate_number?,
5733 vehicle_class: value.vehicle_class?,
5734 })
5735 }
5736 }
5737 impl From<super::CarRentalVehicle> for CarRentalVehicle {
5738 fn from(value: super::CarRentalVehicle) -> Self {
5739 Self {
5740 description: Ok(value.description),
5741 image: Ok(value.image),
5742 license_plate_number: Ok(value.license_plate_number),
5743 vehicle_class: Ok(value.vehicle_class),
5744 }
5745 }
5746 }
5747 #[derive(Clone, Debug)]
5748 pub struct CardPayment {
5749 last_four: Result<super::CardPaymentLastFour, String>,
5750 network: Result<Option<super::CardPaymentNetwork>, String>,
5751 }
5752 impl Default for CardPayment {
5753 fn default() -> Self {
5754 Self {
5755 last_four: Err("no value supplied for last_four".to_string()),
5756 network: Ok(Default::default()),
5757 }
5758 }
5759 }
5760 impl CardPayment {
5761 pub fn last_four<T>(mut self, value: T) -> Self
5762 where
5763 T: std::convert::TryInto<super::CardPaymentLastFour>,
5764 T::Error: std::fmt::Display,
5765 {
5766 self.last_four = value
5767 .try_into()
5768 .map_err(|e| format!("error converting supplied value for last_four: {}", e));
5769 self
5770 }
5771 pub fn network<T>(mut self, value: T) -> Self
5772 where
5773 T: std::convert::TryInto<Option<super::CardPaymentNetwork>>,
5774 T::Error: std::fmt::Display,
5775 {
5776 self.network = value
5777 .try_into()
5778 .map_err(|e| format!("error converting supplied value for network: {}", e));
5779 self
5780 }
5781 }
5782 impl std::convert::TryFrom<CardPayment> for super::CardPayment {
5783 type Error = super::error::ConversionError;
5784 fn try_from(value: CardPayment) -> Result<Self, super::error::ConversionError> {
5785 Ok(Self {
5786 last_four: value.last_four?,
5787 network: value.network?,
5788 })
5789 }
5790 }
5791 impl From<super::CardPayment> for CardPayment {
5792 fn from(value: super::CardPayment) -> Self {
5793 Self {
5794 last_four: Ok(value.last_four),
5795 network: Ok(value.network),
5796 }
5797 }
5798 }
5799 #[derive(Clone, Debug)]
5800 pub struct Customer {
5801 address: Result<Option<super::Address>, String>,
5802 booker: Result<Option<super::Person>, String>,
5803 email: Result<Option<String>, String>,
5804 metadata: Result<Option<Vec<super::Metadatum>>, String>,
5805 name: Result<String, String>,
5806 phone: Result<Option<super::CustomerPhone>, String>,
5807 website: Result<Option<String>, String>,
5808 }
5809 impl Default for Customer {
5810 fn default() -> Self {
5811 Self {
5812 address: Ok(Default::default()),
5813 booker: Ok(Default::default()),
5814 email: Ok(Default::default()),
5815 metadata: Ok(Default::default()),
5816 name: Err("no value supplied for name".to_string()),
5817 phone: Ok(Default::default()),
5818 website: Ok(Default::default()),
5819 }
5820 }
5821 }
5822 impl Customer {
5823 pub fn address<T>(mut self, value: T) -> Self
5824 where
5825 T: std::convert::TryInto<Option<super::Address>>,
5826 T::Error: std::fmt::Display,
5827 {
5828 self.address = value
5829 .try_into()
5830 .map_err(|e| format!("error converting supplied value for address: {}", e));
5831 self
5832 }
5833 pub fn booker<T>(mut self, value: T) -> Self
5834 where
5835 T: std::convert::TryInto<Option<super::Person>>,
5836 T::Error: std::fmt::Display,
5837 {
5838 self.booker = value
5839 .try_into()
5840 .map_err(|e| format!("error converting supplied value for booker: {}", e));
5841 self
5842 }
5843 pub fn email<T>(mut self, value: T) -> Self
5844 where
5845 T: std::convert::TryInto<Option<String>>,
5846 T::Error: std::fmt::Display,
5847 {
5848 self.email = value
5849 .try_into()
5850 .map_err(|e| format!("error converting supplied value for email: {}", e));
5851 self
5852 }
5853 pub fn metadata<T>(mut self, value: T) -> Self
5854 where
5855 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
5856 T::Error: std::fmt::Display,
5857 {
5858 self.metadata = value
5859 .try_into()
5860 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
5861 self
5862 }
5863 pub fn name<T>(mut self, value: T) -> Self
5864 where
5865 T: std::convert::TryInto<String>,
5866 T::Error: std::fmt::Display,
5867 {
5868 self.name = value
5869 .try_into()
5870 .map_err(|e| format!("error converting supplied value for name: {}", e));
5871 self
5872 }
5873 pub fn phone<T>(mut self, value: T) -> Self
5874 where
5875 T: std::convert::TryInto<Option<super::CustomerPhone>>,
5876 T::Error: std::fmt::Display,
5877 {
5878 self.phone = value
5879 .try_into()
5880 .map_err(|e| format!("error converting supplied value for phone: {}", e));
5881 self
5882 }
5883 pub fn website<T>(mut self, value: T) -> Self
5884 where
5885 T: std::convert::TryInto<Option<String>>,
5886 T::Error: std::fmt::Display,
5887 {
5888 self.website = value
5889 .try_into()
5890 .map_err(|e| format!("error converting supplied value for website: {}", e));
5891 self
5892 }
5893 }
5894 impl std::convert::TryFrom<Customer> for super::Customer {
5895 type Error = super::error::ConversionError;
5896 fn try_from(value: Customer) -> Result<Self, super::error::ConversionError> {
5897 Ok(Self {
5898 address: value.address?,
5899 booker: value.booker?,
5900 email: value.email?,
5901 metadata: value.metadata?,
5902 name: value.name?,
5903 phone: value.phone?,
5904 website: value.website?,
5905 })
5906 }
5907 }
5908 impl From<super::Customer> for Customer {
5909 fn from(value: super::Customer) -> Self {
5910 Self {
5911 address: Ok(value.address),
5912 booker: Ok(value.booker),
5913 email: Ok(value.email),
5914 metadata: Ok(value.metadata),
5915 name: Ok(value.name),
5916 phone: Ok(value.phone),
5917 website: Ok(value.website),
5918 }
5919 }
5920 }
5921 #[derive(Clone, Debug)]
5922 pub struct Doc {
5923 body: Result<String, String>,
5924 title: Result<String, String>,
5925 }
5926 impl Default for Doc {
5927 fn default() -> Self {
5928 Self {
5929 body: Err("no value supplied for body".to_string()),
5930 title: Err("no value supplied for title".to_string()),
5931 }
5932 }
5933 }
5934 impl Doc {
5935 pub fn body<T>(mut self, value: T) -> Self
5936 where
5937 T: std::convert::TryInto<String>,
5938 T::Error: std::fmt::Display,
5939 {
5940 self.body = value
5941 .try_into()
5942 .map_err(|e| format!("error converting supplied value for body: {}", e));
5943 self
5944 }
5945 pub fn title<T>(mut self, value: T) -> Self
5946 where
5947 T: std::convert::TryInto<String>,
5948 T::Error: std::fmt::Display,
5949 {
5950 self.title = value
5951 .try_into()
5952 .map_err(|e| format!("error converting supplied value for title: {}", e));
5953 self
5954 }
5955 }
5956 impl std::convert::TryFrom<Doc> for super::Doc {
5957 type Error = super::error::ConversionError;
5958 fn try_from(value: Doc) -> Result<Self, super::error::ConversionError> {
5959 Ok(Self {
5960 body: value.body?,
5961 title: value.title?,
5962 })
5963 }
5964 }
5965 impl From<super::Doc> for Doc {
5966 fn from(value: super::Doc) -> Self {
5967 Self {
5968 body: Ok(value.body),
5969 title: Ok(value.title),
5970 }
5971 }
5972 }
5973 #[derive(Clone, Debug)]
5974 pub struct Ecommerce {
5975 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
5976 invoice_level_line_items: Result<Option<Vec<super::Item>>, String>,
5977 shipments: Result<Vec<super::Shipment>, String>,
5978 }
5979 impl Default for Ecommerce {
5980 fn default() -> Self {
5981 Self {
5982 invoice_level_adjustments: Ok(Default::default()),
5983 invoice_level_line_items: Ok(Default::default()),
5984 shipments: Err("no value supplied for shipments".to_string()),
5985 }
5986 }
5987 }
5988 impl Ecommerce {
5989 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
5990 where
5991 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
5992 T::Error: std::fmt::Display,
5993 {
5994 self.invoice_level_adjustments = value.try_into().map_err(|e| {
5995 format!(
5996 "error converting supplied value for invoice_level_adjustments: {}",
5997 e
5998 )
5999 });
6000 self
6001 }
6002 pub fn invoice_level_line_items<T>(mut self, value: T) -> Self
6003 where
6004 T: std::convert::TryInto<Option<Vec<super::Item>>>,
6005 T::Error: std::fmt::Display,
6006 {
6007 self.invoice_level_line_items = value.try_into().map_err(|e| {
6008 format!(
6009 "error converting supplied value for invoice_level_line_items: {}",
6010 e
6011 )
6012 });
6013 self
6014 }
6015 pub fn shipments<T>(mut self, value: T) -> Self
6016 where
6017 T: std::convert::TryInto<Vec<super::Shipment>>,
6018 T::Error: std::fmt::Display,
6019 {
6020 self.shipments = value
6021 .try_into()
6022 .map_err(|e| format!("error converting supplied value for shipments: {}", e));
6023 self
6024 }
6025 }
6026 impl std::convert::TryFrom<Ecommerce> for super::Ecommerce {
6027 type Error = super::error::ConversionError;
6028 fn try_from(value: Ecommerce) -> Result<Self, super::error::ConversionError> {
6029 Ok(Self {
6030 invoice_level_adjustments: value.invoice_level_adjustments?,
6031 invoice_level_line_items: value.invoice_level_line_items?,
6032 shipments: value.shipments?,
6033 })
6034 }
6035 }
6036 impl From<super::Ecommerce> for Ecommerce {
6037 fn from(value: super::Ecommerce) -> Self {
6038 Self {
6039 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
6040 invoice_level_line_items: Ok(value.invoice_level_line_items),
6041 shipments: Ok(value.shipments),
6042 }
6043 }
6044 }
6045 #[derive(Clone, Debug)]
6046 pub struct Flight {
6047 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6048 itinerary_locator: Result<Option<String>, String>,
6049 tickets: Result<Vec<super::FlightTicket>, String>,
6050 }
6051 impl Default for Flight {
6052 fn default() -> Self {
6053 Self {
6054 invoice_level_adjustments: Ok(Default::default()),
6055 itinerary_locator: Ok(Default::default()),
6056 tickets: Err("no value supplied for tickets".to_string()),
6057 }
6058 }
6059 }
6060 impl Flight {
6061 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
6062 where
6063 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6064 T::Error: std::fmt::Display,
6065 {
6066 self.invoice_level_adjustments = value.try_into().map_err(|e| {
6067 format!(
6068 "error converting supplied value for invoice_level_adjustments: {}",
6069 e
6070 )
6071 });
6072 self
6073 }
6074 pub fn itinerary_locator<T>(mut self, value: T) -> Self
6075 where
6076 T: std::convert::TryInto<Option<String>>,
6077 T::Error: std::fmt::Display,
6078 {
6079 self.itinerary_locator = value.try_into().map_err(|e| {
6080 format!(
6081 "error converting supplied value for itinerary_locator: {}",
6082 e
6083 )
6084 });
6085 self
6086 }
6087 pub fn tickets<T>(mut self, value: T) -> Self
6088 where
6089 T: std::convert::TryInto<Vec<super::FlightTicket>>,
6090 T::Error: std::fmt::Display,
6091 {
6092 self.tickets = value
6093 .try_into()
6094 .map_err(|e| format!("error converting supplied value for tickets: {}", e));
6095 self
6096 }
6097 }
6098 impl std::convert::TryFrom<Flight> for super::Flight {
6099 type Error = super::error::ConversionError;
6100 fn try_from(value: Flight) -> Result<Self, super::error::ConversionError> {
6101 Ok(Self {
6102 invoice_level_adjustments: value.invoice_level_adjustments?,
6103 itinerary_locator: value.itinerary_locator?,
6104 tickets: value.tickets?,
6105 })
6106 }
6107 }
6108 impl From<super::Flight> for Flight {
6109 fn from(value: super::Flight) -> Self {
6110 Self {
6111 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
6112 itinerary_locator: Ok(value.itinerary_locator),
6113 tickets: Ok(value.tickets),
6114 }
6115 }
6116 }
6117 #[derive(Clone, Debug)]
6118 pub struct FlightSegment {
6119 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6120 aircraft_type: Result<Option<super::FlightSegmentAircraftType>, String>,
6121 arrival_airport_code: Result<super::FlightSegmentArrivalAirportCode, String>,
6122 arrival_at: Result<Option<i64>, String>,
6123 arrival_tz: Result<Option<String>, String>,
6124 class_of_service: Result<Option<String>, String>,
6125 departure_airport_code: Result<super::FlightSegmentDepartureAirportCode, String>,
6126 departure_at: Result<Option<i64>, String>,
6127 departure_tz: Result<Option<String>, String>,
6128 fare: Result<Option<i64>, String>,
6129 flight_number: Result<Option<String>, String>,
6130 metadata: Result<Option<Vec<super::Metadatum>>, String>,
6131 seat: Result<Option<String>, String>,
6132 taxes: Result<Option<Vec<super::Tax>>, String>,
6133 }
6134 impl Default for FlightSegment {
6135 fn default() -> Self {
6136 Self {
6137 adjustments: Ok(Default::default()),
6138 aircraft_type: Ok(Default::default()),
6139 arrival_airport_code: Err("no value supplied for arrival_airport_code".to_string()),
6140 arrival_at: Ok(Default::default()),
6141 arrival_tz: Ok(Default::default()),
6142 class_of_service: Ok(Default::default()),
6143 departure_airport_code: Err("no value supplied for departure_airport_code".to_string()),
6144 departure_at: Ok(Default::default()),
6145 departure_tz: Ok(Default::default()),
6146 fare: Ok(Default::default()),
6147 flight_number: Ok(Default::default()),
6148 metadata: Ok(Default::default()),
6149 seat: Ok(Default::default()),
6150 taxes: Ok(Default::default()),
6151 }
6152 }
6153 }
6154 impl FlightSegment {
6155 pub fn adjustments<T>(mut self, value: T) -> Self
6156 where
6157 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6158 T::Error: std::fmt::Display,
6159 {
6160 self.adjustments = value
6161 .try_into()
6162 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
6163 self
6164 }
6165 pub fn aircraft_type<T>(mut self, value: T) -> Self
6166 where
6167 T: std::convert::TryInto<Option<super::FlightSegmentAircraftType>>,
6168 T::Error: std::fmt::Display,
6169 {
6170 self.aircraft_type = value
6171 .try_into()
6172 .map_err(|e| format!("error converting supplied value for aircraft_type: {}", e));
6173 self
6174 }
6175 pub fn arrival_airport_code<T>(mut self, value: T) -> Self
6176 where
6177 T: std::convert::TryInto<super::FlightSegmentArrivalAirportCode>,
6178 T::Error: std::fmt::Display,
6179 {
6180 self.arrival_airport_code = value.try_into().map_err(|e| {
6181 format!(
6182 "error converting supplied value for arrival_airport_code: {}",
6183 e
6184 )
6185 });
6186 self
6187 }
6188 pub fn arrival_at<T>(mut self, value: T) -> Self
6189 where
6190 T: std::convert::TryInto<Option<i64>>,
6191 T::Error: std::fmt::Display,
6192 {
6193 self.arrival_at = value
6194 .try_into()
6195 .map_err(|e| format!("error converting supplied value for arrival_at: {}", e));
6196 self
6197 }
6198 pub fn arrival_tz<T>(mut self, value: T) -> Self
6199 where
6200 T: std::convert::TryInto<Option<String>>,
6201 T::Error: std::fmt::Display,
6202 {
6203 self.arrival_tz = value
6204 .try_into()
6205 .map_err(|e| format!("error converting supplied value for arrival_tz: {}", e));
6206 self
6207 }
6208 pub fn class_of_service<T>(mut self, value: T) -> Self
6209 where
6210 T: std::convert::TryInto<Option<String>>,
6211 T::Error: std::fmt::Display,
6212 {
6213 self.class_of_service = value.try_into().map_err(|e| {
6214 format!(
6215 "error converting supplied value for class_of_service: {}",
6216 e
6217 )
6218 });
6219 self
6220 }
6221 pub fn departure_airport_code<T>(mut self, value: T) -> Self
6222 where
6223 T: std::convert::TryInto<super::FlightSegmentDepartureAirportCode>,
6224 T::Error: std::fmt::Display,
6225 {
6226 self.departure_airport_code = value.try_into().map_err(|e| {
6227 format!(
6228 "error converting supplied value for departure_airport_code: {}",
6229 e
6230 )
6231 });
6232 self
6233 }
6234 pub fn departure_at<T>(mut self, value: T) -> Self
6235 where
6236 T: std::convert::TryInto<Option<i64>>,
6237 T::Error: std::fmt::Display,
6238 {
6239 self.departure_at = value
6240 .try_into()
6241 .map_err(|e| format!("error converting supplied value for departure_at: {}", e));
6242 self
6243 }
6244 pub fn departure_tz<T>(mut self, value: T) -> Self
6245 where
6246 T: std::convert::TryInto<Option<String>>,
6247 T::Error: std::fmt::Display,
6248 {
6249 self.departure_tz = value
6250 .try_into()
6251 .map_err(|e| format!("error converting supplied value for departure_tz: {}", e));
6252 self
6253 }
6254 pub fn fare<T>(mut self, value: T) -> Self
6255 where
6256 T: std::convert::TryInto<Option<i64>>,
6257 T::Error: std::fmt::Display,
6258 {
6259 self.fare = value
6260 .try_into()
6261 .map_err(|e| format!("error converting supplied value for fare: {}", e));
6262 self
6263 }
6264 pub fn flight_number<T>(mut self, value: T) -> Self
6265 where
6266 T: std::convert::TryInto<Option<String>>,
6267 T::Error: std::fmt::Display,
6268 {
6269 self.flight_number = value
6270 .try_into()
6271 .map_err(|e| format!("error converting supplied value for flight_number: {}", e));
6272 self
6273 }
6274 pub fn metadata<T>(mut self, value: T) -> Self
6275 where
6276 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
6277 T::Error: std::fmt::Display,
6278 {
6279 self.metadata = value
6280 .try_into()
6281 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
6282 self
6283 }
6284 pub fn seat<T>(mut self, value: T) -> Self
6285 where
6286 T: std::convert::TryInto<Option<String>>,
6287 T::Error: std::fmt::Display,
6288 {
6289 self.seat = value
6290 .try_into()
6291 .map_err(|e| format!("error converting supplied value for seat: {}", e));
6292 self
6293 }
6294 pub fn taxes<T>(mut self, value: T) -> Self
6295 where
6296 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6297 T::Error: std::fmt::Display,
6298 {
6299 self.taxes = value
6300 .try_into()
6301 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6302 self
6303 }
6304 }
6305 impl std::convert::TryFrom<FlightSegment> for super::FlightSegment {
6306 type Error = super::error::ConversionError;
6307 fn try_from(value: FlightSegment) -> Result<Self, super::error::ConversionError> {
6308 Ok(Self {
6309 adjustments: value.adjustments?,
6310 aircraft_type: value.aircraft_type?,
6311 arrival_airport_code: value.arrival_airport_code?,
6312 arrival_at: value.arrival_at?,
6313 arrival_tz: value.arrival_tz?,
6314 class_of_service: value.class_of_service?,
6315 departure_airport_code: value.departure_airport_code?,
6316 departure_at: value.departure_at?,
6317 departure_tz: value.departure_tz?,
6318 fare: value.fare?,
6319 flight_number: value.flight_number?,
6320 metadata: value.metadata?,
6321 seat: value.seat?,
6322 taxes: value.taxes?,
6323 })
6324 }
6325 }
6326 impl From<super::FlightSegment> for FlightSegment {
6327 fn from(value: super::FlightSegment) -> Self {
6328 Self {
6329 adjustments: Ok(value.adjustments),
6330 aircraft_type: Ok(value.aircraft_type),
6331 arrival_airport_code: Ok(value.arrival_airport_code),
6332 arrival_at: Ok(value.arrival_at),
6333 arrival_tz: Ok(value.arrival_tz),
6334 class_of_service: Ok(value.class_of_service),
6335 departure_airport_code: Ok(value.departure_airport_code),
6336 departure_at: Ok(value.departure_at),
6337 departure_tz: Ok(value.departure_tz),
6338 fare: Ok(value.fare),
6339 flight_number: Ok(value.flight_number),
6340 metadata: Ok(value.metadata),
6341 seat: Ok(value.seat),
6342 taxes: Ok(value.taxes),
6343 }
6344 }
6345 }
6346 #[derive(Clone, Debug)]
6347 pub struct FlightTicket {
6348 fare: Result<Option<i64>, String>,
6349 number: Result<Option<String>, String>,
6350 passenger: Result<Option<super::Person>, String>,
6351 record_locator: Result<Option<String>, String>,
6352 segments: Result<Vec<super::FlightSegment>, String>,
6353 taxes: Result<Option<Vec<super::Tax>>, String>,
6354 }
6355 impl Default for FlightTicket {
6356 fn default() -> Self {
6357 Self {
6358 fare: Ok(Default::default()),
6359 number: Ok(Default::default()),
6360 passenger: Ok(Default::default()),
6361 record_locator: Ok(Default::default()),
6362 segments: Err("no value supplied for segments".to_string()),
6363 taxes: Ok(Default::default()),
6364 }
6365 }
6366 }
6367 impl FlightTicket {
6368 pub fn fare<T>(mut self, value: T) -> Self
6369 where
6370 T: std::convert::TryInto<Option<i64>>,
6371 T::Error: std::fmt::Display,
6372 {
6373 self.fare = value
6374 .try_into()
6375 .map_err(|e| format!("error converting supplied value for fare: {}", e));
6376 self
6377 }
6378 pub fn number<T>(mut self, value: T) -> Self
6379 where
6380 T: std::convert::TryInto<Option<String>>,
6381 T::Error: std::fmt::Display,
6382 {
6383 self.number = value
6384 .try_into()
6385 .map_err(|e| format!("error converting supplied value for number: {}", e));
6386 self
6387 }
6388 pub fn passenger<T>(mut self, value: T) -> Self
6389 where
6390 T: std::convert::TryInto<Option<super::Person>>,
6391 T::Error: std::fmt::Display,
6392 {
6393 self.passenger = value
6394 .try_into()
6395 .map_err(|e| format!("error converting supplied value for passenger: {}", e));
6396 self
6397 }
6398 pub fn record_locator<T>(mut self, value: T) -> Self
6399 where
6400 T: std::convert::TryInto<Option<String>>,
6401 T::Error: std::fmt::Display,
6402 {
6403 self.record_locator = value
6404 .try_into()
6405 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
6406 self
6407 }
6408 pub fn segments<T>(mut self, value: T) -> Self
6409 where
6410 T: std::convert::TryInto<Vec<super::FlightSegment>>,
6411 T::Error: std::fmt::Display,
6412 {
6413 self.segments = value
6414 .try_into()
6415 .map_err(|e| format!("error converting supplied value for segments: {}", e));
6416 self
6417 }
6418 pub fn taxes<T>(mut self, value: T) -> Self
6419 where
6420 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6421 T::Error: std::fmt::Display,
6422 {
6423 self.taxes = value
6424 .try_into()
6425 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6426 self
6427 }
6428 }
6429 impl std::convert::TryFrom<FlightTicket> for super::FlightTicket {
6430 type Error = super::error::ConversionError;
6431 fn try_from(value: FlightTicket) -> Result<Self, super::error::ConversionError> {
6432 Ok(Self {
6433 fare: value.fare?,
6434 number: value.number?,
6435 passenger: value.passenger?,
6436 record_locator: value.record_locator?,
6437 segments: value.segments?,
6438 taxes: value.taxes?,
6439 })
6440 }
6441 }
6442 impl From<super::FlightTicket> for FlightTicket {
6443 fn from(value: super::FlightTicket) -> Self {
6444 Self {
6445 fare: Ok(value.fare),
6446 number: Ok(value.number),
6447 passenger: Ok(value.passenger),
6448 record_locator: Ok(value.record_locator),
6449 segments: Ok(value.segments),
6450 taxes: Ok(value.taxes),
6451 }
6452 }
6453 }
6454 #[derive(Clone, Debug)]
6455 pub struct Footer {
6456 actions: Result<Option<Vec<super::Action>>, String>,
6457 supplemental_text: Result<Option<String>, String>,
6458 }
6459 impl Default for Footer {
6460 fn default() -> Self {
6461 Self {
6462 actions: Ok(Default::default()),
6463 supplemental_text: Ok(Default::default()),
6464 }
6465 }
6466 }
6467 impl Footer {
6468 pub fn actions<T>(mut self, value: T) -> Self
6469 where
6470 T: std::convert::TryInto<Option<Vec<super::Action>>>,
6471 T::Error: std::fmt::Display,
6472 {
6473 self.actions = value
6474 .try_into()
6475 .map_err(|e| format!("error converting supplied value for actions: {}", e));
6476 self
6477 }
6478 pub fn supplemental_text<T>(mut self, value: T) -> Self
6479 where
6480 T: std::convert::TryInto<Option<String>>,
6481 T::Error: std::fmt::Display,
6482 {
6483 self.supplemental_text = value.try_into().map_err(|e| {
6484 format!(
6485 "error converting supplied value for supplemental_text: {}",
6486 e
6487 )
6488 });
6489 self
6490 }
6491 }
6492 impl std::convert::TryFrom<Footer> for super::Footer {
6493 type Error = super::error::ConversionError;
6494 fn try_from(value: Footer) -> Result<Self, super::error::ConversionError> {
6495 Ok(Self {
6496 actions: value.actions?,
6497 supplemental_text: value.supplemental_text?,
6498 })
6499 }
6500 }
6501 impl From<super::Footer> for Footer {
6502 fn from(value: super::Footer) -> Self {
6503 Self {
6504 actions: Ok(value.actions),
6505 supplemental_text: Ok(value.supplemental_text),
6506 }
6507 }
6508 }
6509 #[derive(Clone, Debug)]
6510 pub struct GeneralItemization {
6511 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6512 items: Result<Vec<super::Item>, String>,
6513 }
6514 impl Default for GeneralItemization {
6515 fn default() -> Self {
6516 Self {
6517 invoice_level_adjustments: Ok(Default::default()),
6518 items: Err("no value supplied for items".to_string()),
6519 }
6520 }
6521 }
6522 impl GeneralItemization {
6523 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
6524 where
6525 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6526 T::Error: std::fmt::Display,
6527 {
6528 self.invoice_level_adjustments = value.try_into().map_err(|e| {
6529 format!(
6530 "error converting supplied value for invoice_level_adjustments: {}",
6531 e
6532 )
6533 });
6534 self
6535 }
6536 pub fn items<T>(mut self, value: T) -> Self
6537 where
6538 T: std::convert::TryInto<Vec<super::Item>>,
6539 T::Error: std::fmt::Display,
6540 {
6541 self.items = value
6542 .try_into()
6543 .map_err(|e| format!("error converting supplied value for items: {}", e));
6544 self
6545 }
6546 }
6547 impl std::convert::TryFrom<GeneralItemization> for super::GeneralItemization {
6548 type Error = super::error::ConversionError;
6549 fn try_from(value: GeneralItemization) -> Result<Self, super::error::ConversionError> {
6550 Ok(Self {
6551 invoice_level_adjustments: value.invoice_level_adjustments?,
6552 items: value.items?,
6553 })
6554 }
6555 }
6556 impl From<super::GeneralItemization> for GeneralItemization {
6557 fn from(value: super::GeneralItemization) -> Self {
6558 Self {
6559 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
6560 items: Ok(value.items),
6561 }
6562 }
6563 }
6564 #[derive(Clone, Debug)]
6565 pub struct Header {
6566 currency: Result<super::Currency, String>,
6567 customer: Result<Option<super::Customer>, String>,
6568 invoice_asset_id: Result<Option<String>, String>,
6569 invoice_number: Result<Option<String>, String>,
6570 invoiced_at: Result<i64, String>,
6571 location: Result<Option<super::Place>, String>,
6572 mcc: Result<Option<super::HeaderMcc>, String>,
6573 paid: Result<i64, String>,
6574 receipt_asset_id: Result<Option<String>, String>,
6575 subtotal: Result<i64, String>,
6576 third_party: Result<Option<super::HeaderThirdParty>, String>,
6577 total: Result<i64, String>,
6578 }
6579 impl Default for Header {
6580 fn default() -> Self {
6581 Self {
6582 currency: Err("no value supplied for currency".to_string()),
6583 customer: Ok(Default::default()),
6584 invoice_asset_id: Ok(Default::default()),
6585 invoice_number: Ok(Default::default()),
6586 invoiced_at: Err("no value supplied for invoiced_at".to_string()),
6587 location: Ok(Default::default()),
6588 mcc: Ok(Default::default()),
6589 paid: Err("no value supplied for paid".to_string()),
6590 receipt_asset_id: Ok(Default::default()),
6591 subtotal: Err("no value supplied for subtotal".to_string()),
6592 third_party: Ok(Default::default()),
6593 total: Err("no value supplied for total".to_string()),
6594 }
6595 }
6596 }
6597 impl Header {
6598 pub fn currency<T>(mut self, value: T) -> Self
6599 where
6600 T: std::convert::TryInto<super::Currency>,
6601 T::Error: std::fmt::Display,
6602 {
6603 self.currency = value
6604 .try_into()
6605 .map_err(|e| format!("error converting supplied value for currency: {}", e));
6606 self
6607 }
6608 pub fn customer<T>(mut self, value: T) -> Self
6609 where
6610 T: std::convert::TryInto<Option<super::Customer>>,
6611 T::Error: std::fmt::Display,
6612 {
6613 self.customer = value
6614 .try_into()
6615 .map_err(|e| format!("error converting supplied value for customer: {}", e));
6616 self
6617 }
6618 pub fn invoice_asset_id<T>(mut self, value: T) -> Self
6619 where
6620 T: std::convert::TryInto<Option<String>>,
6621 T::Error: std::fmt::Display,
6622 {
6623 self.invoice_asset_id = value.try_into().map_err(|e| {
6624 format!(
6625 "error converting supplied value for invoice_asset_id: {}",
6626 e
6627 )
6628 });
6629 self
6630 }
6631 pub fn invoice_number<T>(mut self, value: T) -> Self
6632 where
6633 T: std::convert::TryInto<Option<String>>,
6634 T::Error: std::fmt::Display,
6635 {
6636 self.invoice_number = value
6637 .try_into()
6638 .map_err(|e| format!("error converting supplied value for invoice_number: {}", e));
6639 self
6640 }
6641 pub fn invoiced_at<T>(mut self, value: T) -> Self
6642 where
6643 T: std::convert::TryInto<i64>,
6644 T::Error: std::fmt::Display,
6645 {
6646 self.invoiced_at = value
6647 .try_into()
6648 .map_err(|e| format!("error converting supplied value for invoiced_at: {}", e));
6649 self
6650 }
6651 pub fn location<T>(mut self, value: T) -> Self
6652 where
6653 T: std::convert::TryInto<Option<super::Place>>,
6654 T::Error: std::fmt::Display,
6655 {
6656 self.location = value
6657 .try_into()
6658 .map_err(|e| format!("error converting supplied value for location: {}", e));
6659 self
6660 }
6661 pub fn mcc<T>(mut self, value: T) -> Self
6662 where
6663 T: std::convert::TryInto<Option<super::HeaderMcc>>,
6664 T::Error: std::fmt::Display,
6665 {
6666 self.mcc = value
6667 .try_into()
6668 .map_err(|e| format!("error converting supplied value for mcc: {}", e));
6669 self
6670 }
6671 pub fn paid<T>(mut self, value: T) -> Self
6672 where
6673 T: std::convert::TryInto<i64>,
6674 T::Error: std::fmt::Display,
6675 {
6676 self.paid = value
6677 .try_into()
6678 .map_err(|e| format!("error converting supplied value for paid: {}", e));
6679 self
6680 }
6681 pub fn receipt_asset_id<T>(mut self, value: T) -> Self
6682 where
6683 T: std::convert::TryInto<Option<String>>,
6684 T::Error: std::fmt::Display,
6685 {
6686 self.receipt_asset_id = value.try_into().map_err(|e| {
6687 format!(
6688 "error converting supplied value for receipt_asset_id: {}",
6689 e
6690 )
6691 });
6692 self
6693 }
6694 pub fn subtotal<T>(mut self, value: T) -> Self
6695 where
6696 T: std::convert::TryInto<i64>,
6697 T::Error: std::fmt::Display,
6698 {
6699 self.subtotal = value
6700 .try_into()
6701 .map_err(|e| format!("error converting supplied value for subtotal: {}", e));
6702 self
6703 }
6704 pub fn third_party<T>(mut self, value: T) -> Self
6705 where
6706 T: std::convert::TryInto<Option<super::HeaderThirdParty>>,
6707 T::Error: std::fmt::Display,
6708 {
6709 self.third_party = value
6710 .try_into()
6711 .map_err(|e| format!("error converting supplied value for third_party: {}", e));
6712 self
6713 }
6714 pub fn total<T>(mut self, value: T) -> Self
6715 where
6716 T: std::convert::TryInto<i64>,
6717 T::Error: std::fmt::Display,
6718 {
6719 self.total = value
6720 .try_into()
6721 .map_err(|e| format!("error converting supplied value for total: {}", e));
6722 self
6723 }
6724 }
6725 impl std::convert::TryFrom<Header> for super::Header {
6726 type Error = super::error::ConversionError;
6727 fn try_from(value: Header) -> Result<Self, super::error::ConversionError> {
6728 Ok(Self {
6729 currency: value.currency?,
6730 customer: value.customer?,
6731 invoice_asset_id: value.invoice_asset_id?,
6732 invoice_number: value.invoice_number?,
6733 invoiced_at: value.invoiced_at?,
6734 location: value.location?,
6735 mcc: value.mcc?,
6736 paid: value.paid?,
6737 receipt_asset_id: value.receipt_asset_id?,
6738 subtotal: value.subtotal?,
6739 third_party: value.third_party?,
6740 total: value.total?,
6741 })
6742 }
6743 }
6744 impl From<super::Header> for Header {
6745 fn from(value: super::Header) -> Self {
6746 Self {
6747 currency: Ok(value.currency),
6748 customer: Ok(value.customer),
6749 invoice_asset_id: Ok(value.invoice_asset_id),
6750 invoice_number: Ok(value.invoice_number),
6751 invoiced_at: Ok(value.invoiced_at),
6752 location: Ok(value.location),
6753 mcc: Ok(value.mcc),
6754 paid: Ok(value.paid),
6755 receipt_asset_id: Ok(value.receipt_asset_id),
6756 subtotal: Ok(value.subtotal),
6757 third_party: Ok(value.third_party),
6758 total: Ok(value.total),
6759 }
6760 }
6761 }
6762 #[derive(Clone, Debug)]
6763 pub struct HeaderThirdParty {
6764 make_primary: Result<bool, String>,
6765 merchant: Result<Option<super::Org>, String>,
6766 relation: Result<super::HeaderThirdPartyRelation, String>,
6767 }
6768 impl Default for HeaderThirdParty {
6769 fn default() -> Self {
6770 Self {
6771 make_primary: Err("no value supplied for make_primary".to_string()),
6772 merchant: Ok(Default::default()),
6773 relation: Err("no value supplied for relation".to_string()),
6774 }
6775 }
6776 }
6777 impl HeaderThirdParty {
6778 pub fn make_primary<T>(mut self, value: T) -> Self
6779 where
6780 T: std::convert::TryInto<bool>,
6781 T::Error: std::fmt::Display,
6782 {
6783 self.make_primary = value
6784 .try_into()
6785 .map_err(|e| format!("error converting supplied value for make_primary: {}", e));
6786 self
6787 }
6788 pub fn merchant<T>(mut self, value: T) -> Self
6789 where
6790 T: std::convert::TryInto<Option<super::Org>>,
6791 T::Error: std::fmt::Display,
6792 {
6793 self.merchant = value
6794 .try_into()
6795 .map_err(|e| format!("error converting supplied value for merchant: {}", e));
6796 self
6797 }
6798 pub fn relation<T>(mut self, value: T) -> Self
6799 where
6800 T: std::convert::TryInto<super::HeaderThirdPartyRelation>,
6801 T::Error: std::fmt::Display,
6802 {
6803 self.relation = value
6804 .try_into()
6805 .map_err(|e| format!("error converting supplied value for relation: {}", e));
6806 self
6807 }
6808 }
6809 impl std::convert::TryFrom<HeaderThirdParty> for super::HeaderThirdParty {
6810 type Error = super::error::ConversionError;
6811 fn try_from(value: HeaderThirdParty) -> Result<Self, super::error::ConversionError> {
6812 Ok(Self {
6813 make_primary: value.make_primary?,
6814 merchant: value.merchant?,
6815 relation: value.relation?,
6816 })
6817 }
6818 }
6819 impl From<super::HeaderThirdParty> for HeaderThirdParty {
6820 fn from(value: super::HeaderThirdParty) -> Self {
6821 Self {
6822 make_primary: Ok(value.make_primary),
6823 merchant: Ok(value.merchant),
6824 relation: Ok(value.relation),
6825 }
6826 }
6827 }
6828 #[derive(Clone, Debug)]
6829 pub struct Item {
6830 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6831 amount: Result<i64, String>,
6832 date: Result<Option<String>, String>,
6833 description: Result<String, String>,
6834 group: Result<Option<String>, String>,
6835 metadata: Result<Option<Vec<super::Metadatum>>, String>,
6836 product_image_asset_id: Result<Option<String>, String>,
6837 quantity: Result<Option<f64>, String>,
6838 taxes: Result<Option<Vec<super::Tax>>, String>,
6839 unit: Result<Option<String>, String>,
6840 unit_cost: Result<Option<i64>, String>,
6841 unspsc: Result<Option<super::ItemUnspsc>, String>,
6842 url: Result<Option<String>, String>,
6843 }
6844 impl Default for Item {
6845 fn default() -> Self {
6846 Self {
6847 adjustments: Ok(Default::default()),
6848 amount: Err("no value supplied for amount".to_string()),
6849 date: Ok(Default::default()),
6850 description: Err("no value supplied for description".to_string()),
6851 group: Ok(Default::default()),
6852 metadata: Ok(Default::default()),
6853 product_image_asset_id: Ok(Default::default()),
6854 quantity: Ok(Default::default()),
6855 taxes: Ok(Default::default()),
6856 unit: Ok(Default::default()),
6857 unit_cost: Ok(Default::default()),
6858 unspsc: Ok(Default::default()),
6859 url: Ok(Default::default()),
6860 }
6861 }
6862 }
6863 impl Item {
6864 pub fn adjustments<T>(mut self, value: T) -> Self
6865 where
6866 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6867 T::Error: std::fmt::Display,
6868 {
6869 self.adjustments = value
6870 .try_into()
6871 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
6872 self
6873 }
6874 pub fn amount<T>(mut self, value: T) -> Self
6875 where
6876 T: std::convert::TryInto<i64>,
6877 T::Error: std::fmt::Display,
6878 {
6879 self.amount = value
6880 .try_into()
6881 .map_err(|e| format!("error converting supplied value for amount: {}", e));
6882 self
6883 }
6884 pub fn date<T>(mut self, value: T) -> Self
6885 where
6886 T: std::convert::TryInto<Option<String>>,
6887 T::Error: std::fmt::Display,
6888 {
6889 self.date = value
6890 .try_into()
6891 .map_err(|e| format!("error converting supplied value for date: {}", e));
6892 self
6893 }
6894 pub fn description<T>(mut self, value: T) -> Self
6895 where
6896 T: std::convert::TryInto<String>,
6897 T::Error: std::fmt::Display,
6898 {
6899 self.description = value
6900 .try_into()
6901 .map_err(|e| format!("error converting supplied value for description: {}", e));
6902 self
6903 }
6904 pub fn group<T>(mut self, value: T) -> Self
6905 where
6906 T: std::convert::TryInto<Option<String>>,
6907 T::Error: std::fmt::Display,
6908 {
6909 self.group = value
6910 .try_into()
6911 .map_err(|e| format!("error converting supplied value for group: {}", e));
6912 self
6913 }
6914 pub fn metadata<T>(mut self, value: T) -> Self
6915 where
6916 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
6917 T::Error: std::fmt::Display,
6918 {
6919 self.metadata = value
6920 .try_into()
6921 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
6922 self
6923 }
6924 pub fn product_image_asset_id<T>(mut self, value: T) -> Self
6925 where
6926 T: std::convert::TryInto<Option<String>>,
6927 T::Error: std::fmt::Display,
6928 {
6929 self.product_image_asset_id = value.try_into().map_err(|e| {
6930 format!(
6931 "error converting supplied value for product_image_asset_id: {}",
6932 e
6933 )
6934 });
6935 self
6936 }
6937 pub fn quantity<T>(mut self, value: T) -> Self
6938 where
6939 T: std::convert::TryInto<Option<f64>>,
6940 T::Error: std::fmt::Display,
6941 {
6942 self.quantity = value
6943 .try_into()
6944 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
6945 self
6946 }
6947 pub fn taxes<T>(mut self, value: T) -> Self
6948 where
6949 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6950 T::Error: std::fmt::Display,
6951 {
6952 self.taxes = value
6953 .try_into()
6954 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6955 self
6956 }
6957 pub fn unit<T>(mut self, value: T) -> Self
6958 where
6959 T: std::convert::TryInto<Option<String>>,
6960 T::Error: std::fmt::Display,
6961 {
6962 self.unit = value
6963 .try_into()
6964 .map_err(|e| format!("error converting supplied value for unit: {}", e));
6965 self
6966 }
6967 pub fn unit_cost<T>(mut self, value: T) -> Self
6968 where
6969 T: std::convert::TryInto<Option<i64>>,
6970 T::Error: std::fmt::Display,
6971 {
6972 self.unit_cost = value
6973 .try_into()
6974 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
6975 self
6976 }
6977 pub fn unspsc<T>(mut self, value: T) -> Self
6978 where
6979 T: std::convert::TryInto<Option<super::ItemUnspsc>>,
6980 T::Error: std::fmt::Display,
6981 {
6982 self.unspsc = value
6983 .try_into()
6984 .map_err(|e| format!("error converting supplied value for unspsc: {}", e));
6985 self
6986 }
6987 pub fn url<T>(mut self, value: T) -> Self
6988 where
6989 T: std::convert::TryInto<Option<String>>,
6990 T::Error: std::fmt::Display,
6991 {
6992 self.url = value
6993 .try_into()
6994 .map_err(|e| format!("error converting supplied value for url: {}", e));
6995 self
6996 }
6997 }
6998 impl std::convert::TryFrom<Item> for super::Item {
6999 type Error = super::error::ConversionError;
7000 fn try_from(value: Item) -> Result<Self, super::error::ConversionError> {
7001 Ok(Self {
7002 adjustments: value.adjustments?,
7003 amount: value.amount?,
7004 date: value.date?,
7005 description: value.description?,
7006 group: value.group?,
7007 metadata: value.metadata?,
7008 product_image_asset_id: value.product_image_asset_id?,
7009 quantity: value.quantity?,
7010 taxes: value.taxes?,
7011 unit: value.unit?,
7012 unit_cost: value.unit_cost?,
7013 unspsc: value.unspsc?,
7014 url: value.url?,
7015 })
7016 }
7017 }
7018 impl From<super::Item> for Item {
7019 fn from(value: super::Item) -> Self {
7020 Self {
7021 adjustments: Ok(value.adjustments),
7022 amount: Ok(value.amount),
7023 date: Ok(value.date),
7024 description: Ok(value.description),
7025 group: Ok(value.group),
7026 metadata: Ok(value.metadata),
7027 product_image_asset_id: Ok(value.product_image_asset_id),
7028 quantity: Ok(value.quantity),
7029 taxes: Ok(value.taxes),
7030 unit: Ok(value.unit),
7031 unit_cost: Ok(value.unit_cost),
7032 unspsc: Ok(value.unspsc),
7033 url: Ok(value.url),
7034 }
7035 }
7036 }
7037 #[derive(Clone, Debug)]
7038 pub struct Itemization {
7039 car_rental: Result<Option<super::CarRental>, String>,
7040 ecommerce: Result<Option<super::Ecommerce>, String>,
7041 flight: Result<Option<super::Flight>, String>,
7042 general: Result<Option<super::GeneralItemization>, String>,
7043 lodging: Result<Option<super::Lodging>, String>,
7044 service: Result<Option<super::Service>, String>,
7045 subscription: Result<Option<super::Subscription>, String>,
7046 transit_route: Result<Option<super::TransitRoute>, String>,
7047 }
7048 impl Default for Itemization {
7049 fn default() -> Self {
7050 Self {
7051 car_rental: Ok(Default::default()),
7052 ecommerce: Ok(Default::default()),
7053 flight: Ok(Default::default()),
7054 general: Ok(Default::default()),
7055 lodging: Ok(Default::default()),
7056 service: Ok(Default::default()),
7057 subscription: Ok(Default::default()),
7058 transit_route: Ok(Default::default()),
7059 }
7060 }
7061 }
7062 impl Itemization {
7063 pub fn car_rental<T>(mut self, value: T) -> Self
7064 where
7065 T: std::convert::TryInto<Option<super::CarRental>>,
7066 T::Error: std::fmt::Display,
7067 {
7068 self.car_rental = value
7069 .try_into()
7070 .map_err(|e| format!("error converting supplied value for car_rental: {}", e));
7071 self
7072 }
7073 pub fn ecommerce<T>(mut self, value: T) -> Self
7074 where
7075 T: std::convert::TryInto<Option<super::Ecommerce>>,
7076 T::Error: std::fmt::Display,
7077 {
7078 self.ecommerce = value
7079 .try_into()
7080 .map_err(|e| format!("error converting supplied value for ecommerce: {}", e));
7081 self
7082 }
7083 pub fn flight<T>(mut self, value: T) -> Self
7084 where
7085 T: std::convert::TryInto<Option<super::Flight>>,
7086 T::Error: std::fmt::Display,
7087 {
7088 self.flight = value
7089 .try_into()
7090 .map_err(|e| format!("error converting supplied value for flight: {}", e));
7091 self
7092 }
7093 pub fn general<T>(mut self, value: T) -> Self
7094 where
7095 T: std::convert::TryInto<Option<super::GeneralItemization>>,
7096 T::Error: std::fmt::Display,
7097 {
7098 self.general = value
7099 .try_into()
7100 .map_err(|e| format!("error converting supplied value for general: {}", e));
7101 self
7102 }
7103 pub fn lodging<T>(mut self, value: T) -> Self
7104 where
7105 T: std::convert::TryInto<Option<super::Lodging>>,
7106 T::Error: std::fmt::Display,
7107 {
7108 self.lodging = value
7109 .try_into()
7110 .map_err(|e| format!("error converting supplied value for lodging: {}", e));
7111 self
7112 }
7113 pub fn service<T>(mut self, value: T) -> Self
7114 where
7115 T: std::convert::TryInto<Option<super::Service>>,
7116 T::Error: std::fmt::Display,
7117 {
7118 self.service = value
7119 .try_into()
7120 .map_err(|e| format!("error converting supplied value for service: {}", e));
7121 self
7122 }
7123 pub fn subscription<T>(mut self, value: T) -> Self
7124 where
7125 T: std::convert::TryInto<Option<super::Subscription>>,
7126 T::Error: std::fmt::Display,
7127 {
7128 self.subscription = value
7129 .try_into()
7130 .map_err(|e| format!("error converting supplied value for subscription: {}", e));
7131 self
7132 }
7133 pub fn transit_route<T>(mut self, value: T) -> Self
7134 where
7135 T: std::convert::TryInto<Option<super::TransitRoute>>,
7136 T::Error: std::fmt::Display,
7137 {
7138 self.transit_route = value
7139 .try_into()
7140 .map_err(|e| format!("error converting supplied value for transit_route: {}", e));
7141 self
7142 }
7143 }
7144 impl std::convert::TryFrom<Itemization> for super::Itemization {
7145 type Error = super::error::ConversionError;
7146 fn try_from(value: Itemization) -> Result<Self, super::error::ConversionError> {
7147 Ok(Self {
7148 car_rental: value.car_rental?,
7149 ecommerce: value.ecommerce?,
7150 flight: value.flight?,
7151 general: value.general?,
7152 lodging: value.lodging?,
7153 service: value.service?,
7154 subscription: value.subscription?,
7155 transit_route: value.transit_route?,
7156 })
7157 }
7158 }
7159 impl From<super::Itemization> for Itemization {
7160 fn from(value: super::Itemization) -> Self {
7161 Self {
7162 car_rental: Ok(value.car_rental),
7163 ecommerce: Ok(value.ecommerce),
7164 flight: Ok(value.flight),
7165 general: Ok(value.general),
7166 lodging: Ok(value.lodging),
7167 service: Ok(value.service),
7168 subscription: Ok(value.subscription),
7169 transit_route: Ok(value.transit_route),
7170 }
7171 }
7172 }
7173 #[derive(Clone, Debug)]
7174 pub struct Lodging {
7175 chain_code: Result<Option<super::LodgingChainCode>, String>,
7176 check_in: Result<i64, String>,
7177 check_out: Result<i64, String>,
7178 confirmation_number: Result<Option<String>, String>,
7179 guests: Result<Option<Vec<super::Person>>, String>,
7180 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
7181 items: Result<Vec<super::Item>, String>,
7182 location: Result<super::Place, String>,
7183 metadata: Result<Option<Vec<super::Metadatum>>, String>,
7184 property_id: Result<Option<super::LodgingPropertyId>, String>,
7185 record_locator: Result<Option<String>, String>,
7186 room: Result<Option<String>, String>,
7187 }
7188 impl Default for Lodging {
7189 fn default() -> Self {
7190 Self {
7191 chain_code: Ok(Default::default()),
7192 check_in: Err("no value supplied for check_in".to_string()),
7193 check_out: Err("no value supplied for check_out".to_string()),
7194 confirmation_number: Ok(Default::default()),
7195 guests: Ok(Default::default()),
7196 invoice_level_adjustments: Ok(Default::default()),
7197 items: Err("no value supplied for items".to_string()),
7198 location: Err("no value supplied for location".to_string()),
7199 metadata: Ok(Default::default()),
7200 property_id: Ok(Default::default()),
7201 record_locator: Ok(Default::default()),
7202 room: Ok(Default::default()),
7203 }
7204 }
7205 }
7206 impl Lodging {
7207 pub fn chain_code<T>(mut self, value: T) -> Self
7208 where
7209 T: std::convert::TryInto<Option<super::LodgingChainCode>>,
7210 T::Error: std::fmt::Display,
7211 {
7212 self.chain_code = value
7213 .try_into()
7214 .map_err(|e| format!("error converting supplied value for chain_code: {}", e));
7215 self
7216 }
7217 pub fn check_in<T>(mut self, value: T) -> Self
7218 where
7219 T: std::convert::TryInto<i64>,
7220 T::Error: std::fmt::Display,
7221 {
7222 self.check_in = value
7223 .try_into()
7224 .map_err(|e| format!("error converting supplied value for check_in: {}", e));
7225 self
7226 }
7227 pub fn check_out<T>(mut self, value: T) -> Self
7228 where
7229 T: std::convert::TryInto<i64>,
7230 T::Error: std::fmt::Display,
7231 {
7232 self.check_out = value
7233 .try_into()
7234 .map_err(|e| format!("error converting supplied value for check_out: {}", e));
7235 self
7236 }
7237 pub fn confirmation_number<T>(mut self, value: T) -> Self
7238 where
7239 T: std::convert::TryInto<Option<String>>,
7240 T::Error: std::fmt::Display,
7241 {
7242 self.confirmation_number = value.try_into().map_err(|e| {
7243 format!(
7244 "error converting supplied value for confirmation_number: {}",
7245 e
7246 )
7247 });
7248 self
7249 }
7250 pub fn guests<T>(mut self, value: T) -> Self
7251 where
7252 T: std::convert::TryInto<Option<Vec<super::Person>>>,
7253 T::Error: std::fmt::Display,
7254 {
7255 self.guests = value
7256 .try_into()
7257 .map_err(|e| format!("error converting supplied value for guests: {}", e));
7258 self
7259 }
7260 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
7261 where
7262 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
7263 T::Error: std::fmt::Display,
7264 {
7265 self.invoice_level_adjustments = value.try_into().map_err(|e| {
7266 format!(
7267 "error converting supplied value for invoice_level_adjustments: {}",
7268 e
7269 )
7270 });
7271 self
7272 }
7273 pub fn items<T>(mut self, value: T) -> Self
7274 where
7275 T: std::convert::TryInto<Vec<super::Item>>,
7276 T::Error: std::fmt::Display,
7277 {
7278 self.items = value
7279 .try_into()
7280 .map_err(|e| format!("error converting supplied value for items: {}", e));
7281 self
7282 }
7283 pub fn location<T>(mut self, value: T) -> Self
7284 where
7285 T: std::convert::TryInto<super::Place>,
7286 T::Error: std::fmt::Display,
7287 {
7288 self.location = value
7289 .try_into()
7290 .map_err(|e| format!("error converting supplied value for location: {}", e));
7291 self
7292 }
7293 pub fn metadata<T>(mut self, value: T) -> Self
7294 where
7295 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
7296 T::Error: std::fmt::Display,
7297 {
7298 self.metadata = value
7299 .try_into()
7300 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
7301 self
7302 }
7303 pub fn property_id<T>(mut self, value: T) -> Self
7304 where
7305 T: std::convert::TryInto<Option<super::LodgingPropertyId>>,
7306 T::Error: std::fmt::Display,
7307 {
7308 self.property_id = value
7309 .try_into()
7310 .map_err(|e| format!("error converting supplied value for property_id: {}", e));
7311 self
7312 }
7313 pub fn record_locator<T>(mut self, value: T) -> Self
7314 where
7315 T: std::convert::TryInto<Option<String>>,
7316 T::Error: std::fmt::Display,
7317 {
7318 self.record_locator = value
7319 .try_into()
7320 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
7321 self
7322 }
7323 pub fn room<T>(mut self, value: T) -> Self
7324 where
7325 T: std::convert::TryInto<Option<String>>,
7326 T::Error: std::fmt::Display,
7327 {
7328 self.room = value
7329 .try_into()
7330 .map_err(|e| format!("error converting supplied value for room: {}", e));
7331 self
7332 }
7333 }
7334 impl std::convert::TryFrom<Lodging> for super::Lodging {
7335 type Error = super::error::ConversionError;
7336 fn try_from(value: Lodging) -> Result<Self, super::error::ConversionError> {
7337 Ok(Self {
7338 chain_code: value.chain_code?,
7339 check_in: value.check_in?,
7340 check_out: value.check_out?,
7341 confirmation_number: value.confirmation_number?,
7342 guests: value.guests?,
7343 invoice_level_adjustments: value.invoice_level_adjustments?,
7344 items: value.items?,
7345 location: value.location?,
7346 metadata: value.metadata?,
7347 property_id: value.property_id?,
7348 record_locator: value.record_locator?,
7349 room: value.room?,
7350 })
7351 }
7352 }
7353 impl From<super::Lodging> for Lodging {
7354 fn from(value: super::Lodging) -> Self {
7355 Self {
7356 chain_code: Ok(value.chain_code),
7357 check_in: Ok(value.check_in),
7358 check_out: Ok(value.check_out),
7359 confirmation_number: Ok(value.confirmation_number),
7360 guests: Ok(value.guests),
7361 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
7362 items: Ok(value.items),
7363 location: Ok(value.location),
7364 metadata: Ok(value.metadata),
7365 property_id: Ok(value.property_id),
7366 record_locator: Ok(value.record_locator),
7367 room: Ok(value.room),
7368 }
7369 }
7370 }
7371 #[derive(Clone, Debug)]
7372 pub struct Metadatum {
7373 key: Result<String, String>,
7374 value: Result<String, String>,
7375 }
7376 impl Default for Metadatum {
7377 fn default() -> Self {
7378 Self {
7379 key: Err("no value supplied for key".to_string()),
7380 value: Err("no value supplied for value".to_string()),
7381 }
7382 }
7383 }
7384 impl Metadatum {
7385 pub fn key<T>(mut self, value: T) -> Self
7386 where
7387 T: std::convert::TryInto<String>,
7388 T::Error: std::fmt::Display,
7389 {
7390 self.key = value
7391 .try_into()
7392 .map_err(|e| format!("error converting supplied value for key: {}", e));
7393 self
7394 }
7395 pub fn value<T>(mut self, value: T) -> Self
7396 where
7397 T: std::convert::TryInto<String>,
7398 T::Error: std::fmt::Display,
7399 {
7400 self.value = value
7401 .try_into()
7402 .map_err(|e| format!("error converting supplied value for value: {}", e));
7403 self
7404 }
7405 }
7406 impl std::convert::TryFrom<Metadatum> for super::Metadatum {
7407 type Error = super::error::ConversionError;
7408 fn try_from(value: Metadatum) -> Result<Self, super::error::ConversionError> {
7409 Ok(Self {
7410 key: value.key?,
7411 value: value.value?,
7412 })
7413 }
7414 }
7415 impl From<super::Metadatum> for Metadatum {
7416 fn from(value: super::Metadatum) -> Self {
7417 Self {
7418 key: Ok(value.key),
7419 value: Ok(value.value),
7420 }
7421 }
7422 }
7423 #[derive(Clone, Debug)]
7424 pub struct Org {
7425 address: Result<Option<super::Address>, String>,
7426 brand_color: Result<Option<super::OrgBrandColor>, String>,
7427 legal_name: Result<Option<String>, String>,
7428 logo: Result<Option<String>, String>,
7429 logo_asset_id: Result<Option<String>, String>,
7430 name: Result<String, String>,
7431 vat_number: Result<Option<String>, String>,
7432 website: Result<Option<String>, String>,
7433 }
7434 impl Default for Org {
7435 fn default() -> Self {
7436 Self {
7437 address: Ok(Default::default()),
7438 brand_color: Ok(Default::default()),
7439 legal_name: Ok(Default::default()),
7440 logo: Ok(Default::default()),
7441 logo_asset_id: Ok(Default::default()),
7442 name: Err("no value supplied for name".to_string()),
7443 vat_number: Ok(Default::default()),
7444 website: Ok(Default::default()),
7445 }
7446 }
7447 }
7448 impl Org {
7449 pub fn address<T>(mut self, value: T) -> Self
7450 where
7451 T: std::convert::TryInto<Option<super::Address>>,
7452 T::Error: std::fmt::Display,
7453 {
7454 self.address = value
7455 .try_into()
7456 .map_err(|e| format!("error converting supplied value for address: {}", e));
7457 self
7458 }
7459 pub fn brand_color<T>(mut self, value: T) -> Self
7460 where
7461 T: std::convert::TryInto<Option<super::OrgBrandColor>>,
7462 T::Error: std::fmt::Display,
7463 {
7464 self.brand_color = value
7465 .try_into()
7466 .map_err(|e| format!("error converting supplied value for brand_color: {}", e));
7467 self
7468 }
7469 pub fn legal_name<T>(mut self, value: T) -> Self
7470 where
7471 T: std::convert::TryInto<Option<String>>,
7472 T::Error: std::fmt::Display,
7473 {
7474 self.legal_name = value
7475 .try_into()
7476 .map_err(|e| format!("error converting supplied value for legal_name: {}", e));
7477 self
7478 }
7479 pub fn logo<T>(mut self, value: T) -> Self
7480 where
7481 T: std::convert::TryInto<Option<String>>,
7482 T::Error: std::fmt::Display,
7483 {
7484 self.logo = value
7485 .try_into()
7486 .map_err(|e| format!("error converting supplied value for logo: {}", e));
7487 self
7488 }
7489 pub fn logo_asset_id<T>(mut self, value: T) -> Self
7490 where
7491 T: std::convert::TryInto<Option<String>>,
7492 T::Error: std::fmt::Display,
7493 {
7494 self.logo_asset_id = value
7495 .try_into()
7496 .map_err(|e| format!("error converting supplied value for logo_asset_id: {}", e));
7497 self
7498 }
7499 pub fn name<T>(mut self, value: T) -> Self
7500 where
7501 T: std::convert::TryInto<String>,
7502 T::Error: std::fmt::Display,
7503 {
7504 self.name = value
7505 .try_into()
7506 .map_err(|e| format!("error converting supplied value for name: {}", e));
7507 self
7508 }
7509 pub fn vat_number<T>(mut self, value: T) -> Self
7510 where
7511 T: std::convert::TryInto<Option<String>>,
7512 T::Error: std::fmt::Display,
7513 {
7514 self.vat_number = value
7515 .try_into()
7516 .map_err(|e| format!("error converting supplied value for vat_number: {}", e));
7517 self
7518 }
7519 pub fn website<T>(mut self, value: T) -> Self
7520 where
7521 T: std::convert::TryInto<Option<String>>,
7522 T::Error: std::fmt::Display,
7523 {
7524 self.website = value
7525 .try_into()
7526 .map_err(|e| format!("error converting supplied value for website: {}", e));
7527 self
7528 }
7529 }
7530 impl std::convert::TryFrom<Org> for super::Org {
7531 type Error = super::error::ConversionError;
7532 fn try_from(value: Org) -> Result<Self, super::error::ConversionError> {
7533 Ok(Self {
7534 address: value.address?,
7535 brand_color: value.brand_color?,
7536 legal_name: value.legal_name?,
7537 logo: value.logo?,
7538 logo_asset_id: value.logo_asset_id?,
7539 name: value.name?,
7540 vat_number: value.vat_number?,
7541 website: value.website?,
7542 })
7543 }
7544 }
7545 impl From<super::Org> for Org {
7546 fn from(value: super::Org) -> Self {
7547 Self {
7548 address: Ok(value.address),
7549 brand_color: Ok(value.brand_color),
7550 legal_name: Ok(value.legal_name),
7551 logo: Ok(value.logo),
7552 logo_asset_id: Ok(value.logo_asset_id),
7553 name: Ok(value.name),
7554 vat_number: Ok(value.vat_number),
7555 website: Ok(value.website),
7556 }
7557 }
7558 }
7559 #[derive(Clone, Debug)]
7560 pub struct Payment {
7561 ach_payment: Result<Option<super::AchPayment>, String>,
7562 amount: Result<i64, String>,
7563 card_payment: Result<Option<super::CardPayment>, String>,
7564 paid_at: Result<i64, String>,
7565 payment_type: Result<Option<super::PaymentPaymentType>, String>,
7566 }
7567 impl Default for Payment {
7568 fn default() -> Self {
7569 Self {
7570 ach_payment: Ok(Default::default()),
7571 amount: Err("no value supplied for amount".to_string()),
7572 card_payment: Ok(Default::default()),
7573 paid_at: Err("no value supplied for paid_at".to_string()),
7574 payment_type: Ok(Default::default()),
7575 }
7576 }
7577 }
7578 impl Payment {
7579 pub fn ach_payment<T>(mut self, value: T) -> Self
7580 where
7581 T: std::convert::TryInto<Option<super::AchPayment>>,
7582 T::Error: std::fmt::Display,
7583 {
7584 self.ach_payment = value
7585 .try_into()
7586 .map_err(|e| format!("error converting supplied value for ach_payment: {}", e));
7587 self
7588 }
7589 pub fn amount<T>(mut self, value: T) -> Self
7590 where
7591 T: std::convert::TryInto<i64>,
7592 T::Error: std::fmt::Display,
7593 {
7594 self.amount = value
7595 .try_into()
7596 .map_err(|e| format!("error converting supplied value for amount: {}", e));
7597 self
7598 }
7599 pub fn card_payment<T>(mut self, value: T) -> Self
7600 where
7601 T: std::convert::TryInto<Option<super::CardPayment>>,
7602 T::Error: std::fmt::Display,
7603 {
7604 self.card_payment = value
7605 .try_into()
7606 .map_err(|e| format!("error converting supplied value for card_payment: {}", e));
7607 self
7608 }
7609 pub fn paid_at<T>(mut self, value: T) -> Self
7610 where
7611 T: std::convert::TryInto<i64>,
7612 T::Error: std::fmt::Display,
7613 {
7614 self.paid_at = value
7615 .try_into()
7616 .map_err(|e| format!("error converting supplied value for paid_at: {}", e));
7617 self
7618 }
7619 pub fn payment_type<T>(mut self, value: T) -> Self
7620 where
7621 T: std::convert::TryInto<Option<super::PaymentPaymentType>>,
7622 T::Error: std::fmt::Display,
7623 {
7624 self.payment_type = value
7625 .try_into()
7626 .map_err(|e| format!("error converting supplied value for payment_type: {}", e));
7627 self
7628 }
7629 }
7630 impl std::convert::TryFrom<Payment> for super::Payment {
7631 type Error = super::error::ConversionError;
7632 fn try_from(value: Payment) -> Result<Self, super::error::ConversionError> {
7633 Ok(Self {
7634 ach_payment: value.ach_payment?,
7635 amount: value.amount?,
7636 card_payment: value.card_payment?,
7637 paid_at: value.paid_at?,
7638 payment_type: value.payment_type?,
7639 })
7640 }
7641 }
7642 impl From<super::Payment> for Payment {
7643 fn from(value: super::Payment) -> Self {
7644 Self {
7645 ach_payment: Ok(value.ach_payment),
7646 amount: Ok(value.amount),
7647 card_payment: Ok(value.card_payment),
7648 paid_at: Ok(value.paid_at),
7649 payment_type: Ok(value.payment_type),
7650 }
7651 }
7652 }
7653 #[derive(Clone, Debug)]
7654 pub struct Person {
7655 email: Result<Option<String>, String>,
7656 first_name: Result<Option<String>, String>,
7657 last_name: Result<Option<String>, String>,
7658 metadata: Result<Option<Vec<super::Metadatum>>, String>,
7659 phone: Result<Option<super::PersonPhone>, String>,
7660 preferred_first_name: Result<Option<String>, String>,
7661 }
7662 impl Default for Person {
7663 fn default() -> Self {
7664 Self {
7665 email: Ok(Default::default()),
7666 first_name: Ok(Default::default()),
7667 last_name: Ok(Default::default()),
7668 metadata: Ok(Default::default()),
7669 phone: Ok(Default::default()),
7670 preferred_first_name: Ok(Default::default()),
7671 }
7672 }
7673 }
7674 impl Person {
7675 pub fn email<T>(mut self, value: T) -> Self
7676 where
7677 T: std::convert::TryInto<Option<String>>,
7678 T::Error: std::fmt::Display,
7679 {
7680 self.email = value
7681 .try_into()
7682 .map_err(|e| format!("error converting supplied value for email: {}", e));
7683 self
7684 }
7685 pub fn first_name<T>(mut self, value: T) -> Self
7686 where
7687 T: std::convert::TryInto<Option<String>>,
7688 T::Error: std::fmt::Display,
7689 {
7690 self.first_name = value
7691 .try_into()
7692 .map_err(|e| format!("error converting supplied value for first_name: {}", e));
7693 self
7694 }
7695 pub fn last_name<T>(mut self, value: T) -> Self
7696 where
7697 T: std::convert::TryInto<Option<String>>,
7698 T::Error: std::fmt::Display,
7699 {
7700 self.last_name = value
7701 .try_into()
7702 .map_err(|e| format!("error converting supplied value for last_name: {}", e));
7703 self
7704 }
7705 pub fn metadata<T>(mut self, value: T) -> Self
7706 where
7707 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
7708 T::Error: std::fmt::Display,
7709 {
7710 self.metadata = value
7711 .try_into()
7712 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
7713 self
7714 }
7715 pub fn phone<T>(mut self, value: T) -> Self
7716 where
7717 T: std::convert::TryInto<Option<super::PersonPhone>>,
7718 T::Error: std::fmt::Display,
7719 {
7720 self.phone = value
7721 .try_into()
7722 .map_err(|e| format!("error converting supplied value for phone: {}", e));
7723 self
7724 }
7725 pub fn preferred_first_name<T>(mut self, value: T) -> Self
7726 where
7727 T: std::convert::TryInto<Option<String>>,
7728 T::Error: std::fmt::Display,
7729 {
7730 self.preferred_first_name = value.try_into().map_err(|e| {
7731 format!(
7732 "error converting supplied value for preferred_first_name: {}",
7733 e
7734 )
7735 });
7736 self
7737 }
7738 }
7739 impl std::convert::TryFrom<Person> for super::Person {
7740 type Error = super::error::ConversionError;
7741 fn try_from(value: Person) -> Result<Self, super::error::ConversionError> {
7742 Ok(Self {
7743 email: value.email?,
7744 first_name: value.first_name?,
7745 last_name: value.last_name?,
7746 metadata: value.metadata?,
7747 phone: value.phone?,
7748 preferred_first_name: value.preferred_first_name?,
7749 })
7750 }
7751 }
7752 impl From<super::Person> for Person {
7753 fn from(value: super::Person) -> Self {
7754 Self {
7755 email: Ok(value.email),
7756 first_name: Ok(value.first_name),
7757 last_name: Ok(value.last_name),
7758 metadata: Ok(value.metadata),
7759 phone: Ok(value.phone),
7760 preferred_first_name: Ok(value.preferred_first_name),
7761 }
7762 }
7763 }
7764 #[derive(Clone, Debug)]
7765 pub struct Place {
7766 address: Result<Option<super::Address>, String>,
7767 google_place_id: Result<Option<String>, String>,
7768 image: Result<Option<String>, String>,
7769 name: Result<Option<String>, String>,
7770 phone: Result<Option<super::PlacePhone>, String>,
7771 url: Result<Option<String>, String>,
7772 }
7773 impl Default for Place {
7774 fn default() -> Self {
7775 Self {
7776 address: Ok(Default::default()),
7777 google_place_id: Ok(Default::default()),
7778 image: Ok(Default::default()),
7779 name: Ok(Default::default()),
7780 phone: Ok(Default::default()),
7781 url: Ok(Default::default()),
7782 }
7783 }
7784 }
7785 impl Place {
7786 pub fn address<T>(mut self, value: T) -> Self
7787 where
7788 T: std::convert::TryInto<Option<super::Address>>,
7789 T::Error: std::fmt::Display,
7790 {
7791 self.address = value
7792 .try_into()
7793 .map_err(|e| format!("error converting supplied value for address: {}", e));
7794 self
7795 }
7796 pub fn google_place_id<T>(mut self, value: T) -> Self
7797 where
7798 T: std::convert::TryInto<Option<String>>,
7799 T::Error: std::fmt::Display,
7800 {
7801 self.google_place_id = value
7802 .try_into()
7803 .map_err(|e| format!("error converting supplied value for google_place_id: {}", e));
7804 self
7805 }
7806 pub fn image<T>(mut self, value: T) -> Self
7807 where
7808 T: std::convert::TryInto<Option<String>>,
7809 T::Error: std::fmt::Display,
7810 {
7811 self.image = value
7812 .try_into()
7813 .map_err(|e| format!("error converting supplied value for image: {}", e));
7814 self
7815 }
7816 pub fn name<T>(mut self, value: T) -> Self
7817 where
7818 T: std::convert::TryInto<Option<String>>,
7819 T::Error: std::fmt::Display,
7820 {
7821 self.name = value
7822 .try_into()
7823 .map_err(|e| format!("error converting supplied value for name: {}", e));
7824 self
7825 }
7826 pub fn phone<T>(mut self, value: T) -> Self
7827 where
7828 T: std::convert::TryInto<Option<super::PlacePhone>>,
7829 T::Error: std::fmt::Display,
7830 {
7831 self.phone = value
7832 .try_into()
7833 .map_err(|e| format!("error converting supplied value for phone: {}", e));
7834 self
7835 }
7836 pub fn url<T>(mut self, value: T) -> Self
7837 where
7838 T: std::convert::TryInto<Option<String>>,
7839 T::Error: std::fmt::Display,
7840 {
7841 self.url = value
7842 .try_into()
7843 .map_err(|e| format!("error converting supplied value for url: {}", e));
7844 self
7845 }
7846 }
7847 impl std::convert::TryFrom<Place> for super::Place {
7848 type Error = super::error::ConversionError;
7849 fn try_from(value: Place) -> Result<Self, super::error::ConversionError> {
7850 Ok(Self {
7851 address: value.address?,
7852 google_place_id: value.google_place_id?,
7853 image: value.image?,
7854 name: value.name?,
7855 phone: value.phone?,
7856 url: value.url?,
7857 })
7858 }
7859 }
7860 impl From<super::Place> for Place {
7861 fn from(value: super::Place) -> Self {
7862 Self {
7863 address: Ok(value.address),
7864 google_place_id: Ok(value.google_place_id),
7865 image: Ok(value.image),
7866 name: Ok(value.name),
7867 phone: Ok(value.phone),
7868 url: Ok(value.url),
7869 }
7870 }
7871 }
7872 #[derive(Clone, Debug)]
7873 pub struct Receipt {
7874 footer: Result<super::Footer, String>,
7875 header: Result<super::Header, String>,
7876 itemization: Result<super::Itemization, String>,
7877 payments: Result<Vec<super::Payment>, String>,
7878 schema_version: Result<super::SchemaVersion, String>,
7879 }
7880 impl Default for Receipt {
7881 fn default() -> Self {
7882 Self {
7883 footer: Err("no value supplied for footer".to_string()),
7884 header: Err("no value supplied for header".to_string()),
7885 itemization: Err("no value supplied for itemization".to_string()),
7886 payments: Err("no value supplied for payments".to_string()),
7887 schema_version: Err("no value supplied for schema_version".to_string()),
7888 }
7889 }
7890 }
7891 impl Receipt {
7892 pub fn footer<T>(mut self, value: T) -> Self
7893 where
7894 T: std::convert::TryInto<super::Footer>,
7895 T::Error: std::fmt::Display,
7896 {
7897 self.footer = value
7898 .try_into()
7899 .map_err(|e| format!("error converting supplied value for footer: {}", e));
7900 self
7901 }
7902 pub fn header<T>(mut self, value: T) -> Self
7903 where
7904 T: std::convert::TryInto<super::Header>,
7905 T::Error: std::fmt::Display,
7906 {
7907 self.header = value
7908 .try_into()
7909 .map_err(|e| format!("error converting supplied value for header: {}", e));
7910 self
7911 }
7912 pub fn itemization<T>(mut self, value: T) -> Self
7913 where
7914 T: std::convert::TryInto<super::Itemization>,
7915 T::Error: std::fmt::Display,
7916 {
7917 self.itemization = value
7918 .try_into()
7919 .map_err(|e| format!("error converting supplied value for itemization: {}", e));
7920 self
7921 }
7922 pub fn payments<T>(mut self, value: T) -> Self
7923 where
7924 T: std::convert::TryInto<Vec<super::Payment>>,
7925 T::Error: std::fmt::Display,
7926 {
7927 self.payments = value
7928 .try_into()
7929 .map_err(|e| format!("error converting supplied value for payments: {}", e));
7930 self
7931 }
7932 pub fn schema_version<T>(mut self, value: T) -> Self
7933 where
7934 T: std::convert::TryInto<super::SchemaVersion>,
7935 T::Error: std::fmt::Display,
7936 {
7937 self.schema_version = value
7938 .try_into()
7939 .map_err(|e| format!("error converting supplied value for schema_version: {}", e));
7940 self
7941 }
7942 }
7943 impl std::convert::TryFrom<Receipt> for super::Receipt {
7944 type Error = super::error::ConversionError;
7945 fn try_from(value: Receipt) -> Result<Self, super::error::ConversionError> {
7946 Ok(Self {
7947 footer: value.footer?,
7948 header: value.header?,
7949 itemization: value.itemization?,
7950 payments: value.payments?,
7951 schema_version: value.schema_version?,
7952 })
7953 }
7954 }
7955 impl From<super::Receipt> for Receipt {
7956 fn from(value: super::Receipt) -> Self {
7957 Self {
7958 footer: Ok(value.footer),
7959 header: Ok(value.header),
7960 itemization: Ok(value.itemization),
7961 payments: Ok(value.payments),
7962 schema_version: Ok(value.schema_version),
7963 }
7964 }
7965 }
7966 #[derive(Clone, Debug)]
7967 pub struct Service {
7968 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
7969 service_items: Result<Vec<super::ServiceItem>, String>,
7970 }
7971 impl Default for Service {
7972 fn default() -> Self {
7973 Self {
7974 invoice_level_adjustments: Ok(Default::default()),
7975 service_items: Err("no value supplied for service_items".to_string()),
7976 }
7977 }
7978 }
7979 impl Service {
7980 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
7981 where
7982 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
7983 T::Error: std::fmt::Display,
7984 {
7985 self.invoice_level_adjustments = value.try_into().map_err(|e| {
7986 format!(
7987 "error converting supplied value for invoice_level_adjustments: {}",
7988 e
7989 )
7990 });
7991 self
7992 }
7993 pub fn service_items<T>(mut self, value: T) -> Self
7994 where
7995 T: std::convert::TryInto<Vec<super::ServiceItem>>,
7996 T::Error: std::fmt::Display,
7997 {
7998 self.service_items = value
7999 .try_into()
8000 .map_err(|e| format!("error converting supplied value for service_items: {}", e));
8001 self
8002 }
8003 }
8004 impl std::convert::TryFrom<Service> for super::Service {
8005 type Error = super::error::ConversionError;
8006 fn try_from(value: Service) -> Result<Self, super::error::ConversionError> {
8007 Ok(Self {
8008 invoice_level_adjustments: value.invoice_level_adjustments?,
8009 service_items: value.service_items?,
8010 })
8011 }
8012 }
8013 impl From<super::Service> for Service {
8014 fn from(value: super::Service) -> Self {
8015 Self {
8016 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
8017 service_items: Ok(value.service_items),
8018 }
8019 }
8020 }
8021 #[derive(Clone, Debug)]
8022 pub struct ServiceItem {
8023 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8024 amount: Result<i64, String>,
8025 current_period_end_at: Result<Option<i64>, String>,
8026 current_period_start_at: Result<Option<i64>, String>,
8027 description: Result<String, String>,
8028 interval: Result<Option<super::Interval>, String>,
8029 interval_count: Result<Option<i64>, String>,
8030 metadata: Result<Option<Vec<super::Metadatum>>, String>,
8031 quantity: Result<Option<f64>, String>,
8032 recurring: Result<bool, String>,
8033 service_location: Result<Option<super::Place>, String>,
8034 taxes: Result<Option<Vec<super::Tax>>, String>,
8035 unit_cost: Result<Option<f64>, String>,
8036 }
8037 impl Default for ServiceItem {
8038 fn default() -> Self {
8039 Self {
8040 adjustments: Ok(Default::default()),
8041 amount: Err("no value supplied for amount".to_string()),
8042 current_period_end_at: Ok(Default::default()),
8043 current_period_start_at: Ok(Default::default()),
8044 description: Err("no value supplied for description".to_string()),
8045 interval: Ok(Default::default()),
8046 interval_count: Ok(Default::default()),
8047 metadata: Ok(Default::default()),
8048 quantity: Ok(Default::default()),
8049 recurring: Err("no value supplied for recurring".to_string()),
8050 service_location: Ok(Default::default()),
8051 taxes: Ok(Default::default()),
8052 unit_cost: Ok(Default::default()),
8053 }
8054 }
8055 }
8056 impl ServiceItem {
8057 pub fn adjustments<T>(mut self, value: T) -> Self
8058 where
8059 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8060 T::Error: std::fmt::Display,
8061 {
8062 self.adjustments = value
8063 .try_into()
8064 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
8065 self
8066 }
8067 pub fn amount<T>(mut self, value: T) -> Self
8068 where
8069 T: std::convert::TryInto<i64>,
8070 T::Error: std::fmt::Display,
8071 {
8072 self.amount = value
8073 .try_into()
8074 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8075 self
8076 }
8077 pub fn current_period_end_at<T>(mut self, value: T) -> Self
8078 where
8079 T: std::convert::TryInto<Option<i64>>,
8080 T::Error: std::fmt::Display,
8081 {
8082 self.current_period_end_at = value.try_into().map_err(|e| {
8083 format!(
8084 "error converting supplied value for current_period_end_at: {}",
8085 e
8086 )
8087 });
8088 self
8089 }
8090 pub fn current_period_start_at<T>(mut self, value: T) -> Self
8091 where
8092 T: std::convert::TryInto<Option<i64>>,
8093 T::Error: std::fmt::Display,
8094 {
8095 self.current_period_start_at = value.try_into().map_err(|e| {
8096 format!(
8097 "error converting supplied value for current_period_start_at: {}",
8098 e
8099 )
8100 });
8101 self
8102 }
8103 pub fn description<T>(mut self, value: T) -> Self
8104 where
8105 T: std::convert::TryInto<String>,
8106 T::Error: std::fmt::Display,
8107 {
8108 self.description = value
8109 .try_into()
8110 .map_err(|e| format!("error converting supplied value for description: {}", e));
8111 self
8112 }
8113 pub fn interval<T>(mut self, value: T) -> Self
8114 where
8115 T: std::convert::TryInto<Option<super::Interval>>,
8116 T::Error: std::fmt::Display,
8117 {
8118 self.interval = value
8119 .try_into()
8120 .map_err(|e| format!("error converting supplied value for interval: {}", e));
8121 self
8122 }
8123 pub fn interval_count<T>(mut self, value: T) -> Self
8124 where
8125 T: std::convert::TryInto<Option<i64>>,
8126 T::Error: std::fmt::Display,
8127 {
8128 self.interval_count = value
8129 .try_into()
8130 .map_err(|e| format!("error converting supplied value for interval_count: {}", e));
8131 self
8132 }
8133 pub fn metadata<T>(mut self, value: T) -> Self
8134 where
8135 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8136 T::Error: std::fmt::Display,
8137 {
8138 self.metadata = value
8139 .try_into()
8140 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8141 self
8142 }
8143 pub fn quantity<T>(mut self, value: T) -> Self
8144 where
8145 T: std::convert::TryInto<Option<f64>>,
8146 T::Error: std::fmt::Display,
8147 {
8148 self.quantity = value
8149 .try_into()
8150 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
8151 self
8152 }
8153 pub fn recurring<T>(mut self, value: T) -> Self
8154 where
8155 T: std::convert::TryInto<bool>,
8156 T::Error: std::fmt::Display,
8157 {
8158 self.recurring = value
8159 .try_into()
8160 .map_err(|e| format!("error converting supplied value for recurring: {}", e));
8161 self
8162 }
8163 pub fn service_location<T>(mut self, value: T) -> Self
8164 where
8165 T: std::convert::TryInto<Option<super::Place>>,
8166 T::Error: std::fmt::Display,
8167 {
8168 self.service_location = value.try_into().map_err(|e| {
8169 format!(
8170 "error converting supplied value for service_location: {}",
8171 e
8172 )
8173 });
8174 self
8175 }
8176 pub fn taxes<T>(mut self, value: T) -> Self
8177 where
8178 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8179 T::Error: std::fmt::Display,
8180 {
8181 self.taxes = value
8182 .try_into()
8183 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8184 self
8185 }
8186 pub fn unit_cost<T>(mut self, value: T) -> Self
8187 where
8188 T: std::convert::TryInto<Option<f64>>,
8189 T::Error: std::fmt::Display,
8190 {
8191 self.unit_cost = value
8192 .try_into()
8193 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
8194 self
8195 }
8196 }
8197 impl std::convert::TryFrom<ServiceItem> for super::ServiceItem {
8198 type Error = super::error::ConversionError;
8199 fn try_from(value: ServiceItem) -> Result<Self, super::error::ConversionError> {
8200 Ok(Self {
8201 adjustments: value.adjustments?,
8202 amount: value.amount?,
8203 current_period_end_at: value.current_period_end_at?,
8204 current_period_start_at: value.current_period_start_at?,
8205 description: value.description?,
8206 interval: value.interval?,
8207 interval_count: value.interval_count?,
8208 metadata: value.metadata?,
8209 quantity: value.quantity?,
8210 recurring: value.recurring?,
8211 service_location: value.service_location?,
8212 taxes: value.taxes?,
8213 unit_cost: value.unit_cost?,
8214 })
8215 }
8216 }
8217 impl From<super::ServiceItem> for ServiceItem {
8218 fn from(value: super::ServiceItem) -> Self {
8219 Self {
8220 adjustments: Ok(value.adjustments),
8221 amount: Ok(value.amount),
8222 current_period_end_at: Ok(value.current_period_end_at),
8223 current_period_start_at: Ok(value.current_period_start_at),
8224 description: Ok(value.description),
8225 interval: Ok(value.interval),
8226 interval_count: Ok(value.interval_count),
8227 metadata: Ok(value.metadata),
8228 quantity: Ok(value.quantity),
8229 recurring: Ok(value.recurring),
8230 service_location: Ok(value.service_location),
8231 taxes: Ok(value.taxes),
8232 unit_cost: Ok(value.unit_cost),
8233 }
8234 }
8235 }
8236 #[derive(Clone, Debug)]
8237 pub struct Shipment {
8238 carrier: Result<Option<String>, String>,
8239 destination_address: Result<Option<super::Address>, String>,
8240 expected_delivery_at: Result<Option<i64>, String>,
8241 items: Result<Vec<super::Item>, String>,
8242 shipment_status: Result<Option<super::ShipmentShipmentStatus>, String>,
8243 tracking_number: Result<Option<String>, String>,
8244 }
8245 impl Default for Shipment {
8246 fn default() -> Self {
8247 Self {
8248 carrier: Ok(Default::default()),
8249 destination_address: Ok(Default::default()),
8250 expected_delivery_at: Ok(Default::default()),
8251 items: Err("no value supplied for items".to_string()),
8252 shipment_status: Ok(Default::default()),
8253 tracking_number: Ok(Default::default()),
8254 }
8255 }
8256 }
8257 impl Shipment {
8258 pub fn carrier<T>(mut self, value: T) -> Self
8259 where
8260 T: std::convert::TryInto<Option<String>>,
8261 T::Error: std::fmt::Display,
8262 {
8263 self.carrier = value
8264 .try_into()
8265 .map_err(|e| format!("error converting supplied value for carrier: {}", e));
8266 self
8267 }
8268 pub fn destination_address<T>(mut self, value: T) -> Self
8269 where
8270 T: std::convert::TryInto<Option<super::Address>>,
8271 T::Error: std::fmt::Display,
8272 {
8273 self.destination_address = value.try_into().map_err(|e| {
8274 format!(
8275 "error converting supplied value for destination_address: {}",
8276 e
8277 )
8278 });
8279 self
8280 }
8281 pub fn expected_delivery_at<T>(mut self, value: T) -> Self
8282 where
8283 T: std::convert::TryInto<Option<i64>>,
8284 T::Error: std::fmt::Display,
8285 {
8286 self.expected_delivery_at = value.try_into().map_err(|e| {
8287 format!(
8288 "error converting supplied value for expected_delivery_at: {}",
8289 e
8290 )
8291 });
8292 self
8293 }
8294 pub fn items<T>(mut self, value: T) -> Self
8295 where
8296 T: std::convert::TryInto<Vec<super::Item>>,
8297 T::Error: std::fmt::Display,
8298 {
8299 self.items = value
8300 .try_into()
8301 .map_err(|e| format!("error converting supplied value for items: {}", e));
8302 self
8303 }
8304 pub fn shipment_status<T>(mut self, value: T) -> Self
8305 where
8306 T: std::convert::TryInto<Option<super::ShipmentShipmentStatus>>,
8307 T::Error: std::fmt::Display,
8308 {
8309 self.shipment_status = value
8310 .try_into()
8311 .map_err(|e| format!("error converting supplied value for shipment_status: {}", e));
8312 self
8313 }
8314 pub fn tracking_number<T>(mut self, value: T) -> Self
8315 where
8316 T: std::convert::TryInto<Option<String>>,
8317 T::Error: std::fmt::Display,
8318 {
8319 self.tracking_number = value
8320 .try_into()
8321 .map_err(|e| format!("error converting supplied value for tracking_number: {}", e));
8322 self
8323 }
8324 }
8325 impl std::convert::TryFrom<Shipment> for super::Shipment {
8326 type Error = super::error::ConversionError;
8327 fn try_from(value: Shipment) -> Result<Self, super::error::ConversionError> {
8328 Ok(Self {
8329 carrier: value.carrier?,
8330 destination_address: value.destination_address?,
8331 expected_delivery_at: value.expected_delivery_at?,
8332 items: value.items?,
8333 shipment_status: value.shipment_status?,
8334 tracking_number: value.tracking_number?,
8335 })
8336 }
8337 }
8338 impl From<super::Shipment> for Shipment {
8339 fn from(value: super::Shipment) -> Self {
8340 Self {
8341 carrier: Ok(value.carrier),
8342 destination_address: Ok(value.destination_address),
8343 expected_delivery_at: Ok(value.expected_delivery_at),
8344 items: Ok(value.items),
8345 shipment_status: Ok(value.shipment_status),
8346 tracking_number: Ok(value.tracking_number),
8347 }
8348 }
8349 }
8350 #[derive(Clone, Debug)]
8351 pub struct Subscription {
8352 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8353 subscription_items: Result<Vec<super::SubscriptionItem>, String>,
8354 }
8355 impl Default for Subscription {
8356 fn default() -> Self {
8357 Self {
8358 invoice_level_adjustments: Ok(Default::default()),
8359 subscription_items: Err("no value supplied for subscription_items".to_string()),
8360 }
8361 }
8362 }
8363 impl Subscription {
8364 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
8365 where
8366 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8367 T::Error: std::fmt::Display,
8368 {
8369 self.invoice_level_adjustments = value.try_into().map_err(|e| {
8370 format!(
8371 "error converting supplied value for invoice_level_adjustments: {}",
8372 e
8373 )
8374 });
8375 self
8376 }
8377 pub fn subscription_items<T>(mut self, value: T) -> Self
8378 where
8379 T: std::convert::TryInto<Vec<super::SubscriptionItem>>,
8380 T::Error: std::fmt::Display,
8381 {
8382 self.subscription_items = value.try_into().map_err(|e| {
8383 format!(
8384 "error converting supplied value for subscription_items: {}",
8385 e
8386 )
8387 });
8388 self
8389 }
8390 }
8391 impl std::convert::TryFrom<Subscription> for super::Subscription {
8392 type Error = super::error::ConversionError;
8393 fn try_from(value: Subscription) -> Result<Self, super::error::ConversionError> {
8394 Ok(Self {
8395 invoice_level_adjustments: value.invoice_level_adjustments?,
8396 subscription_items: value.subscription_items?,
8397 })
8398 }
8399 }
8400 impl From<super::Subscription> for Subscription {
8401 fn from(value: super::Subscription) -> Self {
8402 Self {
8403 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
8404 subscription_items: Ok(value.subscription_items),
8405 }
8406 }
8407 }
8408 #[derive(Clone, Debug)]
8409 pub struct SubscriptionItem {
8410 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8411 amount: Result<i64, String>,
8412 current_period_end_at: Result<Option<i64>, String>,
8413 current_period_start_at: Result<Option<i64>, String>,
8414 description: Result<String, String>,
8415 interval: Result<Option<super::Interval>, String>,
8416 interval_count: Result<Option<i64>, String>,
8417 metadata: Result<Option<Vec<super::Metadatum>>, String>,
8418 quantity: Result<Option<f64>, String>,
8419 subscription_type: Result<super::SubscriptionType, String>,
8420 taxes: Result<Option<Vec<super::Tax>>, String>,
8421 unit_cost: Result<Option<f64>, String>,
8422 }
8423 impl Default for SubscriptionItem {
8424 fn default() -> Self {
8425 Self {
8426 adjustments: Ok(Default::default()),
8427 amount: Err("no value supplied for amount".to_string()),
8428 current_period_end_at: Ok(Default::default()),
8429 current_period_start_at: Ok(Default::default()),
8430 description: Err("no value supplied for description".to_string()),
8431 interval: Ok(Default::default()),
8432 interval_count: Ok(Default::default()),
8433 metadata: Ok(Default::default()),
8434 quantity: Ok(Default::default()),
8435 subscription_type: Err("no value supplied for subscription_type".to_string()),
8436 taxes: Ok(Default::default()),
8437 unit_cost: Ok(Default::default()),
8438 }
8439 }
8440 }
8441 impl SubscriptionItem {
8442 pub fn adjustments<T>(mut self, value: T) -> Self
8443 where
8444 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8445 T::Error: std::fmt::Display,
8446 {
8447 self.adjustments = value
8448 .try_into()
8449 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
8450 self
8451 }
8452 pub fn amount<T>(mut self, value: T) -> Self
8453 where
8454 T: std::convert::TryInto<i64>,
8455 T::Error: std::fmt::Display,
8456 {
8457 self.amount = value
8458 .try_into()
8459 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8460 self
8461 }
8462 pub fn current_period_end_at<T>(mut self, value: T) -> Self
8463 where
8464 T: std::convert::TryInto<Option<i64>>,
8465 T::Error: std::fmt::Display,
8466 {
8467 self.current_period_end_at = value.try_into().map_err(|e| {
8468 format!(
8469 "error converting supplied value for current_period_end_at: {}",
8470 e
8471 )
8472 });
8473 self
8474 }
8475 pub fn current_period_start_at<T>(mut self, value: T) -> Self
8476 where
8477 T: std::convert::TryInto<Option<i64>>,
8478 T::Error: std::fmt::Display,
8479 {
8480 self.current_period_start_at = value.try_into().map_err(|e| {
8481 format!(
8482 "error converting supplied value for current_period_start_at: {}",
8483 e
8484 )
8485 });
8486 self
8487 }
8488 pub fn description<T>(mut self, value: T) -> Self
8489 where
8490 T: std::convert::TryInto<String>,
8491 T::Error: std::fmt::Display,
8492 {
8493 self.description = value
8494 .try_into()
8495 .map_err(|e| format!("error converting supplied value for description: {}", e));
8496 self
8497 }
8498 pub fn interval<T>(mut self, value: T) -> Self
8499 where
8500 T: std::convert::TryInto<Option<super::Interval>>,
8501 T::Error: std::fmt::Display,
8502 {
8503 self.interval = value
8504 .try_into()
8505 .map_err(|e| format!("error converting supplied value for interval: {}", e));
8506 self
8507 }
8508 pub fn interval_count<T>(mut self, value: T) -> Self
8509 where
8510 T: std::convert::TryInto<Option<i64>>,
8511 T::Error: std::fmt::Display,
8512 {
8513 self.interval_count = value
8514 .try_into()
8515 .map_err(|e| format!("error converting supplied value for interval_count: {}", e));
8516 self
8517 }
8518 pub fn metadata<T>(mut self, value: T) -> Self
8519 where
8520 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8521 T::Error: std::fmt::Display,
8522 {
8523 self.metadata = value
8524 .try_into()
8525 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8526 self
8527 }
8528 pub fn quantity<T>(mut self, value: T) -> Self
8529 where
8530 T: std::convert::TryInto<Option<f64>>,
8531 T::Error: std::fmt::Display,
8532 {
8533 self.quantity = value
8534 .try_into()
8535 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
8536 self
8537 }
8538 pub fn subscription_type<T>(mut self, value: T) -> Self
8539 where
8540 T: std::convert::TryInto<super::SubscriptionType>,
8541 T::Error: std::fmt::Display,
8542 {
8543 self.subscription_type = value.try_into().map_err(|e| {
8544 format!(
8545 "error converting supplied value for subscription_type: {}",
8546 e
8547 )
8548 });
8549 self
8550 }
8551 pub fn taxes<T>(mut self, value: T) -> Self
8552 where
8553 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8554 T::Error: std::fmt::Display,
8555 {
8556 self.taxes = value
8557 .try_into()
8558 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8559 self
8560 }
8561 pub fn unit_cost<T>(mut self, value: T) -> Self
8562 where
8563 T: std::convert::TryInto<Option<f64>>,
8564 T::Error: std::fmt::Display,
8565 {
8566 self.unit_cost = value
8567 .try_into()
8568 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
8569 self
8570 }
8571 }
8572 impl std::convert::TryFrom<SubscriptionItem> for super::SubscriptionItem {
8573 type Error = super::error::ConversionError;
8574 fn try_from(value: SubscriptionItem) -> Result<Self, super::error::ConversionError> {
8575 Ok(Self {
8576 adjustments: value.adjustments?,
8577 amount: value.amount?,
8578 current_period_end_at: value.current_period_end_at?,
8579 current_period_start_at: value.current_period_start_at?,
8580 description: value.description?,
8581 interval: value.interval?,
8582 interval_count: value.interval_count?,
8583 metadata: value.metadata?,
8584 quantity: value.quantity?,
8585 subscription_type: value.subscription_type?,
8586 taxes: value.taxes?,
8587 unit_cost: value.unit_cost?,
8588 })
8589 }
8590 }
8591 impl From<super::SubscriptionItem> for SubscriptionItem {
8592 fn from(value: super::SubscriptionItem) -> Self {
8593 Self {
8594 adjustments: Ok(value.adjustments),
8595 amount: Ok(value.amount),
8596 current_period_end_at: Ok(value.current_period_end_at),
8597 current_period_start_at: Ok(value.current_period_start_at),
8598 description: Ok(value.description),
8599 interval: Ok(value.interval),
8600 interval_count: Ok(value.interval_count),
8601 metadata: Ok(value.metadata),
8602 quantity: Ok(value.quantity),
8603 subscription_type: Ok(value.subscription_type),
8604 taxes: Ok(value.taxes),
8605 unit_cost: Ok(value.unit_cost),
8606 }
8607 }
8608 }
8609 #[derive(Clone, Debug)]
8610 pub struct Tax {
8611 amount: Result<i64, String>,
8612 name: Result<String, String>,
8613 rate: Result<Option<f64>, String>,
8614 }
8615 impl Default for Tax {
8616 fn default() -> Self {
8617 Self {
8618 amount: Err("no value supplied for amount".to_string()),
8619 name: Err("no value supplied for name".to_string()),
8620 rate: Ok(Default::default()),
8621 }
8622 }
8623 }
8624 impl Tax {
8625 pub fn amount<T>(mut self, value: T) -> Self
8626 where
8627 T: std::convert::TryInto<i64>,
8628 T::Error: std::fmt::Display,
8629 {
8630 self.amount = value
8631 .try_into()
8632 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8633 self
8634 }
8635 pub fn name<T>(mut self, value: T) -> Self
8636 where
8637 T: std::convert::TryInto<String>,
8638 T::Error: std::fmt::Display,
8639 {
8640 self.name = value
8641 .try_into()
8642 .map_err(|e| format!("error converting supplied value for name: {}", e));
8643 self
8644 }
8645 pub fn rate<T>(mut self, value: T) -> Self
8646 where
8647 T: std::convert::TryInto<Option<f64>>,
8648 T::Error: std::fmt::Display,
8649 {
8650 self.rate = value
8651 .try_into()
8652 .map_err(|e| format!("error converting supplied value for rate: {}", e));
8653 self
8654 }
8655 }
8656 impl std::convert::TryFrom<Tax> for super::Tax {
8657 type Error = super::error::ConversionError;
8658 fn try_from(value: Tax) -> Result<Self, super::error::ConversionError> {
8659 Ok(Self {
8660 amount: value.amount?,
8661 name: value.name?,
8662 rate: value.rate?,
8663 })
8664 }
8665 }
8666 impl From<super::Tax> for Tax {
8667 fn from(value: super::Tax) -> Self {
8668 Self {
8669 amount: Ok(value.amount),
8670 name: Ok(value.name),
8671 rate: Ok(value.rate),
8672 }
8673 }
8674 }
8675 #[derive(Clone, Debug)]
8676 pub struct TransitRoute {
8677 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8678 transit_route_items: Result<Vec<super::TransitRouteItem>, String>,
8679 }
8680 impl Default for TransitRoute {
8681 fn default() -> Self {
8682 Self {
8683 invoice_level_adjustments: Ok(Default::default()),
8684 transit_route_items: Err("no value supplied for transit_route_items".to_string()),
8685 }
8686 }
8687 }
8688 impl TransitRoute {
8689 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
8690 where
8691 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8692 T::Error: std::fmt::Display,
8693 {
8694 self.invoice_level_adjustments = value.try_into().map_err(|e| {
8695 format!(
8696 "error converting supplied value for invoice_level_adjustments: {}",
8697 e
8698 )
8699 });
8700 self
8701 }
8702 pub fn transit_route_items<T>(mut self, value: T) -> Self
8703 where
8704 T: std::convert::TryInto<Vec<super::TransitRouteItem>>,
8705 T::Error: std::fmt::Display,
8706 {
8707 self.transit_route_items = value.try_into().map_err(|e| {
8708 format!(
8709 "error converting supplied value for transit_route_items: {}",
8710 e
8711 )
8712 });
8713 self
8714 }
8715 }
8716 impl std::convert::TryFrom<TransitRoute> for super::TransitRoute {
8717 type Error = super::error::ConversionError;
8718 fn try_from(value: TransitRoute) -> Result<Self, super::error::ConversionError> {
8719 Ok(Self {
8720 invoice_level_adjustments: value.invoice_level_adjustments?,
8721 transit_route_items: value.transit_route_items?,
8722 })
8723 }
8724 }
8725 impl From<super::TransitRoute> for TransitRoute {
8726 fn from(value: super::TransitRoute) -> Self {
8727 Self {
8728 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
8729 transit_route_items: Ok(value.transit_route_items),
8730 }
8731 }
8732 }
8733 #[derive(Clone, Debug)]
8734 pub struct TransitRouteItem {
8735 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8736 arrival_at: Result<Option<i64>, String>,
8737 arrival_location: Result<Option<super::Place>, String>,
8738 departure_at: Result<Option<i64>, String>,
8739 departure_location: Result<Option<super::Place>, String>,
8740 fare: Result<i64, String>,
8741 metadata: Result<Option<Vec<super::Metadatum>>, String>,
8742 mode: Result<Option<super::TransitRouteItemMode>, String>,
8743 passenger: Result<Option<super::Person>, String>,
8744 polyline: Result<Option<String>, String>,
8745 taxes: Result<Option<Vec<super::Tax>>, String>,
8746 }
8747 impl Default for TransitRouteItem {
8748 fn default() -> Self {
8749 Self {
8750 adjustments: Ok(Default::default()),
8751 arrival_at: Ok(Default::default()),
8752 arrival_location: Ok(Default::default()),
8753 departure_at: Ok(Default::default()),
8754 departure_location: Ok(Default::default()),
8755 fare: Err("no value supplied for fare".to_string()),
8756 metadata: Ok(Default::default()),
8757 mode: Ok(Default::default()),
8758 passenger: Ok(Default::default()),
8759 polyline: Ok(Default::default()),
8760 taxes: Ok(Default::default()),
8761 }
8762 }
8763 }
8764 impl TransitRouteItem {
8765 pub fn adjustments<T>(mut self, value: T) -> Self
8766 where
8767 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8768 T::Error: std::fmt::Display,
8769 {
8770 self.adjustments = value
8771 .try_into()
8772 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
8773 self
8774 }
8775 pub fn arrival_at<T>(mut self, value: T) -> Self
8776 where
8777 T: std::convert::TryInto<Option<i64>>,
8778 T::Error: std::fmt::Display,
8779 {
8780 self.arrival_at = value
8781 .try_into()
8782 .map_err(|e| format!("error converting supplied value for arrival_at: {}", e));
8783 self
8784 }
8785 pub fn arrival_location<T>(mut self, value: T) -> Self
8786 where
8787 T: std::convert::TryInto<Option<super::Place>>,
8788 T::Error: std::fmt::Display,
8789 {
8790 self.arrival_location = value.try_into().map_err(|e| {
8791 format!(
8792 "error converting supplied value for arrival_location: {}",
8793 e
8794 )
8795 });
8796 self
8797 }
8798 pub fn departure_at<T>(mut self, value: T) -> Self
8799 where
8800 T: std::convert::TryInto<Option<i64>>,
8801 T::Error: std::fmt::Display,
8802 {
8803 self.departure_at = value
8804 .try_into()
8805 .map_err(|e| format!("error converting supplied value for departure_at: {}", e));
8806 self
8807 }
8808 pub fn departure_location<T>(mut self, value: T) -> Self
8809 where
8810 T: std::convert::TryInto<Option<super::Place>>,
8811 T::Error: std::fmt::Display,
8812 {
8813 self.departure_location = value.try_into().map_err(|e| {
8814 format!(
8815 "error converting supplied value for departure_location: {}",
8816 e
8817 )
8818 });
8819 self
8820 }
8821 pub fn fare<T>(mut self, value: T) -> Self
8822 where
8823 T: std::convert::TryInto<i64>,
8824 T::Error: std::fmt::Display,
8825 {
8826 self.fare = value
8827 .try_into()
8828 .map_err(|e| format!("error converting supplied value for fare: {}", e));
8829 self
8830 }
8831 pub fn metadata<T>(mut self, value: T) -> Self
8832 where
8833 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8834 T::Error: std::fmt::Display,
8835 {
8836 self.metadata = value
8837 .try_into()
8838 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8839 self
8840 }
8841 pub fn mode<T>(mut self, value: T) -> Self
8842 where
8843 T: std::convert::TryInto<Option<super::TransitRouteItemMode>>,
8844 T::Error: std::fmt::Display,
8845 {
8846 self.mode = value
8847 .try_into()
8848 .map_err(|e| format!("error converting supplied value for mode: {}", e));
8849 self
8850 }
8851 pub fn passenger<T>(mut self, value: T) -> Self
8852 where
8853 T: std::convert::TryInto<Option<super::Person>>,
8854 T::Error: std::fmt::Display,
8855 {
8856 self.passenger = value
8857 .try_into()
8858 .map_err(|e| format!("error converting supplied value for passenger: {}", e));
8859 self
8860 }
8861 pub fn polyline<T>(mut self, value: T) -> Self
8862 where
8863 T: std::convert::TryInto<Option<String>>,
8864 T::Error: std::fmt::Display,
8865 {
8866 self.polyline = value
8867 .try_into()
8868 .map_err(|e| format!("error converting supplied value for polyline: {}", e));
8869 self
8870 }
8871 pub fn taxes<T>(mut self, value: T) -> Self
8872 where
8873 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8874 T::Error: std::fmt::Display,
8875 {
8876 self.taxes = value
8877 .try_into()
8878 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8879 self
8880 }
8881 }
8882 impl std::convert::TryFrom<TransitRouteItem> for super::TransitRouteItem {
8883 type Error = super::error::ConversionError;
8884 fn try_from(value: TransitRouteItem) -> Result<Self, super::error::ConversionError> {
8885 Ok(Self {
8886 adjustments: value.adjustments?,
8887 arrival_at: value.arrival_at?,
8888 arrival_location: value.arrival_location?,
8889 departure_at: value.departure_at?,
8890 departure_location: value.departure_location?,
8891 fare: value.fare?,
8892 metadata: value.metadata?,
8893 mode: value.mode?,
8894 passenger: value.passenger?,
8895 polyline: value.polyline?,
8896 taxes: value.taxes?,
8897 })
8898 }
8899 }
8900 impl From<super::TransitRouteItem> for TransitRouteItem {
8901 fn from(value: super::TransitRouteItem) -> Self {
8902 Self {
8903 adjustments: Ok(value.adjustments),
8904 arrival_at: Ok(value.arrival_at),
8905 arrival_location: Ok(value.arrival_location),
8906 departure_at: Ok(value.departure_at),
8907 departure_location: Ok(value.departure_location),
8908 fare: Ok(value.fare),
8909 metadata: Ok(value.metadata),
8910 mode: Ok(value.mode),
8911 passenger: Ok(value.passenger),
8912 polyline: Ok(value.polyline),
8913 taxes: Ok(value.taxes),
8914 }
8915 }
8916 }
8917}