From dea0233ee38b9cb4d25ca9ef8fc69b6af8a7068f Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Fri, 12 Jun 2020 19:29:52 -0400 Subject: [PATCH] Support tax collection info --- src/abstractions/api.service.ts | 7 ++++++ .../request/organizationCreateRequest.ts | 7 ++++++ .../organizationTaxInfoUpdateRequest.ts | 9 +++++++ src/models/request/taxInfoUpdateRequest.ts | 4 ++++ src/models/response/taxInfoResponse.ts | 24 +++++++++++++++++++ src/services/api.service.ts | 21 ++++++++++++++++ 6 files changed, 72 insertions(+) create mode 100644 src/models/request/organizationTaxInfoUpdateRequest.ts create mode 100644 src/models/request/taxInfoUpdateRequest.ts create mode 100644 src/models/response/taxInfoResponse.ts diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 1fc71b9c1c..3411f06028 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -25,6 +25,7 @@ import { ImportOrganizationCiphersRequest } from '../models/request/importOrgani import { KdfRequest } from '../models/request/kdfRequest'; import { KeysRequest } from '../models/request/keysRequest'; import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest'; +import { OrganizationTaxInfoUpdateRequest } from '../models/request/organizationTaxInfoUpdateRequest'; import { OrganizationUpdateRequest } from '../models/request/organizationUpdateRequest'; import { OrganizationUpgradeRequest } from '../models/request/organizationUpgradeRequest'; import { OrganizationUserAcceptRequest } from '../models/request/organizationUserAcceptRequest'; @@ -42,6 +43,7 @@ import { RegisterRequest } from '../models/request/registerRequest'; import { SeatRequest } from '../models/request/seatRequest'; import { SelectionReadOnlyRequest } from '../models/request/selectionReadOnlyRequest'; import { StorageRequest } from '../models/request/storageRequest'; +import { TaxInfoUpdateRequest } from '../models/request/taxInfoUpdateRequest'; import { TokenRequest } from '../models/request/tokenRequest'; import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest'; import { TwoFactorProviderRequest } from '../models/request/twoFactorProviderRequest'; @@ -90,6 +92,7 @@ import { ProfileResponse } from '../models/response/profileResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SyncResponse } from '../models/response/syncResponse'; +import { TaxInfoResponse } from '../models/response/taxInfoResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; @@ -115,7 +118,9 @@ export abstract class ApiService { getProfile: () => Promise; getUserBilling: () => Promise; getUserSubscription: () => Promise; + getTaxInfo: () => Promise; putProfile: (request: UpdateProfileRequest) => Promise; + putTaxInfo: (request: TaxInfoUpdateRequest) => Promise; postPrelogin: (request: PreloginRequest) => Promise; postEmailToken: (request: EmailTokenRequest) => Promise; postEmail: (request: EmailRequest) => Promise; @@ -254,8 +259,10 @@ export abstract class ApiService { getOrganizationBilling: (id: string) => Promise; getOrganizationSubscription: (id: string) => Promise; getOrganizationLicense: (id: string, installationId: string) => Promise; + getOrganizationTaxInfo: (id: string) => Promise; postOrganization: (request: OrganizationCreateRequest) => Promise; putOrganization: (id: string, request: OrganizationUpdateRequest) => Promise; + putOrganizationTaxInfo: (id: string, request: OrganizationTaxInfoUpdateRequest) => Promise; postLeaveOrganization: (id: string) => Promise; postOrganizationLicense: (data: FormData) => Promise; postOrganizationLicenseUpdate: (id: string, data: FormData) => Promise; diff --git a/src/models/request/organizationCreateRequest.ts b/src/models/request/organizationCreateRequest.ts index c7f7da6822..8366b4cff3 100644 --- a/src/models/request/organizationCreateRequest.ts +++ b/src/models/request/organizationCreateRequest.ts @@ -13,4 +13,11 @@ export class OrganizationCreateRequest { additionalStorageGb: number; premiumAccessAddon: boolean; collectionName: string; + taxIdNumber: string; + billingAddressLine1: string; + billingAddressLine2: string; + billingAddressCity: string; + billingAddressState: string; + billingAddressPostalCode: string; + billingAddressCountry: string; } diff --git a/src/models/request/organizationTaxInfoUpdateRequest.ts b/src/models/request/organizationTaxInfoUpdateRequest.ts new file mode 100644 index 0000000000..73df4ad50c --- /dev/null +++ b/src/models/request/organizationTaxInfoUpdateRequest.ts @@ -0,0 +1,9 @@ +import { TaxInfoUpdateRequest } from './taxInfoUpdateRequest'; + +export class OrganizationTaxInfoUpdateRequest extends TaxInfoUpdateRequest { + taxId: string; + line1: string; + line2: string; + city: string; + state: string; +} diff --git a/src/models/request/taxInfoUpdateRequest.ts b/src/models/request/taxInfoUpdateRequest.ts new file mode 100644 index 0000000000..5485164e7e --- /dev/null +++ b/src/models/request/taxInfoUpdateRequest.ts @@ -0,0 +1,4 @@ +export class TaxInfoUpdateRequest { + country: string; + postalCode: string; +} diff --git a/src/models/response/taxInfoResponse.ts b/src/models/response/taxInfoResponse.ts new file mode 100644 index 0000000000..9759bbe332 --- /dev/null +++ b/src/models/response/taxInfoResponse.ts @@ -0,0 +1,24 @@ +import { BaseResponse } from './baseResponse'; + +export class TaxInfoResponse extends BaseResponse { + taxId: string; + taxIdType: string; + line1: string; + line2: string; + city: string; + state: string; + country: string; + postalCode: string; + + constructor(response: any) { + super(response); + this.taxId = this.getResponseProperty('TaxIdNumber'); + this.taxIdType = this.getResponseProperty('TaxIdType'); + this.line1 = this.getResponseProperty('Line1'); + this.line2 = this.getResponseProperty('Line2'); + this.city = this.getResponseProperty('City'); + this.state = this.getResponseProperty('State'); + this.postalCode = this.getResponseProperty('PostalCode'); + this.country = this.getResponseProperty('Country'); + } +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 70a91f36c3..9acf387819 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -29,6 +29,7 @@ import { ImportOrganizationCiphersRequest } from '../models/request/importOrgani import { KdfRequest } from '../models/request/kdfRequest'; import { KeysRequest } from '../models/request/keysRequest'; import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest'; +import { OrganizationTaxInfoUpdateRequest } from '../models/request/organizationTaxInfoUpdateRequest'; import { OrganizationUpdateRequest } from '../models/request/organizationUpdateRequest'; import { OrganizationUpgradeRequest } from '../models/request/organizationUpgradeRequest'; import { OrganizationUserAcceptRequest } from '../models/request/organizationUserAcceptRequest'; @@ -46,6 +47,7 @@ import { RegisterRequest } from '../models/request/registerRequest'; import { SeatRequest } from '../models/request/seatRequest'; import { SelectionReadOnlyRequest } from '../models/request/selectionReadOnlyRequest'; import { StorageRequest } from '../models/request/storageRequest'; +import { TaxInfoUpdateRequest } from '../models/request/taxInfoUpdateRequest'; import { TokenRequest } from '../models/request/tokenRequest'; import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest'; import { TwoFactorProviderRequest } from '../models/request/twoFactorProviderRequest'; @@ -95,6 +97,7 @@ import { ProfileResponse } from '../models/response/profileResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; import { SubscriptionResponse } from '../models/response/subscriptionResponse'; import { SyncResponse } from '../models/response/syncResponse'; +import { TaxInfoResponse } from '../models/response/taxInfoResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; @@ -220,11 +223,20 @@ export class ApiService implements ApiServiceAbstraction { return new SubscriptionResponse(r); } + async getTaxInfo(): Promise { + const r = await this.send('GET', '/accounts/tax', null, true, true); + return new TaxInfoResponse(r); + } + async putProfile(request: UpdateProfileRequest): Promise { const r = await this.send('PUT', '/accounts/profile', request, true, true); return new ProfileResponse(r); } + putTaxInfo(request: TaxInfoUpdateRequest): Promise { + return this.send('PUT', '/accounts/tax', request, true, false); + } + async postPrelogin(request: PreloginRequest): Promise { const r = await this.send('POST', '/accounts/prelogin', request, false, true); return new PreloginResponse(r); @@ -812,6 +824,11 @@ export class ApiService implements ApiServiceAbstraction { null, true, true); } + async getOrganizationTaxInfo(id: string): Promise { + const r = await this.send('GET', '/organizations/' + id + '/tax', null, true, true); + return new TaxInfoResponse(r); + } + async postOrganization(request: OrganizationCreateRequest): Promise { const r = await this.send('POST', '/organizations', request, true, true); return new OrganizationResponse(r); @@ -822,6 +839,10 @@ export class ApiService implements ApiServiceAbstraction { return new OrganizationResponse(r); } + async putOrganizationTaxInfo(id: string, request: OrganizationTaxInfoUpdateRequest): Promise { + return this.send('PUT', '/organizations/' + id + '/tax', request, true, false); + } + postLeaveOrganization(id: string): Promise { return this.send('POST', '/organizations/' + id + '/leave', null, true, false); }