From 25090dc72c77a4b89a922e45dd7eb389876cbd5e Mon Sep 17 00:00:00 2001 From: zggff Date: Wed, 5 Jan 2022 00:54:45 +0300 Subject: [PATCH] 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,