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)]
48pub struct AchPayment {
49 pub routing_number: AchPaymentRoutingNumber,
50}
51impl From<&AchPayment> for AchPayment {
52 fn from(value: &AchPayment) -> Self {
53 value.clone()
54 }
55}
56impl AchPayment {
57 pub fn builder() -> builder::AchPayment {
58 Default::default()
59 }
60}
61#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
73pub struct AchPaymentRoutingNumber(String);
74impl ::std::ops::Deref for AchPaymentRoutingNumber {
75 type Target = String;
76 fn deref(&self) -> &String {
77 &self.0
78 }
79}
80impl From<AchPaymentRoutingNumber> for String {
81 fn from(value: AchPaymentRoutingNumber) -> Self {
82 value.0
83 }
84}
85impl From<&AchPaymentRoutingNumber> for AchPaymentRoutingNumber {
86 fn from(value: &AchPaymentRoutingNumber) -> Self {
87 value.clone()
88 }
89}
90impl ::std::str::FromStr for AchPaymentRoutingNumber {
91 type Err = self::error::ConversionError;
92 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
93 if regress::Regex::new("^\\d{9}$")
94 .unwrap()
95 .find(value)
96 .is_none()
97 {
98 return Err("doesn't match pattern \"^\\d{9}$\"".into());
99 }
100 Ok(Self(value.to_string()))
101 }
102}
103impl ::std::convert::TryFrom<&str> for AchPaymentRoutingNumber {
104 type Error = self::error::ConversionError;
105 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
106 value.parse()
107 }
108}
109impl ::std::convert::TryFrom<&String> for AchPaymentRoutingNumber {
110 type Error = self::error::ConversionError;
111 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
112 value.parse()
113 }
114}
115impl ::std::convert::TryFrom<String> for AchPaymentRoutingNumber {
116 type Error = self::error::ConversionError;
117 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
118 value.parse()
119 }
120}
121impl<'de> ::serde::Deserialize<'de> for AchPaymentRoutingNumber {
122 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
123 where
124 D: ::serde::Deserializer<'de>,
125 {
126 String::deserialize(deserializer)?
127 .parse()
128 .map_err(|e: self::error::ConversionError| {
129 <D::Error as ::serde::de::Error>::custom(e.to_string())
130 })
131 }
132}
133#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
158pub struct Action {
159 pub name: String,
160 pub url: String,
161}
162impl From<&Action> for Action {
163 fn from(value: &Action) -> Self {
164 value.clone()
165 }
166}
167impl Action {
168 pub fn builder() -> builder::Action {
169 Default::default()
170 }
171}
172#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
257pub struct Address {
258 #[serde(default, skip_serializing_if = "Option::is_none")]
259 pub city: Option<String>,
260 #[serde(default, skip_serializing_if = "Option::is_none")]
261 pub country: Option<AddressCountry>,
262 #[serde(default, skip_serializing_if = "Option::is_none")]
263 pub lat: Option<f64>,
264 #[serde(default, skip_serializing_if = "Option::is_none")]
265 pub lon: Option<f64>,
266 #[serde(default, skip_serializing_if = "Option::is_none")]
267 pub postal_code: Option<String>,
268 #[serde(default, skip_serializing_if = "Option::is_none")]
269 pub region: Option<AddressRegion>,
270 #[serde(default, skip_serializing_if = "Option::is_none")]
271 pub street_address: Option<String>,
272 #[serde(default, skip_serializing_if = "Option::is_none")]
273 pub tz: Option<String>,
274}
275impl From<&Address> for Address {
276 fn from(value: &Address) -> Self {
277 value.clone()
278 }
279}
280impl Address {
281 pub fn builder() -> builder::Address {
282 Default::default()
283 }
284}
285#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
298pub struct AddressCountry(String);
299impl ::std::ops::Deref for AddressCountry {
300 type Target = String;
301 fn deref(&self) -> &String {
302 &self.0
303 }
304}
305impl From<AddressCountry> for String {
306 fn from(value: AddressCountry) -> Self {
307 value.0
308 }
309}
310impl From<&AddressCountry> for AddressCountry {
311 fn from(value: &AddressCountry) -> Self {
312 value.clone()
313 }
314}
315impl ::std::str::FromStr for AddressCountry {
316 type Err = self::error::ConversionError;
317 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
318 if value.len() > 2usize {
319 return Err("longer than 2 characters".into());
320 }
321 if value.len() < 2usize {
322 return Err("shorter than 2 characters".into());
323 }
324 Ok(Self(value.to_string()))
325 }
326}
327impl ::std::convert::TryFrom<&str> for AddressCountry {
328 type Error = self::error::ConversionError;
329 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
330 value.parse()
331 }
332}
333impl ::std::convert::TryFrom<&String> for AddressCountry {
334 type Error = self::error::ConversionError;
335 fn try_from(value: &String) -> 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<'de> ::serde::Deserialize<'de> for AddressCountry {
346 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
347 where
348 D: ::serde::Deserializer<'de>,
349 {
350 String::deserialize(deserializer)?
351 .parse()
352 .map_err(|e: self::error::ConversionError| {
353 <D::Error as ::serde::de::Error>::custom(e.to_string())
354 })
355 }
356}
357#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
369pub struct AddressRegion(String);
370impl ::std::ops::Deref for AddressRegion {
371 type Target = String;
372 fn deref(&self) -> &String {
373 &self.0
374 }
375}
376impl From<AddressRegion> for String {
377 fn from(value: AddressRegion) -> Self {
378 value.0
379 }
380}
381impl From<&AddressRegion> for AddressRegion {
382 fn from(value: &AddressRegion) -> Self {
383 value.clone()
384 }
385}
386impl ::std::str::FromStr for AddressRegion {
387 type Err = self::error::ConversionError;
388 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
389 if regress::Regex::new("^[a-zA-Z0-9]{1,3}$")
390 .unwrap()
391 .find(value)
392 .is_none()
393 {
394 return Err("doesn't match pattern \"^[a-zA-Z0-9]{1,3}$\"".into());
395 }
396 Ok(Self(value.to_string()))
397 }
398}
399impl ::std::convert::TryFrom<&str> for AddressRegion {
400 type Error = self::error::ConversionError;
401 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
402 value.parse()
403 }
404}
405impl ::std::convert::TryFrom<&String> for AddressRegion {
406 type Error = self::error::ConversionError;
407 fn try_from(value: &String) -> 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<'de> ::serde::Deserialize<'de> for AddressRegion {
418 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
419 where
420 D: ::serde::Deserializer<'de>,
421 {
422 String::deserialize(deserializer)?
423 .parse()
424 .map_err(|e: self::error::ConversionError| {
425 <D::Error as ::serde::de::Error>::custom(e.to_string())
426 })
427 }
428}
429#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
473pub struct Adjustment {
474 pub adjustment_type: AdjustmentType,
475 pub amount: i64,
476 #[serde(default, skip_serializing_if = "Option::is_none")]
477 pub name: Option<String>,
478 #[serde(default, skip_serializing_if = "Option::is_none")]
479 pub rate: Option<f64>,
480}
481impl From<&Adjustment> for Adjustment {
482 fn from(value: &Adjustment) -> Self {
483 value.clone()
484 }
485}
486impl Adjustment {
487 pub fn builder() -> builder::Adjustment {
488 Default::default()
489 }
490}
491#[derive(
510 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
511)]
512pub enum AdjustmentType {
513 #[serde(rename = "add_on")]
514 AddOn,
515 #[serde(rename = "discount")]
516 Discount,
517 #[serde(rename = "fee")]
518 Fee,
519 #[serde(rename = "other")]
520 Other,
521 #[serde(rename = "tip")]
522 Tip,
523}
524impl From<&AdjustmentType> for AdjustmentType {
525 fn from(value: &AdjustmentType) -> Self {
526 value.clone()
527 }
528}
529impl ::std::fmt::Display for AdjustmentType {
530 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
531 match *self {
532 Self::AddOn => write!(f, "add_on"),
533 Self::Discount => write!(f, "discount"),
534 Self::Fee => write!(f, "fee"),
535 Self::Other => write!(f, "other"),
536 Self::Tip => write!(f, "tip"),
537 }
538 }
539}
540impl std::str::FromStr for AdjustmentType {
541 type Err = self::error::ConversionError;
542 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
543 match value {
544 "add_on" => Ok(Self::AddOn),
545 "discount" => Ok(Self::Discount),
546 "fee" => Ok(Self::Fee),
547 "other" => Ok(Self::Other),
548 "tip" => Ok(Self::Tip),
549 _ => Err("invalid value".into()),
550 }
551 }
552}
553impl std::convert::TryFrom<&str> for AdjustmentType {
554 type Error = self::error::ConversionError;
555 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
556 value.parse()
557 }
558}
559impl std::convert::TryFrom<&String> for AdjustmentType {
560 type Error = self::error::ConversionError;
561 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
562 value.parse()
563 }
564}
565impl std::convert::TryFrom<String> for AdjustmentType {
566 type Error = self::error::ConversionError;
567 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
568 value.parse()
569 }
570}
571#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
715pub struct CarRental {
716 #[serde(default, skip_serializing_if = "Option::is_none")]
717 pub confirmation_number: Option<String>,
718 #[serde(default, skip_serializing_if = "Option::is_none")]
719 pub drivers: Option<Vec<Person>>,
720 #[serde(default, skip_serializing_if = "Option::is_none")]
721 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
722 pub items: Vec<Item>,
723 #[serde(default, skip_serializing_if = "Option::is_none")]
724 pub metadata: Option<Vec<Metadatum>>,
725 pub odometer_reading_in: i64,
726 pub odometer_reading_out: i64,
727 #[serde(default, skip_serializing_if = "Option::is_none")]
728 pub record_locator: Option<String>,
729 pub rental_at: i64,
730 pub rental_location: Place,
731 pub return_at: i64,
732 pub return_location: Place,
733 #[serde(default, skip_serializing_if = "Option::is_none")]
734 pub vehicle: Option<CarRentalVehicle>,
735 #[serde(default, skip_serializing_if = "Option::is_none")]
736 pub vendor_code: Option<CarRentalVendorCode>,
737}
738impl From<&CarRental> for CarRental {
739 fn from(value: &CarRental) -> Self {
740 value.clone()
741 }
742}
743impl CarRental {
744 pub fn builder() -> builder::CarRental {
745 Default::default()
746 }
747}
748#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
787pub struct CarRentalVehicle {
788 pub description: String,
789 #[serde(default, skip_serializing_if = "Option::is_none")]
790 pub image: Option<String>,
791 #[serde(default, skip_serializing_if = "Option::is_none")]
792 pub license_plate_number: Option<String>,
793 #[serde(default, skip_serializing_if = "Option::is_none")]
794 pub vehicle_class: Option<CarRentalVehicleVehicleClass>,
795}
796impl From<&CarRentalVehicle> for CarRentalVehicle {
797 fn from(value: &CarRentalVehicle) -> Self {
798 value.clone()
799 }
800}
801impl CarRentalVehicle {
802 pub fn builder() -> builder::CarRentalVehicle {
803 Default::default()
804 }
805}
806#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
818pub struct CarRentalVehicleVehicleClass(String);
819impl ::std::ops::Deref for CarRentalVehicleVehicleClass {
820 type Target = String;
821 fn deref(&self) -> &String {
822 &self.0
823 }
824}
825impl From<CarRentalVehicleVehicleClass> for String {
826 fn from(value: CarRentalVehicleVehicleClass) -> Self {
827 value.0
828 }
829}
830impl From<&CarRentalVehicleVehicleClass> for CarRentalVehicleVehicleClass {
831 fn from(value: &CarRentalVehicleVehicleClass) -> Self {
832 value.clone()
833 }
834}
835impl ::std::str::FromStr for CarRentalVehicleVehicleClass {
836 type Err = self::error::ConversionError;
837 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
838 if regress::Regex::new("^[a-zA-Z]{4}$")
839 .unwrap()
840 .find(value)
841 .is_none()
842 {
843 return Err("doesn't match pattern \"^[a-zA-Z]{4}$\"".into());
844 }
845 Ok(Self(value.to_string()))
846 }
847}
848impl ::std::convert::TryFrom<&str> for CarRentalVehicleVehicleClass {
849 type Error = self::error::ConversionError;
850 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
851 value.parse()
852 }
853}
854impl ::std::convert::TryFrom<&String> for CarRentalVehicleVehicleClass {
855 type Error = self::error::ConversionError;
856 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
857 value.parse()
858 }
859}
860impl ::std::convert::TryFrom<String> for CarRentalVehicleVehicleClass {
861 type Error = self::error::ConversionError;
862 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
863 value.parse()
864 }
865}
866impl<'de> ::serde::Deserialize<'de> for CarRentalVehicleVehicleClass {
867 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
868 where
869 D: ::serde::Deserializer<'de>,
870 {
871 String::deserialize(deserializer)?
872 .parse()
873 .map_err(|e: self::error::ConversionError| {
874 <D::Error as ::serde::de::Error>::custom(e.to_string())
875 })
876 }
877}
878#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
890pub struct CarRentalVendorCode(String);
891impl ::std::ops::Deref for CarRentalVendorCode {
892 type Target = String;
893 fn deref(&self) -> &String {
894 &self.0
895 }
896}
897impl From<CarRentalVendorCode> for String {
898 fn from(value: CarRentalVendorCode) -> Self {
899 value.0
900 }
901}
902impl From<&CarRentalVendorCode> for CarRentalVendorCode {
903 fn from(value: &CarRentalVendorCode) -> Self {
904 value.clone()
905 }
906}
907impl ::std::str::FromStr for CarRentalVendorCode {
908 type Err = self::error::ConversionError;
909 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
910 if regress::Regex::new("^[A-Z]{2}$")
911 .unwrap()
912 .find(value)
913 .is_none()
914 {
915 return Err("doesn't match pattern \"^[A-Z]{2}$\"".into());
916 }
917 Ok(Self(value.to_string()))
918 }
919}
920impl ::std::convert::TryFrom<&str> for CarRentalVendorCode {
921 type Error = self::error::ConversionError;
922 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
923 value.parse()
924 }
925}
926impl ::std::convert::TryFrom<&String> for CarRentalVendorCode {
927 type Error = self::error::ConversionError;
928 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
929 value.parse()
930 }
931}
932impl ::std::convert::TryFrom<String> for CarRentalVendorCode {
933 type Error = self::error::ConversionError;
934 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
935 value.parse()
936 }
937}
938impl<'de> ::serde::Deserialize<'de> for CarRentalVendorCode {
939 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
940 where
941 D: ::serde::Deserializer<'de>,
942 {
943 String::deserialize(deserializer)?
944 .parse()
945 .map_err(|e: self::error::ConversionError| {
946 <D::Error as ::serde::de::Error>::custom(e.to_string())
947 })
948 }
949}
950#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
991pub struct CardPayment {
992 pub last_four: CardPaymentLastFour,
993 #[serde(default, skip_serializing_if = "Option::is_none")]
994 pub network: Option<CardPaymentNetwork>,
995}
996impl From<&CardPayment> for CardPayment {
997 fn from(value: &CardPayment) -> Self {
998 value.clone()
999 }
1000}
1001impl CardPayment {
1002 pub fn builder() -> builder::CardPayment {
1003 Default::default()
1004 }
1005}
1006#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1018pub struct CardPaymentLastFour(String);
1019impl ::std::ops::Deref for CardPaymentLastFour {
1020 type Target = String;
1021 fn deref(&self) -> &String {
1022 &self.0
1023 }
1024}
1025impl From<CardPaymentLastFour> for String {
1026 fn from(value: CardPaymentLastFour) -> Self {
1027 value.0
1028 }
1029}
1030impl From<&CardPaymentLastFour> for CardPaymentLastFour {
1031 fn from(value: &CardPaymentLastFour) -> Self {
1032 value.clone()
1033 }
1034}
1035impl ::std::str::FromStr for CardPaymentLastFour {
1036 type Err = self::error::ConversionError;
1037 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1038 if regress::Regex::new("^\\d{4}$")
1039 .unwrap()
1040 .find(value)
1041 .is_none()
1042 {
1043 return Err("doesn't match pattern \"^\\d{4}$\"".into());
1044 }
1045 Ok(Self(value.to_string()))
1046 }
1047}
1048impl ::std::convert::TryFrom<&str> for CardPaymentLastFour {
1049 type Error = self::error::ConversionError;
1050 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1051 value.parse()
1052 }
1053}
1054impl ::std::convert::TryFrom<&String> for CardPaymentLastFour {
1055 type Error = self::error::ConversionError;
1056 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1057 value.parse()
1058 }
1059}
1060impl ::std::convert::TryFrom<String> for CardPaymentLastFour {
1061 type Error = self::error::ConversionError;
1062 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1063 value.parse()
1064 }
1065}
1066impl<'de> ::serde::Deserialize<'de> for CardPaymentLastFour {
1067 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1068 where
1069 D: ::serde::Deserializer<'de>,
1070 {
1071 String::deserialize(deserializer)?
1072 .parse()
1073 .map_err(|e: self::error::ConversionError| {
1074 <D::Error as ::serde::de::Error>::custom(e.to_string())
1075 })
1076 }
1077}
1078#[derive(
1099 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
1100)]
1101pub enum CardPaymentNetwork {
1102 #[serde(rename = "amex")]
1103 Amex,
1104 #[serde(rename = "diners")]
1105 Diners,
1106 #[serde(rename = "discover")]
1107 Discover,
1108 #[serde(rename = "eftpos_au")]
1109 EftposAu,
1110 #[serde(rename = "jcb")]
1111 Jcb,
1112 #[serde(rename = "mastercard")]
1113 Mastercard,
1114 #[serde(rename = "unionpay")]
1115 Unionpay,
1116 #[serde(rename = "visa")]
1117 Visa,
1118}
1119impl From<&CardPaymentNetwork> for CardPaymentNetwork {
1120 fn from(value: &CardPaymentNetwork) -> Self {
1121 value.clone()
1122 }
1123}
1124impl ::std::fmt::Display for CardPaymentNetwork {
1125 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1126 match *self {
1127 Self::Amex => write!(f, "amex"),
1128 Self::Diners => write!(f, "diners"),
1129 Self::Discover => write!(f, "discover"),
1130 Self::EftposAu => write!(f, "eftpos_au"),
1131 Self::Jcb => write!(f, "jcb"),
1132 Self::Mastercard => write!(f, "mastercard"),
1133 Self::Unionpay => write!(f, "unionpay"),
1134 Self::Visa => write!(f, "visa"),
1135 }
1136 }
1137}
1138impl std::str::FromStr for CardPaymentNetwork {
1139 type Err = self::error::ConversionError;
1140 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1141 match value {
1142 "amex" => Ok(Self::Amex),
1143 "diners" => Ok(Self::Diners),
1144 "discover" => Ok(Self::Discover),
1145 "eftpos_au" => Ok(Self::EftposAu),
1146 "jcb" => Ok(Self::Jcb),
1147 "mastercard" => Ok(Self::Mastercard),
1148 "unionpay" => Ok(Self::Unionpay),
1149 "visa" => Ok(Self::Visa),
1150 _ => Err("invalid value".into()),
1151 }
1152 }
1153}
1154impl std::convert::TryFrom<&str> for CardPaymentNetwork {
1155 type Error = self::error::ConversionError;
1156 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1157 value.parse()
1158 }
1159}
1160impl std::convert::TryFrom<&String> for CardPaymentNetwork {
1161 type Error = self::error::ConversionError;
1162 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1163 value.parse()
1164 }
1165}
1166impl std::convert::TryFrom<String> for CardPaymentNetwork {
1167 type Error = self::error::ConversionError;
1168 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1169 value.parse()
1170 }
1171}
1172#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1186pub struct Currency(String);
1187impl ::std::ops::Deref for Currency {
1188 type Target = String;
1189 fn deref(&self) -> &String {
1190 &self.0
1191 }
1192}
1193impl From<Currency> for String {
1194 fn from(value: Currency) -> Self {
1195 value.0
1196 }
1197}
1198impl From<&Currency> for Currency {
1199 fn from(value: &Currency) -> Self {
1200 value.clone()
1201 }
1202}
1203impl ::std::str::FromStr for Currency {
1204 type Err = self::error::ConversionError;
1205 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1206 if regress::Regex::new("^[a-z]{3}$")
1207 .unwrap()
1208 .find(value)
1209 .is_none()
1210 {
1211 return Err("doesn't match pattern \"^[a-z]{3}$\"".into());
1212 }
1213 Ok(Self(value.to_string()))
1214 }
1215}
1216impl ::std::convert::TryFrom<&str> for Currency {
1217 type Error = self::error::ConversionError;
1218 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1219 value.parse()
1220 }
1221}
1222impl ::std::convert::TryFrom<&String> for Currency {
1223 type Error = self::error::ConversionError;
1224 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1225 value.parse()
1226 }
1227}
1228impl ::std::convert::TryFrom<String> for Currency {
1229 type Error = self::error::ConversionError;
1230 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1231 value.parse()
1232 }
1233}
1234impl<'de> ::serde::Deserialize<'de> for Currency {
1235 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1236 where
1237 D: ::serde::Deserializer<'de>,
1238 {
1239 String::deserialize(deserializer)?
1240 .parse()
1241 .map_err(|e: self::error::ConversionError| {
1242 <D::Error as ::serde::de::Error>::custom(e.to_string())
1243 })
1244 }
1245}
1246#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1322pub struct Customer {
1323 #[serde(default, skip_serializing_if = "Option::is_none")]
1324 pub address: Option<Address>,
1325 #[serde(default, skip_serializing_if = "Option::is_none")]
1326 pub booker: Option<Person>,
1327 #[serde(default, skip_serializing_if = "Option::is_none")]
1328 pub email: Option<String>,
1329 #[serde(default, skip_serializing_if = "Option::is_none")]
1330 pub metadata: Option<Vec<Metadatum>>,
1331 pub name: String,
1332 #[serde(default, skip_serializing_if = "Option::is_none")]
1333 pub phone: Option<CustomerPhone>,
1334 #[serde(default, skip_serializing_if = "Option::is_none")]
1335 pub website: Option<String>,
1336}
1337impl From<&Customer> for Customer {
1338 fn from(value: &Customer) -> Self {
1339 value.clone()
1340 }
1341}
1342impl Customer {
1343 pub fn builder() -> builder::Customer {
1344 Default::default()
1345 }
1346}
1347#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1359pub struct CustomerPhone(String);
1360impl ::std::ops::Deref for CustomerPhone {
1361 type Target = String;
1362 fn deref(&self) -> &String {
1363 &self.0
1364 }
1365}
1366impl From<CustomerPhone> for String {
1367 fn from(value: CustomerPhone) -> Self {
1368 value.0
1369 }
1370}
1371impl From<&CustomerPhone> for CustomerPhone {
1372 fn from(value: &CustomerPhone) -> Self {
1373 value.clone()
1374 }
1375}
1376impl ::std::str::FromStr for CustomerPhone {
1377 type Err = self::error::ConversionError;
1378 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1379 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
1380 .unwrap()
1381 .find(value)
1382 .is_none()
1383 {
1384 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
1385 }
1386 Ok(Self(value.to_string()))
1387 }
1388}
1389impl ::std::convert::TryFrom<&str> for CustomerPhone {
1390 type Error = self::error::ConversionError;
1391 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1392 value.parse()
1393 }
1394}
1395impl ::std::convert::TryFrom<&String> for CustomerPhone {
1396 type Error = self::error::ConversionError;
1397 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1398 value.parse()
1399 }
1400}
1401impl ::std::convert::TryFrom<String> for CustomerPhone {
1402 type Error = self::error::ConversionError;
1403 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1404 value.parse()
1405 }
1406}
1407impl<'de> ::serde::Deserialize<'de> for CustomerPhone {
1408 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1409 where
1410 D: ::serde::Deserializer<'de>,
1411 {
1412 String::deserialize(deserializer)?
1413 .parse()
1414 .map_err(|e: self::error::ConversionError| {
1415 <D::Error as ::serde::de::Error>::custom(e.to_string())
1416 })
1417 }
1418}
1419#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1443pub struct Doc {
1444 pub body: String,
1445 pub title: String,
1446}
1447impl From<&Doc> for Doc {
1448 fn from(value: &Doc) -> Self {
1449 value.clone()
1450 }
1451}
1452impl Doc {
1453 pub fn builder() -> builder::Doc {
1454 Default::default()
1455 }
1456}
1457#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1506pub struct Ecommerce {
1507 #[serde(default, skip_serializing_if = "Option::is_none")]
1508 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
1509 #[serde(default, skip_serializing_if = "Option::is_none")]
1510 pub invoice_level_line_items: Option<Vec<Item>>,
1511 pub shipments: Vec<Shipment>,
1512}
1513impl From<&Ecommerce> for Ecommerce {
1514 fn from(value: &Ecommerce) -> Self {
1515 value.clone()
1516 }
1517}
1518impl Ecommerce {
1519 pub fn builder() -> builder::Ecommerce {
1520 Default::default()
1521 }
1522}
1523#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1566pub struct Flight {
1567 #[serde(default, skip_serializing_if = "Option::is_none")]
1568 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
1569 #[serde(default, skip_serializing_if = "Option::is_none")]
1570 pub itinerary_locator: Option<String>,
1571 pub tickets: Vec<FlightTicket>,
1572}
1573impl From<&Flight> for Flight {
1574 fn from(value: &Flight) -> Self {
1575 value.clone()
1576 }
1577}
1578impl Flight {
1579 pub fn builder() -> builder::Flight {
1580 Default::default()
1581 }
1582}
1583#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
1707pub struct FlightSegment {
1708 #[serde(default, skip_serializing_if = "Option::is_none")]
1709 pub adjustments: Option<Vec<Adjustment>>,
1710 #[serde(default, skip_serializing_if = "Option::is_none")]
1711 pub aircraft_type: Option<FlightSegmentAircraftType>,
1712 pub arrival_airport_code: FlightSegmentArrivalAirportCode,
1713 #[serde(default, skip_serializing_if = "Option::is_none")]
1714 pub arrival_at: Option<i64>,
1715 #[serde(default, skip_serializing_if = "Option::is_none")]
1716 pub arrival_tz: Option<String>,
1717 #[serde(default, skip_serializing_if = "Option::is_none")]
1718 pub class_of_service: Option<String>,
1719 pub departure_airport_code: FlightSegmentDepartureAirportCode,
1720 #[serde(default, skip_serializing_if = "Option::is_none")]
1721 pub departure_at: Option<i64>,
1722 #[serde(default, skip_serializing_if = "Option::is_none")]
1723 pub departure_tz: Option<String>,
1724 #[serde(default, skip_serializing_if = "Option::is_none")]
1725 pub fare: Option<i64>,
1726 #[serde(default, skip_serializing_if = "Option::is_none")]
1727 pub flight_number: Option<String>,
1728 #[serde(default, skip_serializing_if = "Option::is_none")]
1729 pub metadata: Option<Vec<Metadatum>>,
1730 #[serde(default, skip_serializing_if = "Option::is_none")]
1731 pub seat: Option<String>,
1732 #[serde(default, skip_serializing_if = "Option::is_none")]
1733 pub taxes: Option<Vec<Tax>>,
1734}
1735impl From<&FlightSegment> for FlightSegment {
1736 fn from(value: &FlightSegment) -> Self {
1737 value.clone()
1738 }
1739}
1740impl FlightSegment {
1741 pub fn builder() -> builder::FlightSegment {
1742 Default::default()
1743 }
1744}
1745#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1757pub struct FlightSegmentAircraftType(String);
1758impl ::std::ops::Deref for FlightSegmentAircraftType {
1759 type Target = String;
1760 fn deref(&self) -> &String {
1761 &self.0
1762 }
1763}
1764impl From<FlightSegmentAircraftType> for String {
1765 fn from(value: FlightSegmentAircraftType) -> Self {
1766 value.0
1767 }
1768}
1769impl From<&FlightSegmentAircraftType> for FlightSegmentAircraftType {
1770 fn from(value: &FlightSegmentAircraftType) -> Self {
1771 value.clone()
1772 }
1773}
1774impl ::std::str::FromStr for FlightSegmentAircraftType {
1775 type Err = self::error::ConversionError;
1776 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1777 if regress::Regex::new("^[a-zA-Z0-9]{2,4}$")
1778 .unwrap()
1779 .find(value)
1780 .is_none()
1781 {
1782 return Err("doesn't match pattern \"^[a-zA-Z0-9]{2,4}$\"".into());
1783 }
1784 Ok(Self(value.to_string()))
1785 }
1786}
1787impl ::std::convert::TryFrom<&str> for FlightSegmentAircraftType {
1788 type Error = self::error::ConversionError;
1789 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1790 value.parse()
1791 }
1792}
1793impl ::std::convert::TryFrom<&String> for FlightSegmentAircraftType {
1794 type Error = self::error::ConversionError;
1795 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1796 value.parse()
1797 }
1798}
1799impl ::std::convert::TryFrom<String> for FlightSegmentAircraftType {
1800 type Error = self::error::ConversionError;
1801 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1802 value.parse()
1803 }
1804}
1805impl<'de> ::serde::Deserialize<'de> for FlightSegmentAircraftType {
1806 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1807 where
1808 D: ::serde::Deserializer<'de>,
1809 {
1810 String::deserialize(deserializer)?
1811 .parse()
1812 .map_err(|e: self::error::ConversionError| {
1813 <D::Error as ::serde::de::Error>::custom(e.to_string())
1814 })
1815 }
1816}
1817#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1829pub struct FlightSegmentArrivalAirportCode(String);
1830impl ::std::ops::Deref for FlightSegmentArrivalAirportCode {
1831 type Target = String;
1832 fn deref(&self) -> &String {
1833 &self.0
1834 }
1835}
1836impl From<FlightSegmentArrivalAirportCode> for String {
1837 fn from(value: FlightSegmentArrivalAirportCode) -> Self {
1838 value.0
1839 }
1840}
1841impl From<&FlightSegmentArrivalAirportCode> for FlightSegmentArrivalAirportCode {
1842 fn from(value: &FlightSegmentArrivalAirportCode) -> Self {
1843 value.clone()
1844 }
1845}
1846impl ::std::str::FromStr for FlightSegmentArrivalAirportCode {
1847 type Err = self::error::ConversionError;
1848 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1849 if regress::Regex::new("^[a-zA-Z]{3}$")
1850 .unwrap()
1851 .find(value)
1852 .is_none()
1853 {
1854 return Err("doesn't match pattern \"^[a-zA-Z]{3}$\"".into());
1855 }
1856 Ok(Self(value.to_string()))
1857 }
1858}
1859impl ::std::convert::TryFrom<&str> for FlightSegmentArrivalAirportCode {
1860 type Error = self::error::ConversionError;
1861 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1862 value.parse()
1863 }
1864}
1865impl ::std::convert::TryFrom<&String> for FlightSegmentArrivalAirportCode {
1866 type Error = self::error::ConversionError;
1867 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1868 value.parse()
1869 }
1870}
1871impl ::std::convert::TryFrom<String> for FlightSegmentArrivalAirportCode {
1872 type Error = self::error::ConversionError;
1873 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1874 value.parse()
1875 }
1876}
1877impl<'de> ::serde::Deserialize<'de> for FlightSegmentArrivalAirportCode {
1878 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1879 where
1880 D: ::serde::Deserializer<'de>,
1881 {
1882 String::deserialize(deserializer)?
1883 .parse()
1884 .map_err(|e: self::error::ConversionError| {
1885 <D::Error as ::serde::de::Error>::custom(e.to_string())
1886 })
1887 }
1888}
1889#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1901pub struct FlightSegmentDepartureAirportCode(String);
1902impl ::std::ops::Deref for FlightSegmentDepartureAirportCode {
1903 type Target = String;
1904 fn deref(&self) -> &String {
1905 &self.0
1906 }
1907}
1908impl From<FlightSegmentDepartureAirportCode> for String {
1909 fn from(value: FlightSegmentDepartureAirportCode) -> Self {
1910 value.0
1911 }
1912}
1913impl From<&FlightSegmentDepartureAirportCode> for FlightSegmentDepartureAirportCode {
1914 fn from(value: &FlightSegmentDepartureAirportCode) -> Self {
1915 value.clone()
1916 }
1917}
1918impl ::std::str::FromStr for FlightSegmentDepartureAirportCode {
1919 type Err = self::error::ConversionError;
1920 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
1921 if regress::Regex::new("^[a-zA-Z]{3}$")
1922 .unwrap()
1923 .find(value)
1924 .is_none()
1925 {
1926 return Err("doesn't match pattern \"^[a-zA-Z]{3}$\"".into());
1927 }
1928 Ok(Self(value.to_string()))
1929 }
1930}
1931impl ::std::convert::TryFrom<&str> for FlightSegmentDepartureAirportCode {
1932 type Error = self::error::ConversionError;
1933 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
1934 value.parse()
1935 }
1936}
1937impl ::std::convert::TryFrom<&String> for FlightSegmentDepartureAirportCode {
1938 type Error = self::error::ConversionError;
1939 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
1940 value.parse()
1941 }
1942}
1943impl ::std::convert::TryFrom<String> for FlightSegmentDepartureAirportCode {
1944 type Error = self::error::ConversionError;
1945 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
1946 value.parse()
1947 }
1948}
1949impl<'de> ::serde::Deserialize<'de> for FlightSegmentDepartureAirportCode {
1950 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1951 where
1952 D: ::serde::Deserializer<'de>,
1953 {
1954 String::deserialize(deserializer)?
1955 .parse()
1956 .map_err(|e: self::error::ConversionError| {
1957 <D::Error as ::serde::de::Error>::custom(e.to_string())
1958 })
1959 }
1960}
1961#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2027pub struct FlightTicket {
2028 #[serde(default, skip_serializing_if = "Option::is_none")]
2030 pub fare: Option<i64>,
2031 #[serde(default, skip_serializing_if = "Option::is_none")]
2032 pub number: Option<String>,
2033 #[serde(default, skip_serializing_if = "Option::is_none")]
2034 pub passenger: Option<Person>,
2035 #[serde(default, skip_serializing_if = "Option::is_none")]
2036 pub record_locator: Option<String>,
2037 pub segments: Vec<FlightSegment>,
2038 #[serde(default, skip_serializing_if = "Option::is_none")]
2039 pub taxes: Option<Vec<Tax>>,
2040}
2041impl From<&FlightTicket> for FlightTicket {
2042 fn from(value: &FlightTicket) -> Self {
2043 value.clone()
2044 }
2045}
2046impl FlightTicket {
2047 pub fn builder() -> builder::FlightTicket {
2048 Default::default()
2049 }
2050}
2051#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2084pub struct Footer {
2085 #[serde(default, skip_serializing_if = "Option::is_none")]
2086 pub actions: Option<Vec<Action>>,
2087 #[serde(default, skip_serializing_if = "Option::is_none")]
2088 pub supplemental_text: Option<String>,
2089}
2090impl From<&Footer> for Footer {
2091 fn from(value: &Footer) -> Self {
2092 value.clone()
2093 }
2094}
2095impl Footer {
2096 pub fn builder() -> builder::Footer {
2097 Default::default()
2098 }
2099}
2100#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2137pub struct GeneralItemization {
2138 #[serde(default, skip_serializing_if = "Option::is_none")]
2139 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
2140 pub items: Vec<Item>,
2141}
2142impl From<&GeneralItemization> for GeneralItemization {
2143 fn from(value: &GeneralItemization) -> Self {
2144 value.clone()
2145 }
2146}
2147impl GeneralItemization {
2148 pub fn builder() -> builder::GeneralItemization {
2149 Default::default()
2150 }
2151}
2152#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2275pub struct Header {
2276 pub currency: Currency,
2278 #[serde(default, skip_serializing_if = "Option::is_none")]
2279 pub customer: Option<Customer>,
2280 #[serde(default, skip_serializing_if = "Option::is_none")]
2281 pub invoice_asset_id: Option<String>,
2282 #[serde(default, skip_serializing_if = "Option::is_none")]
2283 pub invoice_number: Option<String>,
2284 pub invoiced_at: i64,
2285 #[serde(default, skip_serializing_if = "Option::is_none")]
2286 pub location: Option<Place>,
2287 #[serde(default, skip_serializing_if = "Option::is_none")]
2288 pub mcc: Option<HeaderMcc>,
2289 pub paid: i64,
2290 #[serde(default, skip_serializing_if = "Option::is_none")]
2291 pub receipt_asset_id: Option<String>,
2292 pub subtotal: i64,
2293 #[serde(default, skip_serializing_if = "Option::is_none")]
2294 pub third_party: Option<HeaderThirdParty>,
2295 pub total: i64,
2296}
2297impl From<&Header> for Header {
2298 fn from(value: &Header) -> Self {
2299 value.clone()
2300 }
2301}
2302impl Header {
2303 pub fn builder() -> builder::Header {
2304 Default::default()
2305 }
2306}
2307#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2319pub struct HeaderMcc(String);
2320impl ::std::ops::Deref for HeaderMcc {
2321 type Target = String;
2322 fn deref(&self) -> &String {
2323 &self.0
2324 }
2325}
2326impl From<HeaderMcc> for String {
2327 fn from(value: HeaderMcc) -> Self {
2328 value.0
2329 }
2330}
2331impl From<&HeaderMcc> for HeaderMcc {
2332 fn from(value: &HeaderMcc) -> Self {
2333 value.clone()
2334 }
2335}
2336impl ::std::str::FromStr for HeaderMcc {
2337 type Err = self::error::ConversionError;
2338 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2339 if regress::Regex::new("^\\d{4}$")
2340 .unwrap()
2341 .find(value)
2342 .is_none()
2343 {
2344 return Err("doesn't match pattern \"^\\d{4}$\"".into());
2345 }
2346 Ok(Self(value.to_string()))
2347 }
2348}
2349impl ::std::convert::TryFrom<&str> for HeaderMcc {
2350 type Error = self::error::ConversionError;
2351 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2352 value.parse()
2353 }
2354}
2355impl ::std::convert::TryFrom<&String> for HeaderMcc {
2356 type Error = self::error::ConversionError;
2357 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2358 value.parse()
2359 }
2360}
2361impl ::std::convert::TryFrom<String> for HeaderMcc {
2362 type Error = self::error::ConversionError;
2363 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2364 value.parse()
2365 }
2366}
2367impl<'de> ::serde::Deserialize<'de> for HeaderMcc {
2368 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2369 where
2370 D: ::serde::Deserializer<'de>,
2371 {
2372 String::deserialize(deserializer)?
2373 .parse()
2374 .map_err(|e: self::error::ConversionError| {
2375 <D::Error as ::serde::de::Error>::custom(e.to_string())
2376 })
2377 }
2378}
2379#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2421pub struct HeaderThirdParty {
2422 pub make_primary: bool,
2424 #[serde(default, skip_serializing_if = "Option::is_none")]
2425 pub merchant: Option<Org>,
2426 pub relation: HeaderThirdPartyRelation,
2427}
2428impl From<&HeaderThirdParty> for HeaderThirdParty {
2429 fn from(value: &HeaderThirdParty) -> Self {
2430 value.clone()
2431 }
2432}
2433impl HeaderThirdParty {
2434 pub fn builder() -> builder::HeaderThirdParty {
2435 Default::default()
2436 }
2437}
2438#[derive(
2457 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
2458)]
2459pub enum HeaderThirdPartyRelation {
2460 #[serde(rename = "bnpl")]
2461 Bnpl,
2462 #[serde(rename = "delivery_service")]
2463 DeliveryService,
2464 #[serde(rename = "marketplace")]
2465 Marketplace,
2466 #[serde(rename = "payment_processor")]
2467 PaymentProcessor,
2468 #[serde(rename = "platform")]
2469 Platform,
2470 #[serde(rename = "point_of_sale")]
2471 PointOfSale,
2472}
2473impl From<&HeaderThirdPartyRelation> for HeaderThirdPartyRelation {
2474 fn from(value: &HeaderThirdPartyRelation) -> Self {
2475 value.clone()
2476 }
2477}
2478impl ::std::fmt::Display for HeaderThirdPartyRelation {
2479 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2480 match *self {
2481 Self::Bnpl => write!(f, "bnpl"),
2482 Self::DeliveryService => write!(f, "delivery_service"),
2483 Self::Marketplace => write!(f, "marketplace"),
2484 Self::PaymentProcessor => write!(f, "payment_processor"),
2485 Self::Platform => write!(f, "platform"),
2486 Self::PointOfSale => write!(f, "point_of_sale"),
2487 }
2488 }
2489}
2490impl std::str::FromStr for HeaderThirdPartyRelation {
2491 type Err = self::error::ConversionError;
2492 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2493 match value {
2494 "bnpl" => Ok(Self::Bnpl),
2495 "delivery_service" => Ok(Self::DeliveryService),
2496 "marketplace" => Ok(Self::Marketplace),
2497 "payment_processor" => Ok(Self::PaymentProcessor),
2498 "platform" => Ok(Self::Platform),
2499 "point_of_sale" => Ok(Self::PointOfSale),
2500 _ => Err("invalid value".into()),
2501 }
2502 }
2503}
2504impl std::convert::TryFrom<&str> for HeaderThirdPartyRelation {
2505 type Error = self::error::ConversionError;
2506 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2507 value.parse()
2508 }
2509}
2510impl std::convert::TryFrom<&String> for HeaderThirdPartyRelation {
2511 type Error = self::error::ConversionError;
2512 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2513 value.parse()
2514 }
2515}
2516impl std::convert::TryFrom<String> for HeaderThirdPartyRelation {
2517 type Error = self::error::ConversionError;
2518 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2519 value.parse()
2520 }
2521}
2522#[derive(
2540 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
2541)]
2542pub enum Interval {
2543 #[serde(rename = "day")]
2544 Day,
2545 #[serde(rename = "week")]
2546 Week,
2547 #[serde(rename = "month")]
2548 Month,
2549 #[serde(rename = "year")]
2550 Year,
2551}
2552impl From<&Interval> for Interval {
2553 fn from(value: &Interval) -> Self {
2554 value.clone()
2555 }
2556}
2557impl ::std::fmt::Display for Interval {
2558 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2559 match *self {
2560 Self::Day => write!(f, "day"),
2561 Self::Week => write!(f, "week"),
2562 Self::Month => write!(f, "month"),
2563 Self::Year => write!(f, "year"),
2564 }
2565 }
2566}
2567impl std::str::FromStr for Interval {
2568 type Err = self::error::ConversionError;
2569 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2570 match value {
2571 "day" => Ok(Self::Day),
2572 "week" => Ok(Self::Week),
2573 "month" => Ok(Self::Month),
2574 "year" => Ok(Self::Year),
2575 _ => Err("invalid value".into()),
2576 }
2577 }
2578}
2579impl std::convert::TryFrom<&str> for Interval {
2580 type Error = self::error::ConversionError;
2581 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2582 value.parse()
2583 }
2584}
2585impl std::convert::TryFrom<&String> for Interval {
2586 type Error = self::error::ConversionError;
2587 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2588 value.parse()
2589 }
2590}
2591impl std::convert::TryFrom<String> for Interval {
2592 type Error = self::error::ConversionError;
2593 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2594 value.parse()
2595 }
2596}
2597#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2723pub struct Item {
2724 #[serde(default, skip_serializing_if = "Option::is_none")]
2725 pub adjustments: Option<Vec<Adjustment>>,
2726 pub amount: i64,
2727 #[serde(default, skip_serializing_if = "Option::is_none")]
2728 pub date: Option<String>,
2729 pub description: String,
2730 #[serde(default, skip_serializing_if = "Option::is_none")]
2731 pub group: Option<String>,
2732 #[serde(default, skip_serializing_if = "Option::is_none")]
2733 pub metadata: Option<Vec<Metadatum>>,
2734 #[serde(default, skip_serializing_if = "Option::is_none")]
2735 pub product_image_asset_id: Option<String>,
2736 #[serde(default, skip_serializing_if = "Option::is_none")]
2737 pub quantity: Option<f64>,
2738 #[serde(default, skip_serializing_if = "Option::is_none")]
2739 pub taxes: Option<Vec<Tax>>,
2740 #[serde(default, skip_serializing_if = "Option::is_none")]
2741 pub unit: Option<String>,
2742 #[serde(default, skip_serializing_if = "Option::is_none")]
2743 pub unit_cost: Option<i64>,
2744 #[serde(default, skip_serializing_if = "Option::is_none")]
2745 pub unspsc: Option<ItemUnspsc>,
2746 #[serde(default, skip_serializing_if = "Option::is_none")]
2747 pub url: Option<String>,
2748}
2749impl From<&Item> for Item {
2750 fn from(value: &Item) -> Self {
2751 value.clone()
2752 }
2753}
2754impl Item {
2755 pub fn builder() -> builder::Item {
2756 Default::default()
2757 }
2758}
2759#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2771pub struct ItemUnspsc(String);
2772impl ::std::ops::Deref for ItemUnspsc {
2773 type Target = String;
2774 fn deref(&self) -> &String {
2775 &self.0
2776 }
2777}
2778impl From<ItemUnspsc> for String {
2779 fn from(value: ItemUnspsc) -> Self {
2780 value.0
2781 }
2782}
2783impl From<&ItemUnspsc> for ItemUnspsc {
2784 fn from(value: &ItemUnspsc) -> Self {
2785 value.clone()
2786 }
2787}
2788impl ::std::str::FromStr for ItemUnspsc {
2789 type Err = self::error::ConversionError;
2790 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
2791 if regress::Regex::new("^\\d{8}$")
2792 .unwrap()
2793 .find(value)
2794 .is_none()
2795 {
2796 return Err("doesn't match pattern \"^\\d{8}$\"".into());
2797 }
2798 Ok(Self(value.to_string()))
2799 }
2800}
2801impl ::std::convert::TryFrom<&str> for ItemUnspsc {
2802 type Error = self::error::ConversionError;
2803 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
2804 value.parse()
2805 }
2806}
2807impl ::std::convert::TryFrom<&String> for ItemUnspsc {
2808 type Error = self::error::ConversionError;
2809 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
2810 value.parse()
2811 }
2812}
2813impl ::std::convert::TryFrom<String> for ItemUnspsc {
2814 type Error = self::error::ConversionError;
2815 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
2816 value.parse()
2817 }
2818}
2819impl<'de> ::serde::Deserialize<'de> for ItemUnspsc {
2820 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2821 where
2822 D: ::serde::Deserializer<'de>,
2823 {
2824 String::deserialize(deserializer)?
2825 .parse()
2826 .map_err(|e: self::error::ConversionError| {
2827 <D::Error as ::serde::de::Error>::custom(e.to_string())
2828 })
2829 }
2830}
2831#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2925pub struct Itemization {
2926 #[serde(default, skip_serializing_if = "Option::is_none")]
2927 pub car_rental: Option<CarRental>,
2928 #[serde(default, skip_serializing_if = "Option::is_none")]
2929 pub ecommerce: Option<Ecommerce>,
2930 #[serde(default, skip_serializing_if = "Option::is_none")]
2931 pub flight: Option<Flight>,
2932 #[serde(default, skip_serializing_if = "Option::is_none")]
2933 pub general: Option<GeneralItemization>,
2934 #[serde(default, skip_serializing_if = "Option::is_none")]
2935 pub lodging: Option<Lodging>,
2936 #[serde(default, skip_serializing_if = "Option::is_none")]
2937 pub service: Option<Service>,
2938 #[serde(default, skip_serializing_if = "Option::is_none")]
2939 pub subscription: Option<Subscription>,
2940 #[serde(default, skip_serializing_if = "Option::is_none")]
2941 pub transit_route: Option<TransitRoute>,
2942}
2943impl From<&Itemization> for Itemization {
2944 fn from(value: &Itemization) -> Self {
2945 value.clone()
2946 }
2947}
2948impl Itemization {
2949 pub fn builder() -> builder::Itemization {
2950 Default::default()
2951 }
2952}
2953#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3060pub struct Lodging {
3061 #[serde(default, skip_serializing_if = "Option::is_none")]
3062 pub chain_code: Option<LodgingChainCode>,
3063 pub check_in: i64,
3064 pub check_out: i64,
3065 #[serde(default, skip_serializing_if = "Option::is_none")]
3066 pub confirmation_number: Option<String>,
3067 #[serde(default, skip_serializing_if = "Option::is_none")]
3068 pub guests: Option<Vec<Person>>,
3069 #[serde(default, skip_serializing_if = "Option::is_none")]
3070 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
3071 pub items: Vec<Item>,
3072 pub location: Place,
3073 #[serde(default, skip_serializing_if = "Option::is_none")]
3074 pub metadata: Option<Vec<Metadatum>>,
3075 #[serde(default, skip_serializing_if = "Option::is_none")]
3076 pub property_id: Option<LodgingPropertyId>,
3077 #[serde(default, skip_serializing_if = "Option::is_none")]
3078 pub record_locator: Option<String>,
3079 #[serde(default, skip_serializing_if = "Option::is_none")]
3080 pub room: Option<String>,
3081}
3082impl From<&Lodging> for Lodging {
3083 fn from(value: &Lodging) -> Self {
3084 value.clone()
3085 }
3086}
3087impl Lodging {
3088 pub fn builder() -> builder::Lodging {
3089 Default::default()
3090 }
3091}
3092#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3104pub struct LodgingChainCode(String);
3105impl ::std::ops::Deref for LodgingChainCode {
3106 type Target = String;
3107 fn deref(&self) -> &String {
3108 &self.0
3109 }
3110}
3111impl From<LodgingChainCode> for String {
3112 fn from(value: LodgingChainCode) -> Self {
3113 value.0
3114 }
3115}
3116impl From<&LodgingChainCode> for LodgingChainCode {
3117 fn from(value: &LodgingChainCode) -> Self {
3118 value.clone()
3119 }
3120}
3121impl ::std::str::FromStr for LodgingChainCode {
3122 type Err = self::error::ConversionError;
3123 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3124 if regress::Regex::new("^[A-Z]{2}$")
3125 .unwrap()
3126 .find(value)
3127 .is_none()
3128 {
3129 return Err("doesn't match pattern \"^[A-Z]{2}$\"".into());
3130 }
3131 Ok(Self(value.to_string()))
3132 }
3133}
3134impl ::std::convert::TryFrom<&str> for LodgingChainCode {
3135 type Error = self::error::ConversionError;
3136 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3137 value.parse()
3138 }
3139}
3140impl ::std::convert::TryFrom<&String> for LodgingChainCode {
3141 type Error = self::error::ConversionError;
3142 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3143 value.parse()
3144 }
3145}
3146impl ::std::convert::TryFrom<String> for LodgingChainCode {
3147 type Error = self::error::ConversionError;
3148 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3149 value.parse()
3150 }
3151}
3152impl<'de> ::serde::Deserialize<'de> for LodgingChainCode {
3153 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3154 where
3155 D: ::serde::Deserializer<'de>,
3156 {
3157 String::deserialize(deserializer)?
3158 .parse()
3159 .map_err(|e: self::error::ConversionError| {
3160 <D::Error as ::serde::de::Error>::custom(e.to_string())
3161 })
3162 }
3163}
3164#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3176pub struct LodgingPropertyId(String);
3177impl ::std::ops::Deref for LodgingPropertyId {
3178 type Target = String;
3179 fn deref(&self) -> &String {
3180 &self.0
3181 }
3182}
3183impl From<LodgingPropertyId> for String {
3184 fn from(value: LodgingPropertyId) -> Self {
3185 value.0
3186 }
3187}
3188impl From<&LodgingPropertyId> for LodgingPropertyId {
3189 fn from(value: &LodgingPropertyId) -> Self {
3190 value.clone()
3191 }
3192}
3193impl ::std::str::FromStr for LodgingPropertyId {
3194 type Err = self::error::ConversionError;
3195 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3196 if regress::Regex::new("^(gds\\.[a-z]+|chain\\.[a-z]+|giata):[a-zA-Z0-9]+$")
3197 .unwrap()
3198 .find(value)
3199 .is_none()
3200 {
3201 return Err(
3202 "doesn't match pattern \"^(gds\\.[a-z]+|chain\\.[a-z]+|giata):[a-zA-Z0-9]+$\"".into(),
3203 );
3204 }
3205 Ok(Self(value.to_string()))
3206 }
3207}
3208impl ::std::convert::TryFrom<&str> for LodgingPropertyId {
3209 type Error = self::error::ConversionError;
3210 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3211 value.parse()
3212 }
3213}
3214impl ::std::convert::TryFrom<&String> for LodgingPropertyId {
3215 type Error = self::error::ConversionError;
3216 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3217 value.parse()
3218 }
3219}
3220impl ::std::convert::TryFrom<String> for LodgingPropertyId {
3221 type Error = self::error::ConversionError;
3222 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3223 value.parse()
3224 }
3225}
3226impl<'de> ::serde::Deserialize<'de> for LodgingPropertyId {
3227 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3228 where
3229 D: ::serde::Deserializer<'de>,
3230 {
3231 String::deserialize(deserializer)?
3232 .parse()
3233 .map_err(|e: self::error::ConversionError| {
3234 <D::Error as ::serde::de::Error>::custom(e.to_string())
3235 })
3236 }
3237}
3238#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3262pub struct Metadatum {
3263 pub key: String,
3264 pub value: String,
3265}
3266impl From<&Metadatum> for Metadatum {
3267 fn from(value: &Metadatum) -> Self {
3268 value.clone()
3269 }
3270}
3271impl Metadatum {
3272 pub fn builder() -> builder::Metadatum {
3273 Default::default()
3274 }
3275}
3276#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3346pub struct Org {
3347 #[serde(default, skip_serializing_if = "Option::is_none")]
3348 pub address: Option<Address>,
3349 #[serde(default, skip_serializing_if = "Option::is_none")]
3351 pub brand_color: Option<OrgBrandColor>,
3352 #[serde(default, skip_serializing_if = "Option::is_none")]
3353 pub legal_name: Option<String>,
3354 #[serde(default, skip_serializing_if = "Option::is_none")]
3355 pub logo: Option<String>,
3356 #[serde(default, skip_serializing_if = "Option::is_none")]
3357 pub logo_asset_id: Option<String>,
3358 pub name: String,
3359 #[serde(default, skip_serializing_if = "Option::is_none")]
3360 pub vat_number: Option<String>,
3361 #[serde(default, skip_serializing_if = "Option::is_none")]
3362 pub website: Option<String>,
3363}
3364impl From<&Org> for Org {
3365 fn from(value: &Org) -> Self {
3366 value.clone()
3367 }
3368}
3369impl Org {
3370 pub fn builder() -> builder::Org {
3371 Default::default()
3372 }
3373}
3374#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3387pub struct OrgBrandColor(String);
3388impl ::std::ops::Deref for OrgBrandColor {
3389 type Target = String;
3390 fn deref(&self) -> &String {
3391 &self.0
3392 }
3393}
3394impl From<OrgBrandColor> for String {
3395 fn from(value: OrgBrandColor) -> Self {
3396 value.0
3397 }
3398}
3399impl From<&OrgBrandColor> for OrgBrandColor {
3400 fn from(value: &OrgBrandColor) -> Self {
3401 value.clone()
3402 }
3403}
3404impl ::std::str::FromStr for OrgBrandColor {
3405 type Err = self::error::ConversionError;
3406 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3407 if regress::Regex::new("^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$")
3408 .unwrap()
3409 .find(value)
3410 .is_none()
3411 {
3412 return Err("doesn't match pattern \"^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\"".into());
3413 }
3414 Ok(Self(value.to_string()))
3415 }
3416}
3417impl ::std::convert::TryFrom<&str> for OrgBrandColor {
3418 type Error = self::error::ConversionError;
3419 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3420 value.parse()
3421 }
3422}
3423impl ::std::convert::TryFrom<&String> for OrgBrandColor {
3424 type Error = self::error::ConversionError;
3425 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3426 value.parse()
3427 }
3428}
3429impl ::std::convert::TryFrom<String> for OrgBrandColor {
3430 type Error = self::error::ConversionError;
3431 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3432 value.parse()
3433 }
3434}
3435impl<'de> ::serde::Deserialize<'de> for OrgBrandColor {
3436 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3437 where
3438 D: ::serde::Deserializer<'de>,
3439 {
3440 String::deserialize(deserializer)?
3441 .parse()
3442 .map_err(|e: self::error::ConversionError| {
3443 <D::Error as ::serde::de::Error>::custom(e.to_string())
3444 })
3445 }
3446}
3447#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3507pub struct Payment {
3508 #[serde(default, skip_serializing_if = "Option::is_none")]
3509 pub ach_payment: Option<AchPayment>,
3510 pub amount: i64,
3511 #[serde(default, skip_serializing_if = "Option::is_none")]
3512 pub card_payment: Option<CardPayment>,
3513 pub paid_at: i64,
3514 #[serde(default, skip_serializing_if = "Option::is_none")]
3515 pub payment_type: Option<PaymentPaymentType>,
3516}
3517impl From<&Payment> for Payment {
3518 fn from(value: &Payment) -> Self {
3519 value.clone()
3520 }
3521}
3522impl Payment {
3523 pub fn builder() -> builder::Payment {
3524 Default::default()
3525 }
3526}
3527#[derive(
3542 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
3543)]
3544pub enum PaymentPaymentType {
3545 #[serde(rename = "card")]
3546 Card,
3547 #[serde(rename = "ach")]
3548 Ach,
3549}
3550impl From<&PaymentPaymentType> for PaymentPaymentType {
3551 fn from(value: &PaymentPaymentType) -> Self {
3552 value.clone()
3553 }
3554}
3555impl ::std::fmt::Display for PaymentPaymentType {
3556 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3557 match *self {
3558 Self::Card => write!(f, "card"),
3559 Self::Ach => write!(f, "ach"),
3560 }
3561 }
3562}
3563impl std::str::FromStr for PaymentPaymentType {
3564 type Err = self::error::ConversionError;
3565 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3566 match value {
3567 "card" => Ok(Self::Card),
3568 "ach" => Ok(Self::Ach),
3569 _ => Err("invalid value".into()),
3570 }
3571 }
3572}
3573impl std::convert::TryFrom<&str> for PaymentPaymentType {
3574 type Error = self::error::ConversionError;
3575 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3576 value.parse()
3577 }
3578}
3579impl std::convert::TryFrom<&String> for PaymentPaymentType {
3580 type Error = self::error::ConversionError;
3581 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3582 value.parse()
3583 }
3584}
3585impl std::convert::TryFrom<String> for PaymentPaymentType {
3586 type Error = self::error::ConversionError;
3587 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3588 value.parse()
3589 }
3590}
3591#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3652pub struct Person {
3653 #[serde(default, skip_serializing_if = "Option::is_none")]
3654 pub email: Option<String>,
3655 #[serde(default, skip_serializing_if = "Option::is_none")]
3656 pub first_name: Option<String>,
3657 #[serde(default, skip_serializing_if = "Option::is_none")]
3658 pub last_name: Option<String>,
3659 #[serde(default, skip_serializing_if = "Option::is_none")]
3660 pub metadata: Option<Vec<Metadatum>>,
3661 #[serde(default, skip_serializing_if = "Option::is_none")]
3662 pub phone: Option<PersonPhone>,
3663 #[serde(default, skip_serializing_if = "Option::is_none")]
3664 pub preferred_first_name: Option<String>,
3665}
3666impl From<&Person> for Person {
3667 fn from(value: &Person) -> Self {
3668 value.clone()
3669 }
3670}
3671impl Person {
3672 pub fn builder() -> builder::Person {
3673 Default::default()
3674 }
3675}
3676#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3688pub struct PersonPhone(String);
3689impl ::std::ops::Deref for PersonPhone {
3690 type Target = String;
3691 fn deref(&self) -> &String {
3692 &self.0
3693 }
3694}
3695impl From<PersonPhone> for String {
3696 fn from(value: PersonPhone) -> Self {
3697 value.0
3698 }
3699}
3700impl From<&PersonPhone> for PersonPhone {
3701 fn from(value: &PersonPhone) -> Self {
3702 value.clone()
3703 }
3704}
3705impl ::std::str::FromStr for PersonPhone {
3706 type Err = self::error::ConversionError;
3707 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3708 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
3709 .unwrap()
3710 .find(value)
3711 .is_none()
3712 {
3713 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
3714 }
3715 Ok(Self(value.to_string()))
3716 }
3717}
3718impl ::std::convert::TryFrom<&str> for PersonPhone {
3719 type Error = self::error::ConversionError;
3720 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3721 value.parse()
3722 }
3723}
3724impl ::std::convert::TryFrom<&String> for PersonPhone {
3725 type Error = self::error::ConversionError;
3726 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3727 value.parse()
3728 }
3729}
3730impl ::std::convert::TryFrom<String> for PersonPhone {
3731 type Error = self::error::ConversionError;
3732 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3733 value.parse()
3734 }
3735}
3736impl<'de> ::serde::Deserialize<'de> for PersonPhone {
3737 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3738 where
3739 D: ::serde::Deserializer<'de>,
3740 {
3741 String::deserialize(deserializer)?
3742 .parse()
3743 .map_err(|e: self::error::ConversionError| {
3744 <D::Error as ::serde::de::Error>::custom(e.to_string())
3745 })
3746 }
3747}
3748#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3814pub struct Place {
3815 #[serde(default, skip_serializing_if = "Option::is_none")]
3816 pub address: Option<Address>,
3817 #[serde(default, skip_serializing_if = "Option::is_none")]
3818 pub google_place_id: Option<String>,
3819 #[serde(default, skip_serializing_if = "Option::is_none")]
3820 pub image: Option<String>,
3821 #[serde(default, skip_serializing_if = "Option::is_none")]
3822 pub name: Option<String>,
3823 #[serde(default, skip_serializing_if = "Option::is_none")]
3824 pub phone: Option<PlacePhone>,
3825 #[serde(default, skip_serializing_if = "Option::is_none")]
3826 pub url: Option<String>,
3827}
3828impl From<&Place> for Place {
3829 fn from(value: &Place) -> Self {
3830 value.clone()
3831 }
3832}
3833impl Place {
3834 pub fn builder() -> builder::Place {
3835 Default::default()
3836 }
3837}
3838#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3850pub struct PlacePhone(String);
3851impl ::std::ops::Deref for PlacePhone {
3852 type Target = String;
3853 fn deref(&self) -> &String {
3854 &self.0
3855 }
3856}
3857impl From<PlacePhone> for String {
3858 fn from(value: PlacePhone) -> Self {
3859 value.0
3860 }
3861}
3862impl From<&PlacePhone> for PlacePhone {
3863 fn from(value: &PlacePhone) -> Self {
3864 value.clone()
3865 }
3866}
3867impl ::std::str::FromStr for PlacePhone {
3868 type Err = self::error::ConversionError;
3869 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
3870 if regress::Regex::new("^\\+?[1-9]\\d{1,14}$")
3871 .unwrap()
3872 .find(value)
3873 .is_none()
3874 {
3875 return Err("doesn't match pattern \"^\\+?[1-9]\\d{1,14}$\"".into());
3876 }
3877 Ok(Self(value.to_string()))
3878 }
3879}
3880impl ::std::convert::TryFrom<&str> for PlacePhone {
3881 type Error = self::error::ConversionError;
3882 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
3883 value.parse()
3884 }
3885}
3886impl ::std::convert::TryFrom<&String> for PlacePhone {
3887 type Error = self::error::ConversionError;
3888 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
3889 value.parse()
3890 }
3891}
3892impl ::std::convert::TryFrom<String> for PlacePhone {
3893 type Error = self::error::ConversionError;
3894 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
3895 value.parse()
3896 }
3897}
3898impl<'de> ::serde::Deserialize<'de> for PlacePhone {
3899 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3900 where
3901 D: ::serde::Deserializer<'de>,
3902 {
3903 String::deserialize(deserializer)?
3904 .parse()
3905 .map_err(|e: self::error::ConversionError| {
3906 <D::Error as ::serde::de::Error>::custom(e.to_string())
3907 })
3908 }
3909}
3910#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
3955pub struct Receipt {
3956 pub footer: Footer,
3957 pub header: Header,
3958 pub itemization: Itemization,
3959 pub payments: Vec<Payment>,
3960 pub schema_version: SchemaVersion,
3961}
3962impl From<&Receipt> for Receipt {
3963 fn from(value: &Receipt) -> Self {
3964 value.clone()
3965 }
3966}
3967impl Receipt {
3968 pub fn builder() -> builder::Receipt {
3969 Default::default()
3970 }
3971}
3972#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3987pub struct SchemaVersion(String);
3988impl ::std::ops::Deref for SchemaVersion {
3989 type Target = String;
3990 fn deref(&self) -> &String {
3991 &self.0
3992 }
3993}
3994impl From<SchemaVersion> for String {
3995 fn from(value: SchemaVersion) -> Self {
3996 value.0
3997 }
3998}
3999impl From<&SchemaVersion> for SchemaVersion {
4000 fn from(value: &SchemaVersion) -> Self {
4001 value.clone()
4002 }
4003}
4004impl ::std::str::FromStr for SchemaVersion {
4005 type Err = self::error::ConversionError;
4006 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4007 if value.len() > 14usize {
4008 return Err("longer than 14 characters".into());
4009 }
4010 if value.len() < 5usize {
4011 return Err("shorter than 5 characters".into());
4012 }
4013 if regress::Regex::new("^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$")
4014 .unwrap()
4015 .find(value)
4016 .is_none()
4017 {
4018 return Err(
4019 "doesn't match pattern \"^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$\"".into(),
4020 );
4021 }
4022 Ok(Self(value.to_string()))
4023 }
4024}
4025impl ::std::convert::TryFrom<&str> for SchemaVersion {
4026 type Error = self::error::ConversionError;
4027 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4028 value.parse()
4029 }
4030}
4031impl ::std::convert::TryFrom<&String> for SchemaVersion {
4032 type Error = self::error::ConversionError;
4033 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4034 value.parse()
4035 }
4036}
4037impl ::std::convert::TryFrom<String> for SchemaVersion {
4038 type Error = self::error::ConversionError;
4039 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4040 value.parse()
4041 }
4042}
4043impl<'de> ::serde::Deserialize<'de> for SchemaVersion {
4044 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4045 where
4046 D: ::serde::Deserializer<'de>,
4047 {
4048 String::deserialize(deserializer)?
4049 .parse()
4050 .map_err(|e: self::error::ConversionError| {
4051 <D::Error as ::serde::de::Error>::custom(e.to_string())
4052 })
4053 }
4054}
4055#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4092pub struct Service {
4093 #[serde(default, skip_serializing_if = "Option::is_none")]
4094 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4095 pub service_items: Vec<ServiceItem>,
4096}
4097impl From<&Service> for Service {
4098 fn from(value: &Service) -> Self {
4099 value.clone()
4100 }
4101}
4102impl Service {
4103 pub fn builder() -> builder::Service {
4104 Default::default()
4105 }
4106}
4107#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4235pub struct ServiceItem {
4236 #[serde(default, skip_serializing_if = "Option::is_none")]
4237 pub adjustments: Option<Vec<Adjustment>>,
4238 pub amount: i64,
4239 #[serde(default, skip_serializing_if = "Option::is_none")]
4240 pub current_period_end_at: Option<i64>,
4241 #[serde(default, skip_serializing_if = "Option::is_none")]
4242 pub current_period_start_at: Option<i64>,
4243 pub description: String,
4244 #[serde(default, skip_serializing_if = "Option::is_none")]
4245 pub interval: Option<Interval>,
4246 #[serde(default, skip_serializing_if = "Option::is_none")]
4247 pub interval_count: Option<i64>,
4248 #[serde(default, skip_serializing_if = "Option::is_none")]
4249 pub metadata: Option<Vec<Metadatum>>,
4250 #[serde(default, skip_serializing_if = "Option::is_none")]
4251 pub quantity: Option<f64>,
4252 pub recurring: bool,
4253 #[serde(default, skip_serializing_if = "Option::is_none")]
4254 pub service_location: Option<Place>,
4255 #[serde(default, skip_serializing_if = "Option::is_none")]
4256 pub taxes: Option<Vec<Tax>>,
4257 #[serde(default, skip_serializing_if = "Option::is_none")]
4258 pub unit_cost: Option<f64>,
4259}
4260impl From<&ServiceItem> for ServiceItem {
4261 fn from(value: &ServiceItem) -> Self {
4262 value.clone()
4263 }
4264}
4265impl ServiceItem {
4266 pub fn builder() -> builder::ServiceItem {
4267 Default::default()
4268 }
4269}
4270#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4339pub struct Shipment {
4340 #[serde(default, skip_serializing_if = "Option::is_none")]
4341 pub carrier: Option<String>,
4342 #[serde(default, skip_serializing_if = "Option::is_none")]
4343 pub destination_address: Option<Address>,
4344 #[serde(default, skip_serializing_if = "Option::is_none")]
4345 pub expected_delivery_at: Option<i64>,
4346 pub items: Vec<Item>,
4347 #[serde(default, skip_serializing_if = "Option::is_none")]
4348 pub shipment_status: Option<ShipmentShipmentStatus>,
4349 #[serde(default, skip_serializing_if = "Option::is_none")]
4350 pub tracking_number: Option<String>,
4351}
4352impl From<&Shipment> for Shipment {
4353 fn from(value: &Shipment) -> Self {
4354 value.clone()
4355 }
4356}
4357impl Shipment {
4358 pub fn builder() -> builder::Shipment {
4359 Default::default()
4360 }
4361}
4362#[derive(
4378 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
4379)]
4380pub enum ShipmentShipmentStatus {
4381 #[serde(rename = "prep")]
4382 Prep,
4383 #[serde(rename = "in_transit")]
4384 InTransit,
4385 #[serde(rename = "delivered")]
4386 Delivered,
4387}
4388impl From<&ShipmentShipmentStatus> for ShipmentShipmentStatus {
4389 fn from(value: &ShipmentShipmentStatus) -> Self {
4390 value.clone()
4391 }
4392}
4393impl ::std::fmt::Display for ShipmentShipmentStatus {
4394 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4395 match *self {
4396 Self::Prep => write!(f, "prep"),
4397 Self::InTransit => write!(f, "in_transit"),
4398 Self::Delivered => write!(f, "delivered"),
4399 }
4400 }
4401}
4402impl std::str::FromStr for ShipmentShipmentStatus {
4403 type Err = self::error::ConversionError;
4404 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4405 match value {
4406 "prep" => Ok(Self::Prep),
4407 "in_transit" => Ok(Self::InTransit),
4408 "delivered" => Ok(Self::Delivered),
4409 _ => Err("invalid value".into()),
4410 }
4411 }
4412}
4413impl std::convert::TryFrom<&str> for ShipmentShipmentStatus {
4414 type Error = self::error::ConversionError;
4415 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4416 value.parse()
4417 }
4418}
4419impl std::convert::TryFrom<&String> for ShipmentShipmentStatus {
4420 type Error = self::error::ConversionError;
4421 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4422 value.parse()
4423 }
4424}
4425impl std::convert::TryFrom<String> for ShipmentShipmentStatus {
4426 type Error = self::error::ConversionError;
4427 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4428 value.parse()
4429 }
4430}
4431#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4468pub struct Subscription {
4469 #[serde(default, skip_serializing_if = "Option::is_none")]
4470 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4471 pub subscription_items: Vec<SubscriptionItem>,
4472}
4473impl From<&Subscription> for Subscription {
4474 fn from(value: &Subscription) -> Self {
4475 value.clone()
4476 }
4477}
4478impl Subscription {
4479 pub fn builder() -> builder::Subscription {
4480 Default::default()
4481 }
4482}
4483#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4606pub struct SubscriptionItem {
4607 #[serde(default, skip_serializing_if = "Option::is_none")]
4608 pub adjustments: Option<Vec<Adjustment>>,
4609 pub amount: i64,
4610 #[serde(default, skip_serializing_if = "Option::is_none")]
4611 pub current_period_end_at: Option<i64>,
4612 #[serde(default, skip_serializing_if = "Option::is_none")]
4613 pub current_period_start_at: Option<i64>,
4614 pub description: String,
4615 #[serde(default, skip_serializing_if = "Option::is_none")]
4616 pub interval: Option<Interval>,
4617 #[serde(default, skip_serializing_if = "Option::is_none")]
4618 pub interval_count: Option<i64>,
4619 #[serde(default, skip_serializing_if = "Option::is_none")]
4620 pub metadata: Option<Vec<Metadatum>>,
4621 #[serde(default, skip_serializing_if = "Option::is_none")]
4622 pub quantity: Option<f64>,
4623 pub subscription_type: SubscriptionType,
4624 #[serde(default, skip_serializing_if = "Option::is_none")]
4625 pub taxes: Option<Vec<Tax>>,
4626 #[serde(default, skip_serializing_if = "Option::is_none")]
4627 pub unit_cost: Option<f64>,
4628}
4629impl From<&SubscriptionItem> for SubscriptionItem {
4630 fn from(value: &SubscriptionItem) -> Self {
4631 value.clone()
4632 }
4633}
4634impl SubscriptionItem {
4635 pub fn builder() -> builder::SubscriptionItem {
4636 Default::default()
4637 }
4638}
4639#[derive(
4655 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
4656)]
4657pub enum SubscriptionType {
4658 #[serde(rename = "one_time")]
4659 OneTime,
4660 #[serde(rename = "recurring")]
4661 Recurring,
4662}
4663impl From<&SubscriptionType> for SubscriptionType {
4664 fn from(value: &SubscriptionType) -> Self {
4665 value.clone()
4666 }
4667}
4668impl ::std::fmt::Display for SubscriptionType {
4669 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4670 match *self {
4671 Self::OneTime => write!(f, "one_time"),
4672 Self::Recurring => write!(f, "recurring"),
4673 }
4674 }
4675}
4676impl std::str::FromStr for SubscriptionType {
4677 type Err = self::error::ConversionError;
4678 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
4679 match value {
4680 "one_time" => Ok(Self::OneTime),
4681 "recurring" => Ok(Self::Recurring),
4682 _ => Err("invalid value".into()),
4683 }
4684 }
4685}
4686impl std::convert::TryFrom<&str> for SubscriptionType {
4687 type Error = self::error::ConversionError;
4688 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
4689 value.parse()
4690 }
4691}
4692impl std::convert::TryFrom<&String> for SubscriptionType {
4693 type Error = self::error::ConversionError;
4694 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
4695 value.parse()
4696 }
4697}
4698impl std::convert::TryFrom<String> for SubscriptionType {
4699 type Error = self::error::ConversionError;
4700 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
4701 value.parse()
4702 }
4703}
4704#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4734pub struct Tax {
4735 pub amount: i64,
4736 pub name: String,
4737 #[serde(default, skip_serializing_if = "Option::is_none")]
4738 pub rate: Option<f64>,
4739}
4740impl From<&Tax> for Tax {
4741 fn from(value: &Tax) -> Self {
4742 value.clone()
4743 }
4744}
4745impl Tax {
4746 pub fn builder() -> builder::Tax {
4747 Default::default()
4748 }
4749}
4750#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4787pub struct TransitRoute {
4788 #[serde(default, skip_serializing_if = "Option::is_none")]
4789 pub invoice_level_adjustments: Option<Vec<Adjustment>>,
4790 pub transit_route_items: Vec<TransitRouteItem>,
4791}
4792impl From<&TransitRoute> for TransitRoute {
4793 fn from(value: &TransitRoute) -> Self {
4794 value.clone()
4795 }
4796}
4797impl TransitRoute {
4798 pub fn builder() -> builder::TransitRoute {
4799 Default::default()
4800 }
4801}
4802#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4937pub struct TransitRouteItem {
4938 #[serde(default, skip_serializing_if = "Option::is_none")]
4939 pub adjustments: Option<Vec<Adjustment>>,
4940 #[serde(default, skip_serializing_if = "Option::is_none")]
4941 pub arrival_at: Option<i64>,
4942 #[serde(default, skip_serializing_if = "Option::is_none")]
4943 pub arrival_location: Option<Place>,
4944 #[serde(default, skip_serializing_if = "Option::is_none")]
4945 pub departure_at: Option<i64>,
4946 #[serde(default, skip_serializing_if = "Option::is_none")]
4947 pub departure_location: Option<Place>,
4948 pub fare: i64,
4949 #[serde(default, skip_serializing_if = "Option::is_none")]
4950 pub metadata: Option<Vec<Metadatum>>,
4951 #[serde(default, skip_serializing_if = "Option::is_none")]
4952 pub mode: Option<TransitRouteItemMode>,
4953 #[serde(default, skip_serializing_if = "Option::is_none")]
4954 pub passenger: Option<Person>,
4955 #[serde(default, skip_serializing_if = "Option::is_none")]
4956 pub polyline: Option<String>,
4957 #[serde(default, skip_serializing_if = "Option::is_none")]
4958 pub taxes: Option<Vec<Tax>>,
4959}
4960impl From<&TransitRouteItem> for TransitRouteItem {
4961 fn from(value: &TransitRouteItem) -> Self {
4962 value.clone()
4963 }
4964}
4965impl TransitRouteItem {
4966 pub fn builder() -> builder::TransitRouteItem {
4967 Default::default()
4968 }
4969}
4970#[derive(
4989 ::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
4990)]
4991pub enum TransitRouteItemMode {
4992 #[serde(rename = "car")]
4993 Car,
4994 #[serde(rename = "taxi")]
4995 Taxi,
4996 #[serde(rename = "rail")]
4997 Rail,
4998 #[serde(rename = "bus")]
4999 Bus,
5000 #[serde(rename = "ferry")]
5001 Ferry,
5002 #[serde(rename = "other")]
5003 Other,
5004}
5005impl From<&TransitRouteItemMode> for TransitRouteItemMode {
5006 fn from(value: &TransitRouteItemMode) -> Self {
5007 value.clone()
5008 }
5009}
5010impl ::std::fmt::Display for TransitRouteItemMode {
5011 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5012 match *self {
5013 Self::Car => write!(f, "car"),
5014 Self::Taxi => write!(f, "taxi"),
5015 Self::Rail => write!(f, "rail"),
5016 Self::Bus => write!(f, "bus"),
5017 Self::Ferry => write!(f, "ferry"),
5018 Self::Other => write!(f, "other"),
5019 }
5020 }
5021}
5022impl std::str::FromStr for TransitRouteItemMode {
5023 type Err = self::error::ConversionError;
5024 fn from_str(value: &str) -> Result<Self, self::error::ConversionError> {
5025 match value {
5026 "car" => Ok(Self::Car),
5027 "taxi" => Ok(Self::Taxi),
5028 "rail" => Ok(Self::Rail),
5029 "bus" => Ok(Self::Bus),
5030 "ferry" => Ok(Self::Ferry),
5031 "other" => Ok(Self::Other),
5032 _ => Err("invalid value".into()),
5033 }
5034 }
5035}
5036impl std::convert::TryFrom<&str> for TransitRouteItemMode {
5037 type Error = self::error::ConversionError;
5038 fn try_from(value: &str) -> Result<Self, self::error::ConversionError> {
5039 value.parse()
5040 }
5041}
5042impl std::convert::TryFrom<&String> for TransitRouteItemMode {
5043 type Error = self::error::ConversionError;
5044 fn try_from(value: &String) -> Result<Self, self::error::ConversionError> {
5045 value.parse()
5046 }
5047}
5048impl std::convert::TryFrom<String> for TransitRouteItemMode {
5049 type Error = self::error::ConversionError;
5050 fn try_from(value: String) -> Result<Self, self::error::ConversionError> {
5051 value.parse()
5052 }
5053}
5054pub mod builder {
5056 #[derive(Clone, Debug)]
5057 pub struct AchPayment {
5058 routing_number: Result<super::AchPaymentRoutingNumber, String>,
5059 }
5060 impl Default for AchPayment {
5061 fn default() -> Self {
5062 Self {
5063 routing_number: Err("no value supplied for routing_number".to_string()),
5064 }
5065 }
5066 }
5067 impl AchPayment {
5068 pub fn routing_number<T>(mut self, value: T) -> Self
5069 where
5070 T: std::convert::TryInto<super::AchPaymentRoutingNumber>,
5071 T::Error: std::fmt::Display,
5072 {
5073 self.routing_number = value
5074 .try_into()
5075 .map_err(|e| format!("error converting supplied value for routing_number: {}", e));
5076 self
5077 }
5078 }
5079 impl std::convert::TryFrom<AchPayment> for super::AchPayment {
5080 type Error = super::error::ConversionError;
5081 fn try_from(value: AchPayment) -> Result<Self, super::error::ConversionError> {
5082 Ok(Self {
5083 routing_number: value.routing_number?,
5084 })
5085 }
5086 }
5087 impl From<super::AchPayment> for AchPayment {
5088 fn from(value: super::AchPayment) -> Self {
5089 Self {
5090 routing_number: Ok(value.routing_number),
5091 }
5092 }
5093 }
5094 #[derive(Clone, Debug)]
5095 pub struct Action {
5096 name: Result<String, String>,
5097 url: Result<String, String>,
5098 }
5099 impl Default for Action {
5100 fn default() -> Self {
5101 Self {
5102 name: Err("no value supplied for name".to_string()),
5103 url: Err("no value supplied for url".to_string()),
5104 }
5105 }
5106 }
5107 impl Action {
5108 pub fn name<T>(mut self, value: T) -> Self
5109 where
5110 T: std::convert::TryInto<String>,
5111 T::Error: std::fmt::Display,
5112 {
5113 self.name = value
5114 .try_into()
5115 .map_err(|e| format!("error converting supplied value for name: {}", e));
5116 self
5117 }
5118 pub fn url<T>(mut self, value: T) -> Self
5119 where
5120 T: std::convert::TryInto<String>,
5121 T::Error: std::fmt::Display,
5122 {
5123 self.url = value
5124 .try_into()
5125 .map_err(|e| format!("error converting supplied value for url: {}", e));
5126 self
5127 }
5128 }
5129 impl std::convert::TryFrom<Action> for super::Action {
5130 type Error = super::error::ConversionError;
5131 fn try_from(value: Action) -> Result<Self, super::error::ConversionError> {
5132 Ok(Self {
5133 name: value.name?,
5134 url: value.url?,
5135 })
5136 }
5137 }
5138 impl From<super::Action> for Action {
5139 fn from(value: super::Action) -> Self {
5140 Self {
5141 name: Ok(value.name),
5142 url: Ok(value.url),
5143 }
5144 }
5145 }
5146 #[derive(Clone, Debug)]
5147 pub struct Address {
5148 city: Result<Option<String>, String>,
5149 country: Result<Option<super::AddressCountry>, String>,
5150 lat: Result<Option<f64>, String>,
5151 lon: Result<Option<f64>, String>,
5152 postal_code: Result<Option<String>, String>,
5153 region: Result<Option<super::AddressRegion>, String>,
5154 street_address: Result<Option<String>, String>,
5155 tz: Result<Option<String>, String>,
5156 }
5157 impl Default for Address {
5158 fn default() -> Self {
5159 Self {
5160 city: Ok(Default::default()),
5161 country: Ok(Default::default()),
5162 lat: Ok(Default::default()),
5163 lon: Ok(Default::default()),
5164 postal_code: Ok(Default::default()),
5165 region: Ok(Default::default()),
5166 street_address: Ok(Default::default()),
5167 tz: Ok(Default::default()),
5168 }
5169 }
5170 }
5171 impl Address {
5172 pub fn city<T>(mut self, value: T) -> Self
5173 where
5174 T: std::convert::TryInto<Option<String>>,
5175 T::Error: std::fmt::Display,
5176 {
5177 self.city = value
5178 .try_into()
5179 .map_err(|e| format!("error converting supplied value for city: {}", e));
5180 self
5181 }
5182 pub fn country<T>(mut self, value: T) -> Self
5183 where
5184 T: std::convert::TryInto<Option<super::AddressCountry>>,
5185 T::Error: std::fmt::Display,
5186 {
5187 self.country = value
5188 .try_into()
5189 .map_err(|e| format!("error converting supplied value for country: {}", e));
5190 self
5191 }
5192 pub fn lat<T>(mut self, value: T) -> Self
5193 where
5194 T: std::convert::TryInto<Option<f64>>,
5195 T::Error: std::fmt::Display,
5196 {
5197 self.lat = value
5198 .try_into()
5199 .map_err(|e| format!("error converting supplied value for lat: {}", e));
5200 self
5201 }
5202 pub fn lon<T>(mut self, value: T) -> Self
5203 where
5204 T: std::convert::TryInto<Option<f64>>,
5205 T::Error: std::fmt::Display,
5206 {
5207 self.lon = value
5208 .try_into()
5209 .map_err(|e| format!("error converting supplied value for lon: {}", e));
5210 self
5211 }
5212 pub fn postal_code<T>(mut self, value: T) -> Self
5213 where
5214 T: std::convert::TryInto<Option<String>>,
5215 T::Error: std::fmt::Display,
5216 {
5217 self.postal_code = value
5218 .try_into()
5219 .map_err(|e| format!("error converting supplied value for postal_code: {}", e));
5220 self
5221 }
5222 pub fn region<T>(mut self, value: T) -> Self
5223 where
5224 T: std::convert::TryInto<Option<super::AddressRegion>>,
5225 T::Error: std::fmt::Display,
5226 {
5227 self.region = value
5228 .try_into()
5229 .map_err(|e| format!("error converting supplied value for region: {}", e));
5230 self
5231 }
5232 pub fn street_address<T>(mut self, value: T) -> Self
5233 where
5234 T: std::convert::TryInto<Option<String>>,
5235 T::Error: std::fmt::Display,
5236 {
5237 self.street_address = value
5238 .try_into()
5239 .map_err(|e| format!("error converting supplied value for street_address: {}", e));
5240 self
5241 }
5242 pub fn tz<T>(mut self, value: T) -> Self
5243 where
5244 T: std::convert::TryInto<Option<String>>,
5245 T::Error: std::fmt::Display,
5246 {
5247 self.tz = value
5248 .try_into()
5249 .map_err(|e| format!("error converting supplied value for tz: {}", e));
5250 self
5251 }
5252 }
5253 impl std::convert::TryFrom<Address> for super::Address {
5254 type Error = super::error::ConversionError;
5255 fn try_from(value: Address) -> Result<Self, super::error::ConversionError> {
5256 Ok(Self {
5257 city: value.city?,
5258 country: value.country?,
5259 lat: value.lat?,
5260 lon: value.lon?,
5261 postal_code: value.postal_code?,
5262 region: value.region?,
5263 street_address: value.street_address?,
5264 tz: value.tz?,
5265 })
5266 }
5267 }
5268 impl From<super::Address> for Address {
5269 fn from(value: super::Address) -> Self {
5270 Self {
5271 city: Ok(value.city),
5272 country: Ok(value.country),
5273 lat: Ok(value.lat),
5274 lon: Ok(value.lon),
5275 postal_code: Ok(value.postal_code),
5276 region: Ok(value.region),
5277 street_address: Ok(value.street_address),
5278 tz: Ok(value.tz),
5279 }
5280 }
5281 }
5282 #[derive(Clone, Debug)]
5283 pub struct Adjustment {
5284 adjustment_type: Result<super::AdjustmentType, String>,
5285 amount: Result<i64, String>,
5286 name: Result<Option<String>, String>,
5287 rate: Result<Option<f64>, String>,
5288 }
5289 impl Default for Adjustment {
5290 fn default() -> Self {
5291 Self {
5292 adjustment_type: Err("no value supplied for adjustment_type".to_string()),
5293 amount: Err("no value supplied for amount".to_string()),
5294 name: Ok(Default::default()),
5295 rate: Ok(Default::default()),
5296 }
5297 }
5298 }
5299 impl Adjustment {
5300 pub fn adjustment_type<T>(mut self, value: T) -> Self
5301 where
5302 T: std::convert::TryInto<super::AdjustmentType>,
5303 T::Error: std::fmt::Display,
5304 {
5305 self.adjustment_type = value
5306 .try_into()
5307 .map_err(|e| format!("error converting supplied value for adjustment_type: {}", e));
5308 self
5309 }
5310 pub fn amount<T>(mut self, value: T) -> Self
5311 where
5312 T: std::convert::TryInto<i64>,
5313 T::Error: std::fmt::Display,
5314 {
5315 self.amount = value
5316 .try_into()
5317 .map_err(|e| format!("error converting supplied value for amount: {}", e));
5318 self
5319 }
5320 pub fn name<T>(mut self, value: T) -> Self
5321 where
5322 T: std::convert::TryInto<Option<String>>,
5323 T::Error: std::fmt::Display,
5324 {
5325 self.name = value
5326 .try_into()
5327 .map_err(|e| format!("error converting supplied value for name: {}", e));
5328 self
5329 }
5330 pub fn rate<T>(mut self, value: T) -> Self
5331 where
5332 T: std::convert::TryInto<Option<f64>>,
5333 T::Error: std::fmt::Display,
5334 {
5335 self.rate = value
5336 .try_into()
5337 .map_err(|e| format!("error converting supplied value for rate: {}", e));
5338 self
5339 }
5340 }
5341 impl std::convert::TryFrom<Adjustment> for super::Adjustment {
5342 type Error = super::error::ConversionError;
5343 fn try_from(value: Adjustment) -> Result<Self, super::error::ConversionError> {
5344 Ok(Self {
5345 adjustment_type: value.adjustment_type?,
5346 amount: value.amount?,
5347 name: value.name?,
5348 rate: value.rate?,
5349 })
5350 }
5351 }
5352 impl From<super::Adjustment> for Adjustment {
5353 fn from(value: super::Adjustment) -> Self {
5354 Self {
5355 adjustment_type: Ok(value.adjustment_type),
5356 amount: Ok(value.amount),
5357 name: Ok(value.name),
5358 rate: Ok(value.rate),
5359 }
5360 }
5361 }
5362 #[derive(Clone, Debug)]
5363 pub struct CarRental {
5364 confirmation_number: Result<Option<String>, String>,
5365 drivers: Result<Option<Vec<super::Person>>, String>,
5366 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
5367 items: Result<Vec<super::Item>, String>,
5368 metadata: Result<Option<Vec<super::Metadatum>>, String>,
5369 odometer_reading_in: Result<i64, String>,
5370 odometer_reading_out: Result<i64, String>,
5371 record_locator: Result<Option<String>, String>,
5372 rental_at: Result<i64, String>,
5373 rental_location: Result<super::Place, String>,
5374 return_at: Result<i64, String>,
5375 return_location: Result<super::Place, String>,
5376 vehicle: Result<Option<super::CarRentalVehicle>, String>,
5377 vendor_code: Result<Option<super::CarRentalVendorCode>, String>,
5378 }
5379 impl Default for CarRental {
5380 fn default() -> Self {
5381 Self {
5382 confirmation_number: Ok(Default::default()),
5383 drivers: Ok(Default::default()),
5384 invoice_level_adjustments: Ok(Default::default()),
5385 items: Err("no value supplied for items".to_string()),
5386 metadata: Ok(Default::default()),
5387 odometer_reading_in: Err("no value supplied for odometer_reading_in".to_string()),
5388 odometer_reading_out: Err("no value supplied for odometer_reading_out".to_string()),
5389 record_locator: Ok(Default::default()),
5390 rental_at: Err("no value supplied for rental_at".to_string()),
5391 rental_location: Err("no value supplied for rental_location".to_string()),
5392 return_at: Err("no value supplied for return_at".to_string()),
5393 return_location: Err("no value supplied for return_location".to_string()),
5394 vehicle: Ok(Default::default()),
5395 vendor_code: Ok(Default::default()),
5396 }
5397 }
5398 }
5399 impl CarRental {
5400 pub fn confirmation_number<T>(mut self, value: T) -> Self
5401 where
5402 T: std::convert::TryInto<Option<String>>,
5403 T::Error: std::fmt::Display,
5404 {
5405 self.confirmation_number = value.try_into().map_err(|e| {
5406 format!(
5407 "error converting supplied value for confirmation_number: {}",
5408 e
5409 )
5410 });
5411 self
5412 }
5413 pub fn drivers<T>(mut self, value: T) -> Self
5414 where
5415 T: std::convert::TryInto<Option<Vec<super::Person>>>,
5416 T::Error: std::fmt::Display,
5417 {
5418 self.drivers = value
5419 .try_into()
5420 .map_err(|e| format!("error converting supplied value for drivers: {}", e));
5421 self
5422 }
5423 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
5424 where
5425 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
5426 T::Error: std::fmt::Display,
5427 {
5428 self.invoice_level_adjustments = value.try_into().map_err(|e| {
5429 format!(
5430 "error converting supplied value for invoice_level_adjustments: {}",
5431 e
5432 )
5433 });
5434 self
5435 }
5436 pub fn items<T>(mut self, value: T) -> Self
5437 where
5438 T: std::convert::TryInto<Vec<super::Item>>,
5439 T::Error: std::fmt::Display,
5440 {
5441 self.items = value
5442 .try_into()
5443 .map_err(|e| format!("error converting supplied value for items: {}", e));
5444 self
5445 }
5446 pub fn metadata<T>(mut self, value: T) -> Self
5447 where
5448 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
5449 T::Error: std::fmt::Display,
5450 {
5451 self.metadata = value
5452 .try_into()
5453 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
5454 self
5455 }
5456 pub fn odometer_reading_in<T>(mut self, value: T) -> Self
5457 where
5458 T: std::convert::TryInto<i64>,
5459 T::Error: std::fmt::Display,
5460 {
5461 self.odometer_reading_in = value.try_into().map_err(|e| {
5462 format!(
5463 "error converting supplied value for odometer_reading_in: {}",
5464 e
5465 )
5466 });
5467 self
5468 }
5469 pub fn odometer_reading_out<T>(mut self, value: T) -> Self
5470 where
5471 T: std::convert::TryInto<i64>,
5472 T::Error: std::fmt::Display,
5473 {
5474 self.odometer_reading_out = value.try_into().map_err(|e| {
5475 format!(
5476 "error converting supplied value for odometer_reading_out: {}",
5477 e
5478 )
5479 });
5480 self
5481 }
5482 pub fn record_locator<T>(mut self, value: T) -> Self
5483 where
5484 T: std::convert::TryInto<Option<String>>,
5485 T::Error: std::fmt::Display,
5486 {
5487 self.record_locator = value
5488 .try_into()
5489 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
5490 self
5491 }
5492 pub fn rental_at<T>(mut self, value: T) -> Self
5493 where
5494 T: std::convert::TryInto<i64>,
5495 T::Error: std::fmt::Display,
5496 {
5497 self.rental_at = value
5498 .try_into()
5499 .map_err(|e| format!("error converting supplied value for rental_at: {}", e));
5500 self
5501 }
5502 pub fn rental_location<T>(mut self, value: T) -> Self
5503 where
5504 T: std::convert::TryInto<super::Place>,
5505 T::Error: std::fmt::Display,
5506 {
5507 self.rental_location = value
5508 .try_into()
5509 .map_err(|e| format!("error converting supplied value for rental_location: {}", e));
5510 self
5511 }
5512 pub fn return_at<T>(mut self, value: T) -> Self
5513 where
5514 T: std::convert::TryInto<i64>,
5515 T::Error: std::fmt::Display,
5516 {
5517 self.return_at = value
5518 .try_into()
5519 .map_err(|e| format!("error converting supplied value for return_at: {}", e));
5520 self
5521 }
5522 pub fn return_location<T>(mut self, value: T) -> Self
5523 where
5524 T: std::convert::TryInto<super::Place>,
5525 T::Error: std::fmt::Display,
5526 {
5527 self.return_location = value
5528 .try_into()
5529 .map_err(|e| format!("error converting supplied value for return_location: {}", e));
5530 self
5531 }
5532 pub fn vehicle<T>(mut self, value: T) -> Self
5533 where
5534 T: std::convert::TryInto<Option<super::CarRentalVehicle>>,
5535 T::Error: std::fmt::Display,
5536 {
5537 self.vehicle = value
5538 .try_into()
5539 .map_err(|e| format!("error converting supplied value for vehicle: {}", e));
5540 self
5541 }
5542 pub fn vendor_code<T>(mut self, value: T) -> Self
5543 where
5544 T: std::convert::TryInto<Option<super::CarRentalVendorCode>>,
5545 T::Error: std::fmt::Display,
5546 {
5547 self.vendor_code = value
5548 .try_into()
5549 .map_err(|e| format!("error converting supplied value for vendor_code: {}", e));
5550 self
5551 }
5552 }
5553 impl std::convert::TryFrom<CarRental> for super::CarRental {
5554 type Error = super::error::ConversionError;
5555 fn try_from(value: CarRental) -> Result<Self, super::error::ConversionError> {
5556 Ok(Self {
5557 confirmation_number: value.confirmation_number?,
5558 drivers: value.drivers?,
5559 invoice_level_adjustments: value.invoice_level_adjustments?,
5560 items: value.items?,
5561 metadata: value.metadata?,
5562 odometer_reading_in: value.odometer_reading_in?,
5563 odometer_reading_out: value.odometer_reading_out?,
5564 record_locator: value.record_locator?,
5565 rental_at: value.rental_at?,
5566 rental_location: value.rental_location?,
5567 return_at: value.return_at?,
5568 return_location: value.return_location?,
5569 vehicle: value.vehicle?,
5570 vendor_code: value.vendor_code?,
5571 })
5572 }
5573 }
5574 impl From<super::CarRental> for CarRental {
5575 fn from(value: super::CarRental) -> Self {
5576 Self {
5577 confirmation_number: Ok(value.confirmation_number),
5578 drivers: Ok(value.drivers),
5579 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
5580 items: Ok(value.items),
5581 metadata: Ok(value.metadata),
5582 odometer_reading_in: Ok(value.odometer_reading_in),
5583 odometer_reading_out: Ok(value.odometer_reading_out),
5584 record_locator: Ok(value.record_locator),
5585 rental_at: Ok(value.rental_at),
5586 rental_location: Ok(value.rental_location),
5587 return_at: Ok(value.return_at),
5588 return_location: Ok(value.return_location),
5589 vehicle: Ok(value.vehicle),
5590 vendor_code: Ok(value.vendor_code),
5591 }
5592 }
5593 }
5594 #[derive(Clone, Debug)]
5595 pub struct CarRentalVehicle {
5596 description: Result<String, String>,
5597 image: Result<Option<String>, String>,
5598 license_plate_number: Result<Option<String>, String>,
5599 vehicle_class: Result<Option<super::CarRentalVehicleVehicleClass>, String>,
5600 }
5601 impl Default for CarRentalVehicle {
5602 fn default() -> Self {
5603 Self {
5604 description: Err("no value supplied for description".to_string()),
5605 image: Ok(Default::default()),
5606 license_plate_number: Ok(Default::default()),
5607 vehicle_class: Ok(Default::default()),
5608 }
5609 }
5610 }
5611 impl CarRentalVehicle {
5612 pub fn description<T>(mut self, value: T) -> Self
5613 where
5614 T: std::convert::TryInto<String>,
5615 T::Error: std::fmt::Display,
5616 {
5617 self.description = value
5618 .try_into()
5619 .map_err(|e| format!("error converting supplied value for description: {}", e));
5620 self
5621 }
5622 pub fn image<T>(mut self, value: T) -> Self
5623 where
5624 T: std::convert::TryInto<Option<String>>,
5625 T::Error: std::fmt::Display,
5626 {
5627 self.image = value
5628 .try_into()
5629 .map_err(|e| format!("error converting supplied value for image: {}", e));
5630 self
5631 }
5632 pub fn license_plate_number<T>(mut self, value: T) -> Self
5633 where
5634 T: std::convert::TryInto<Option<String>>,
5635 T::Error: std::fmt::Display,
5636 {
5637 self.license_plate_number = value.try_into().map_err(|e| {
5638 format!(
5639 "error converting supplied value for license_plate_number: {}",
5640 e
5641 )
5642 });
5643 self
5644 }
5645 pub fn vehicle_class<T>(mut self, value: T) -> Self
5646 where
5647 T: std::convert::TryInto<Option<super::CarRentalVehicleVehicleClass>>,
5648 T::Error: std::fmt::Display,
5649 {
5650 self.vehicle_class = value
5651 .try_into()
5652 .map_err(|e| format!("error converting supplied value for vehicle_class: {}", e));
5653 self
5654 }
5655 }
5656 impl std::convert::TryFrom<CarRentalVehicle> for super::CarRentalVehicle {
5657 type Error = super::error::ConversionError;
5658 fn try_from(value: CarRentalVehicle) -> Result<Self, super::error::ConversionError> {
5659 Ok(Self {
5660 description: value.description?,
5661 image: value.image?,
5662 license_plate_number: value.license_plate_number?,
5663 vehicle_class: value.vehicle_class?,
5664 })
5665 }
5666 }
5667 impl From<super::CarRentalVehicle> for CarRentalVehicle {
5668 fn from(value: super::CarRentalVehicle) -> Self {
5669 Self {
5670 description: Ok(value.description),
5671 image: Ok(value.image),
5672 license_plate_number: Ok(value.license_plate_number),
5673 vehicle_class: Ok(value.vehicle_class),
5674 }
5675 }
5676 }
5677 #[derive(Clone, Debug)]
5678 pub struct CardPayment {
5679 last_four: Result<super::CardPaymentLastFour, String>,
5680 network: Result<Option<super::CardPaymentNetwork>, String>,
5681 }
5682 impl Default for CardPayment {
5683 fn default() -> Self {
5684 Self {
5685 last_four: Err("no value supplied for last_four".to_string()),
5686 network: Ok(Default::default()),
5687 }
5688 }
5689 }
5690 impl CardPayment {
5691 pub fn last_four<T>(mut self, value: T) -> Self
5692 where
5693 T: std::convert::TryInto<super::CardPaymentLastFour>,
5694 T::Error: std::fmt::Display,
5695 {
5696 self.last_four = value
5697 .try_into()
5698 .map_err(|e| format!("error converting supplied value for last_four: {}", e));
5699 self
5700 }
5701 pub fn network<T>(mut self, value: T) -> Self
5702 where
5703 T: std::convert::TryInto<Option<super::CardPaymentNetwork>>,
5704 T::Error: std::fmt::Display,
5705 {
5706 self.network = value
5707 .try_into()
5708 .map_err(|e| format!("error converting supplied value for network: {}", e));
5709 self
5710 }
5711 }
5712 impl std::convert::TryFrom<CardPayment> for super::CardPayment {
5713 type Error = super::error::ConversionError;
5714 fn try_from(value: CardPayment) -> Result<Self, super::error::ConversionError> {
5715 Ok(Self {
5716 last_four: value.last_four?,
5717 network: value.network?,
5718 })
5719 }
5720 }
5721 impl From<super::CardPayment> for CardPayment {
5722 fn from(value: super::CardPayment) -> Self {
5723 Self {
5724 last_four: Ok(value.last_four),
5725 network: Ok(value.network),
5726 }
5727 }
5728 }
5729 #[derive(Clone, Debug)]
5730 pub struct Customer {
5731 address: Result<Option<super::Address>, String>,
5732 booker: Result<Option<super::Person>, String>,
5733 email: Result<Option<String>, String>,
5734 metadata: Result<Option<Vec<super::Metadatum>>, String>,
5735 name: Result<String, String>,
5736 phone: Result<Option<super::CustomerPhone>, String>,
5737 website: Result<Option<String>, String>,
5738 }
5739 impl Default for Customer {
5740 fn default() -> Self {
5741 Self {
5742 address: Ok(Default::default()),
5743 booker: Ok(Default::default()),
5744 email: Ok(Default::default()),
5745 metadata: Ok(Default::default()),
5746 name: Err("no value supplied for name".to_string()),
5747 phone: Ok(Default::default()),
5748 website: Ok(Default::default()),
5749 }
5750 }
5751 }
5752 impl Customer {
5753 pub fn address<T>(mut self, value: T) -> Self
5754 where
5755 T: std::convert::TryInto<Option<super::Address>>,
5756 T::Error: std::fmt::Display,
5757 {
5758 self.address = value
5759 .try_into()
5760 .map_err(|e| format!("error converting supplied value for address: {}", e));
5761 self
5762 }
5763 pub fn booker<T>(mut self, value: T) -> Self
5764 where
5765 T: std::convert::TryInto<Option<super::Person>>,
5766 T::Error: std::fmt::Display,
5767 {
5768 self.booker = value
5769 .try_into()
5770 .map_err(|e| format!("error converting supplied value for booker: {}", e));
5771 self
5772 }
5773 pub fn email<T>(mut self, value: T) -> Self
5774 where
5775 T: std::convert::TryInto<Option<String>>,
5776 T::Error: std::fmt::Display,
5777 {
5778 self.email = value
5779 .try_into()
5780 .map_err(|e| format!("error converting supplied value for email: {}", e));
5781 self
5782 }
5783 pub fn metadata<T>(mut self, value: T) -> Self
5784 where
5785 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
5786 T::Error: std::fmt::Display,
5787 {
5788 self.metadata = value
5789 .try_into()
5790 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
5791 self
5792 }
5793 pub fn name<T>(mut self, value: T) -> Self
5794 where
5795 T: std::convert::TryInto<String>,
5796 T::Error: std::fmt::Display,
5797 {
5798 self.name = value
5799 .try_into()
5800 .map_err(|e| format!("error converting supplied value for name: {}", e));
5801 self
5802 }
5803 pub fn phone<T>(mut self, value: T) -> Self
5804 where
5805 T: std::convert::TryInto<Option<super::CustomerPhone>>,
5806 T::Error: std::fmt::Display,
5807 {
5808 self.phone = value
5809 .try_into()
5810 .map_err(|e| format!("error converting supplied value for phone: {}", e));
5811 self
5812 }
5813 pub fn website<T>(mut self, value: T) -> Self
5814 where
5815 T: std::convert::TryInto<Option<String>>,
5816 T::Error: std::fmt::Display,
5817 {
5818 self.website = value
5819 .try_into()
5820 .map_err(|e| format!("error converting supplied value for website: {}", e));
5821 self
5822 }
5823 }
5824 impl std::convert::TryFrom<Customer> for super::Customer {
5825 type Error = super::error::ConversionError;
5826 fn try_from(value: Customer) -> Result<Self, super::error::ConversionError> {
5827 Ok(Self {
5828 address: value.address?,
5829 booker: value.booker?,
5830 email: value.email?,
5831 metadata: value.metadata?,
5832 name: value.name?,
5833 phone: value.phone?,
5834 website: value.website?,
5835 })
5836 }
5837 }
5838 impl From<super::Customer> for Customer {
5839 fn from(value: super::Customer) -> Self {
5840 Self {
5841 address: Ok(value.address),
5842 booker: Ok(value.booker),
5843 email: Ok(value.email),
5844 metadata: Ok(value.metadata),
5845 name: Ok(value.name),
5846 phone: Ok(value.phone),
5847 website: Ok(value.website),
5848 }
5849 }
5850 }
5851 #[derive(Clone, Debug)]
5852 pub struct Doc {
5853 body: Result<String, String>,
5854 title: Result<String, String>,
5855 }
5856 impl Default for Doc {
5857 fn default() -> Self {
5858 Self {
5859 body: Err("no value supplied for body".to_string()),
5860 title: Err("no value supplied for title".to_string()),
5861 }
5862 }
5863 }
5864 impl Doc {
5865 pub fn body<T>(mut self, value: T) -> Self
5866 where
5867 T: std::convert::TryInto<String>,
5868 T::Error: std::fmt::Display,
5869 {
5870 self.body = value
5871 .try_into()
5872 .map_err(|e| format!("error converting supplied value for body: {}", e));
5873 self
5874 }
5875 pub fn title<T>(mut self, value: T) -> Self
5876 where
5877 T: std::convert::TryInto<String>,
5878 T::Error: std::fmt::Display,
5879 {
5880 self.title = value
5881 .try_into()
5882 .map_err(|e| format!("error converting supplied value for title: {}", e));
5883 self
5884 }
5885 }
5886 impl std::convert::TryFrom<Doc> for super::Doc {
5887 type Error = super::error::ConversionError;
5888 fn try_from(value: Doc) -> Result<Self, super::error::ConversionError> {
5889 Ok(Self {
5890 body: value.body?,
5891 title: value.title?,
5892 })
5893 }
5894 }
5895 impl From<super::Doc> for Doc {
5896 fn from(value: super::Doc) -> Self {
5897 Self {
5898 body: Ok(value.body),
5899 title: Ok(value.title),
5900 }
5901 }
5902 }
5903 #[derive(Clone, Debug)]
5904 pub struct Ecommerce {
5905 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
5906 invoice_level_line_items: Result<Option<Vec<super::Item>>, String>,
5907 shipments: Result<Vec<super::Shipment>, String>,
5908 }
5909 impl Default for Ecommerce {
5910 fn default() -> Self {
5911 Self {
5912 invoice_level_adjustments: Ok(Default::default()),
5913 invoice_level_line_items: Ok(Default::default()),
5914 shipments: Err("no value supplied for shipments".to_string()),
5915 }
5916 }
5917 }
5918 impl Ecommerce {
5919 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
5920 where
5921 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
5922 T::Error: std::fmt::Display,
5923 {
5924 self.invoice_level_adjustments = value.try_into().map_err(|e| {
5925 format!(
5926 "error converting supplied value for invoice_level_adjustments: {}",
5927 e
5928 )
5929 });
5930 self
5931 }
5932 pub fn invoice_level_line_items<T>(mut self, value: T) -> Self
5933 where
5934 T: std::convert::TryInto<Option<Vec<super::Item>>>,
5935 T::Error: std::fmt::Display,
5936 {
5937 self.invoice_level_line_items = value.try_into().map_err(|e| {
5938 format!(
5939 "error converting supplied value for invoice_level_line_items: {}",
5940 e
5941 )
5942 });
5943 self
5944 }
5945 pub fn shipments<T>(mut self, value: T) -> Self
5946 where
5947 T: std::convert::TryInto<Vec<super::Shipment>>,
5948 T::Error: std::fmt::Display,
5949 {
5950 self.shipments = value
5951 .try_into()
5952 .map_err(|e| format!("error converting supplied value for shipments: {}", e));
5953 self
5954 }
5955 }
5956 impl std::convert::TryFrom<Ecommerce> for super::Ecommerce {
5957 type Error = super::error::ConversionError;
5958 fn try_from(value: Ecommerce) -> Result<Self, super::error::ConversionError> {
5959 Ok(Self {
5960 invoice_level_adjustments: value.invoice_level_adjustments?,
5961 invoice_level_line_items: value.invoice_level_line_items?,
5962 shipments: value.shipments?,
5963 })
5964 }
5965 }
5966 impl From<super::Ecommerce> for Ecommerce {
5967 fn from(value: super::Ecommerce) -> Self {
5968 Self {
5969 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
5970 invoice_level_line_items: Ok(value.invoice_level_line_items),
5971 shipments: Ok(value.shipments),
5972 }
5973 }
5974 }
5975 #[derive(Clone, Debug)]
5976 pub struct Flight {
5977 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
5978 itinerary_locator: Result<Option<String>, String>,
5979 tickets: Result<Vec<super::FlightTicket>, String>,
5980 }
5981 impl Default for Flight {
5982 fn default() -> Self {
5983 Self {
5984 invoice_level_adjustments: Ok(Default::default()),
5985 itinerary_locator: Ok(Default::default()),
5986 tickets: Err("no value supplied for tickets".to_string()),
5987 }
5988 }
5989 }
5990 impl Flight {
5991 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
5992 where
5993 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
5994 T::Error: std::fmt::Display,
5995 {
5996 self.invoice_level_adjustments = value.try_into().map_err(|e| {
5997 format!(
5998 "error converting supplied value for invoice_level_adjustments: {}",
5999 e
6000 )
6001 });
6002 self
6003 }
6004 pub fn itinerary_locator<T>(mut self, value: T) -> Self
6005 where
6006 T: std::convert::TryInto<Option<String>>,
6007 T::Error: std::fmt::Display,
6008 {
6009 self.itinerary_locator = value.try_into().map_err(|e| {
6010 format!(
6011 "error converting supplied value for itinerary_locator: {}",
6012 e
6013 )
6014 });
6015 self
6016 }
6017 pub fn tickets<T>(mut self, value: T) -> Self
6018 where
6019 T: std::convert::TryInto<Vec<super::FlightTicket>>,
6020 T::Error: std::fmt::Display,
6021 {
6022 self.tickets = value
6023 .try_into()
6024 .map_err(|e| format!("error converting supplied value for tickets: {}", e));
6025 self
6026 }
6027 }
6028 impl std::convert::TryFrom<Flight> for super::Flight {
6029 type Error = super::error::ConversionError;
6030 fn try_from(value: Flight) -> Result<Self, super::error::ConversionError> {
6031 Ok(Self {
6032 invoice_level_adjustments: value.invoice_level_adjustments?,
6033 itinerary_locator: value.itinerary_locator?,
6034 tickets: value.tickets?,
6035 })
6036 }
6037 }
6038 impl From<super::Flight> for Flight {
6039 fn from(value: super::Flight) -> Self {
6040 Self {
6041 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
6042 itinerary_locator: Ok(value.itinerary_locator),
6043 tickets: Ok(value.tickets),
6044 }
6045 }
6046 }
6047 #[derive(Clone, Debug)]
6048 pub struct FlightSegment {
6049 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6050 aircraft_type: Result<Option<super::FlightSegmentAircraftType>, String>,
6051 arrival_airport_code: Result<super::FlightSegmentArrivalAirportCode, String>,
6052 arrival_at: Result<Option<i64>, String>,
6053 arrival_tz: Result<Option<String>, String>,
6054 class_of_service: Result<Option<String>, String>,
6055 departure_airport_code: Result<super::FlightSegmentDepartureAirportCode, String>,
6056 departure_at: Result<Option<i64>, String>,
6057 departure_tz: Result<Option<String>, String>,
6058 fare: Result<Option<i64>, String>,
6059 flight_number: Result<Option<String>, String>,
6060 metadata: Result<Option<Vec<super::Metadatum>>, String>,
6061 seat: Result<Option<String>, String>,
6062 taxes: Result<Option<Vec<super::Tax>>, String>,
6063 }
6064 impl Default for FlightSegment {
6065 fn default() -> Self {
6066 Self {
6067 adjustments: Ok(Default::default()),
6068 aircraft_type: Ok(Default::default()),
6069 arrival_airport_code: Err("no value supplied for arrival_airport_code".to_string()),
6070 arrival_at: Ok(Default::default()),
6071 arrival_tz: Ok(Default::default()),
6072 class_of_service: Ok(Default::default()),
6073 departure_airport_code: Err("no value supplied for departure_airport_code".to_string()),
6074 departure_at: Ok(Default::default()),
6075 departure_tz: Ok(Default::default()),
6076 fare: Ok(Default::default()),
6077 flight_number: Ok(Default::default()),
6078 metadata: Ok(Default::default()),
6079 seat: Ok(Default::default()),
6080 taxes: Ok(Default::default()),
6081 }
6082 }
6083 }
6084 impl FlightSegment {
6085 pub fn adjustments<T>(mut self, value: T) -> Self
6086 where
6087 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6088 T::Error: std::fmt::Display,
6089 {
6090 self.adjustments = value
6091 .try_into()
6092 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
6093 self
6094 }
6095 pub fn aircraft_type<T>(mut self, value: T) -> Self
6096 where
6097 T: std::convert::TryInto<Option<super::FlightSegmentAircraftType>>,
6098 T::Error: std::fmt::Display,
6099 {
6100 self.aircraft_type = value
6101 .try_into()
6102 .map_err(|e| format!("error converting supplied value for aircraft_type: {}", e));
6103 self
6104 }
6105 pub fn arrival_airport_code<T>(mut self, value: T) -> Self
6106 where
6107 T: std::convert::TryInto<super::FlightSegmentArrivalAirportCode>,
6108 T::Error: std::fmt::Display,
6109 {
6110 self.arrival_airport_code = value.try_into().map_err(|e| {
6111 format!(
6112 "error converting supplied value for arrival_airport_code: {}",
6113 e
6114 )
6115 });
6116 self
6117 }
6118 pub fn arrival_at<T>(mut self, value: T) -> Self
6119 where
6120 T: std::convert::TryInto<Option<i64>>,
6121 T::Error: std::fmt::Display,
6122 {
6123 self.arrival_at = value
6124 .try_into()
6125 .map_err(|e| format!("error converting supplied value for arrival_at: {}", e));
6126 self
6127 }
6128 pub fn arrival_tz<T>(mut self, value: T) -> Self
6129 where
6130 T: std::convert::TryInto<Option<String>>,
6131 T::Error: std::fmt::Display,
6132 {
6133 self.arrival_tz = value
6134 .try_into()
6135 .map_err(|e| format!("error converting supplied value for arrival_tz: {}", e));
6136 self
6137 }
6138 pub fn class_of_service<T>(mut self, value: T) -> Self
6139 where
6140 T: std::convert::TryInto<Option<String>>,
6141 T::Error: std::fmt::Display,
6142 {
6143 self.class_of_service = value.try_into().map_err(|e| {
6144 format!(
6145 "error converting supplied value for class_of_service: {}",
6146 e
6147 )
6148 });
6149 self
6150 }
6151 pub fn departure_airport_code<T>(mut self, value: T) -> Self
6152 where
6153 T: std::convert::TryInto<super::FlightSegmentDepartureAirportCode>,
6154 T::Error: std::fmt::Display,
6155 {
6156 self.departure_airport_code = value.try_into().map_err(|e| {
6157 format!(
6158 "error converting supplied value for departure_airport_code: {}",
6159 e
6160 )
6161 });
6162 self
6163 }
6164 pub fn departure_at<T>(mut self, value: T) -> Self
6165 where
6166 T: std::convert::TryInto<Option<i64>>,
6167 T::Error: std::fmt::Display,
6168 {
6169 self.departure_at = value
6170 .try_into()
6171 .map_err(|e| format!("error converting supplied value for departure_at: {}", e));
6172 self
6173 }
6174 pub fn departure_tz<T>(mut self, value: T) -> Self
6175 where
6176 T: std::convert::TryInto<Option<String>>,
6177 T::Error: std::fmt::Display,
6178 {
6179 self.departure_tz = value
6180 .try_into()
6181 .map_err(|e| format!("error converting supplied value for departure_tz: {}", e));
6182 self
6183 }
6184 pub fn fare<T>(mut self, value: T) -> Self
6185 where
6186 T: std::convert::TryInto<Option<i64>>,
6187 T::Error: std::fmt::Display,
6188 {
6189 self.fare = value
6190 .try_into()
6191 .map_err(|e| format!("error converting supplied value for fare: {}", e));
6192 self
6193 }
6194 pub fn flight_number<T>(mut self, value: T) -> Self
6195 where
6196 T: std::convert::TryInto<Option<String>>,
6197 T::Error: std::fmt::Display,
6198 {
6199 self.flight_number = value
6200 .try_into()
6201 .map_err(|e| format!("error converting supplied value for flight_number: {}", e));
6202 self
6203 }
6204 pub fn metadata<T>(mut self, value: T) -> Self
6205 where
6206 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
6207 T::Error: std::fmt::Display,
6208 {
6209 self.metadata = value
6210 .try_into()
6211 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
6212 self
6213 }
6214 pub fn seat<T>(mut self, value: T) -> Self
6215 where
6216 T: std::convert::TryInto<Option<String>>,
6217 T::Error: std::fmt::Display,
6218 {
6219 self.seat = value
6220 .try_into()
6221 .map_err(|e| format!("error converting supplied value for seat: {}", e));
6222 self
6223 }
6224 pub fn taxes<T>(mut self, value: T) -> Self
6225 where
6226 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6227 T::Error: std::fmt::Display,
6228 {
6229 self.taxes = value
6230 .try_into()
6231 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6232 self
6233 }
6234 }
6235 impl std::convert::TryFrom<FlightSegment> for super::FlightSegment {
6236 type Error = super::error::ConversionError;
6237 fn try_from(value: FlightSegment) -> Result<Self, super::error::ConversionError> {
6238 Ok(Self {
6239 adjustments: value.adjustments?,
6240 aircraft_type: value.aircraft_type?,
6241 arrival_airport_code: value.arrival_airport_code?,
6242 arrival_at: value.arrival_at?,
6243 arrival_tz: value.arrival_tz?,
6244 class_of_service: value.class_of_service?,
6245 departure_airport_code: value.departure_airport_code?,
6246 departure_at: value.departure_at?,
6247 departure_tz: value.departure_tz?,
6248 fare: value.fare?,
6249 flight_number: value.flight_number?,
6250 metadata: value.metadata?,
6251 seat: value.seat?,
6252 taxes: value.taxes?,
6253 })
6254 }
6255 }
6256 impl From<super::FlightSegment> for FlightSegment {
6257 fn from(value: super::FlightSegment) -> Self {
6258 Self {
6259 adjustments: Ok(value.adjustments),
6260 aircraft_type: Ok(value.aircraft_type),
6261 arrival_airport_code: Ok(value.arrival_airport_code),
6262 arrival_at: Ok(value.arrival_at),
6263 arrival_tz: Ok(value.arrival_tz),
6264 class_of_service: Ok(value.class_of_service),
6265 departure_airport_code: Ok(value.departure_airport_code),
6266 departure_at: Ok(value.departure_at),
6267 departure_tz: Ok(value.departure_tz),
6268 fare: Ok(value.fare),
6269 flight_number: Ok(value.flight_number),
6270 metadata: Ok(value.metadata),
6271 seat: Ok(value.seat),
6272 taxes: Ok(value.taxes),
6273 }
6274 }
6275 }
6276 #[derive(Clone, Debug)]
6277 pub struct FlightTicket {
6278 fare: Result<Option<i64>, String>,
6279 number: Result<Option<String>, String>,
6280 passenger: Result<Option<super::Person>, String>,
6281 record_locator: Result<Option<String>, String>,
6282 segments: Result<Vec<super::FlightSegment>, String>,
6283 taxes: Result<Option<Vec<super::Tax>>, String>,
6284 }
6285 impl Default for FlightTicket {
6286 fn default() -> Self {
6287 Self {
6288 fare: Ok(Default::default()),
6289 number: Ok(Default::default()),
6290 passenger: Ok(Default::default()),
6291 record_locator: Ok(Default::default()),
6292 segments: Err("no value supplied for segments".to_string()),
6293 taxes: Ok(Default::default()),
6294 }
6295 }
6296 }
6297 impl FlightTicket {
6298 pub fn fare<T>(mut self, value: T) -> Self
6299 where
6300 T: std::convert::TryInto<Option<i64>>,
6301 T::Error: std::fmt::Display,
6302 {
6303 self.fare = value
6304 .try_into()
6305 .map_err(|e| format!("error converting supplied value for fare: {}", e));
6306 self
6307 }
6308 pub fn number<T>(mut self, value: T) -> Self
6309 where
6310 T: std::convert::TryInto<Option<String>>,
6311 T::Error: std::fmt::Display,
6312 {
6313 self.number = value
6314 .try_into()
6315 .map_err(|e| format!("error converting supplied value for number: {}", e));
6316 self
6317 }
6318 pub fn passenger<T>(mut self, value: T) -> Self
6319 where
6320 T: std::convert::TryInto<Option<super::Person>>,
6321 T::Error: std::fmt::Display,
6322 {
6323 self.passenger = value
6324 .try_into()
6325 .map_err(|e| format!("error converting supplied value for passenger: {}", e));
6326 self
6327 }
6328 pub fn record_locator<T>(mut self, value: T) -> Self
6329 where
6330 T: std::convert::TryInto<Option<String>>,
6331 T::Error: std::fmt::Display,
6332 {
6333 self.record_locator = value
6334 .try_into()
6335 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
6336 self
6337 }
6338 pub fn segments<T>(mut self, value: T) -> Self
6339 where
6340 T: std::convert::TryInto<Vec<super::FlightSegment>>,
6341 T::Error: std::fmt::Display,
6342 {
6343 self.segments = value
6344 .try_into()
6345 .map_err(|e| format!("error converting supplied value for segments: {}", e));
6346 self
6347 }
6348 pub fn taxes<T>(mut self, value: T) -> Self
6349 where
6350 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6351 T::Error: std::fmt::Display,
6352 {
6353 self.taxes = value
6354 .try_into()
6355 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6356 self
6357 }
6358 }
6359 impl std::convert::TryFrom<FlightTicket> for super::FlightTicket {
6360 type Error = super::error::ConversionError;
6361 fn try_from(value: FlightTicket) -> Result<Self, super::error::ConversionError> {
6362 Ok(Self {
6363 fare: value.fare?,
6364 number: value.number?,
6365 passenger: value.passenger?,
6366 record_locator: value.record_locator?,
6367 segments: value.segments?,
6368 taxes: value.taxes?,
6369 })
6370 }
6371 }
6372 impl From<super::FlightTicket> for FlightTicket {
6373 fn from(value: super::FlightTicket) -> Self {
6374 Self {
6375 fare: Ok(value.fare),
6376 number: Ok(value.number),
6377 passenger: Ok(value.passenger),
6378 record_locator: Ok(value.record_locator),
6379 segments: Ok(value.segments),
6380 taxes: Ok(value.taxes),
6381 }
6382 }
6383 }
6384 #[derive(Clone, Debug)]
6385 pub struct Footer {
6386 actions: Result<Option<Vec<super::Action>>, String>,
6387 supplemental_text: Result<Option<String>, String>,
6388 }
6389 impl Default for Footer {
6390 fn default() -> Self {
6391 Self {
6392 actions: Ok(Default::default()),
6393 supplemental_text: Ok(Default::default()),
6394 }
6395 }
6396 }
6397 impl Footer {
6398 pub fn actions<T>(mut self, value: T) -> Self
6399 where
6400 T: std::convert::TryInto<Option<Vec<super::Action>>>,
6401 T::Error: std::fmt::Display,
6402 {
6403 self.actions = value
6404 .try_into()
6405 .map_err(|e| format!("error converting supplied value for actions: {}", e));
6406 self
6407 }
6408 pub fn supplemental_text<T>(mut self, value: T) -> Self
6409 where
6410 T: std::convert::TryInto<Option<String>>,
6411 T::Error: std::fmt::Display,
6412 {
6413 self.supplemental_text = value.try_into().map_err(|e| {
6414 format!(
6415 "error converting supplied value for supplemental_text: {}",
6416 e
6417 )
6418 });
6419 self
6420 }
6421 }
6422 impl std::convert::TryFrom<Footer> for super::Footer {
6423 type Error = super::error::ConversionError;
6424 fn try_from(value: Footer) -> Result<Self, super::error::ConversionError> {
6425 Ok(Self {
6426 actions: value.actions?,
6427 supplemental_text: value.supplemental_text?,
6428 })
6429 }
6430 }
6431 impl From<super::Footer> for Footer {
6432 fn from(value: super::Footer) -> Self {
6433 Self {
6434 actions: Ok(value.actions),
6435 supplemental_text: Ok(value.supplemental_text),
6436 }
6437 }
6438 }
6439 #[derive(Clone, Debug)]
6440 pub struct GeneralItemization {
6441 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6442 items: Result<Vec<super::Item>, String>,
6443 }
6444 impl Default for GeneralItemization {
6445 fn default() -> Self {
6446 Self {
6447 invoice_level_adjustments: Ok(Default::default()),
6448 items: Err("no value supplied for items".to_string()),
6449 }
6450 }
6451 }
6452 impl GeneralItemization {
6453 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
6454 where
6455 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6456 T::Error: std::fmt::Display,
6457 {
6458 self.invoice_level_adjustments = value.try_into().map_err(|e| {
6459 format!(
6460 "error converting supplied value for invoice_level_adjustments: {}",
6461 e
6462 )
6463 });
6464 self
6465 }
6466 pub fn items<T>(mut self, value: T) -> Self
6467 where
6468 T: std::convert::TryInto<Vec<super::Item>>,
6469 T::Error: std::fmt::Display,
6470 {
6471 self.items = value
6472 .try_into()
6473 .map_err(|e| format!("error converting supplied value for items: {}", e));
6474 self
6475 }
6476 }
6477 impl std::convert::TryFrom<GeneralItemization> for super::GeneralItemization {
6478 type Error = super::error::ConversionError;
6479 fn try_from(value: GeneralItemization) -> Result<Self, super::error::ConversionError> {
6480 Ok(Self {
6481 invoice_level_adjustments: value.invoice_level_adjustments?,
6482 items: value.items?,
6483 })
6484 }
6485 }
6486 impl From<super::GeneralItemization> for GeneralItemization {
6487 fn from(value: super::GeneralItemization) -> Self {
6488 Self {
6489 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
6490 items: Ok(value.items),
6491 }
6492 }
6493 }
6494 #[derive(Clone, Debug)]
6495 pub struct Header {
6496 currency: Result<super::Currency, String>,
6497 customer: Result<Option<super::Customer>, String>,
6498 invoice_asset_id: Result<Option<String>, String>,
6499 invoice_number: Result<Option<String>, String>,
6500 invoiced_at: Result<i64, String>,
6501 location: Result<Option<super::Place>, String>,
6502 mcc: Result<Option<super::HeaderMcc>, String>,
6503 paid: Result<i64, String>,
6504 receipt_asset_id: Result<Option<String>, String>,
6505 subtotal: Result<i64, String>,
6506 third_party: Result<Option<super::HeaderThirdParty>, String>,
6507 total: Result<i64, String>,
6508 }
6509 impl Default for Header {
6510 fn default() -> Self {
6511 Self {
6512 currency: Err("no value supplied for currency".to_string()),
6513 customer: Ok(Default::default()),
6514 invoice_asset_id: Ok(Default::default()),
6515 invoice_number: Ok(Default::default()),
6516 invoiced_at: Err("no value supplied for invoiced_at".to_string()),
6517 location: Ok(Default::default()),
6518 mcc: Ok(Default::default()),
6519 paid: Err("no value supplied for paid".to_string()),
6520 receipt_asset_id: Ok(Default::default()),
6521 subtotal: Err("no value supplied for subtotal".to_string()),
6522 third_party: Ok(Default::default()),
6523 total: Err("no value supplied for total".to_string()),
6524 }
6525 }
6526 }
6527 impl Header {
6528 pub fn currency<T>(mut self, value: T) -> Self
6529 where
6530 T: std::convert::TryInto<super::Currency>,
6531 T::Error: std::fmt::Display,
6532 {
6533 self.currency = value
6534 .try_into()
6535 .map_err(|e| format!("error converting supplied value for currency: {}", e));
6536 self
6537 }
6538 pub fn customer<T>(mut self, value: T) -> Self
6539 where
6540 T: std::convert::TryInto<Option<super::Customer>>,
6541 T::Error: std::fmt::Display,
6542 {
6543 self.customer = value
6544 .try_into()
6545 .map_err(|e| format!("error converting supplied value for customer: {}", e));
6546 self
6547 }
6548 pub fn invoice_asset_id<T>(mut self, value: T) -> Self
6549 where
6550 T: std::convert::TryInto<Option<String>>,
6551 T::Error: std::fmt::Display,
6552 {
6553 self.invoice_asset_id = value.try_into().map_err(|e| {
6554 format!(
6555 "error converting supplied value for invoice_asset_id: {}",
6556 e
6557 )
6558 });
6559 self
6560 }
6561 pub fn invoice_number<T>(mut self, value: T) -> Self
6562 where
6563 T: std::convert::TryInto<Option<String>>,
6564 T::Error: std::fmt::Display,
6565 {
6566 self.invoice_number = value
6567 .try_into()
6568 .map_err(|e| format!("error converting supplied value for invoice_number: {}", e));
6569 self
6570 }
6571 pub fn invoiced_at<T>(mut self, value: T) -> Self
6572 where
6573 T: std::convert::TryInto<i64>,
6574 T::Error: std::fmt::Display,
6575 {
6576 self.invoiced_at = value
6577 .try_into()
6578 .map_err(|e| format!("error converting supplied value for invoiced_at: {}", e));
6579 self
6580 }
6581 pub fn location<T>(mut self, value: T) -> Self
6582 where
6583 T: std::convert::TryInto<Option<super::Place>>,
6584 T::Error: std::fmt::Display,
6585 {
6586 self.location = value
6587 .try_into()
6588 .map_err(|e| format!("error converting supplied value for location: {}", e));
6589 self
6590 }
6591 pub fn mcc<T>(mut self, value: T) -> Self
6592 where
6593 T: std::convert::TryInto<Option<super::HeaderMcc>>,
6594 T::Error: std::fmt::Display,
6595 {
6596 self.mcc = value
6597 .try_into()
6598 .map_err(|e| format!("error converting supplied value for mcc: {}", e));
6599 self
6600 }
6601 pub fn paid<T>(mut self, value: T) -> Self
6602 where
6603 T: std::convert::TryInto<i64>,
6604 T::Error: std::fmt::Display,
6605 {
6606 self.paid = value
6607 .try_into()
6608 .map_err(|e| format!("error converting supplied value for paid: {}", e));
6609 self
6610 }
6611 pub fn receipt_asset_id<T>(mut self, value: T) -> Self
6612 where
6613 T: std::convert::TryInto<Option<String>>,
6614 T::Error: std::fmt::Display,
6615 {
6616 self.receipt_asset_id = value.try_into().map_err(|e| {
6617 format!(
6618 "error converting supplied value for receipt_asset_id: {}",
6619 e
6620 )
6621 });
6622 self
6623 }
6624 pub fn subtotal<T>(mut self, value: T) -> Self
6625 where
6626 T: std::convert::TryInto<i64>,
6627 T::Error: std::fmt::Display,
6628 {
6629 self.subtotal = value
6630 .try_into()
6631 .map_err(|e| format!("error converting supplied value for subtotal: {}", e));
6632 self
6633 }
6634 pub fn third_party<T>(mut self, value: T) -> Self
6635 where
6636 T: std::convert::TryInto<Option<super::HeaderThirdParty>>,
6637 T::Error: std::fmt::Display,
6638 {
6639 self.third_party = value
6640 .try_into()
6641 .map_err(|e| format!("error converting supplied value for third_party: {}", e));
6642 self
6643 }
6644 pub fn total<T>(mut self, value: T) -> Self
6645 where
6646 T: std::convert::TryInto<i64>,
6647 T::Error: std::fmt::Display,
6648 {
6649 self.total = value
6650 .try_into()
6651 .map_err(|e| format!("error converting supplied value for total: {}", e));
6652 self
6653 }
6654 }
6655 impl std::convert::TryFrom<Header> for super::Header {
6656 type Error = super::error::ConversionError;
6657 fn try_from(value: Header) -> Result<Self, super::error::ConversionError> {
6658 Ok(Self {
6659 currency: value.currency?,
6660 customer: value.customer?,
6661 invoice_asset_id: value.invoice_asset_id?,
6662 invoice_number: value.invoice_number?,
6663 invoiced_at: value.invoiced_at?,
6664 location: value.location?,
6665 mcc: value.mcc?,
6666 paid: value.paid?,
6667 receipt_asset_id: value.receipt_asset_id?,
6668 subtotal: value.subtotal?,
6669 third_party: value.third_party?,
6670 total: value.total?,
6671 })
6672 }
6673 }
6674 impl From<super::Header> for Header {
6675 fn from(value: super::Header) -> Self {
6676 Self {
6677 currency: Ok(value.currency),
6678 customer: Ok(value.customer),
6679 invoice_asset_id: Ok(value.invoice_asset_id),
6680 invoice_number: Ok(value.invoice_number),
6681 invoiced_at: Ok(value.invoiced_at),
6682 location: Ok(value.location),
6683 mcc: Ok(value.mcc),
6684 paid: Ok(value.paid),
6685 receipt_asset_id: Ok(value.receipt_asset_id),
6686 subtotal: Ok(value.subtotal),
6687 third_party: Ok(value.third_party),
6688 total: Ok(value.total),
6689 }
6690 }
6691 }
6692 #[derive(Clone, Debug)]
6693 pub struct HeaderThirdParty {
6694 make_primary: Result<bool, String>,
6695 merchant: Result<Option<super::Org>, String>,
6696 relation: Result<super::HeaderThirdPartyRelation, String>,
6697 }
6698 impl Default for HeaderThirdParty {
6699 fn default() -> Self {
6700 Self {
6701 make_primary: Err("no value supplied for make_primary".to_string()),
6702 merchant: Ok(Default::default()),
6703 relation: Err("no value supplied for relation".to_string()),
6704 }
6705 }
6706 }
6707 impl HeaderThirdParty {
6708 pub fn make_primary<T>(mut self, value: T) -> Self
6709 where
6710 T: std::convert::TryInto<bool>,
6711 T::Error: std::fmt::Display,
6712 {
6713 self.make_primary = value
6714 .try_into()
6715 .map_err(|e| format!("error converting supplied value for make_primary: {}", e));
6716 self
6717 }
6718 pub fn merchant<T>(mut self, value: T) -> Self
6719 where
6720 T: std::convert::TryInto<Option<super::Org>>,
6721 T::Error: std::fmt::Display,
6722 {
6723 self.merchant = value
6724 .try_into()
6725 .map_err(|e| format!("error converting supplied value for merchant: {}", e));
6726 self
6727 }
6728 pub fn relation<T>(mut self, value: T) -> Self
6729 where
6730 T: std::convert::TryInto<super::HeaderThirdPartyRelation>,
6731 T::Error: std::fmt::Display,
6732 {
6733 self.relation = value
6734 .try_into()
6735 .map_err(|e| format!("error converting supplied value for relation: {}", e));
6736 self
6737 }
6738 }
6739 impl std::convert::TryFrom<HeaderThirdParty> for super::HeaderThirdParty {
6740 type Error = super::error::ConversionError;
6741 fn try_from(value: HeaderThirdParty) -> Result<Self, super::error::ConversionError> {
6742 Ok(Self {
6743 make_primary: value.make_primary?,
6744 merchant: value.merchant?,
6745 relation: value.relation?,
6746 })
6747 }
6748 }
6749 impl From<super::HeaderThirdParty> for HeaderThirdParty {
6750 fn from(value: super::HeaderThirdParty) -> Self {
6751 Self {
6752 make_primary: Ok(value.make_primary),
6753 merchant: Ok(value.merchant),
6754 relation: Ok(value.relation),
6755 }
6756 }
6757 }
6758 #[derive(Clone, Debug)]
6759 pub struct Item {
6760 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
6761 amount: Result<i64, String>,
6762 date: Result<Option<String>, String>,
6763 description: Result<String, String>,
6764 group: Result<Option<String>, String>,
6765 metadata: Result<Option<Vec<super::Metadatum>>, String>,
6766 product_image_asset_id: Result<Option<String>, String>,
6767 quantity: Result<Option<f64>, String>,
6768 taxes: Result<Option<Vec<super::Tax>>, String>,
6769 unit: Result<Option<String>, String>,
6770 unit_cost: Result<Option<i64>, String>,
6771 unspsc: Result<Option<super::ItemUnspsc>, String>,
6772 url: Result<Option<String>, String>,
6773 }
6774 impl Default for Item {
6775 fn default() -> Self {
6776 Self {
6777 adjustments: Ok(Default::default()),
6778 amount: Err("no value supplied for amount".to_string()),
6779 date: Ok(Default::default()),
6780 description: Err("no value supplied for description".to_string()),
6781 group: Ok(Default::default()),
6782 metadata: Ok(Default::default()),
6783 product_image_asset_id: Ok(Default::default()),
6784 quantity: Ok(Default::default()),
6785 taxes: Ok(Default::default()),
6786 unit: Ok(Default::default()),
6787 unit_cost: Ok(Default::default()),
6788 unspsc: Ok(Default::default()),
6789 url: Ok(Default::default()),
6790 }
6791 }
6792 }
6793 impl Item {
6794 pub fn adjustments<T>(mut self, value: T) -> Self
6795 where
6796 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
6797 T::Error: std::fmt::Display,
6798 {
6799 self.adjustments = value
6800 .try_into()
6801 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
6802 self
6803 }
6804 pub fn amount<T>(mut self, value: T) -> Self
6805 where
6806 T: std::convert::TryInto<i64>,
6807 T::Error: std::fmt::Display,
6808 {
6809 self.amount = value
6810 .try_into()
6811 .map_err(|e| format!("error converting supplied value for amount: {}", e));
6812 self
6813 }
6814 pub fn date<T>(mut self, value: T) -> Self
6815 where
6816 T: std::convert::TryInto<Option<String>>,
6817 T::Error: std::fmt::Display,
6818 {
6819 self.date = value
6820 .try_into()
6821 .map_err(|e| format!("error converting supplied value for date: {}", e));
6822 self
6823 }
6824 pub fn description<T>(mut self, value: T) -> Self
6825 where
6826 T: std::convert::TryInto<String>,
6827 T::Error: std::fmt::Display,
6828 {
6829 self.description = value
6830 .try_into()
6831 .map_err(|e| format!("error converting supplied value for description: {}", e));
6832 self
6833 }
6834 pub fn group<T>(mut self, value: T) -> Self
6835 where
6836 T: std::convert::TryInto<Option<String>>,
6837 T::Error: std::fmt::Display,
6838 {
6839 self.group = value
6840 .try_into()
6841 .map_err(|e| format!("error converting supplied value for group: {}", e));
6842 self
6843 }
6844 pub fn metadata<T>(mut self, value: T) -> Self
6845 where
6846 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
6847 T::Error: std::fmt::Display,
6848 {
6849 self.metadata = value
6850 .try_into()
6851 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
6852 self
6853 }
6854 pub fn product_image_asset_id<T>(mut self, value: T) -> Self
6855 where
6856 T: std::convert::TryInto<Option<String>>,
6857 T::Error: std::fmt::Display,
6858 {
6859 self.product_image_asset_id = value.try_into().map_err(|e| {
6860 format!(
6861 "error converting supplied value for product_image_asset_id: {}",
6862 e
6863 )
6864 });
6865 self
6866 }
6867 pub fn quantity<T>(mut self, value: T) -> Self
6868 where
6869 T: std::convert::TryInto<Option<f64>>,
6870 T::Error: std::fmt::Display,
6871 {
6872 self.quantity = value
6873 .try_into()
6874 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
6875 self
6876 }
6877 pub fn taxes<T>(mut self, value: T) -> Self
6878 where
6879 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
6880 T::Error: std::fmt::Display,
6881 {
6882 self.taxes = value
6883 .try_into()
6884 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
6885 self
6886 }
6887 pub fn unit<T>(mut self, value: T) -> Self
6888 where
6889 T: std::convert::TryInto<Option<String>>,
6890 T::Error: std::fmt::Display,
6891 {
6892 self.unit = value
6893 .try_into()
6894 .map_err(|e| format!("error converting supplied value for unit: {}", e));
6895 self
6896 }
6897 pub fn unit_cost<T>(mut self, value: T) -> Self
6898 where
6899 T: std::convert::TryInto<Option<i64>>,
6900 T::Error: std::fmt::Display,
6901 {
6902 self.unit_cost = value
6903 .try_into()
6904 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
6905 self
6906 }
6907 pub fn unspsc<T>(mut self, value: T) -> Self
6908 where
6909 T: std::convert::TryInto<Option<super::ItemUnspsc>>,
6910 T::Error: std::fmt::Display,
6911 {
6912 self.unspsc = value
6913 .try_into()
6914 .map_err(|e| format!("error converting supplied value for unspsc: {}", e));
6915 self
6916 }
6917 pub fn url<T>(mut self, value: T) -> Self
6918 where
6919 T: std::convert::TryInto<Option<String>>,
6920 T::Error: std::fmt::Display,
6921 {
6922 self.url = value
6923 .try_into()
6924 .map_err(|e| format!("error converting supplied value for url: {}", e));
6925 self
6926 }
6927 }
6928 impl std::convert::TryFrom<Item> for super::Item {
6929 type Error = super::error::ConversionError;
6930 fn try_from(value: Item) -> Result<Self, super::error::ConversionError> {
6931 Ok(Self {
6932 adjustments: value.adjustments?,
6933 amount: value.amount?,
6934 date: value.date?,
6935 description: value.description?,
6936 group: value.group?,
6937 metadata: value.metadata?,
6938 product_image_asset_id: value.product_image_asset_id?,
6939 quantity: value.quantity?,
6940 taxes: value.taxes?,
6941 unit: value.unit?,
6942 unit_cost: value.unit_cost?,
6943 unspsc: value.unspsc?,
6944 url: value.url?,
6945 })
6946 }
6947 }
6948 impl From<super::Item> for Item {
6949 fn from(value: super::Item) -> Self {
6950 Self {
6951 adjustments: Ok(value.adjustments),
6952 amount: Ok(value.amount),
6953 date: Ok(value.date),
6954 description: Ok(value.description),
6955 group: Ok(value.group),
6956 metadata: Ok(value.metadata),
6957 product_image_asset_id: Ok(value.product_image_asset_id),
6958 quantity: Ok(value.quantity),
6959 taxes: Ok(value.taxes),
6960 unit: Ok(value.unit),
6961 unit_cost: Ok(value.unit_cost),
6962 unspsc: Ok(value.unspsc),
6963 url: Ok(value.url),
6964 }
6965 }
6966 }
6967 #[derive(Clone, Debug)]
6968 pub struct Itemization {
6969 car_rental: Result<Option<super::CarRental>, String>,
6970 ecommerce: Result<Option<super::Ecommerce>, String>,
6971 flight: Result<Option<super::Flight>, String>,
6972 general: Result<Option<super::GeneralItemization>, String>,
6973 lodging: Result<Option<super::Lodging>, String>,
6974 service: Result<Option<super::Service>, String>,
6975 subscription: Result<Option<super::Subscription>, String>,
6976 transit_route: Result<Option<super::TransitRoute>, String>,
6977 }
6978 impl Default for Itemization {
6979 fn default() -> Self {
6980 Self {
6981 car_rental: Ok(Default::default()),
6982 ecommerce: Ok(Default::default()),
6983 flight: Ok(Default::default()),
6984 general: Ok(Default::default()),
6985 lodging: Ok(Default::default()),
6986 service: Ok(Default::default()),
6987 subscription: Ok(Default::default()),
6988 transit_route: Ok(Default::default()),
6989 }
6990 }
6991 }
6992 impl Itemization {
6993 pub fn car_rental<T>(mut self, value: T) -> Self
6994 where
6995 T: std::convert::TryInto<Option<super::CarRental>>,
6996 T::Error: std::fmt::Display,
6997 {
6998 self.car_rental = value
6999 .try_into()
7000 .map_err(|e| format!("error converting supplied value for car_rental: {}", e));
7001 self
7002 }
7003 pub fn ecommerce<T>(mut self, value: T) -> Self
7004 where
7005 T: std::convert::TryInto<Option<super::Ecommerce>>,
7006 T::Error: std::fmt::Display,
7007 {
7008 self.ecommerce = value
7009 .try_into()
7010 .map_err(|e| format!("error converting supplied value for ecommerce: {}", e));
7011 self
7012 }
7013 pub fn flight<T>(mut self, value: T) -> Self
7014 where
7015 T: std::convert::TryInto<Option<super::Flight>>,
7016 T::Error: std::fmt::Display,
7017 {
7018 self.flight = value
7019 .try_into()
7020 .map_err(|e| format!("error converting supplied value for flight: {}", e));
7021 self
7022 }
7023 pub fn general<T>(mut self, value: T) -> Self
7024 where
7025 T: std::convert::TryInto<Option<super::GeneralItemization>>,
7026 T::Error: std::fmt::Display,
7027 {
7028 self.general = value
7029 .try_into()
7030 .map_err(|e| format!("error converting supplied value for general: {}", e));
7031 self
7032 }
7033 pub fn lodging<T>(mut self, value: T) -> Self
7034 where
7035 T: std::convert::TryInto<Option<super::Lodging>>,
7036 T::Error: std::fmt::Display,
7037 {
7038 self.lodging = value
7039 .try_into()
7040 .map_err(|e| format!("error converting supplied value for lodging: {}", e));
7041 self
7042 }
7043 pub fn service<T>(mut self, value: T) -> Self
7044 where
7045 T: std::convert::TryInto<Option<super::Service>>,
7046 T::Error: std::fmt::Display,
7047 {
7048 self.service = value
7049 .try_into()
7050 .map_err(|e| format!("error converting supplied value for service: {}", e));
7051 self
7052 }
7053 pub fn subscription<T>(mut self, value: T) -> Self
7054 where
7055 T: std::convert::TryInto<Option<super::Subscription>>,
7056 T::Error: std::fmt::Display,
7057 {
7058 self.subscription = value
7059 .try_into()
7060 .map_err(|e| format!("error converting supplied value for subscription: {}", e));
7061 self
7062 }
7063 pub fn transit_route<T>(mut self, value: T) -> Self
7064 where
7065 T: std::convert::TryInto<Option<super::TransitRoute>>,
7066 T::Error: std::fmt::Display,
7067 {
7068 self.transit_route = value
7069 .try_into()
7070 .map_err(|e| format!("error converting supplied value for transit_route: {}", e));
7071 self
7072 }
7073 }
7074 impl std::convert::TryFrom<Itemization> for super::Itemization {
7075 type Error = super::error::ConversionError;
7076 fn try_from(value: Itemization) -> Result<Self, super::error::ConversionError> {
7077 Ok(Self {
7078 car_rental: value.car_rental?,
7079 ecommerce: value.ecommerce?,
7080 flight: value.flight?,
7081 general: value.general?,
7082 lodging: value.lodging?,
7083 service: value.service?,
7084 subscription: value.subscription?,
7085 transit_route: value.transit_route?,
7086 })
7087 }
7088 }
7089 impl From<super::Itemization> for Itemization {
7090 fn from(value: super::Itemization) -> Self {
7091 Self {
7092 car_rental: Ok(value.car_rental),
7093 ecommerce: Ok(value.ecommerce),
7094 flight: Ok(value.flight),
7095 general: Ok(value.general),
7096 lodging: Ok(value.lodging),
7097 service: Ok(value.service),
7098 subscription: Ok(value.subscription),
7099 transit_route: Ok(value.transit_route),
7100 }
7101 }
7102 }
7103 #[derive(Clone, Debug)]
7104 pub struct Lodging {
7105 chain_code: Result<Option<super::LodgingChainCode>, String>,
7106 check_in: Result<i64, String>,
7107 check_out: Result<i64, String>,
7108 confirmation_number: Result<Option<String>, String>,
7109 guests: Result<Option<Vec<super::Person>>, String>,
7110 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
7111 items: Result<Vec<super::Item>, String>,
7112 location: Result<super::Place, String>,
7113 metadata: Result<Option<Vec<super::Metadatum>>, String>,
7114 property_id: Result<Option<super::LodgingPropertyId>, String>,
7115 record_locator: Result<Option<String>, String>,
7116 room: Result<Option<String>, String>,
7117 }
7118 impl Default for Lodging {
7119 fn default() -> Self {
7120 Self {
7121 chain_code: Ok(Default::default()),
7122 check_in: Err("no value supplied for check_in".to_string()),
7123 check_out: Err("no value supplied for check_out".to_string()),
7124 confirmation_number: Ok(Default::default()),
7125 guests: Ok(Default::default()),
7126 invoice_level_adjustments: Ok(Default::default()),
7127 items: Err("no value supplied for items".to_string()),
7128 location: Err("no value supplied for location".to_string()),
7129 metadata: Ok(Default::default()),
7130 property_id: Ok(Default::default()),
7131 record_locator: Ok(Default::default()),
7132 room: Ok(Default::default()),
7133 }
7134 }
7135 }
7136 impl Lodging {
7137 pub fn chain_code<T>(mut self, value: T) -> Self
7138 where
7139 T: std::convert::TryInto<Option<super::LodgingChainCode>>,
7140 T::Error: std::fmt::Display,
7141 {
7142 self.chain_code = value
7143 .try_into()
7144 .map_err(|e| format!("error converting supplied value for chain_code: {}", e));
7145 self
7146 }
7147 pub fn check_in<T>(mut self, value: T) -> Self
7148 where
7149 T: std::convert::TryInto<i64>,
7150 T::Error: std::fmt::Display,
7151 {
7152 self.check_in = value
7153 .try_into()
7154 .map_err(|e| format!("error converting supplied value for check_in: {}", e));
7155 self
7156 }
7157 pub fn check_out<T>(mut self, value: T) -> Self
7158 where
7159 T: std::convert::TryInto<i64>,
7160 T::Error: std::fmt::Display,
7161 {
7162 self.check_out = value
7163 .try_into()
7164 .map_err(|e| format!("error converting supplied value for check_out: {}", e));
7165 self
7166 }
7167 pub fn confirmation_number<T>(mut self, value: T) -> Self
7168 where
7169 T: std::convert::TryInto<Option<String>>,
7170 T::Error: std::fmt::Display,
7171 {
7172 self.confirmation_number = value.try_into().map_err(|e| {
7173 format!(
7174 "error converting supplied value for confirmation_number: {}",
7175 e
7176 )
7177 });
7178 self
7179 }
7180 pub fn guests<T>(mut self, value: T) -> Self
7181 where
7182 T: std::convert::TryInto<Option<Vec<super::Person>>>,
7183 T::Error: std::fmt::Display,
7184 {
7185 self.guests = value
7186 .try_into()
7187 .map_err(|e| format!("error converting supplied value for guests: {}", e));
7188 self
7189 }
7190 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
7191 where
7192 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
7193 T::Error: std::fmt::Display,
7194 {
7195 self.invoice_level_adjustments = value.try_into().map_err(|e| {
7196 format!(
7197 "error converting supplied value for invoice_level_adjustments: {}",
7198 e
7199 )
7200 });
7201 self
7202 }
7203 pub fn items<T>(mut self, value: T) -> Self
7204 where
7205 T: std::convert::TryInto<Vec<super::Item>>,
7206 T::Error: std::fmt::Display,
7207 {
7208 self.items = value
7209 .try_into()
7210 .map_err(|e| format!("error converting supplied value for items: {}", e));
7211 self
7212 }
7213 pub fn location<T>(mut self, value: T) -> Self
7214 where
7215 T: std::convert::TryInto<super::Place>,
7216 T::Error: std::fmt::Display,
7217 {
7218 self.location = value
7219 .try_into()
7220 .map_err(|e| format!("error converting supplied value for location: {}", e));
7221 self
7222 }
7223 pub fn metadata<T>(mut self, value: T) -> Self
7224 where
7225 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
7226 T::Error: std::fmt::Display,
7227 {
7228 self.metadata = value
7229 .try_into()
7230 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
7231 self
7232 }
7233 pub fn property_id<T>(mut self, value: T) -> Self
7234 where
7235 T: std::convert::TryInto<Option<super::LodgingPropertyId>>,
7236 T::Error: std::fmt::Display,
7237 {
7238 self.property_id = value
7239 .try_into()
7240 .map_err(|e| format!("error converting supplied value for property_id: {}", e));
7241 self
7242 }
7243 pub fn record_locator<T>(mut self, value: T) -> Self
7244 where
7245 T: std::convert::TryInto<Option<String>>,
7246 T::Error: std::fmt::Display,
7247 {
7248 self.record_locator = value
7249 .try_into()
7250 .map_err(|e| format!("error converting supplied value for record_locator: {}", e));
7251 self
7252 }
7253 pub fn room<T>(mut self, value: T) -> Self
7254 where
7255 T: std::convert::TryInto<Option<String>>,
7256 T::Error: std::fmt::Display,
7257 {
7258 self.room = value
7259 .try_into()
7260 .map_err(|e| format!("error converting supplied value for room: {}", e));
7261 self
7262 }
7263 }
7264 impl std::convert::TryFrom<Lodging> for super::Lodging {
7265 type Error = super::error::ConversionError;
7266 fn try_from(value: Lodging) -> Result<Self, super::error::ConversionError> {
7267 Ok(Self {
7268 chain_code: value.chain_code?,
7269 check_in: value.check_in?,
7270 check_out: value.check_out?,
7271 confirmation_number: value.confirmation_number?,
7272 guests: value.guests?,
7273 invoice_level_adjustments: value.invoice_level_adjustments?,
7274 items: value.items?,
7275 location: value.location?,
7276 metadata: value.metadata?,
7277 property_id: value.property_id?,
7278 record_locator: value.record_locator?,
7279 room: value.room?,
7280 })
7281 }
7282 }
7283 impl From<super::Lodging> for Lodging {
7284 fn from(value: super::Lodging) -> Self {
7285 Self {
7286 chain_code: Ok(value.chain_code),
7287 check_in: Ok(value.check_in),
7288 check_out: Ok(value.check_out),
7289 confirmation_number: Ok(value.confirmation_number),
7290 guests: Ok(value.guests),
7291 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
7292 items: Ok(value.items),
7293 location: Ok(value.location),
7294 metadata: Ok(value.metadata),
7295 property_id: Ok(value.property_id),
7296 record_locator: Ok(value.record_locator),
7297 room: Ok(value.room),
7298 }
7299 }
7300 }
7301 #[derive(Clone, Debug)]
7302 pub struct Metadatum {
7303 key: Result<String, String>,
7304 value: Result<String, String>,
7305 }
7306 impl Default for Metadatum {
7307 fn default() -> Self {
7308 Self {
7309 key: Err("no value supplied for key".to_string()),
7310 value: Err("no value supplied for value".to_string()),
7311 }
7312 }
7313 }
7314 impl Metadatum {
7315 pub fn key<T>(mut self, value: T) -> Self
7316 where
7317 T: std::convert::TryInto<String>,
7318 T::Error: std::fmt::Display,
7319 {
7320 self.key = value
7321 .try_into()
7322 .map_err(|e| format!("error converting supplied value for key: {}", e));
7323 self
7324 }
7325 pub fn value<T>(mut self, value: T) -> Self
7326 where
7327 T: std::convert::TryInto<String>,
7328 T::Error: std::fmt::Display,
7329 {
7330 self.value = value
7331 .try_into()
7332 .map_err(|e| format!("error converting supplied value for value: {}", e));
7333 self
7334 }
7335 }
7336 impl std::convert::TryFrom<Metadatum> for super::Metadatum {
7337 type Error = super::error::ConversionError;
7338 fn try_from(value: Metadatum) -> Result<Self, super::error::ConversionError> {
7339 Ok(Self {
7340 key: value.key?,
7341 value: value.value?,
7342 })
7343 }
7344 }
7345 impl From<super::Metadatum> for Metadatum {
7346 fn from(value: super::Metadatum) -> Self {
7347 Self {
7348 key: Ok(value.key),
7349 value: Ok(value.value),
7350 }
7351 }
7352 }
7353 #[derive(Clone, Debug)]
7354 pub struct Org {
7355 address: Result<Option<super::Address>, String>,
7356 brand_color: Result<Option<super::OrgBrandColor>, String>,
7357 legal_name: Result<Option<String>, String>,
7358 logo: Result<Option<String>, String>,
7359 logo_asset_id: Result<Option<String>, String>,
7360 name: Result<String, String>,
7361 vat_number: Result<Option<String>, String>,
7362 website: Result<Option<String>, String>,
7363 }
7364 impl Default for Org {
7365 fn default() -> Self {
7366 Self {
7367 address: Ok(Default::default()),
7368 brand_color: Ok(Default::default()),
7369 legal_name: Ok(Default::default()),
7370 logo: Ok(Default::default()),
7371 logo_asset_id: Ok(Default::default()),
7372 name: Err("no value supplied for name".to_string()),
7373 vat_number: Ok(Default::default()),
7374 website: Ok(Default::default()),
7375 }
7376 }
7377 }
7378 impl Org {
7379 pub fn address<T>(mut self, value: T) -> Self
7380 where
7381 T: std::convert::TryInto<Option<super::Address>>,
7382 T::Error: std::fmt::Display,
7383 {
7384 self.address = value
7385 .try_into()
7386 .map_err(|e| format!("error converting supplied value for address: {}", e));
7387 self
7388 }
7389 pub fn brand_color<T>(mut self, value: T) -> Self
7390 where
7391 T: std::convert::TryInto<Option<super::OrgBrandColor>>,
7392 T::Error: std::fmt::Display,
7393 {
7394 self.brand_color = value
7395 .try_into()
7396 .map_err(|e| format!("error converting supplied value for brand_color: {}", e));
7397 self
7398 }
7399 pub fn legal_name<T>(mut self, value: T) -> Self
7400 where
7401 T: std::convert::TryInto<Option<String>>,
7402 T::Error: std::fmt::Display,
7403 {
7404 self.legal_name = value
7405 .try_into()
7406 .map_err(|e| format!("error converting supplied value for legal_name: {}", e));
7407 self
7408 }
7409 pub fn logo<T>(mut self, value: T) -> Self
7410 where
7411 T: std::convert::TryInto<Option<String>>,
7412 T::Error: std::fmt::Display,
7413 {
7414 self.logo = value
7415 .try_into()
7416 .map_err(|e| format!("error converting supplied value for logo: {}", e));
7417 self
7418 }
7419 pub fn logo_asset_id<T>(mut self, value: T) -> Self
7420 where
7421 T: std::convert::TryInto<Option<String>>,
7422 T::Error: std::fmt::Display,
7423 {
7424 self.logo_asset_id = value
7425 .try_into()
7426 .map_err(|e| format!("error converting supplied value for logo_asset_id: {}", e));
7427 self
7428 }
7429 pub fn name<T>(mut self, value: T) -> Self
7430 where
7431 T: std::convert::TryInto<String>,
7432 T::Error: std::fmt::Display,
7433 {
7434 self.name = value
7435 .try_into()
7436 .map_err(|e| format!("error converting supplied value for name: {}", e));
7437 self
7438 }
7439 pub fn vat_number<T>(mut self, value: T) -> Self
7440 where
7441 T: std::convert::TryInto<Option<String>>,
7442 T::Error: std::fmt::Display,
7443 {
7444 self.vat_number = value
7445 .try_into()
7446 .map_err(|e| format!("error converting supplied value for vat_number: {}", e));
7447 self
7448 }
7449 pub fn website<T>(mut self, value: T) -> Self
7450 where
7451 T: std::convert::TryInto<Option<String>>,
7452 T::Error: std::fmt::Display,
7453 {
7454 self.website = value
7455 .try_into()
7456 .map_err(|e| format!("error converting supplied value for website: {}", e));
7457 self
7458 }
7459 }
7460 impl std::convert::TryFrom<Org> for super::Org {
7461 type Error = super::error::ConversionError;
7462 fn try_from(value: Org) -> Result<Self, super::error::ConversionError> {
7463 Ok(Self {
7464 address: value.address?,
7465 brand_color: value.brand_color?,
7466 legal_name: value.legal_name?,
7467 logo: value.logo?,
7468 logo_asset_id: value.logo_asset_id?,
7469 name: value.name?,
7470 vat_number: value.vat_number?,
7471 website: value.website?,
7472 })
7473 }
7474 }
7475 impl From<super::Org> for Org {
7476 fn from(value: super::Org) -> Self {
7477 Self {
7478 address: Ok(value.address),
7479 brand_color: Ok(value.brand_color),
7480 legal_name: Ok(value.legal_name),
7481 logo: Ok(value.logo),
7482 logo_asset_id: Ok(value.logo_asset_id),
7483 name: Ok(value.name),
7484 vat_number: Ok(value.vat_number),
7485 website: Ok(value.website),
7486 }
7487 }
7488 }
7489 #[derive(Clone, Debug)]
7490 pub struct Payment {
7491 ach_payment: Result<Option<super::AchPayment>, String>,
7492 amount: Result<i64, String>,
7493 card_payment: Result<Option<super::CardPayment>, String>,
7494 paid_at: Result<i64, String>,
7495 payment_type: Result<Option<super::PaymentPaymentType>, String>,
7496 }
7497 impl Default for Payment {
7498 fn default() -> Self {
7499 Self {
7500 ach_payment: Ok(Default::default()),
7501 amount: Err("no value supplied for amount".to_string()),
7502 card_payment: Ok(Default::default()),
7503 paid_at: Err("no value supplied for paid_at".to_string()),
7504 payment_type: Ok(Default::default()),
7505 }
7506 }
7507 }
7508 impl Payment {
7509 pub fn ach_payment<T>(mut self, value: T) -> Self
7510 where
7511 T: std::convert::TryInto<Option<super::AchPayment>>,
7512 T::Error: std::fmt::Display,
7513 {
7514 self.ach_payment = value
7515 .try_into()
7516 .map_err(|e| format!("error converting supplied value for ach_payment: {}", e));
7517 self
7518 }
7519 pub fn amount<T>(mut self, value: T) -> Self
7520 where
7521 T: std::convert::TryInto<i64>,
7522 T::Error: std::fmt::Display,
7523 {
7524 self.amount = value
7525 .try_into()
7526 .map_err(|e| format!("error converting supplied value for amount: {}", e));
7527 self
7528 }
7529 pub fn card_payment<T>(mut self, value: T) -> Self
7530 where
7531 T: std::convert::TryInto<Option<super::CardPayment>>,
7532 T::Error: std::fmt::Display,
7533 {
7534 self.card_payment = value
7535 .try_into()
7536 .map_err(|e| format!("error converting supplied value for card_payment: {}", e));
7537 self
7538 }
7539 pub fn paid_at<T>(mut self, value: T) -> Self
7540 where
7541 T: std::convert::TryInto<i64>,
7542 T::Error: std::fmt::Display,
7543 {
7544 self.paid_at = value
7545 .try_into()
7546 .map_err(|e| format!("error converting supplied value for paid_at: {}", e));
7547 self
7548 }
7549 pub fn payment_type<T>(mut self, value: T) -> Self
7550 where
7551 T: std::convert::TryInto<Option<super::PaymentPaymentType>>,
7552 T::Error: std::fmt::Display,
7553 {
7554 self.payment_type = value
7555 .try_into()
7556 .map_err(|e| format!("error converting supplied value for payment_type: {}", e));
7557 self
7558 }
7559 }
7560 impl std::convert::TryFrom<Payment> for super::Payment {
7561 type Error = super::error::ConversionError;
7562 fn try_from(value: Payment) -> Result<Self, super::error::ConversionError> {
7563 Ok(Self {
7564 ach_payment: value.ach_payment?,
7565 amount: value.amount?,
7566 card_payment: value.card_payment?,
7567 paid_at: value.paid_at?,
7568 payment_type: value.payment_type?,
7569 })
7570 }
7571 }
7572 impl From<super::Payment> for Payment {
7573 fn from(value: super::Payment) -> Self {
7574 Self {
7575 ach_payment: Ok(value.ach_payment),
7576 amount: Ok(value.amount),
7577 card_payment: Ok(value.card_payment),
7578 paid_at: Ok(value.paid_at),
7579 payment_type: Ok(value.payment_type),
7580 }
7581 }
7582 }
7583 #[derive(Clone, Debug)]
7584 pub struct Person {
7585 email: Result<Option<String>, String>,
7586 first_name: Result<Option<String>, String>,
7587 last_name: Result<Option<String>, String>,
7588 metadata: Result<Option<Vec<super::Metadatum>>, String>,
7589 phone: Result<Option<super::PersonPhone>, String>,
7590 preferred_first_name: Result<Option<String>, String>,
7591 }
7592 impl Default for Person {
7593 fn default() -> Self {
7594 Self {
7595 email: Ok(Default::default()),
7596 first_name: Ok(Default::default()),
7597 last_name: Ok(Default::default()),
7598 metadata: Ok(Default::default()),
7599 phone: Ok(Default::default()),
7600 preferred_first_name: Ok(Default::default()),
7601 }
7602 }
7603 }
7604 impl Person {
7605 pub fn email<T>(mut self, value: T) -> Self
7606 where
7607 T: std::convert::TryInto<Option<String>>,
7608 T::Error: std::fmt::Display,
7609 {
7610 self.email = value
7611 .try_into()
7612 .map_err(|e| format!("error converting supplied value for email: {}", e));
7613 self
7614 }
7615 pub fn first_name<T>(mut self, value: T) -> Self
7616 where
7617 T: std::convert::TryInto<Option<String>>,
7618 T::Error: std::fmt::Display,
7619 {
7620 self.first_name = value
7621 .try_into()
7622 .map_err(|e| format!("error converting supplied value for first_name: {}", e));
7623 self
7624 }
7625 pub fn last_name<T>(mut self, value: T) -> Self
7626 where
7627 T: std::convert::TryInto<Option<String>>,
7628 T::Error: std::fmt::Display,
7629 {
7630 self.last_name = value
7631 .try_into()
7632 .map_err(|e| format!("error converting supplied value for last_name: {}", e));
7633 self
7634 }
7635 pub fn metadata<T>(mut self, value: T) -> Self
7636 where
7637 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
7638 T::Error: std::fmt::Display,
7639 {
7640 self.metadata = value
7641 .try_into()
7642 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
7643 self
7644 }
7645 pub fn phone<T>(mut self, value: T) -> Self
7646 where
7647 T: std::convert::TryInto<Option<super::PersonPhone>>,
7648 T::Error: std::fmt::Display,
7649 {
7650 self.phone = value
7651 .try_into()
7652 .map_err(|e| format!("error converting supplied value for phone: {}", e));
7653 self
7654 }
7655 pub fn preferred_first_name<T>(mut self, value: T) -> Self
7656 where
7657 T: std::convert::TryInto<Option<String>>,
7658 T::Error: std::fmt::Display,
7659 {
7660 self.preferred_first_name = value.try_into().map_err(|e| {
7661 format!(
7662 "error converting supplied value for preferred_first_name: {}",
7663 e
7664 )
7665 });
7666 self
7667 }
7668 }
7669 impl std::convert::TryFrom<Person> for super::Person {
7670 type Error = super::error::ConversionError;
7671 fn try_from(value: Person) -> Result<Self, super::error::ConversionError> {
7672 Ok(Self {
7673 email: value.email?,
7674 first_name: value.first_name?,
7675 last_name: value.last_name?,
7676 metadata: value.metadata?,
7677 phone: value.phone?,
7678 preferred_first_name: value.preferred_first_name?,
7679 })
7680 }
7681 }
7682 impl From<super::Person> for Person {
7683 fn from(value: super::Person) -> Self {
7684 Self {
7685 email: Ok(value.email),
7686 first_name: Ok(value.first_name),
7687 last_name: Ok(value.last_name),
7688 metadata: Ok(value.metadata),
7689 phone: Ok(value.phone),
7690 preferred_first_name: Ok(value.preferred_first_name),
7691 }
7692 }
7693 }
7694 #[derive(Clone, Debug)]
7695 pub struct Place {
7696 address: Result<Option<super::Address>, String>,
7697 google_place_id: Result<Option<String>, String>,
7698 image: Result<Option<String>, String>,
7699 name: Result<Option<String>, String>,
7700 phone: Result<Option<super::PlacePhone>, String>,
7701 url: Result<Option<String>, String>,
7702 }
7703 impl Default for Place {
7704 fn default() -> Self {
7705 Self {
7706 address: Ok(Default::default()),
7707 google_place_id: Ok(Default::default()),
7708 image: Ok(Default::default()),
7709 name: Ok(Default::default()),
7710 phone: Ok(Default::default()),
7711 url: Ok(Default::default()),
7712 }
7713 }
7714 }
7715 impl Place {
7716 pub fn address<T>(mut self, value: T) -> Self
7717 where
7718 T: std::convert::TryInto<Option<super::Address>>,
7719 T::Error: std::fmt::Display,
7720 {
7721 self.address = value
7722 .try_into()
7723 .map_err(|e| format!("error converting supplied value for address: {}", e));
7724 self
7725 }
7726 pub fn google_place_id<T>(mut self, value: T) -> Self
7727 where
7728 T: std::convert::TryInto<Option<String>>,
7729 T::Error: std::fmt::Display,
7730 {
7731 self.google_place_id = value
7732 .try_into()
7733 .map_err(|e| format!("error converting supplied value for google_place_id: {}", e));
7734 self
7735 }
7736 pub fn image<T>(mut self, value: T) -> Self
7737 where
7738 T: std::convert::TryInto<Option<String>>,
7739 T::Error: std::fmt::Display,
7740 {
7741 self.image = value
7742 .try_into()
7743 .map_err(|e| format!("error converting supplied value for image: {}", e));
7744 self
7745 }
7746 pub fn name<T>(mut self, value: T) -> Self
7747 where
7748 T: std::convert::TryInto<Option<String>>,
7749 T::Error: std::fmt::Display,
7750 {
7751 self.name = value
7752 .try_into()
7753 .map_err(|e| format!("error converting supplied value for name: {}", e));
7754 self
7755 }
7756 pub fn phone<T>(mut self, value: T) -> Self
7757 where
7758 T: std::convert::TryInto<Option<super::PlacePhone>>,
7759 T::Error: std::fmt::Display,
7760 {
7761 self.phone = value
7762 .try_into()
7763 .map_err(|e| format!("error converting supplied value for phone: {}", e));
7764 self
7765 }
7766 pub fn url<T>(mut self, value: T) -> Self
7767 where
7768 T: std::convert::TryInto<Option<String>>,
7769 T::Error: std::fmt::Display,
7770 {
7771 self.url = value
7772 .try_into()
7773 .map_err(|e| format!("error converting supplied value for url: {}", e));
7774 self
7775 }
7776 }
7777 impl std::convert::TryFrom<Place> for super::Place {
7778 type Error = super::error::ConversionError;
7779 fn try_from(value: Place) -> Result<Self, super::error::ConversionError> {
7780 Ok(Self {
7781 address: value.address?,
7782 google_place_id: value.google_place_id?,
7783 image: value.image?,
7784 name: value.name?,
7785 phone: value.phone?,
7786 url: value.url?,
7787 })
7788 }
7789 }
7790 impl From<super::Place> for Place {
7791 fn from(value: super::Place) -> Self {
7792 Self {
7793 address: Ok(value.address),
7794 google_place_id: Ok(value.google_place_id),
7795 image: Ok(value.image),
7796 name: Ok(value.name),
7797 phone: Ok(value.phone),
7798 url: Ok(value.url),
7799 }
7800 }
7801 }
7802 #[derive(Clone, Debug)]
7803 pub struct Receipt {
7804 footer: Result<super::Footer, String>,
7805 header: Result<super::Header, String>,
7806 itemization: Result<super::Itemization, String>,
7807 payments: Result<Vec<super::Payment>, String>,
7808 schema_version: Result<super::SchemaVersion, String>,
7809 }
7810 impl Default for Receipt {
7811 fn default() -> Self {
7812 Self {
7813 footer: Err("no value supplied for footer".to_string()),
7814 header: Err("no value supplied for header".to_string()),
7815 itemization: Err("no value supplied for itemization".to_string()),
7816 payments: Err("no value supplied for payments".to_string()),
7817 schema_version: Err("no value supplied for schema_version".to_string()),
7818 }
7819 }
7820 }
7821 impl Receipt {
7822 pub fn footer<T>(mut self, value: T) -> Self
7823 where
7824 T: std::convert::TryInto<super::Footer>,
7825 T::Error: std::fmt::Display,
7826 {
7827 self.footer = value
7828 .try_into()
7829 .map_err(|e| format!("error converting supplied value for footer: {}", e));
7830 self
7831 }
7832 pub fn header<T>(mut self, value: T) -> Self
7833 where
7834 T: std::convert::TryInto<super::Header>,
7835 T::Error: std::fmt::Display,
7836 {
7837 self.header = value
7838 .try_into()
7839 .map_err(|e| format!("error converting supplied value for header: {}", e));
7840 self
7841 }
7842 pub fn itemization<T>(mut self, value: T) -> Self
7843 where
7844 T: std::convert::TryInto<super::Itemization>,
7845 T::Error: std::fmt::Display,
7846 {
7847 self.itemization = value
7848 .try_into()
7849 .map_err(|e| format!("error converting supplied value for itemization: {}", e));
7850 self
7851 }
7852 pub fn payments<T>(mut self, value: T) -> Self
7853 where
7854 T: std::convert::TryInto<Vec<super::Payment>>,
7855 T::Error: std::fmt::Display,
7856 {
7857 self.payments = value
7858 .try_into()
7859 .map_err(|e| format!("error converting supplied value for payments: {}", e));
7860 self
7861 }
7862 pub fn schema_version<T>(mut self, value: T) -> Self
7863 where
7864 T: std::convert::TryInto<super::SchemaVersion>,
7865 T::Error: std::fmt::Display,
7866 {
7867 self.schema_version = value
7868 .try_into()
7869 .map_err(|e| format!("error converting supplied value for schema_version: {}", e));
7870 self
7871 }
7872 }
7873 impl std::convert::TryFrom<Receipt> for super::Receipt {
7874 type Error = super::error::ConversionError;
7875 fn try_from(value: Receipt) -> Result<Self, super::error::ConversionError> {
7876 Ok(Self {
7877 footer: value.footer?,
7878 header: value.header?,
7879 itemization: value.itemization?,
7880 payments: value.payments?,
7881 schema_version: value.schema_version?,
7882 })
7883 }
7884 }
7885 impl From<super::Receipt> for Receipt {
7886 fn from(value: super::Receipt) -> Self {
7887 Self {
7888 footer: Ok(value.footer),
7889 header: Ok(value.header),
7890 itemization: Ok(value.itemization),
7891 payments: Ok(value.payments),
7892 schema_version: Ok(value.schema_version),
7893 }
7894 }
7895 }
7896 #[derive(Clone, Debug)]
7897 pub struct Service {
7898 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
7899 service_items: Result<Vec<super::ServiceItem>, String>,
7900 }
7901 impl Default for Service {
7902 fn default() -> Self {
7903 Self {
7904 invoice_level_adjustments: Ok(Default::default()),
7905 service_items: Err("no value supplied for service_items".to_string()),
7906 }
7907 }
7908 }
7909 impl Service {
7910 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
7911 where
7912 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
7913 T::Error: std::fmt::Display,
7914 {
7915 self.invoice_level_adjustments = value.try_into().map_err(|e| {
7916 format!(
7917 "error converting supplied value for invoice_level_adjustments: {}",
7918 e
7919 )
7920 });
7921 self
7922 }
7923 pub fn service_items<T>(mut self, value: T) -> Self
7924 where
7925 T: std::convert::TryInto<Vec<super::ServiceItem>>,
7926 T::Error: std::fmt::Display,
7927 {
7928 self.service_items = value
7929 .try_into()
7930 .map_err(|e| format!("error converting supplied value for service_items: {}", e));
7931 self
7932 }
7933 }
7934 impl std::convert::TryFrom<Service> for super::Service {
7935 type Error = super::error::ConversionError;
7936 fn try_from(value: Service) -> Result<Self, super::error::ConversionError> {
7937 Ok(Self {
7938 invoice_level_adjustments: value.invoice_level_adjustments?,
7939 service_items: value.service_items?,
7940 })
7941 }
7942 }
7943 impl From<super::Service> for Service {
7944 fn from(value: super::Service) -> Self {
7945 Self {
7946 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
7947 service_items: Ok(value.service_items),
7948 }
7949 }
7950 }
7951 #[derive(Clone, Debug)]
7952 pub struct ServiceItem {
7953 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
7954 amount: Result<i64, String>,
7955 current_period_end_at: Result<Option<i64>, String>,
7956 current_period_start_at: Result<Option<i64>, String>,
7957 description: Result<String, String>,
7958 interval: Result<Option<super::Interval>, String>,
7959 interval_count: Result<Option<i64>, String>,
7960 metadata: Result<Option<Vec<super::Metadatum>>, String>,
7961 quantity: Result<Option<f64>, String>,
7962 recurring: Result<bool, String>,
7963 service_location: Result<Option<super::Place>, String>,
7964 taxes: Result<Option<Vec<super::Tax>>, String>,
7965 unit_cost: Result<Option<f64>, String>,
7966 }
7967 impl Default for ServiceItem {
7968 fn default() -> Self {
7969 Self {
7970 adjustments: Ok(Default::default()),
7971 amount: Err("no value supplied for amount".to_string()),
7972 current_period_end_at: Ok(Default::default()),
7973 current_period_start_at: Ok(Default::default()),
7974 description: Err("no value supplied for description".to_string()),
7975 interval: Ok(Default::default()),
7976 interval_count: Ok(Default::default()),
7977 metadata: Ok(Default::default()),
7978 quantity: Ok(Default::default()),
7979 recurring: Err("no value supplied for recurring".to_string()),
7980 service_location: Ok(Default::default()),
7981 taxes: Ok(Default::default()),
7982 unit_cost: Ok(Default::default()),
7983 }
7984 }
7985 }
7986 impl ServiceItem {
7987 pub fn adjustments<T>(mut self, value: T) -> Self
7988 where
7989 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
7990 T::Error: std::fmt::Display,
7991 {
7992 self.adjustments = value
7993 .try_into()
7994 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
7995 self
7996 }
7997 pub fn amount<T>(mut self, value: T) -> Self
7998 where
7999 T: std::convert::TryInto<i64>,
8000 T::Error: std::fmt::Display,
8001 {
8002 self.amount = value
8003 .try_into()
8004 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8005 self
8006 }
8007 pub fn current_period_end_at<T>(mut self, value: T) -> Self
8008 where
8009 T: std::convert::TryInto<Option<i64>>,
8010 T::Error: std::fmt::Display,
8011 {
8012 self.current_period_end_at = value.try_into().map_err(|e| {
8013 format!(
8014 "error converting supplied value for current_period_end_at: {}",
8015 e
8016 )
8017 });
8018 self
8019 }
8020 pub fn current_period_start_at<T>(mut self, value: T) -> Self
8021 where
8022 T: std::convert::TryInto<Option<i64>>,
8023 T::Error: std::fmt::Display,
8024 {
8025 self.current_period_start_at = value.try_into().map_err(|e| {
8026 format!(
8027 "error converting supplied value for current_period_start_at: {}",
8028 e
8029 )
8030 });
8031 self
8032 }
8033 pub fn description<T>(mut self, value: T) -> Self
8034 where
8035 T: std::convert::TryInto<String>,
8036 T::Error: std::fmt::Display,
8037 {
8038 self.description = value
8039 .try_into()
8040 .map_err(|e| format!("error converting supplied value for description: {}", e));
8041 self
8042 }
8043 pub fn interval<T>(mut self, value: T) -> Self
8044 where
8045 T: std::convert::TryInto<Option<super::Interval>>,
8046 T::Error: std::fmt::Display,
8047 {
8048 self.interval = value
8049 .try_into()
8050 .map_err(|e| format!("error converting supplied value for interval: {}", e));
8051 self
8052 }
8053 pub fn interval_count<T>(mut self, value: T) -> Self
8054 where
8055 T: std::convert::TryInto<Option<i64>>,
8056 T::Error: std::fmt::Display,
8057 {
8058 self.interval_count = value
8059 .try_into()
8060 .map_err(|e| format!("error converting supplied value for interval_count: {}", e));
8061 self
8062 }
8063 pub fn metadata<T>(mut self, value: T) -> Self
8064 where
8065 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8066 T::Error: std::fmt::Display,
8067 {
8068 self.metadata = value
8069 .try_into()
8070 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8071 self
8072 }
8073 pub fn quantity<T>(mut self, value: T) -> Self
8074 where
8075 T: std::convert::TryInto<Option<f64>>,
8076 T::Error: std::fmt::Display,
8077 {
8078 self.quantity = value
8079 .try_into()
8080 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
8081 self
8082 }
8083 pub fn recurring<T>(mut self, value: T) -> Self
8084 where
8085 T: std::convert::TryInto<bool>,
8086 T::Error: std::fmt::Display,
8087 {
8088 self.recurring = value
8089 .try_into()
8090 .map_err(|e| format!("error converting supplied value for recurring: {}", e));
8091 self
8092 }
8093 pub fn service_location<T>(mut self, value: T) -> Self
8094 where
8095 T: std::convert::TryInto<Option<super::Place>>,
8096 T::Error: std::fmt::Display,
8097 {
8098 self.service_location = value.try_into().map_err(|e| {
8099 format!(
8100 "error converting supplied value for service_location: {}",
8101 e
8102 )
8103 });
8104 self
8105 }
8106 pub fn taxes<T>(mut self, value: T) -> Self
8107 where
8108 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8109 T::Error: std::fmt::Display,
8110 {
8111 self.taxes = value
8112 .try_into()
8113 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8114 self
8115 }
8116 pub fn unit_cost<T>(mut self, value: T) -> Self
8117 where
8118 T: std::convert::TryInto<Option<f64>>,
8119 T::Error: std::fmt::Display,
8120 {
8121 self.unit_cost = value
8122 .try_into()
8123 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
8124 self
8125 }
8126 }
8127 impl std::convert::TryFrom<ServiceItem> for super::ServiceItem {
8128 type Error = super::error::ConversionError;
8129 fn try_from(value: ServiceItem) -> Result<Self, super::error::ConversionError> {
8130 Ok(Self {
8131 adjustments: value.adjustments?,
8132 amount: value.amount?,
8133 current_period_end_at: value.current_period_end_at?,
8134 current_period_start_at: value.current_period_start_at?,
8135 description: value.description?,
8136 interval: value.interval?,
8137 interval_count: value.interval_count?,
8138 metadata: value.metadata?,
8139 quantity: value.quantity?,
8140 recurring: value.recurring?,
8141 service_location: value.service_location?,
8142 taxes: value.taxes?,
8143 unit_cost: value.unit_cost?,
8144 })
8145 }
8146 }
8147 impl From<super::ServiceItem> for ServiceItem {
8148 fn from(value: super::ServiceItem) -> Self {
8149 Self {
8150 adjustments: Ok(value.adjustments),
8151 amount: Ok(value.amount),
8152 current_period_end_at: Ok(value.current_period_end_at),
8153 current_period_start_at: Ok(value.current_period_start_at),
8154 description: Ok(value.description),
8155 interval: Ok(value.interval),
8156 interval_count: Ok(value.interval_count),
8157 metadata: Ok(value.metadata),
8158 quantity: Ok(value.quantity),
8159 recurring: Ok(value.recurring),
8160 service_location: Ok(value.service_location),
8161 taxes: Ok(value.taxes),
8162 unit_cost: Ok(value.unit_cost),
8163 }
8164 }
8165 }
8166 #[derive(Clone, Debug)]
8167 pub struct Shipment {
8168 carrier: Result<Option<String>, String>,
8169 destination_address: Result<Option<super::Address>, String>,
8170 expected_delivery_at: Result<Option<i64>, String>,
8171 items: Result<Vec<super::Item>, String>,
8172 shipment_status: Result<Option<super::ShipmentShipmentStatus>, String>,
8173 tracking_number: Result<Option<String>, String>,
8174 }
8175 impl Default for Shipment {
8176 fn default() -> Self {
8177 Self {
8178 carrier: Ok(Default::default()),
8179 destination_address: Ok(Default::default()),
8180 expected_delivery_at: Ok(Default::default()),
8181 items: Err("no value supplied for items".to_string()),
8182 shipment_status: Ok(Default::default()),
8183 tracking_number: Ok(Default::default()),
8184 }
8185 }
8186 }
8187 impl Shipment {
8188 pub fn carrier<T>(mut self, value: T) -> Self
8189 where
8190 T: std::convert::TryInto<Option<String>>,
8191 T::Error: std::fmt::Display,
8192 {
8193 self.carrier = value
8194 .try_into()
8195 .map_err(|e| format!("error converting supplied value for carrier: {}", e));
8196 self
8197 }
8198 pub fn destination_address<T>(mut self, value: T) -> Self
8199 where
8200 T: std::convert::TryInto<Option<super::Address>>,
8201 T::Error: std::fmt::Display,
8202 {
8203 self.destination_address = value.try_into().map_err(|e| {
8204 format!(
8205 "error converting supplied value for destination_address: {}",
8206 e
8207 )
8208 });
8209 self
8210 }
8211 pub fn expected_delivery_at<T>(mut self, value: T) -> Self
8212 where
8213 T: std::convert::TryInto<Option<i64>>,
8214 T::Error: std::fmt::Display,
8215 {
8216 self.expected_delivery_at = value.try_into().map_err(|e| {
8217 format!(
8218 "error converting supplied value for expected_delivery_at: {}",
8219 e
8220 )
8221 });
8222 self
8223 }
8224 pub fn items<T>(mut self, value: T) -> Self
8225 where
8226 T: std::convert::TryInto<Vec<super::Item>>,
8227 T::Error: std::fmt::Display,
8228 {
8229 self.items = value
8230 .try_into()
8231 .map_err(|e| format!("error converting supplied value for items: {}", e));
8232 self
8233 }
8234 pub fn shipment_status<T>(mut self, value: T) -> Self
8235 where
8236 T: std::convert::TryInto<Option<super::ShipmentShipmentStatus>>,
8237 T::Error: std::fmt::Display,
8238 {
8239 self.shipment_status = value
8240 .try_into()
8241 .map_err(|e| format!("error converting supplied value for shipment_status: {}", e));
8242 self
8243 }
8244 pub fn tracking_number<T>(mut self, value: T) -> Self
8245 where
8246 T: std::convert::TryInto<Option<String>>,
8247 T::Error: std::fmt::Display,
8248 {
8249 self.tracking_number = value
8250 .try_into()
8251 .map_err(|e| format!("error converting supplied value for tracking_number: {}", e));
8252 self
8253 }
8254 }
8255 impl std::convert::TryFrom<Shipment> for super::Shipment {
8256 type Error = super::error::ConversionError;
8257 fn try_from(value: Shipment) -> Result<Self, super::error::ConversionError> {
8258 Ok(Self {
8259 carrier: value.carrier?,
8260 destination_address: value.destination_address?,
8261 expected_delivery_at: value.expected_delivery_at?,
8262 items: value.items?,
8263 shipment_status: value.shipment_status?,
8264 tracking_number: value.tracking_number?,
8265 })
8266 }
8267 }
8268 impl From<super::Shipment> for Shipment {
8269 fn from(value: super::Shipment) -> Self {
8270 Self {
8271 carrier: Ok(value.carrier),
8272 destination_address: Ok(value.destination_address),
8273 expected_delivery_at: Ok(value.expected_delivery_at),
8274 items: Ok(value.items),
8275 shipment_status: Ok(value.shipment_status),
8276 tracking_number: Ok(value.tracking_number),
8277 }
8278 }
8279 }
8280 #[derive(Clone, Debug)]
8281 pub struct Subscription {
8282 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8283 subscription_items: Result<Vec<super::SubscriptionItem>, String>,
8284 }
8285 impl Default for Subscription {
8286 fn default() -> Self {
8287 Self {
8288 invoice_level_adjustments: Ok(Default::default()),
8289 subscription_items: Err("no value supplied for subscription_items".to_string()),
8290 }
8291 }
8292 }
8293 impl Subscription {
8294 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
8295 where
8296 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8297 T::Error: std::fmt::Display,
8298 {
8299 self.invoice_level_adjustments = value.try_into().map_err(|e| {
8300 format!(
8301 "error converting supplied value for invoice_level_adjustments: {}",
8302 e
8303 )
8304 });
8305 self
8306 }
8307 pub fn subscription_items<T>(mut self, value: T) -> Self
8308 where
8309 T: std::convert::TryInto<Vec<super::SubscriptionItem>>,
8310 T::Error: std::fmt::Display,
8311 {
8312 self.subscription_items = value.try_into().map_err(|e| {
8313 format!(
8314 "error converting supplied value for subscription_items: {}",
8315 e
8316 )
8317 });
8318 self
8319 }
8320 }
8321 impl std::convert::TryFrom<Subscription> for super::Subscription {
8322 type Error = super::error::ConversionError;
8323 fn try_from(value: Subscription) -> Result<Self, super::error::ConversionError> {
8324 Ok(Self {
8325 invoice_level_adjustments: value.invoice_level_adjustments?,
8326 subscription_items: value.subscription_items?,
8327 })
8328 }
8329 }
8330 impl From<super::Subscription> for Subscription {
8331 fn from(value: super::Subscription) -> Self {
8332 Self {
8333 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
8334 subscription_items: Ok(value.subscription_items),
8335 }
8336 }
8337 }
8338 #[derive(Clone, Debug)]
8339 pub struct SubscriptionItem {
8340 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8341 amount: Result<i64, String>,
8342 current_period_end_at: Result<Option<i64>, String>,
8343 current_period_start_at: Result<Option<i64>, String>,
8344 description: Result<String, String>,
8345 interval: Result<Option<super::Interval>, String>,
8346 interval_count: Result<Option<i64>, String>,
8347 metadata: Result<Option<Vec<super::Metadatum>>, String>,
8348 quantity: Result<Option<f64>, String>,
8349 subscription_type: Result<super::SubscriptionType, String>,
8350 taxes: Result<Option<Vec<super::Tax>>, String>,
8351 unit_cost: Result<Option<f64>, String>,
8352 }
8353 impl Default for SubscriptionItem {
8354 fn default() -> Self {
8355 Self {
8356 adjustments: Ok(Default::default()),
8357 amount: Err("no value supplied for amount".to_string()),
8358 current_period_end_at: Ok(Default::default()),
8359 current_period_start_at: Ok(Default::default()),
8360 description: Err("no value supplied for description".to_string()),
8361 interval: Ok(Default::default()),
8362 interval_count: Ok(Default::default()),
8363 metadata: Ok(Default::default()),
8364 quantity: Ok(Default::default()),
8365 subscription_type: Err("no value supplied for subscription_type".to_string()),
8366 taxes: Ok(Default::default()),
8367 unit_cost: Ok(Default::default()),
8368 }
8369 }
8370 }
8371 impl SubscriptionItem {
8372 pub fn adjustments<T>(mut self, value: T) -> Self
8373 where
8374 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8375 T::Error: std::fmt::Display,
8376 {
8377 self.adjustments = value
8378 .try_into()
8379 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
8380 self
8381 }
8382 pub fn amount<T>(mut self, value: T) -> Self
8383 where
8384 T: std::convert::TryInto<i64>,
8385 T::Error: std::fmt::Display,
8386 {
8387 self.amount = value
8388 .try_into()
8389 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8390 self
8391 }
8392 pub fn current_period_end_at<T>(mut self, value: T) -> Self
8393 where
8394 T: std::convert::TryInto<Option<i64>>,
8395 T::Error: std::fmt::Display,
8396 {
8397 self.current_period_end_at = value.try_into().map_err(|e| {
8398 format!(
8399 "error converting supplied value for current_period_end_at: {}",
8400 e
8401 )
8402 });
8403 self
8404 }
8405 pub fn current_period_start_at<T>(mut self, value: T) -> Self
8406 where
8407 T: std::convert::TryInto<Option<i64>>,
8408 T::Error: std::fmt::Display,
8409 {
8410 self.current_period_start_at = value.try_into().map_err(|e| {
8411 format!(
8412 "error converting supplied value for current_period_start_at: {}",
8413 e
8414 )
8415 });
8416 self
8417 }
8418 pub fn description<T>(mut self, value: T) -> Self
8419 where
8420 T: std::convert::TryInto<String>,
8421 T::Error: std::fmt::Display,
8422 {
8423 self.description = value
8424 .try_into()
8425 .map_err(|e| format!("error converting supplied value for description: {}", e));
8426 self
8427 }
8428 pub fn interval<T>(mut self, value: T) -> Self
8429 where
8430 T: std::convert::TryInto<Option<super::Interval>>,
8431 T::Error: std::fmt::Display,
8432 {
8433 self.interval = value
8434 .try_into()
8435 .map_err(|e| format!("error converting supplied value for interval: {}", e));
8436 self
8437 }
8438 pub fn interval_count<T>(mut self, value: T) -> Self
8439 where
8440 T: std::convert::TryInto<Option<i64>>,
8441 T::Error: std::fmt::Display,
8442 {
8443 self.interval_count = value
8444 .try_into()
8445 .map_err(|e| format!("error converting supplied value for interval_count: {}", e));
8446 self
8447 }
8448 pub fn metadata<T>(mut self, value: T) -> Self
8449 where
8450 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8451 T::Error: std::fmt::Display,
8452 {
8453 self.metadata = value
8454 .try_into()
8455 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8456 self
8457 }
8458 pub fn quantity<T>(mut self, value: T) -> Self
8459 where
8460 T: std::convert::TryInto<Option<f64>>,
8461 T::Error: std::fmt::Display,
8462 {
8463 self.quantity = value
8464 .try_into()
8465 .map_err(|e| format!("error converting supplied value for quantity: {}", e));
8466 self
8467 }
8468 pub fn subscription_type<T>(mut self, value: T) -> Self
8469 where
8470 T: std::convert::TryInto<super::SubscriptionType>,
8471 T::Error: std::fmt::Display,
8472 {
8473 self.subscription_type = value.try_into().map_err(|e| {
8474 format!(
8475 "error converting supplied value for subscription_type: {}",
8476 e
8477 )
8478 });
8479 self
8480 }
8481 pub fn taxes<T>(mut self, value: T) -> Self
8482 where
8483 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8484 T::Error: std::fmt::Display,
8485 {
8486 self.taxes = value
8487 .try_into()
8488 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8489 self
8490 }
8491 pub fn unit_cost<T>(mut self, value: T) -> Self
8492 where
8493 T: std::convert::TryInto<Option<f64>>,
8494 T::Error: std::fmt::Display,
8495 {
8496 self.unit_cost = value
8497 .try_into()
8498 .map_err(|e| format!("error converting supplied value for unit_cost: {}", e));
8499 self
8500 }
8501 }
8502 impl std::convert::TryFrom<SubscriptionItem> for super::SubscriptionItem {
8503 type Error = super::error::ConversionError;
8504 fn try_from(value: SubscriptionItem) -> Result<Self, super::error::ConversionError> {
8505 Ok(Self {
8506 adjustments: value.adjustments?,
8507 amount: value.amount?,
8508 current_period_end_at: value.current_period_end_at?,
8509 current_period_start_at: value.current_period_start_at?,
8510 description: value.description?,
8511 interval: value.interval?,
8512 interval_count: value.interval_count?,
8513 metadata: value.metadata?,
8514 quantity: value.quantity?,
8515 subscription_type: value.subscription_type?,
8516 taxes: value.taxes?,
8517 unit_cost: value.unit_cost?,
8518 })
8519 }
8520 }
8521 impl From<super::SubscriptionItem> for SubscriptionItem {
8522 fn from(value: super::SubscriptionItem) -> Self {
8523 Self {
8524 adjustments: Ok(value.adjustments),
8525 amount: Ok(value.amount),
8526 current_period_end_at: Ok(value.current_period_end_at),
8527 current_period_start_at: Ok(value.current_period_start_at),
8528 description: Ok(value.description),
8529 interval: Ok(value.interval),
8530 interval_count: Ok(value.interval_count),
8531 metadata: Ok(value.metadata),
8532 quantity: Ok(value.quantity),
8533 subscription_type: Ok(value.subscription_type),
8534 taxes: Ok(value.taxes),
8535 unit_cost: Ok(value.unit_cost),
8536 }
8537 }
8538 }
8539 #[derive(Clone, Debug)]
8540 pub struct Tax {
8541 amount: Result<i64, String>,
8542 name: Result<String, String>,
8543 rate: Result<Option<f64>, String>,
8544 }
8545 impl Default for Tax {
8546 fn default() -> Self {
8547 Self {
8548 amount: Err("no value supplied for amount".to_string()),
8549 name: Err("no value supplied for name".to_string()),
8550 rate: Ok(Default::default()),
8551 }
8552 }
8553 }
8554 impl Tax {
8555 pub fn amount<T>(mut self, value: T) -> Self
8556 where
8557 T: std::convert::TryInto<i64>,
8558 T::Error: std::fmt::Display,
8559 {
8560 self.amount = value
8561 .try_into()
8562 .map_err(|e| format!("error converting supplied value for amount: {}", e));
8563 self
8564 }
8565 pub fn name<T>(mut self, value: T) -> Self
8566 where
8567 T: std::convert::TryInto<String>,
8568 T::Error: std::fmt::Display,
8569 {
8570 self.name = value
8571 .try_into()
8572 .map_err(|e| format!("error converting supplied value for name: {}", e));
8573 self
8574 }
8575 pub fn rate<T>(mut self, value: T) -> Self
8576 where
8577 T: std::convert::TryInto<Option<f64>>,
8578 T::Error: std::fmt::Display,
8579 {
8580 self.rate = value
8581 .try_into()
8582 .map_err(|e| format!("error converting supplied value for rate: {}", e));
8583 self
8584 }
8585 }
8586 impl std::convert::TryFrom<Tax> for super::Tax {
8587 type Error = super::error::ConversionError;
8588 fn try_from(value: Tax) -> Result<Self, super::error::ConversionError> {
8589 Ok(Self {
8590 amount: value.amount?,
8591 name: value.name?,
8592 rate: value.rate?,
8593 })
8594 }
8595 }
8596 impl From<super::Tax> for Tax {
8597 fn from(value: super::Tax) -> Self {
8598 Self {
8599 amount: Ok(value.amount),
8600 name: Ok(value.name),
8601 rate: Ok(value.rate),
8602 }
8603 }
8604 }
8605 #[derive(Clone, Debug)]
8606 pub struct TransitRoute {
8607 invoice_level_adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8608 transit_route_items: Result<Vec<super::TransitRouteItem>, String>,
8609 }
8610 impl Default for TransitRoute {
8611 fn default() -> Self {
8612 Self {
8613 invoice_level_adjustments: Ok(Default::default()),
8614 transit_route_items: Err("no value supplied for transit_route_items".to_string()),
8615 }
8616 }
8617 }
8618 impl TransitRoute {
8619 pub fn invoice_level_adjustments<T>(mut self, value: T) -> Self
8620 where
8621 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8622 T::Error: std::fmt::Display,
8623 {
8624 self.invoice_level_adjustments = value.try_into().map_err(|e| {
8625 format!(
8626 "error converting supplied value for invoice_level_adjustments: {}",
8627 e
8628 )
8629 });
8630 self
8631 }
8632 pub fn transit_route_items<T>(mut self, value: T) -> Self
8633 where
8634 T: std::convert::TryInto<Vec<super::TransitRouteItem>>,
8635 T::Error: std::fmt::Display,
8636 {
8637 self.transit_route_items = value.try_into().map_err(|e| {
8638 format!(
8639 "error converting supplied value for transit_route_items: {}",
8640 e
8641 )
8642 });
8643 self
8644 }
8645 }
8646 impl std::convert::TryFrom<TransitRoute> for super::TransitRoute {
8647 type Error = super::error::ConversionError;
8648 fn try_from(value: TransitRoute) -> Result<Self, super::error::ConversionError> {
8649 Ok(Self {
8650 invoice_level_adjustments: value.invoice_level_adjustments?,
8651 transit_route_items: value.transit_route_items?,
8652 })
8653 }
8654 }
8655 impl From<super::TransitRoute> for TransitRoute {
8656 fn from(value: super::TransitRoute) -> Self {
8657 Self {
8658 invoice_level_adjustments: Ok(value.invoice_level_adjustments),
8659 transit_route_items: Ok(value.transit_route_items),
8660 }
8661 }
8662 }
8663 #[derive(Clone, Debug)]
8664 pub struct TransitRouteItem {
8665 adjustments: Result<Option<Vec<super::Adjustment>>, String>,
8666 arrival_at: Result<Option<i64>, String>,
8667 arrival_location: Result<Option<super::Place>, String>,
8668 departure_at: Result<Option<i64>, String>,
8669 departure_location: Result<Option<super::Place>, String>,
8670 fare: Result<i64, String>,
8671 metadata: Result<Option<Vec<super::Metadatum>>, String>,
8672 mode: Result<Option<super::TransitRouteItemMode>, String>,
8673 passenger: Result<Option<super::Person>, String>,
8674 polyline: Result<Option<String>, String>,
8675 taxes: Result<Option<Vec<super::Tax>>, String>,
8676 }
8677 impl Default for TransitRouteItem {
8678 fn default() -> Self {
8679 Self {
8680 adjustments: Ok(Default::default()),
8681 arrival_at: Ok(Default::default()),
8682 arrival_location: Ok(Default::default()),
8683 departure_at: Ok(Default::default()),
8684 departure_location: Ok(Default::default()),
8685 fare: Err("no value supplied for fare".to_string()),
8686 metadata: Ok(Default::default()),
8687 mode: Ok(Default::default()),
8688 passenger: Ok(Default::default()),
8689 polyline: Ok(Default::default()),
8690 taxes: Ok(Default::default()),
8691 }
8692 }
8693 }
8694 impl TransitRouteItem {
8695 pub fn adjustments<T>(mut self, value: T) -> Self
8696 where
8697 T: std::convert::TryInto<Option<Vec<super::Adjustment>>>,
8698 T::Error: std::fmt::Display,
8699 {
8700 self.adjustments = value
8701 .try_into()
8702 .map_err(|e| format!("error converting supplied value for adjustments: {}", e));
8703 self
8704 }
8705 pub fn arrival_at<T>(mut self, value: T) -> Self
8706 where
8707 T: std::convert::TryInto<Option<i64>>,
8708 T::Error: std::fmt::Display,
8709 {
8710 self.arrival_at = value
8711 .try_into()
8712 .map_err(|e| format!("error converting supplied value for arrival_at: {}", e));
8713 self
8714 }
8715 pub fn arrival_location<T>(mut self, value: T) -> Self
8716 where
8717 T: std::convert::TryInto<Option<super::Place>>,
8718 T::Error: std::fmt::Display,
8719 {
8720 self.arrival_location = value.try_into().map_err(|e| {
8721 format!(
8722 "error converting supplied value for arrival_location: {}",
8723 e
8724 )
8725 });
8726 self
8727 }
8728 pub fn departure_at<T>(mut self, value: T) -> Self
8729 where
8730 T: std::convert::TryInto<Option<i64>>,
8731 T::Error: std::fmt::Display,
8732 {
8733 self.departure_at = value
8734 .try_into()
8735 .map_err(|e| format!("error converting supplied value for departure_at: {}", e));
8736 self
8737 }
8738 pub fn departure_location<T>(mut self, value: T) -> Self
8739 where
8740 T: std::convert::TryInto<Option<super::Place>>,
8741 T::Error: std::fmt::Display,
8742 {
8743 self.departure_location = value.try_into().map_err(|e| {
8744 format!(
8745 "error converting supplied value for departure_location: {}",
8746 e
8747 )
8748 });
8749 self
8750 }
8751 pub fn fare<T>(mut self, value: T) -> Self
8752 where
8753 T: std::convert::TryInto<i64>,
8754 T::Error: std::fmt::Display,
8755 {
8756 self.fare = value
8757 .try_into()
8758 .map_err(|e| format!("error converting supplied value for fare: {}", e));
8759 self
8760 }
8761 pub fn metadata<T>(mut self, value: T) -> Self
8762 where
8763 T: std::convert::TryInto<Option<Vec<super::Metadatum>>>,
8764 T::Error: std::fmt::Display,
8765 {
8766 self.metadata = value
8767 .try_into()
8768 .map_err(|e| format!("error converting supplied value for metadata: {}", e));
8769 self
8770 }
8771 pub fn mode<T>(mut self, value: T) -> Self
8772 where
8773 T: std::convert::TryInto<Option<super::TransitRouteItemMode>>,
8774 T::Error: std::fmt::Display,
8775 {
8776 self.mode = value
8777 .try_into()
8778 .map_err(|e| format!("error converting supplied value for mode: {}", e));
8779 self
8780 }
8781 pub fn passenger<T>(mut self, value: T) -> Self
8782 where
8783 T: std::convert::TryInto<Option<super::Person>>,
8784 T::Error: std::fmt::Display,
8785 {
8786 self.passenger = value
8787 .try_into()
8788 .map_err(|e| format!("error converting supplied value for passenger: {}", e));
8789 self
8790 }
8791 pub fn polyline<T>(mut self, value: T) -> Self
8792 where
8793 T: std::convert::TryInto<Option<String>>,
8794 T::Error: std::fmt::Display,
8795 {
8796 self.polyline = value
8797 .try_into()
8798 .map_err(|e| format!("error converting supplied value for polyline: {}", e));
8799 self
8800 }
8801 pub fn taxes<T>(mut self, value: T) -> Self
8802 where
8803 T: std::convert::TryInto<Option<Vec<super::Tax>>>,
8804 T::Error: std::fmt::Display,
8805 {
8806 self.taxes = value
8807 .try_into()
8808 .map_err(|e| format!("error converting supplied value for taxes: {}", e));
8809 self
8810 }
8811 }
8812 impl std::convert::TryFrom<TransitRouteItem> for super::TransitRouteItem {
8813 type Error = super::error::ConversionError;
8814 fn try_from(value: TransitRouteItem) -> Result<Self, super::error::ConversionError> {
8815 Ok(Self {
8816 adjustments: value.adjustments?,
8817 arrival_at: value.arrival_at?,
8818 arrival_location: value.arrival_location?,
8819 departure_at: value.departure_at?,
8820 departure_location: value.departure_location?,
8821 fare: value.fare?,
8822 metadata: value.metadata?,
8823 mode: value.mode?,
8824 passenger: value.passenger?,
8825 polyline: value.polyline?,
8826 taxes: value.taxes?,
8827 })
8828 }
8829 }
8830 impl From<super::TransitRouteItem> for TransitRouteItem {
8831 fn from(value: super::TransitRouteItem) -> Self {
8832 Self {
8833 adjustments: Ok(value.adjustments),
8834 arrival_at: Ok(value.arrival_at),
8835 arrival_location: Ok(value.arrival_location),
8836 departure_at: Ok(value.departure_at),
8837 departure_location: Ok(value.departure_location),
8838 fare: Ok(value.fare),
8839 metadata: Ok(value.metadata),
8840 mode: Ok(value.mode),
8841 passenger: Ok(value.passenger),
8842 polyline: Ok(value.polyline),
8843 taxes: Ok(value.taxes),
8844 }
8845 }
8846 }
8847}