shopify_client/admin/app_installation/
mod.rs1pub mod remote;
2
3use crate::common::ServiceContext;
4
5use std::sync::Arc;
6
7use crate::{
8 common::types::{APIError, RequestCallbacks},
9 types::app_installation::{
10 DeleteMetafieldsResp, GetCurrentAppInstallationResp, GetMetafieldResp, ListMetafieldsResp,
11 MetafieldIdentifierInput, MetafieldInput, SetMetafieldsResp,
12 },
13};
14
15pub struct AppInstallation {
16 pub(crate) ctx: ServiceContext,
17}
18
19impl AppInstallation {
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_current(&self) -> Result<GetCurrentAppInstallationResp, APIError> {
41 remote::get_current_app_installation(&self.ctx).await
42 }
43
44 pub async fn set_metafields(
45 &self,
46 metafields: Vec<MetafieldInput>,
47 ) -> Result<SetMetafieldsResp, APIError> {
48 remote::set_metafields(&self.ctx, metafields).await
49 }
50
51 pub async fn get_metafield(
52 &self,
53 app_installation_id: &str,
54 namespace: &str,
55 key: &str,
56 ) -> Result<GetMetafieldResp, APIError> {
57 remote::get_metafield(&self.ctx, app_installation_id, namespace, key).await
58 }
59
60 pub async fn list_metafields(
61 &self,
62 app_installation_id: &str,
63 first: Option<i32>,
64 ) -> Result<ListMetafieldsResp, APIError> {
65 remote::list_metafields(&self.ctx, app_installation_id, first).await
66 }
67
68 pub async fn delete_metafields(
69 &self,
70 metafields: &[MetafieldIdentifierInput],
71 ) -> Result<DeleteMetafieldsResp, APIError> {
72 remote::delete_metafields(&self.ctx, metafields).await
73 }
74}