1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::{
methods::AnswerShippingQuery,
types::{shipping, User},
Bot,
};
use std::sync::Arc;
common! {
struct Shipping {
id: shipping::query::Id,
from: User,
invoice_payload: String,
shipping_address: shipping::Address,
}
}
impl<C> Shipping<C> {
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn new(bot: Arc<Bot<C>>, query: shipping::Query) -> Self {
Self {
bot,
id: query.id,
from: query.from,
invoice_payload: query.invoice_payload,
shipping_address: query.shipping_address,
}
}
pub fn answer<'a>(
&'a self,
result: Result<&'a [shipping::Option<'a>], &'a str>,
) -> AnswerShippingQuery<'a, C> {
self.bot.answer_shipping_query(self.id.as_ref(), result)
}
pub fn ok<'a>(
&'a self,
options: &'a [shipping::Option<'a>],
) -> AnswerShippingQuery<'a, C> {
self.answer(Ok(options))
}
pub fn err<'a>(&'a self, err: &'a str) -> AnswerShippingQuery<'a, C> {
self.answer(Err(err))
}
}