diff --git a/examples/minimal/src/main.rs b/examples/minimal/src/main.rs index dd7be2a..61eeab0 100644 --- a/examples/minimal/src/main.rs +++ b/examples/minimal/src/main.rs @@ -3,7 +3,7 @@ use std::env; use isideload::{ anisette::remote_v3::RemoteV3AnisetteProvider, auth::apple_account::AppleAccount, - dev::developer_session::{AppIdsApi, DeveloperSession, TeamsApi}, + dev::developer_session::{AppGroupsApi, DeveloperSession, TeamsApi}, }; use tracing::Level; @@ -60,7 +60,7 @@ async fn main() { .expect("No developer teams available for this account"); let res = dev_session - .list_app_ids(team, None) + .add_app_group(team, "Example", "group.me.nabdev.example.59AV98CNR7", None) .await .expect("Failed to add appid"); diff --git a/isideload/src/dev/app_groups.rs b/isideload/src/dev/app_groups.rs new file mode 100644 index 0000000..e3cc176 --- /dev/null +++ b/isideload/src/dev/app_groups.rs @@ -0,0 +1,79 @@ +use crate::{ + dev::{ + developer_session::DeveloperSession, + device_type::{DeveloperDeviceType, dev_url}, + teams::DeveloperTeam, + }, + util::plist::SensitivePlistAttachment, +}; +use plist::{Date, Dictionary, Value}; +use plist_macro::plist; +use rootcause::prelude::*; +use serde::Deserialize; + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct AppGroup { + pub name: Option, + pub identifier: String, + pub application_group: String, +} + +#[async_trait::async_trait] +pub trait AppGroupsApi { + fn developer_session(&self) -> &DeveloperSession<'_>; + + async fn list_app_groups( + &self, + team: &DeveloperTeam, + device_type: impl Into> + Send, + ) -> Result, Report> { + let body = plist!(dict { + "teamId": &team.team_id, + }); + + let app_groups: Vec = self + .developer_session() + .send_dev_request( + &dev_url("listApplicationGroups", device_type), + body, + "applicationGroupList", + ) + .await + .context("Failed to list developer app groups")?; + + Ok(app_groups) + } + + async fn add_app_group( + &self, + team: &DeveloperTeam, + name: &str, + identifier: &str, + device_type: impl Into> + Send, + ) -> Result { + let body = plist!(dict { + "teamId": &team.team_id, + "name": name, + "identifier": identifier, + }); + + let app_group: AppGroup = self + .developer_session() + .send_dev_request( + &dev_url("addApplicationGroup", device_type), + body, + "applicationGroup", + ) + .await + .context("Failed to add developer app group")?; + + Ok(app_group) + } +} + +impl AppGroupsApi for DeveloperSession<'_> { + fn developer_session(&self) -> &DeveloperSession<'_> { + self + } +} diff --git a/isideload/src/dev/developer_session.rs b/isideload/src/dev/developer_session.rs index f279791..1ecce74 100644 --- a/isideload/src/dev/developer_session.rs +++ b/isideload/src/dev/developer_session.rs @@ -14,6 +14,7 @@ use crate::{ util::plist::PlistDataExtract, }; +pub use super::app_groups::*; pub use super::app_ids::*; pub use super::certificates::*; pub use super::device_type::DeveloperDeviceType; diff --git a/isideload/src/dev/mod.rs b/isideload/src/dev/mod.rs index 1f8b80a..e4e7a16 100644 --- a/isideload/src/dev/mod.rs +++ b/isideload/src/dev/mod.rs @@ -1,3 +1,4 @@ +pub mod app_groups; pub mod app_ids; pub mod certificates; pub mod developer_session;