shopify_client/services/order/
mod.rs1mod remote;
2pub mod types;
3
4use std::sync::Arc;
5
6use crate::common::types::APIError;
7use types::GetOrderResp;
8
9pub struct Order {
10 pub shop_url: Arc<String>,
11 pub version: Arc<String>,
12 pub access_token: Arc<String>,
13}
14
15impl Order {
16 pub fn new(shop_url: Arc<String>, version: Arc<String>, access_token: Arc<String>) -> Self {
17 Order {
18 shop_url,
19 version,
20 access_token,
21 }
22 }
23
24 pub async fn get_with_id(&self, order_id: &String) -> Result<GetOrderResp, APIError> {
25 remote::get_order_with_id(&self.shop_url, &self.version, &self.access_token, order_id).await
26 }
27
28 pub async fn get_with_name(
29 &self,
30 order_name: &String,
31 ) -> Result<types::OrderQueryResp, APIError> {
32 remote::get_order_with_name(
33 &self.shop_url,
34 &self.version,
35 order_name,
36 &self.access_token,
37 )
38 .await
39 }
40
41 pub async fn patch(
42 &self,
43 order_id: &String,
44 patch_request: &types::PatchOrderRequest,
45 ) -> Result<GetOrderResp, APIError> {
46 remote::patch_order(
47 &self.shop_url,
48 &self.version,
49 &self.access_token,
50 order_id,
51 patch_request,
52 )
53 .await
54 }
55}