diff --git a/src/enums/transactionType.ts b/src/enums/transactionType.ts new file mode 100644 index 0000000000..68cce6322f --- /dev/null +++ b/src/enums/transactionType.ts @@ -0,0 +1,7 @@ +export enum TransactionType { + Charge = 0, + Credit = 1, + PromotionalCredit = 2, + ReferralCredit = 3, + Refund = 4, +} diff --git a/src/models/response/billingResponse.ts b/src/models/response/billingResponse.ts index 4c3cd5ad01..2e32dfcb4b 100644 --- a/src/models/response/billingResponse.ts +++ b/src/models/response/billingResponse.ts @@ -1,4 +1,5 @@ import { PaymentMethodType } from '../../enums/paymentMethodType'; +import { TransactionType } from '../../enums/transactionType'; export class BillingResponse { storageName: string; @@ -6,8 +7,10 @@ export class BillingResponse { maxStorageGb: number; paymentSource: BillingSourceResponse; subscription: BillingSubscriptionResponse; - upcomingInvoice: BillingInvoiceResponse; + upcomingInvoice: BillingInvoiceInfoResponse; charges: BillingChargeResponse[] = []; + invoices: BillingInvoiceResponse[] = []; + transactions: BillingTransactionResponse[] = []; license: any; expiration: string; @@ -19,10 +22,16 @@ export class BillingResponse { this.subscription = response.Subscription == null ? null : new BillingSubscriptionResponse(response.Subscription); this.upcomingInvoice = response.UpcomingInvoice == null ? - null : new BillingInvoiceResponse(response.UpcomingInvoice); + null : new BillingInvoiceInfoResponse(response.UpcomingInvoice); if (response.Charges != null) { this.charges = response.Charges.map((c: any) => new BillingChargeResponse(c)); } + if (response.Transactions != null) { + this.transactions = response.Transactions.map((t: any) => new BillingTransactionResponse(t)); + } + if (response.Invoices != null) { + this.invoices = response.Invoices.map((i: any) => new BillingInvoiceResponse(i)); + } this.license = response.License; this.expiration = response.Expiration; } @@ -82,7 +91,7 @@ export class BillingSubscriptionItemResponse { } } -export class BillingInvoiceResponse { +export class BillingInvoiceInfoResponse { date: string; amount: number; @@ -115,3 +124,40 @@ export class BillingChargeResponse { this.invoiceId = response.InvoiceId; } } + +export class BillingInvoiceResponse extends BillingInvoiceInfoResponse { + url: string; + pdfUrl: string; + number: string; + paid: boolean; + + constructor(response: any) { + super(response); + this.url = response.Url; + this.pdfUrl = response.PdfUrl; + this.number = response.Number; + this.paid = response.Paid; + } +} + +export class BillingTransactionResponse { + createdDate: string; + amount: number; + refunded: boolean; + partiallyRefunded: boolean; + refundedAmount: number; + type: TransactionType; + paymentMethodType: PaymentMethodType; + details: string; + + constructor(response: any) { + this.createdDate = response.CreatedDate; + this.amount = response.Amount; + this.refunded = response.Refunded; + this.partiallyRefunded = response.PartiallyRefunded; + this.refundedAmount = response.RefundedAmount; + this.type = response.Type; + this.paymentMethodType = response.PaymentMethodType; + this.details = response.Details; + } +} diff --git a/src/models/response/organizationBillingResponse.ts b/src/models/response/organizationBillingResponse.ts index f68ef9e6c8..258da85b67 100644 --- a/src/models/response/organizationBillingResponse.ts +++ b/src/models/response/organizationBillingResponse.ts @@ -1,8 +1,10 @@ import { BillingChargeResponse, + BillingInvoiceInfoResponse, BillingInvoiceResponse, BillingSourceResponse, BillingSubscriptionResponse, + BillingTransactionResponse, } from './billingResponse'; import { OrganizationResponse } from './organizationResponse'; @@ -11,8 +13,10 @@ export class OrganizationBillingResponse extends OrganizationResponse { storageGb: number; paymentSource: BillingSourceResponse; subscription: BillingSubscriptionResponse; - upcomingInvoice: BillingInvoiceResponse; + upcomingInvoice: BillingInvoiceInfoResponse; charges: BillingChargeResponse[] = []; + invoices: BillingInvoiceResponse[] = []; + transactions: BillingTransactionResponse[] = []; expiration: string; constructor(response: any) { @@ -23,10 +27,16 @@ export class OrganizationBillingResponse extends OrganizationResponse { this.subscription = response.Subscription == null ? null : new BillingSubscriptionResponse(response.Subscription); this.upcomingInvoice = response.UpcomingInvoice == null ? - null : new BillingInvoiceResponse(response.UpcomingInvoice); + null : new BillingInvoiceInfoResponse(response.UpcomingInvoice); if (response.Charges != null) { this.charges = response.Charges.map((c: any) => new BillingChargeResponse(c)); } + if (response.Transactions != null) { + this.transactions = response.Transactions.map((t: any) => new BillingTransactionResponse(t)); + } + if (response.Invoices != null) { + this.invoices = response.Invoices.map((i: any) => new BillingInvoiceResponse(i)); + } this.expiration = response.Expiration; } }