shopify_client/admin/order/
mod.rs1pub mod remote;
2
3use crate::common::ServiceContext;
4
5use std::sync::Arc;
6
7use crate::{
8 common::types::{APIError, RequestCallbacks},
9 types::order::{
10 GetOrderResp, OrderDetailByNameResp, OrderDetailResp, OrderDiscountsAndTransactionsResp,
11 OrderQueryResp, PatchOrderRequest,
12 },
13};
14
15pub struct Order {
16 pub(crate) ctx: ServiceContext,
17}
18
19impl Order {
20 pub fn new(
21 shop_url: Arc<String>,
22 version: Arc<String>,
23 access_token: Arc<String>,
24 callbacks: Arc<RequestCallbacks>,
25 ) -> Self {
26 Self::with_ctx(ServiceContext::new(
27 shop_url,
28 version,
29 access_token,
30 callbacks,
31 ))
32 }
33
34 pub fn with_ctx(ctx: ServiceContext) -> Self {
37 Self { ctx }
38 }
39
40 pub async fn get_with_id(&self, order_id: &String) -> Result<GetOrderResp, APIError> {
41 remote::get_order_with_id(&self.ctx, order_id).await
42 }
43
44 pub async fn detail(
45 &self,
46 order_gid: &str,
47 lines: u32,
48 fulfillments: u32,
49 ) -> Result<OrderDetailResp, APIError> {
50 remote::get_order_detail(&self.ctx, order_gid, lines, fulfillments).await
51 }
52
53 pub async fn detail_by_name(
54 &self,
55 name: &str,
56 lines: u32,
57 fulfillments: u32,
58 ) -> Result<OrderDetailByNameResp, APIError> {
59 remote::find_order_detail_by_name(&self.ctx, name, lines, fulfillments).await
60 }
61
62 pub async fn discounts_and_transactions(
63 &self,
64 order_gid: &str,
65 lines: u32,
66 ) -> Result<OrderDiscountsAndTransactionsResp, APIError> {
67 remote::get_order_discounts_and_transactions(&self.ctx, order_gid, lines).await
68 }
69
70 pub async fn get_with_name(&self, order_name: &String) -> Result<OrderQueryResp, APIError> {
71 remote::get_order_with_name(&self.ctx, order_name).await
72 }
73
74 pub async fn patch(
75 &self,
76 order_id: &String,
77 patch_request: &PatchOrderRequest,
78 ) -> Result<GetOrderResp, APIError> {
79 remote::patch_order(&self.ctx, order_id, patch_request).await
80 }
81}