From 1d0ff0a0f6258ed4f4718e29d2d8b43572e6fd11 Mon Sep 17 00:00:00 2001 From: zggff Date: Tue, 4 Jan 2022 23:21:48 +0300 Subject: [PATCH 1/3] make OrderInfo use Option instead of String --- src/types/order_info.rs | 8 ++++---- src/types/pre_checkout_query.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/types/order_info.rs b/src/types/order_info.rs index e5b35bbc..8353cc6c 100644 --- a/src/types/order_info.rs +++ b/src/types/order_info.rs @@ -8,14 +8,14 @@ use crate::types::ShippingAddress; #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct OrderInfo { /// User's name. - pub name: String, + pub name: Option, /// User's phone number. - pub phone_number: String, + pub phone_number: Option, /// User's email. - pub email: String, + pub email: Option, /// User's shipping address. - pub shipping_address: ShippingAddress, + pub shipping_address: Option, } diff --git a/src/types/pre_checkout_query.rs b/src/types/pre_checkout_query.rs index 172e5e8f..6038c514 100644 --- a/src/types/pre_checkout_query.rs +++ b/src/types/pre_checkout_query.rs @@ -35,5 +35,5 @@ pub struct PreCheckoutQuery { pub shipping_option_id: Option, /// Order info provided by the user. - pub order_info: Option, + pub order_info: OrderInfo, } From 25090dc72c77a4b89a922e45dd7eb389876cbd5e Mon Sep 17 00:00:00 2001 From: zggff Date: Wed, 5 Jan 2022 00:54:45 +0300 Subject: [PATCH 2/3] make successful payment use OrderInfo; derive Default on OrderInfo --- src/types/order_info.rs | 2 +- src/types/pre_checkout_query.rs | 1 + src/types/successful_payment.rs | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/types/order_info.rs b/src/types/order_info.rs index 8353cc6c..a512b7ac 100644 --- a/src/types/order_info.rs +++ b/src/types/order_info.rs @@ -5,7 +5,7 @@ use crate::types::ShippingAddress; /// This object represents information about an order. /// /// [The official docs](https://core.telegram.org/bots/api#orderinfo). -#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Default)] pub struct OrderInfo { /// User's name. pub name: Option, diff --git a/src/types/pre_checkout_query.rs b/src/types/pre_checkout_query.rs index 6038c514..75fb909c 100644 --- a/src/types/pre_checkout_query.rs +++ b/src/types/pre_checkout_query.rs @@ -35,5 +35,6 @@ pub struct PreCheckoutQuery { pub shipping_option_id: Option, /// Order info provided by the user. + #[serde(default)] pub order_info: OrderInfo, } diff --git a/src/types/successful_payment.rs b/src/types/successful_payment.rs index d38a36b5..270768c4 100644 --- a/src/types/successful_payment.rs +++ b/src/types/successful_payment.rs @@ -29,7 +29,8 @@ pub struct SuccessfulPayment { pub shipping_option_id: Option, /// Order info provided by the user. - pub order_info: Option, + #[serde(default)] + pub order_info: OrderInfo, /// Telegram payment identifier. pub telegram_payment_charge_id: String, From b72df9b657ef51e70f56d53f45ddb42c5374fbaf Mon Sep 17 00:00:00 2001 From: zggff Date: Wed, 5 Jan 2022 00:54:45 +0300 Subject: [PATCH 3/3] make successful payment use OrderInfo; derive Default on OrderInfo --- src/types/order_info.rs | 2 +- src/types/pre_checkout_query.rs | 1 + src/types/successful_payment.rs | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/types/order_info.rs b/src/types/order_info.rs index 8353cc6c..a512b7ac 100644 --- a/src/types/order_info.rs +++ b/src/types/order_info.rs @@ -5,7 +5,7 @@ use crate::types::ShippingAddress; /// This object represents information about an order. /// /// [The official docs](https://core.telegram.org/bots/api#orderinfo). -#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Default)] pub struct OrderInfo { /// User's name. pub name: Option, diff --git a/src/types/pre_checkout_query.rs b/src/types/pre_checkout_query.rs index 6038c514..75fb909c 100644 --- a/src/types/pre_checkout_query.rs +++ b/src/types/pre_checkout_query.rs @@ -35,5 +35,6 @@ pub struct PreCheckoutQuery { pub shipping_option_id: Option, /// Order info provided by the user. + #[serde(default)] pub order_info: OrderInfo, } diff --git a/src/types/successful_payment.rs b/src/types/successful_payment.rs index d38a36b5..270768c4 100644 --- a/src/types/successful_payment.rs +++ b/src/types/successful_payment.rs @@ -29,7 +29,8 @@ pub struct SuccessfulPayment { pub shipping_option_id: Option, /// Order info provided by the user. - pub order_info: Option, + #[serde(default)] + pub order_info: OrderInfo, /// Telegram payment identifier. pub telegram_payment_charge_id: String,