@smbcloud / smbcloud-ascapi Mirror · read-only / commits / cf2fed6
Fork 0

Read-only mirror of github.com/smbcloudXYZ/smbcloud-ascapi.

Mirrored from https://github.com/smbcloudXYZ/smbcloud-ascapi.git

Synced Nov 25, 09:15 UTC

Add app-store-review-details to read and set App Review information

asc had no way to set the contact details, demo account and notes that App Review sees, so they had to be edited in the App Store Connect website. `app-store-review-details get` reads them for a version, and `set` creates or updates them. The record belongs to a version and does not exist until it is created, so `set` checks first. --dry-run prints the request without the password. Notes are checked against the 4000 character limit before sending. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Seto Elkahfi committed Oct 28, 2026 at 10:21 UTC cf2fed677cedd628dd6c16454b452de6a51551c6
3 files changed +310
crates/aso/src/app_store_review_detail.rs new
+171
@@ -0,0 +1,171 @@
1 +//! `AppStoreReviewDetail` — the "App Review Information" of an App Store
2 +//! Version: contact details, a demo account and notes for the reviewer.
3 +//!
4 +//! Unlike the Beta App Review detail, this one belongs to a version and does
5 +//! not exist until it is created. Reading a version without one returns
6 +//! `None`; use [`AppStoreReviewDetailApi::create_app_store_review_detail`]
7 +//! then.
8 +
9 +use async_trait::async_trait;
10 +use reqwest::Method;
11 +use serde::{Deserialize, Serialize};
12 +use smbcloud_ascapi_core::jsonapi::{
13 + CreateBody, CreateData, Document, OptionalDocument, Resource, ResourceId, ToOne, UpdateBody,
14 + UpdateData,
15 +};
16 +use smbcloud_ascapi_core::Client;
17 +use smbcloud_ascapi_core::Result;
18 +
19 +pub const RESOURCE_TYPE: &str = "appStoreReviewDetails";
20 +
21 +/// Maximum `notes` length App Store Connect accepts, in characters.
22 +pub const NOTES_MAX_LEN: usize = 4000;
23 +
24 +#[derive(Debug, Clone, Serialize, Deserialize)]
25 +#[serde(rename_all = "camelCase")]
26 +pub struct AppStoreReviewDetailAttributes {
27 + pub contact_first_name: Option<String>,
28 + pub contact_last_name: Option<String>,
29 + pub contact_phone: Option<String>,
30 + pub contact_email: Option<String>,
31 + pub demo_account_name: Option<String>,
32 + pub demo_account_password: Option<String>,
33 + pub demo_account_required: Option<bool>,
34 + pub notes: Option<String>,
35 +}
36 +
37 +pub type AppStoreReviewDetail = Resource<AppStoreReviewDetailAttributes>;
38 +
39 +/// Fields to send. `None` fields are left out, so an update is partial.
40 +#[derive(Debug, Clone, Default, Serialize)]
41 +#[serde(rename_all = "camelCase")]
42 +pub struct AppStoreReviewDetailWrite {
43 + #[serde(skip_serializing_if = "Option::is_none")]
44 + pub contact_first_name: Option<String>,
45 + #[serde(skip_serializing_if = "Option::is_none")]
46 + pub contact_last_name: Option<String>,
47 + #[serde(skip_serializing_if = "Option::is_none")]
48 + pub contact_phone: Option<String>,
49 + #[serde(skip_serializing_if = "Option::is_none")]
50 + pub contact_email: Option<String>,
51 + #[serde(skip_serializing_if = "Option::is_none")]
52 + pub demo_account_name: Option<String>,
53 + #[serde(skip_serializing_if = "Option::is_none")]
54 + pub demo_account_password: Option<String>,
55 + #[serde(skip_serializing_if = "Option::is_none")]
56 + pub demo_account_required: Option<bool>,
57 + #[serde(skip_serializing_if = "Option::is_none")]
58 + pub notes: Option<String>,
59 +}
60 +
61 +#[derive(Debug, Clone, Serialize)]
62 +#[serde(rename_all = "camelCase")]
63 +struct Relationships {
64 + app_store_version: ToOne,
65 +}
66 +
67 +#[async_trait]
68 +pub trait AppStoreReviewDetailApi {
69 + /// `GET /v1/appStoreVersions/{id}/appStoreReviewDetail`, `None` when the
70 + /// version has no review information yet.
71 + async fn get_app_store_review_detail(
72 + &self,
73 + app_store_version_id: &str,
74 + ) -> Result<Option<AppStoreReviewDetail>>;
75 +
76 + /// `POST /v1/appStoreReviewDetails`
77 + async fn create_app_store_review_detail(
78 + &self,
79 + app_store_version_id: &str,
80 + write: AppStoreReviewDetailWrite,
81 + ) -> Result<AppStoreReviewDetail>;
82 +
83 + /// `PATCH /v1/appStoreReviewDetails/{id}`
84 + async fn update_app_store_review_detail(
85 + &self,
86 + id: &str,
87 + write: AppStoreReviewDetailWrite,
88 + ) -> Result<AppStoreReviewDetail>;
89 +}
90 +
91 +#[async_trait]
92 +impl AppStoreReviewDetailApi for Client {
93 + async fn get_app_store_review_detail(
94 + &self,
95 + app_store_version_id: &str,
96 + ) -> Result<Option<AppStoreReviewDetail>> {
97 + let path = format!("/v1/appStoreVersions/{app_store_version_id}/appStoreReviewDetail");
98 + let doc: OptionalDocument<AppStoreReviewDetailAttributes> =
99 + self.request(Method::GET, &path, &[], None::<&()>).await?;
100 + Ok(doc.data)
101 + }
102 +
103 + async fn create_app_store_review_detail(
104 + &self,
105 + app_store_version_id: &str,
106 + write: AppStoreReviewDetailWrite,
107 + ) -> Result<AppStoreReviewDetail> {
108 + let body = CreateBody {
109 + data: CreateData {
110 + resource_type: RESOURCE_TYPE,
111 + attributes: write,
112 + relationships: Some(Relationships {
113 + app_store_version: ToOne {
114 + data: ResourceId {
115 + resource_type: crate::app_store_version::RESOURCE_TYPE,
116 + id: app_store_version_id.to_string(),
117 + },
118 + },
119 + }),
120 + },
121 + };
122 + let doc: Document<AppStoreReviewDetailAttributes> = self
123 + .request(Method::POST, "/v1/appStoreReviewDetails", &[], Some(&body))
124 + .await?;
125 + Ok(doc.data)
126 + }
127 +
128 + async fn update_app_store_review_detail(
129 + &self,
130 + id: &str,
131 + write: AppStoreReviewDetailWrite,
132 + ) -> Result<AppStoreReviewDetail> {
133 + let path = format!("/v1/appStoreReviewDetails/{id}");
134 + let body = UpdateBody {
135 + data: UpdateData {
136 + resource_type: RESOURCE_TYPE,
137 + id: id.to_string(),
138 + attributes: write,
139 + },
140 + };
141 + let doc: Document<AppStoreReviewDetailAttributes> =
142 + self.request(Method::PATCH, &path, &[], Some(&body)).await?;
143 + Ok(doc.data)
144 + }
145 +}
146 +
147 +#[cfg(test)]
148 +mod tests {
149 + use super::*;
150 +
151 + #[test]
152 + fn a_write_leaves_out_fields_that_are_not_set() {
153 + let write = AppStoreReviewDetailWrite {
154 + demo_account_name: Some("demo@example.com".into()),
155 + demo_account_required: Some(true),
156 + ..Default::default()
157 + };
158 + let v = serde_json::to_value(&write).unwrap();
159 + assert_eq!(v["demoAccountName"], "demo@example.com");
160 + assert_eq!(v["demoAccountRequired"], true);
161 + assert!(v.get("notes").is_none());
162 + assert!(v.get("demoAccountPassword").is_none());
163 + }
164 +
165 + #[test]
166 + fn a_version_without_review_information_reads_as_none() {
167 + let doc: OptionalDocument<AppStoreReviewDetailAttributes> =
168 + serde_json::from_value(serde_json::json!({ "data": null })).unwrap();
169 + assert!(doc.data.is_none());
170 + }
171 +}
crates/aso/src/lib.rs
+2
@@ -25,6 +25,7 @@ pub mod app_info;
25 pub mod app_info_localization;
26 pub mod app_screenshot;
27 pub mod app_screenshot_set;
28 +pub mod app_store_review_detail;
29 pub mod app_store_version;
30 pub mod app_store_version_localization;
31 pub mod beta_app_review_detail;
@@ -42,6 +43,7 @@ pub mod prelude {
43 pub use crate::app_info_localization::AppInfoLocalizationsApi;
44 pub use crate::app_screenshot::AppScreenshotsApi;
45 pub use crate::app_screenshot_set::AppScreenshotSetsApi;
46 + pub use crate::app_store_review_detail::AppStoreReviewDetailApi;
47 pub use crate::app_store_version::AppStoreVersionsApi;
48 pub use crate::app_store_version_localization::AppStoreVersionLocalizationsApi;
49 pub use crate::beta_app_review_detail::BetaAppReviewDetailApi;
crates/cli/src/main.rs
+137
@@ -13,6 +13,7 @@ use smbcloud_ascapi_aso::app_info_localization::{
13 use smbcloud_ascapi_aso::app_screenshot_set::{
14 AppScreenshotSetCreateAttributes, ScreenshotDisplayType,
15 };
16 +use smbcloud_ascapi_aso::app_store_review_detail::{AppStoreReviewDetailWrite, NOTES_MAX_LEN};
17 use smbcloud_ascapi_aso::app_store_version::{
18 AppStoreVersionCreateAttributes, AppStoreVersionUpdateFields, Platform,
19 };
@@ -604,6 +605,12 @@ enum Command {
605 #[command(subcommand)]
606 command: AppStoreVersionsCommand,
607 },
608 + /// The App Review Information of an App Store Version: contact, demo
609 + /// account and notes for the reviewer.
610 + AppStoreReviewDetails {
611 + #[command(subcommand)]
612 + command: AppStoreReviewDetailsCommand,
613 + },
614 /// Send an App Store Version to App Review, see what's waiting, or
615 /// withdraw a submission that hasn't been reviewed yet.
616 ReviewSubmissions {
@@ -1121,6 +1128,50 @@ enum BetaGroupsCommand {
1128 },
1129 }
1130
1131 +#[derive(Subcommand)]
1132 +enum AppStoreReviewDetailsCommand {
1133 + /// Show the review information of a version, or `null` when it has none.
1134 + Get {
1135 + /// The App Store Version id.
1136 + app_store_version_id: String,
1137 + },
1138 + /// Set the review information of a version. Creates it when the version
1139 + /// has none. Only supplied flags are sent. Each `--<field>-file` conflicts
1140 + /// with its inline flag.
1141 + Set(Box<ReviewDetailSetArgs>),
1142 +}
1143 +
1144 +#[derive(clap::Args)]
1145 +struct ReviewDetailSetArgs {
1146 + /// The App Store Version id.
1147 + app_store_version_id: String,
1148 + #[arg(long)]
1149 + contact_first_name: Option<String>,
1150 + #[arg(long)]
1151 + contact_last_name: Option<String>,
1152 + #[arg(long)]
1153 + contact_phone: Option<String>,
1154 + #[arg(long)]
1155 + contact_email: Option<String>,
1156 + /// Demo account username.
1157 + #[arg(long)]
1158 + demo_account_name: Option<String>,
1159 + /// Demo account password. Prefer `--demo-account-password-file` so it
1160 + /// stays out of shell history.
1161 + #[arg(long, conflicts_with = "demo_account_password_file")]
1162 + demo_account_password: Option<String>,
1163 + #[arg(long)]
1164 + demo_account_password_file: Option<std::path::PathBuf>,
1165 + /// Whether the reviewer needs the demo account to sign in.
1166 + #[arg(long)]
1167 + demo_account_required: Option<bool>,
1168 + /// Notes for the reviewer (max 4000 characters).
1169 + #[arg(long, conflicts_with = "notes_file")]
1170 + notes: Option<String>,
1171 + #[arg(long)]
1172 + notes_file: Option<std::path::PathBuf>,
1173 +}
1174 +
1175 #[derive(Subcommand)]
1176 enum BetaAppReviewDetailCommand {
1177 /// Fetch the Beta App Review contact details for an app.
@@ -2150,6 +2201,9 @@ async fn main() -> Result<()> {
2201 Command::AppStoreVersions { command } => {
2202 run_app_store_versions(&client, command, cli.dry_run).await
2203 }
2204 + Command::AppStoreReviewDetails { command } => {
2205 + run_app_store_review_details(&client, command, cli.dry_run).await
2206 + }
2207 Command::AppInfoLocalizations { command } => {
2208 run_app_info_localizations(&client, command, cli.dry_run).await
2209 }
@@ -2518,6 +2572,89 @@ async fn run_bundle_ids(client: &Client, command: BundleIdsCommand, dry_run: boo
2572 }
2573 }
2574
2575 +async fn run_app_store_review_details(
2576 + client: &Client,
2577 + command: AppStoreReviewDetailsCommand,
2578 + dry_run: bool,
2579 +) -> Result<()> {
2580 + match command {
2581 + AppStoreReviewDetailsCommand::Get {
2582 + app_store_version_id,
2583 + } => {
2584 + let detail = client
2585 + .get_app_store_review_detail(&app_store_version_id)
2586 + .await?;
2587 + print_json(&detail)
2588 + }
2589 + AppStoreReviewDetailsCommand::Set(args) => {
2590 + let ReviewDetailSetArgs {
2591 + app_store_version_id,
2592 + contact_first_name,
2593 + contact_last_name,
2594 + contact_phone,
2595 + contact_email,
2596 + demo_account_name,
2597 + demo_account_password,
2598 + demo_account_password_file,
2599 + demo_account_required,
2600 + notes,
2601 + notes_file,
2602 + } = *args;
2603 + let write = AppStoreReviewDetailWrite {
2604 + contact_first_name,
2605 + contact_last_name,
2606 + contact_phone,
2607 + contact_email,
2608 + demo_account_name,
2609 + demo_account_password: text_arg(
2610 + demo_account_password,
2611 + demo_account_password_file,
2612 + "--demo-account-password-file",
2613 + )?,
2614 + demo_account_required,
2615 + notes: text_arg(notes, notes_file, "--notes-file")?,
2616 + };
2617 + if let Some(notes) = &write.notes {
2618 + if notes.chars().count() > NOTES_MAX_LEN {
2619 + anyhow::bail!("notes are over {NOTES_MAX_LEN} characters");
2620 + }
2621 + }
2622 + let existing = client
2623 + .get_app_store_review_detail(&app_store_version_id)
2624 + .await?;
2625 + if dry_run {
2626 + let mut shown = serde_json::to_value(&write)?;
2627 + // The password is never printed.
2628 + if shown.get("demoAccountPassword").is_some() {
2629 + shown["demoAccountPassword"] = "<hidden>".into();
2630 + }
2631 + println!(
2632 + "[dry-run] would {} the review information of version {app_store_version_id}:",
2633 + if existing.is_some() {
2634 + "update"
2635 + } else {
2636 + "create"
2637 + }
2638 + );
2639 + return print_json(&shown);
2640 + }
2641 + let saved = match existing {
2642 + Some(detail) => {
2643 + client
2644 + .update_app_store_review_detail(&detail.id, write)
2645 + .await?
2646 + }
2647 + None => {
2648 + client
2649 + .create_app_store_review_detail(&app_store_version_id, write)
2650 + .await?
2651 + }
2652 + };
2653 + print_json(&saved)
2654 + }
2655 + }
2656 +}
2657 +
2658 async fn run_app_store_versions(
2659 client: &Client,
2660 command: AppStoreVersionsCommand,