diff --git a/apps/web/src/app/billing/organizations/adjust-subscription.component.ts b/apps/web/src/app/billing/organizations/adjust-subscription.component.ts index 012d815b5f..7fbdcf0581 100644 --- a/apps/web/src/app/billing/organizations/adjust-subscription.component.ts +++ b/apps/web/src/app/billing/organizations/adjust-subscription.component.ts @@ -39,7 +39,10 @@ export class AdjustSubscription { async submit() { try { const seatAdjustment = this.newSeatCount - this.currentSeatCount; - const request = new OrganizationSubscriptionUpdateRequest(seatAdjustment, this.newMaxSeats); + const request = OrganizationSubscriptionUpdateRequest.forPasswordManager( + seatAdjustment, + this.newMaxSeats + ); this.formPromise = this.organizationApiService.updateSubscription( this.organizationId, request diff --git a/libs/common/src/billing/models/request/organization-subscription-update.request.ts b/libs/common/src/billing/models/request/organization-subscription-update.request.ts index 9db3d4be80..35bd22993d 100644 --- a/libs/common/src/billing/models/request/organization-subscription-update.request.ts +++ b/libs/common/src/billing/models/request/organization-subscription-update.request.ts @@ -1,3 +1,69 @@ +import { BitwardenProductType } from "../../enums/bitwarden-product-type.enum"; + export class OrganizationSubscriptionUpdateRequest { - constructor(public seatAdjustment: number, public maxAutoscaleSeats?: number) {} + productType: BitwardenProductType; + + /** + * The number of seats to add or remove from the subscription. + * Applies to both PM and SM request types. + */ + seatAdjustment: number; + + /** + * The maximum number of seats that can be auto-scaled for the subscription. + * Applies to both PM and SM request types. + */ + maxAutoscaleSeats?: number; + + /** + * The number of additional service accounts to add or remove from the subscription. + * Applies only to the SM request type. + */ + serviceAccountAdjustment?: number; + + /** + * The maximum number of additional service accounts that can be auto-scaled for the subscription. + * Applies only to the SM request type. + */ + maxAutoscaleServiceAccounts?: number; + + constructor(productType: BitwardenProductType) { + this.productType = productType; + } + + /** + * Build a subscription update request for the Password Manager product type. + * @param seatAdjustment - The number of seats to add or remove from the subscription. + * @param maxAutoscaleSeats - The maximum number of seats that can be auto-scaled for the subscription. + */ + static forPasswordManager( + seatAdjustment: number, + maxAutoscaleSeats?: number + ): OrganizationSubscriptionUpdateRequest { + const request = new OrganizationSubscriptionUpdateRequest(BitwardenProductType.PasswordManager); + request.seatAdjustment = seatAdjustment; + request.maxAutoscaleSeats = maxAutoscaleSeats; + return request; + } + + /** + * Build a subscription update request for the Secrets Manager product type. + * @param seatAdjustment - The number of seats to add or remove from the subscription. + * @param serviceAccountAdjustment - The number of additional service accounts to add or remove from the subscription. + * @param maxAutoscaleSeats - The maximum number of seats that can be auto-scaled for the subscription. + * @param maxAutoscaleServiceAccounts - The maximum number of additional service accounts that can be auto-scaled for the subscription. + */ + static forSecretsManager( + seatAdjustment: number, + serviceAccountAdjustment: number, + maxAutoscaleSeats?: number, + maxAutoscaleServiceAccounts?: number + ): OrganizationSubscriptionUpdateRequest { + const request = new OrganizationSubscriptionUpdateRequest(BitwardenProductType.SecretsManager); + request.seatAdjustment = seatAdjustment; + request.serviceAccountAdjustment = serviceAccountAdjustment; + request.maxAutoscaleSeats = maxAutoscaleSeats; + request.maxAutoscaleServiceAccounts = maxAutoscaleServiceAccounts; + return request; + } }