Add setters to PreCheckoutQuery
@@ -38,3 +38,71 @@ pub struct PreCheckoutQuery {
/// Order info provided by the user.
pub order_info: Option<OrderInfo>,
}
+
+impl PreCheckoutQuery {
+ pub fn new<S1, S2>(
+ id: S1,
+ from: User,
+ currency: Currency,
+ total_amount: i32,
+ invoice_payload: S2,
+ ) -> Self
+ where
+ S1: Into<String>,
+ S2: Into<String>,
+ {
+ Self {
+ id: id.into(),
+ from,
+ currency,
+ total_amount,
+ invoice_payload: invoice_payload.into(),
+ shipping_option_id: None,
+ order_info: None,
+ }
+ }
+
+ pub fn id<S>(mut self, val: S) -> Self
+ where
+ S: Into<String>,
+ {
+ self.id = val.into();
+ self
+ }
+
+ pub fn from(mut self, val: User) -> Self {
+ self.from = val;
+ self
+ }
+
+ pub fn currency<S>(mut self, val: Currency) -> Self {
+ self.currency = val;
+ self
+ }
+
+ pub fn total_amount(mut self, val: i32) -> Self {
+ self.total_amount = val;
+ self
+ }
+
+ pub fn invoice_payload<S>(mut self, val: S) -> Self
+ where
+ S: Into<String>,
+ {
+ self.invoice_payload = val.into();
+ self
+ }
+
+ pub fn shipping_option_id<S>(mut self, val: S) -> Self
+ where
+ S: Into<String>,
+ {
+ self.shipping_option_id = Some(val.into());
+ self
+ }
+
+ pub fn order_info(mut self, val: OrderInfo) -> Self {
+ self.order_info = Some(val);
+ self
+ }
+}
