diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 7809b9e397..56b6f61836 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -61,6 +61,7 @@ import { GroupUserResponse } from '../models/response/groupUserResponse'; import { IdentityTokenResponse } from '../models/response/identityTokenResponse'; import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; +import { OrganizationBillingResponse } from '../models/response/organizationBillingResponse'; import { OrganizationResponse } from '../models/response/organizationResponse'; import { OrganizationUserDetailsResponse, @@ -93,7 +94,7 @@ export abstract class ApiService { postEmail: (request: EmailRequest) => Promise; postPassword: (request: PasswordRequest) => Promise; postSecurityStamp: (request: PasswordVerificationRequest) => Promise; - postDeleteAccount: (request: PasswordVerificationRequest) => Promise; + deleteAccount: (request: PasswordVerificationRequest) => Promise; getAccountRevisionDate: () => Promise; postPasswordHint: (request: PasswordHintRequest) => Promise; postRegister: (request: RegisterRequest) => Promise; @@ -194,11 +195,14 @@ export abstract class ApiService { postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise; getOrganization: (id: string) => Promise; + getOrganizationBilling: (id: string) => Promise; postOrganization: (request: OrganizationCreateRequest) => Promise; putOrganization: (id: string, request: OrganizationUpdateRequest) => Promise; postLeaveOrganization: (id: string) => Promise; postOrganizationLicense: (data: FormData) => Promise; - postDeleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise; + postOrganizationStorage: (id: string, request: StorageRequest) => Promise; + postOrganizationPayment: (id: string, request: PaymentRequest) => Promise; + deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise; getEvents: (start: string, end: string, token: string) => Promise>; getEventsCipher: (id: string, start: string, end: string, token: string) => Promise>; diff --git a/src/models/response/organizationBillingResponse.ts b/src/models/response/organizationBillingResponse.ts new file mode 100644 index 0000000000..db5e5ca2bb --- /dev/null +++ b/src/models/response/organizationBillingResponse.ts @@ -0,0 +1,32 @@ +import { + BillingChargeResponse, + BillingInvoiceResponse, + BillingSourceResponse, + BillingSubscriptionResponse, +} from './billingResponse'; +import { OrganizationResponse } from './organizationResponse'; + +export class OrganizationBillingResponse extends OrganizationResponse { + storageName: string; + storageGb: number; + paymentSource: BillingSourceResponse; + subscription: BillingSubscriptionResponse; + upcomingInvoice: BillingInvoiceResponse; + charges: BillingChargeResponse[] = []; + expiration: Date; + + constructor(response: any) { + super(response); + this.storageName = response.StorageName; + this.storageGb = response.StorageGb; + this.paymentSource = response.PaymentSource == null ? null : new BillingSourceResponse(response.PaymentSource); + this.subscription = response.Subscription == null ? + null : new BillingSubscriptionResponse(response.Subscription); + this.upcomingInvoice = response.UpcomingInvoice == null ? + null : new BillingInvoiceResponse(response.UpcomingInvoice); + if (response.Charges != null) { + this.charges = response.Charges.map((c: any) => new BillingChargeResponse(c)); + } + this.expiration = response.Expiration; + } +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 8b0c6fd825..1a09753848 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -68,6 +68,7 @@ import { GroupUserResponse } from '../models/response/groupUserResponse'; import { IdentityTokenResponse } from '../models/response/identityTokenResponse'; import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; +import { OrganizationBillingResponse } from '../models/response/organizationBillingResponse'; import { OrganizationResponse } from '../models/response/organizationResponse'; import { OrganizationUserDetailsResponse, @@ -208,8 +209,8 @@ export class ApiService implements ApiServiceAbstraction { return this.send('POST', '/accounts/security-stamp', request, true, false); } - postDeleteAccount(request: PasswordVerificationRequest): Promise { - return this.send('POST', '/accounts/delete', request, true, false); + deleteAccount(request: PasswordVerificationRequest): Promise { + return this.send('DELETE', '/accounts/delete', request, true, false); } async getAccountRevisionDate(): Promise { @@ -632,6 +633,11 @@ export class ApiService implements ApiServiceAbstraction { return new OrganizationResponse(r); } + async getOrganizationBilling(id: string): Promise { + const r = await this.send('GET', '/organizations/' + id + '/billing', null, true, true); + return new OrganizationBillingResponse(r); + } + async postOrganization(request: OrganizationCreateRequest): Promise { const r = await this.send('POST', '/organizations', request, true, true); return new OrganizationResponse(r); @@ -651,8 +657,16 @@ export class ApiService implements ApiServiceAbstraction { return new OrganizationResponse(r); } - postDeleteOrganization(id: string, request: PasswordVerificationRequest): Promise { - return this.send('POST', '/organizations/' + id + '/delete', request, true, false); + postOrganizationStorage(id: string, request: StorageRequest): Promise { + return this.send('POST', '/organizations/' + id + '/storage', request, true, false); + } + + postOrganizationPayment(id: string, request: PaymentRequest): Promise { + return this.send('POST', '/organizations/' + id + '/payment', request, true, false); + } + + deleteOrganization(id: string, request: PasswordVerificationRequest): Promise { + return this.send('DELETE', '/organizations/' + id, request, true, false); } // Event APIs