Add playProductId to backup level configuration
This commit is contained in:
parent
564dba3053
commit
7df978390f
|
@ -29,6 +29,7 @@ public sealed interface SubscriptionLevelConfiguration permits
|
||||||
}
|
}
|
||||||
|
|
||||||
record Backup(
|
record Backup(
|
||||||
|
@JsonProperty("playProductId") @NotEmpty String playProductId,
|
||||||
@JsonProperty("prices") @Valid Map<@NotEmpty String, @NotNull @Valid SubscriptionPriceConfiguration> prices)
|
@JsonProperty("prices") @Valid Map<@NotEmpty String, @NotNull @Valid SubscriptionPriceConfiguration> prices)
|
||||||
implements SubscriptionLevelConfiguration {}
|
implements SubscriptionLevelConfiguration {}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class SubscriptionController {
|
||||||
.entrySet().stream()
|
.entrySet().stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
e -> String.valueOf(e.getKey()),
|
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,
|
return new GetSubscriptionConfigurationResponse(buildCurrencyConfiguration(), donationLevels,
|
||||||
new BackupConfiguration(backupLevels, subscriptionConfiguration.getbackupFreeTierMediaDuration().toDays()),
|
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")
|
@Schema(description = "A map of numeric backup level IDs to level-specific backup configuration")
|
||||||
Map<String, BackupLevelConfiguration> levels,
|
Map<String, BackupLevelConfiguration> levels,
|
||||||
@Schema(description = "The number of days of media a free tier backup user gets")
|
@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")
|
@Schema(description = "Configuration for a backup level - use to present appropriate client interfaces")
|
||||||
public record BackupLevelConfiguration(
|
public record BackupLevelConfiguration(
|
||||||
@Schema(description = "The amount of media storage in bytes that a paying subscriber may store")
|
@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
|
@GET
|
||||||
@Path("/configuration")
|
@Path("/configuration")
|
||||||
|
|
|
@ -1107,8 +1107,9 @@ class SubscriptionControllerTest {
|
||||||
|
|
||||||
assertThat(response.backup().levels()).containsOnlyKeys("201").extractingByKey("201").satisfies(configuration -> {
|
assertThat(response.backup().levels()).containsOnlyKeys("201").extractingByKey("201").satisfies(configuration -> {
|
||||||
assertThat(configuration.storageAllowanceBytes()).isEqualTo(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES);
|
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
|
// check the badge vs purchasable badge fields
|
||||||
// subscription levels are Badge, while one-time levels are PurchasableBadge, which adds `duration`
|
// subscription levels are Badge, while one-time levels are PurchasableBadge, which adds `duration`
|
||||||
|
@ -1165,6 +1166,7 @@ class SubscriptionControllerTest {
|
||||||
backupFreeTierMediaDuration: P30D
|
backupFreeTierMediaDuration: P30D
|
||||||
backupLevels:
|
backupLevels:
|
||||||
201:
|
201:
|
||||||
|
playProductId: testPlayProductId
|
||||||
prices:
|
prices:
|
||||||
usd:
|
usd:
|
||||||
amount: '5'
|
amount: '5'
|
||||||
|
|
Loading…
Reference in New Issue