From 0565d6f66750ab084c0398e38309e222b3bc2963 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Fri, 4 Dec 2020 12:05:31 -0500 Subject: [PATCH] Implemented tax collection for subscriptions (#215) --- src/abstractions/api.service.ts | 2 ++ .../request/organizationUpgradeRequest.ts | 2 ++ src/models/response/taxRateResponse.ts | 18 ++++++++++++++++++ src/services/api.service.ts | 6 ++++++ 4 files changed, 28 insertions(+) create mode 100644 src/models/response/taxRateResponse.ts diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 8d0e5652db..65b8356074 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -99,6 +99,7 @@ import { SendResponse } from '../models/response/sendResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SyncResponse } from '../models/response/syncResponse'; import { TaxInfoResponse } from '../models/response/taxInfoResponse'; +import { TaxRateResponse } from '../models/response/taxRateResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; @@ -299,6 +300,7 @@ export abstract class ApiService { postOrganizationReinstate: (id: string) => Promise; deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise; getPlans: () => Promise>; + getTaxRates: () => Promise>; getEvents: (start: string, end: string, token: string) => Promise>; getEventsCipher: (id: string, start: string, end: string, token: string) => Promise>; diff --git a/src/models/request/organizationUpgradeRequest.ts b/src/models/request/organizationUpgradeRequest.ts index 7f8793b2d1..0c0bfa8a07 100644 --- a/src/models/request/organizationUpgradeRequest.ts +++ b/src/models/request/organizationUpgradeRequest.ts @@ -6,4 +6,6 @@ export class OrganizationUpgradeRequest { additionalSeats: number; additionalStorageGb: number; premiumAccessAddon: boolean; + billingAddressCountry: string; + billingAddressPostalCode: string; } diff --git a/src/models/response/taxRateResponse.ts b/src/models/response/taxRateResponse.ts new file mode 100644 index 0000000000..83970afac5 --- /dev/null +++ b/src/models/response/taxRateResponse.ts @@ -0,0 +1,18 @@ +import { BaseResponse } from './baseResponse'; + +export class TaxRateResponse extends BaseResponse { + id: string; + country: string; + state: string; + postalCode: string; + rate: number; + + constructor(response: any) { + super(response); + this.id = this.getResponseProperty('Id'); + this.country = this.getResponseProperty('Country'); + this.state = this.getResponseProperty('State'); + this.postalCode = this.getResponseProperty('PostalCode'); + this.rate = this.getResponseProperty('Rate'); + } +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index cfcdddb573..037c8c6d9c 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -104,6 +104,7 @@ import { SendResponse } from '../models/response/sendResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SyncResponse } from '../models/response/syncResponse'; import { TaxInfoResponse } from '../models/response/taxInfoResponse'; +import { TaxRateResponse } from '../models/response/taxRateResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; @@ -760,6 +761,11 @@ export class ApiService implements ApiServiceAbstraction { return this.send('POST', '/organizations/' + organizationId + '/import', request, true, false); } + async getTaxRates(): Promise> { + const r = await this.send('GET', '/plans/sales-tax-rates/', null, true, true); + return new ListResponse(r, TaxRateResponse); + } + // Settings APIs async getSettingsDomains(): Promise {