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 asc play details get and update
Reads and patches edits.details: contact website, email, phone and default language. update honors --dry-run and reads the values back from a fresh edit after commit, failing if any requested field differs. AdMob checks the developer website, so this covers that step from the CLI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Nov 10, 2026 at 00:04 UTC
b481b990e4be29282f244f6f71ad6b736c43bece
6 files changed
+219
-4
.agents/AGENTS.md
+2
@@ -307,6 +307,8 @@ Everything in Play happens inside an *edit*. Each command opens one, applies,
307
and deletes the edit. Writes read back after commit and fail on any difference.
308
309
```sh
310
+asc play details get <PACKAGE>
311
+asc play details update <PACKAGE> [--contact-website U] [--contact-email E] [--contact-phone P] [--default-language L]
312
asc play listings list <PACKAGE>
313
asc play listings update <PACKAGE> --locale en-US \
314
--title-file t.txt --short-description-file s.txt --full-description-file d.txt
crates/cli/src/main.rs
+53
-2
@@ -41,8 +41,8 @@ use smbcloud_ascapi_iap::localization::LocalizationUpdate;
41
use smbcloud_ascapi_iap::prelude::*;
42
use smbcloud_ascapi_msstore::ListingFields as MsStoreListingFields;
43
use smbcloud_ascapi_play::{
44
- ImageType as PlayImageType, ListingFields as PlayListingFields, Money as PlayMoney,
45
- NewProduct as PlayNewProduct,
44
+ Details as PlayDetails, ImageType as PlayImageType, ListingFields as PlayListingFields,
45
+ Money as PlayMoney, NewProduct as PlayNewProduct,
46
};
47
use smbcloud_ascapi_pricing::app_price::PriceKind;
48
use smbcloud_ascapi_pricing::prelude::*;
@@ -96,8 +96,33 @@ struct Cli {
96
command: Option<Command>,
97
}
98
99
+#[derive(Subcommand)]
100
+enum PlayDetailsCommand {
101
+ /// Contact website, email, phone and default language.
102
+ Get { package: String },
103
+ /// Patch the details, then read them back from a fresh edit. Honors
104
+ /// --dry-run.
105
+ Update {
106
+ package: String,
107
+ #[arg(long)]
108
+ contact_website: Option<String>,
109
+ #[arg(long)]
110
+ contact_email: Option<String>,
111
+ #[arg(long)]
112
+ contact_phone: Option<String>,
113
+ /// BCP-47 tag, for example en-US.
114
+ #[arg(long)]
115
+ default_language: Option<String>,
116
+ },
117
+}
118
+
119
#[derive(Subcommand)]
120
enum PlayCommand {
121
+ /// App details: contact website, email, phone, default language.
122
+ Details {
123
+ #[command(subcommand)]
124
+ command: PlayDetailsCommand,
125
+ },
126
/// Localized store listing text (title, short and full description).
127
Listings {
128
#[command(subcommand)]
@@ -1370,6 +1395,32 @@ async fn run_play(
1395
let client = play::play_client(service_account).map_err(|e| anyhow::anyhow!(e))?;
1396
let fail = |e: String| anyhow::anyhow!(e);
1397
match command {
1398
+ PlayCommand::Details { command } => match command {
1399
+ PlayDetailsCommand::Get { package } => {
1400
+ print_json(&play::read_details(&client, &package).await.map_err(fail)?)
1401
+ }
1402
+ PlayDetailsCommand::Update {
1403
+ package,
1404
+ contact_website,
1405
+ contact_email,
1406
+ contact_phone,
1407
+ default_language,
1408
+ } => {
1409
+ let details = PlayDetails {
1410
+ contact_website,
1411
+ contact_email,
1412
+ contact_phone,
1413
+ default_language,
1414
+ };
1415
+ let result = play::update_details(&client, &package, details, dry_run)
1416
+ .await
1417
+ .map_err(fail)?;
1418
+ if result.dry_run {
1419
+ println!("# dry run: nothing was committed; body that would be sent:");
1420
+ }
1421
+ print_json(&result)
1422
+ }
1423
+ },
1424
PlayCommand::Listings { command } => match command {
1425
PlayListingsCommand::List { package } => {
1426
print_json(&play::read_listings(&client, &package).await.map_err(fail)?)
crates/frontend/src/play.rs
+59
-2
@@ -15,8 +15,8 @@ use smbcloud_ascapi_play::{
15
check_applied, existing_price, is_billing_refusal, pick_purchase_option, product_body,
16
purchase_option_state, regions_version, BILLING_HINT,
17
},
18
- Image, ImageType, Listing, ListingFields, Money, NewProduct, PlayClient, ProductChanges,
19
- RolloutAction, ServiceAccount, Track,
18
+ Details, Image, ImageType, Listing, ListingFields, Money, NewProduct, PlayClient,
19
+ ProductChanges, RolloutAction, ServiceAccount, Track,
20
};
21
22
/// Resolve the Play client. `path` wins; then `PLAY_SERVICE_ACCOUNT_JSON_PATH`;
@@ -133,6 +133,63 @@ pub async fn read_track(client: &PlayClient, package: &str, track: &str) -> Resu
133
})
134
}
135
136
+pub async fn read_details(client: &PlayClient, package: &str) -> Result<Details, String> {
137
+ in_edit!(client, package, false, |c, id| {
138
+ Box::pin(async move { c.get_details(package, id).await.map_err(err) })
139
+ })
140
+}
141
+
142
+/// The result of a details update.
143
+#[derive(Debug, Serialize)]
144
+#[serde(rename_all = "camelCase")]
145
+pub struct DetailsUpdate {
146
+ pub dry_run: bool,
147
+ pub sent: Details,
148
+ pub before: Details,
149
+ /// Read back from a fresh edit after commit. `None` on a dry run.
150
+ pub after: Option<Details>,
151
+}
152
+
153
+pub async fn update_details(
154
+ client: &PlayClient,
155
+ package: &str,
156
+ details: Details,
157
+ dry_run: bool,
158
+) -> Result<DetailsUpdate, String> {
159
+ if details.is_empty() {
160
+ return Err("nothing to update: pass at least one details field".to_string());
161
+ }
162
+ let sent = details.clone();
163
+ let before = in_edit!(client, package, !dry_run, |c, id| {
164
+ Box::pin(async move {
165
+ let before = c.get_details(package, id).await.map_err(err)?;
166
+ if !dry_run {
167
+ c.patch_details(package, id, &details).await.map_err(err)?;
168
+ }
169
+ Ok(before)
170
+ })
171
+ })?;
172
+ let after = if dry_run {
173
+ None
174
+ } else {
175
+ let stored = read_details(client, package).await?;
176
+ let wrong = sent.diff(&stored);
177
+ if !wrong.is_empty() {
178
+ return Err(format!(
179
+ "committed, but the read-back differs in: {}",
180
+ wrong.join(", ")
181
+ ));
182
+ }
183
+ Some(stored)
184
+ };
185
+ Ok(DetailsUpdate {
186
+ dry_run,
187
+ sent,
188
+ before,
189
+ after,
190
+ })
191
+}
192
+
193
/// The result of a listing update.
194
#[derive(Debug, Serialize)]
195
#[serde(rename_all = "camelCase")]
crates/play/src/client.rs
+25
@@ -3,6 +3,7 @@ use serde::de::DeserializeOwned;
3
use serde::{Deserialize, Serialize};
4
5
use crate::auth::{ServiceAccount, TokenCache};
6
+use crate::details::Details;
7
use crate::error::{Error, Result};
8
use crate::image::{Image, ImageType};
9
use crate::listing::{Listing, ListingFields};
@@ -218,6 +219,30 @@ impl PlayClient {
219
.await
220
}
221
222
+ pub async fn get_details(&self, package: &str, edit_id: &str) -> Result<Details> {
223
+ self.json(
224
+ Method::GET,
225
+ &edits_path(package, &format!("/{edit_id}/details")),
226
+ None::<&()>,
227
+ )
228
+ .await
229
+ }
230
+
231
+ /// `details.patch`: only the fields set in `details` change.
232
+ pub async fn patch_details(
233
+ &self,
234
+ package: &str,
235
+ edit_id: &str,
236
+ details: &Details,
237
+ ) -> Result<Details> {
238
+ self.json(
239
+ Method::PATCH,
240
+ &edits_path(package, &format!("/{edit_id}/details")),
241
+ Some(details),
242
+ )
243
+ .await
244
+ }
245
+
246
pub async fn list_listings(&self, package: &str, edit_id: &str) -> Result<Vec<Listing>> {
247
#[derive(Deserialize)]
248
struct Page {
crates/play/src/details.rs
new
+78
@@ -0,0 +1,78 @@
1
+use serde::{Deserialize, Serialize};
2
+
3
+/// `edits.details`: the app's contact details and default language.
4
+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
5
+#[serde(rename_all = "camelCase")]
6
+pub struct Details {
7
+ #[serde(default, skip_serializing_if = "Option::is_none")]
8
+ pub contact_website: Option<String>,
9
+ #[serde(default, skip_serializing_if = "Option::is_none")]
10
+ pub contact_email: Option<String>,
11
+ #[serde(default, skip_serializing_if = "Option::is_none")]
12
+ pub contact_phone: Option<String>,
13
+ #[serde(default, skip_serializing_if = "Option::is_none")]
14
+ pub default_language: Option<String>,
15
+}
16
+
17
+impl Details {
18
+ pub fn is_empty(&self) -> bool {
19
+ self == &Self::default()
20
+ }
21
+
22
+ /// Names of the fields set here whose value differs in `stored`.
23
+ pub fn diff(&self, stored: &Details) -> Vec<&'static str> {
24
+ let mut wrong = Vec::new();
25
+ let mut check = |name, want: &Option<String>, got: &Option<String>| {
26
+ if want.is_some() && want != got {
27
+ wrong.push(name);
28
+ }
29
+ };
30
+ check(
31
+ "contactWebsite",
32
+ &self.contact_website,
33
+ &stored.contact_website,
34
+ );
35
+ check("contactEmail", &self.contact_email, &stored.contact_email);
36
+ check("contactPhone", &self.contact_phone, &stored.contact_phone);
37
+ check(
38
+ "defaultLanguage",
39
+ &self.default_language,
40
+ &stored.default_language,
41
+ );
42
+ wrong
43
+ }
44
+}
45
+
46
+#[cfg(test)]
47
+mod tests {
48
+ use super::*;
49
+
50
+ #[test]
51
+ fn unset_fields_are_left_out_of_the_body() {
52
+ let d = Details {
53
+ contact_website: Some("https://a.app".into()),
54
+ ..Default::default()
55
+ };
56
+ assert_eq!(
57
+ serde_json::to_value(&d).unwrap(),
58
+ serde_json::json!({"contactWebsite": "https://a.app"})
59
+ );
60
+ }
61
+
62
+ #[test]
63
+ fn diff_names_only_requested_fields_that_differ() {
64
+ let want = Details {
65
+ contact_website: Some("x".into()),
66
+ contact_email: Some("e".into()),
67
+ ..Default::default()
68
+ };
69
+ let got = Details {
70
+ contact_website: Some("x".into()),
71
+ contact_email: Some("other".into()),
72
+ contact_phone: Some("1".into()),
73
+ ..Default::default()
74
+ };
75
+ assert_eq!(want.diff(&got), vec!["contactEmail"]);
76
+ assert!(Details::default().is_empty());
77
+ }
78
+}
crates/play/src/lib.rs
+2
@@ -9,6 +9,7 @@
9
10
pub mod auth;
11
pub mod client;
12
+pub mod details;
13
pub mod error;
14
pub mod image;
15
pub mod listing;
@@ -17,6 +18,7 @@ pub mod track;
18
19
pub use auth::ServiceAccount;
20
pub use client::{Edit, PlayClient, UploadedBundle};
21
+pub use details::Details;
22
pub use error::{Error, Result};
23
pub use image::{png_dimensions, Image, ImageType};
24
pub use listing::{