Merge pull request #163 from zggff/master

make OrderInfo use Option<String> instead of String. It allows teloxide to ask only one needed field of the shipping query.
This commit is contained in:
Waffle Maybe 2022-01-12 11:18:37 +03:00 committed by GitHub
commit 53df041940
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -5,17 +5,17 @@ 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: String,
pub name: Option<String>,
/// User's phone number.
pub phone_number: String,
pub phone_number: Option<String>,
/// User's email.
pub email: String,
pub email: Option<String>,
/// User's shipping address.
pub shipping_address: ShippingAddress,
pub shipping_address: Option<ShippingAddress>,
}

View file

@ -35,5 +35,6 @@ pub struct PreCheckoutQuery {
pub shipping_option_id: Option<String>,
/// Order info provided by the user.
pub order_info: Option<OrderInfo>,
#[serde(default)]
pub order_info: OrderInfo,
}

View file

@ -29,7 +29,8 @@ pub struct SuccessfulPayment {
pub shipping_option_id: Option<String>,
/// Order info provided by the user.
pub order_info: Option<OrderInfo>,
#[serde(default)]
pub order_info: OrderInfo,
/// Telegram payment identifier.
pub telegram_payment_charge_id: String,