Skip to main content

wechat_mp_delivery/
lib.rs

1//! 微信小程序即时配送(商家侧)
2//!
3//! 文档:[即时配送接口列表](https://developers.weixin.qq.com/miniprogram/dev/server/API/immediate-delivery/)
4
5mod models;
6mod order;
7mod shop;
8mod sign;
9
10pub use models::*;
11pub use order::*;
12pub use shop::*;
13pub use sign::delivery_sign;
14
15use wechat_mp_core::MpClient;
16
17/// 即时配送 API 门面
18#[derive(Clone)]
19pub struct DeliveryApi {
20    client: MpClient,
21}
22
23impl DeliveryApi {
24    pub fn new(client: MpClient) -> Self {
25        Self { client }
26    }
27
28    pub fn client(&self) -> &MpClient {
29        &self.client
30    }
31
32    pub async fn get_all_delivery(&self) -> wechat_mp_core::Result<GetAllLocalDeliveryResponse> {
33        get_all_delivery(&self.client).await
34    }
35
36    pub async fn get_shop(&self) -> wechat_mp_core::Result<GetShopResponse> {
37        get_shop(&self.client).await
38    }
39
40    pub async fn add_shop(&self, req: &AddShopRequest) -> wechat_mp_core::Result<()> {
41        add_shop(&self.client, req).await
42    }
43
44    pub async fn open_delivery(&self) -> wechat_mp_core::Result<()> {
45        open_delivery(&self.client).await
46    }
47
48    pub async fn pre_add_order(
49        &self,
50        req: &LocalOrderRequest,
51    ) -> wechat_mp_core::Result<PreAddOrderResponse> {
52        pre_add_order(&self.client, req).await
53    }
54
55    pub async fn add_order(
56        &self,
57        req: &LocalOrderRequest,
58    ) -> wechat_mp_core::Result<AddOrderResponse> {
59        add_order(&self.client, req).await
60    }
61
62    pub async fn readd_order(
63        &self,
64        req: &LocalOrderRequest,
65    ) -> wechat_mp_core::Result<AddOrderResponse> {
66        readd_order(&self.client, req).await
67    }
68
69    pub async fn get_order(
70        &self,
71        req: &GetLocalOrderRequest,
72    ) -> wechat_mp_core::Result<GetLocalOrderResponse> {
73        get_order(&self.client, req).await
74    }
75
76    pub async fn cancel_order(
77        &self,
78        req: &CancelLocalOrderRequest,
79    ) -> wechat_mp_core::Result<CancelLocalOrderResponse> {
80        cancel_order(&self.client, req).await
81    }
82
83    pub async fn precancel_order(
84        &self,
85        req: &PreCancelOrderRequest,
86    ) -> wechat_mp_core::Result<PreCancelOrderResponse> {
87        precancel_order(&self.client, req).await
88    }
89
90    pub async fn add_tips(
91        &self,
92        req: &AddTipsRequest,
93    ) -> wechat_mp_core::Result<SimpleDeliveryResponse> {
94        add_tips(&self.client, req).await
95    }
96
97    pub async fn confirm_return(
98        &self,
99        req: &ConfirmReturnRequest,
100    ) -> wechat_mp_core::Result<SimpleDeliveryResponse> {
101        confirm_return(&self.client, req).await
102    }
103
104    pub async fn test_update_order(
105        &self,
106        req: &TestUpdateOrderRequest,
107    ) -> wechat_mp_core::Result<SimpleDeliveryResponse> {
108        test_update_order(&self.client, req).await
109    }
110
111    pub async fn realmock_update_order(
112        &self,
113        req: &TestUpdateOrderRequest,
114    ) -> wechat_mp_core::Result<SimpleDeliveryResponse> {
115        realmock_update_order(&self.client, req).await
116    }
117}