Add playProductId to backup level configuration

This commit is contained in:
ravi-signal 2024-08-30 12:59:09 -05:00 committed by GitHub
parent 564dba3053
commit 7df978390f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -29,6 +29,7 @@ public sealed interface SubscriptionLevelConfiguration permits
}
record Backup(
@JsonProperty("playProductId") @NotEmpty String playProductId,
@JsonProperty("prices") @Valid Map<@NotEmpty String, @NotNull @Valid SubscriptionPriceConfiguration> prices)
implements SubscriptionLevelConfiguration {}

View File

@ -210,7 +210,7 @@ public class SubscriptionController {
.entrySet().stream()
.collect(Collectors.toMap(
e -> String.valueOf(e.getKey()),
ignored -> new BackupLevelConfiguration(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES)));
e -> new BackupLevelConfiguration(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES, e.getValue().playProductId())));
return new GetSubscriptionConfigurationResponse(buildCurrencyConfiguration(), donationLevels,
new BackupConfiguration(backupLevels, subscriptionConfiguration.getbackupFreeTierMediaDuration().toDays()),
@ -476,12 +476,14 @@ public class SubscriptionController {
@Schema(description = "A map of numeric backup level IDs to level-specific backup configuration")
Map<String, BackupLevelConfiguration> levels,
@Schema(description = "The number of days of media a free tier backup user gets")
long backupFreeTierMediaDays) {}
long freeTierMediaDays) {}
@Schema(description = "Configuration for a backup level - use to present appropriate client interfaces")
public record BackupLevelConfiguration(
@Schema(description = "The amount of media storage in bytes that a paying subscriber may store")
long storageAllowanceBytes) {}
long storageAllowanceBytes,
@Schema(description = "The play billing productID associated with this backup level")
String playProductId) {}
@GET
@Path("/configuration")

View File

@ -1107,8 +1107,9 @@ class SubscriptionControllerTest {
assertThat(response.backup().levels()).containsOnlyKeys("201").extractingByKey("201").satisfies(configuration -> {
assertThat(configuration.storageAllowanceBytes()).isEqualTo(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES);
assertThat(configuration.playProductId()).isEqualTo("testPlayProductId");
});
assertThat(response.backup().backupFreeTierMediaDays()).isEqualTo(30);
assertThat(response.backup().freeTierMediaDays()).isEqualTo(30);
// check the badge vs purchasable badge fields
// subscription levels are Badge, while one-time levels are PurchasableBadge, which adds `duration`
@ -1165,6 +1166,7 @@ class SubscriptionControllerTest {
backupFreeTierMediaDuration: P30D
backupLevels:
201:
playProductId: testPlayProductId
prices:
usd:
amount: '5'