diff --git a/package-lock.json b/package-lock.json index 9c7e2625..d1cc0dc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@unit-finance/unit-node-sdk", - "version": "1.3.9", + "version": "1.3.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@unit-finance/unit-node-sdk", - "version": "1.3.9", + "version": "1.3.10", "license": "MPLv2", "dependencies": { "axios": "^1.8.4" diff --git a/package.json b/package.json index 56048ed0..03de74f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unit-finance/unit-node-sdk", - "version": "1.3.9", + "version": "1.3.10", "description": "", "main": "dist/unit.js", "types": "dist/unit.d.ts", diff --git a/tests/applicationForms.spec.ts b/tests/applicationForms.spec.ts index 0b7b13e4..23846a53 100644 --- a/tests/applicationForms.spec.ts +++ b/tests/applicationForms.spec.ts @@ -150,4 +150,261 @@ describe("ApplicationForms", () => { expect(applicationFormPrefill.applicationType).toBe("Business") }) + + test("Create Application Form V2 for Business with requestedProducts", async () => { + const req: CreateApplicationFormV2 = { + type: "applicationForm", + attributes: { + idempotencyKey: Math.random().toString(36).substring(7), + applicantDetails: { + applicationType: "SingleMemberBusiness", + name: "Pied Piper", + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + }, + phone: { + countryCode: "1", + number: "5555555555" + }, + stateOfIncorporation: "DE", + ein: "123456789", + entityType: "Corporation", + contact: { + fullName: { + first: "Richard", + last: "Hendricks" + }, + email: "richard@piedpiper.com", + phone: { + countryCode: "1", + number: "5555555555" + } + }, + officer: { + fullName: { + first: "Richard", + last: "Hendricks" + }, + dateOfBirth: "2001-08-10", + title: "CEO", + ssn: "721074426", + email: "richard@piedpiper.com", + phone: { + countryCode: "1", + number: "5555555555" + }, + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + } + }, + beneficialOwners: [ + { + fullName: { + first: "Richard", + last: "Hendricks" + }, + dateOfBirth: "2001-08-10", + ssn: "123456789", + email: "richard@piedpiper.com", + percentage: 75, + phone: { + countryCode: "1", + number: "5555555555" + }, + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + } + } + ], + businessVertical: "TechnologyMediaOrTelecom", + yearOfIncorporation: "2014" + }, + requestedProducts: ["Banking", "BillPay"] + }, + relationships: {} + } + const res = await unitWithVersion.applicationForms.create(req) + expect(res.data.type).toBe("applicationFormV2") + }) + + test("Create Application Form V2 for Sole Proprietor with requestedProducts", async () => { + const req: CreateApplicationFormV2 = { + type: "applicationForm", + attributes: { + idempotencyKey: Math.random().toString(36).substring(7), + applicantDetails: { + applicationType: "SoleProprietorship", + fullName: { + first: "Peter", + last: "Parker" + }, + ssn: "721074426", + dateOfBirth: "2001-08-10", + address: { + street: "20 Ingram St", + city: "Forest Hills", + state: "NY", + postalCode: "11375", + country: "US" + }, + email: "peter@oscorp.com", + phone: { + countryCode: "1", + number: "5555555555" + }, + occupation: "ArchitectOrEngineer", + annualIncome: "Between50kAnd100k", + sourceOfIncome: "EmploymentOrPayrollIncome", + annualRevenue: "Between100kAnd200k", + ein: "123456789", + dba: "Piedpiper Inc", + numberOfEmployees: "Between5And10", + businessVertical: "TechnologyMediaOrTelecom", + website: "https://www.piedpiper.com" + }, + requestedProducts: ["BillPay"] + }, + relationships: {} + } + const res = await unitWithVersion.applicationForms.create(req) + expect(res.data.type).toBe("applicationFormV2") + }) + + test("Simulation CreateApplicationFormV2 for Business with requestedProducts - test structure", () => { + const req: CreateApplicationFormV2 = { + type: "applicationForm", + attributes: { + idempotencyKey: "3a1a33be-4e12-4603-9ed0-820922389fb8", + applicantDetails: { + applicationType: "Business", + name: "Pied Piper", + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + }, + phone: { + countryCode: "1", + number: "5555555555" + }, + stateOfIncorporation: "DE", + ein: "123456789", + entityType: "Corporation", + contact: { + fullName: { + first: "Richard", + last: "Hendricks" + }, + email: "richard@piedpiper.com", + phone: { + countryCode: "1", + number: "5555555555" + } + }, + officer: { + fullName: { + first: "Richard", + last: "Hendricks" + }, + dateOfBirth: "2001-08-10", + title: "CEO", + ssn: "721074426", + email: "richard@piedpiper.com", + phone: { + countryCode: "1", + number: "5555555555" + }, + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + } + }, + beneficialOwners: [ + { + fullName: { + first: "Richard", + last: "Hendricks" + }, + dateOfBirth: "2001-08-10", + ssn: "123456789", + email: "richard@piedpiper.com", + percentage: 75, + phone: { + countryCode: "1", + number: "5555555555" + }, + address: { + street: "5230 Newell Rd", + city: "Palo Alto", + state: "CA", + postalCode: "94303", + country: "US" + } + } + ], + businessVertical: "TechnologyMediaOrTelecom", + yearOfIncorporation: "2014" + }, + requestedProducts: ["Banking", "BillPay", "Capital"] + }, + relationships: {} + } + + expect(req.type).toBe("applicationForm") + expect(req.attributes.requestedProducts).toEqual(["Banking", "BillPay", "Capital"]) + }) + + test("Simulation CreateApplicationFormV2 for Sole Proprietor with requestedProducts - test structure", () => { + const req: CreateApplicationFormV2 = { + type: "applicationForm", + attributes: { + idempotencyKey: "3a1a33be-4e12-4603-9ed0-820922389fb8", + applicantDetails: { + applicationType: "SoleProprietorship", + fullName: { + first: "Peter", + last: "Parker" + }, + ssn: "721074426", + dateOfBirth: "2001-08-10", + address: { + street: "20 Ingram St", + city: "Forest Hills", + state: "NY", + postalCode: "11375", + country: "US" + }, + email: "peter@oscorp.com", + phone: { + countryCode: "1", + number: "5555555555" + }, + ein: "123456789", + dba: "Piedpiper Inc" + }, + requestedProducts: ["Banking"] + }, + relationships: {} + } + + expect(req.type).toBe("applicationForm") + expect(req.attributes.requestedProducts).toEqual(["Banking"]) + }) }) \ No newline at end of file diff --git a/tests/applications.spec.ts b/tests/applications.spec.ts index cebdc439..8ee2e3cb 100644 --- a/tests/applications.spec.ts +++ b/tests/applications.spec.ts @@ -8,7 +8,6 @@ import { CreateSoleProprietorApplicationRequest, IndividualApplication, PatchApplicationRequest, - PatchBusinessApplicationAttributes, PatchBusinessApplicationBeneficialOwner, RelationshipsArrayData, Unit, @@ -81,6 +80,131 @@ describe("Create Application", () => { const res = await unit.applications.get(createRes.data.id) expect(res.data.type).toBe("businessApplication") }) + + test("Create Business Application with requestedProducts", async () => { + const req: CreateBusinessApplicationRequest = { + "type": "businessApplication", + "attributes": { + "name": "Pied Piper", + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + }, + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "stateOfIncorporation": "DE", + "ein": "123456789", + "entityType": "Corporation", + "contact": { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "email": "richard@piedpiper.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + } + }, + "officer": { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "dateOfBirth": "2001-08-10", + "title": "CEO", + "ssn": "721074426", + "email": "richard@piedpiper.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + } + }, + "beneficialOwners": [ + { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "dateOfBirth": "2001-08-10", + "ssn": "123456789", + "email": "richard@piedpiper.com", + "percentage": 75, + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + } + } + ], + "businessVertical": "TechnologyMediaOrTelecom", + "yearOfIncorporation": "2014", + "requestedProducts": ["Banking", "BillPay"] + } + } + + const res = await unit.applications.create(req) + expect(res.data.type).toBe("businessApplication") + }) + + test("Create Sole Proprietor Application with requestedProducts", async () => { + const req: CreateSoleProprietorApplicationRequest = { + "type": "individualApplication", + "attributes": { + "ssn": "721074426", + "fullName": { + "first": "Peter", + "last": "Parker" + }, + "dateOfBirth": "2001-08-10", + "address": { + "street": "20 Ingram St", + "city": "Forest Hills", + "state": "NY", + "postalCode": "11375", + "country": "US" + }, + "email": "peter@oscorp.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "ip": "127.0.0.2", + "occupation": "ArchitectOrEngineer", + "annualIncome": "Between50kAnd100k", + "sourceOfIncome": "EmploymentOrPayrollIncome", + "annualRevenue": "Between100kAnd200k", + "soleProprietorship": true, + "ein": "123456789", + "dba": "Piedpiper Inc", + "numberOfEmployees": "Between5And10", + "businessVertical": "TechnologyMediaOrTelecom", + "website": "https://www.piedpiper.com", + "requestedProducts": ["BillPay"] + } + } + + const res = await unit.applications.create(req) + expect(res.data.type).toBe("individualApplication") + }) }) describe("Applications", () => { @@ -533,6 +657,121 @@ describe("Business Applications", () => { expect(req.type).toBe("businessApplication") }) + test("Simulation CreateBusinessApplicationRequest with requestedProducts - test structure", () => { + const req: CreateBusinessApplicationRequest = { + "type": "businessApplication", + "attributes": { + "name": "Pied Piper", + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + }, + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "stateOfIncorporation": "DE", + "ein": "123456789", + "entityType": "Corporation", + "contact": { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "email": "richard@piedpiper.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + } + }, + "officer": { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "dateOfBirth": "2001-08-10", + "title": "CEO", + "ssn": "721074426", + "email": "richard@piedpiper.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + } + }, + "beneficialOwners": [ + { + "fullName": { + "first": "Richard", + "last": "Hendricks" + }, + "dateOfBirth": "2001-08-10", + "ssn": "123456789", + "email": "richard@piedpiper.com", + "percentage": 75, + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "address": { + "street": "5230 Newell Rd", + "city": "Palo Alto", + "state": "CA", + "postalCode": "94303", + "country": "US" + } + } + ], + "requestedProducts": ["Banking", "BillPay", "Capital"] + } + } + + expect(req.type).toBe("businessApplication") + expect(req.attributes.requestedProducts).toEqual(["Banking", "BillPay", "Capital"]) + }) + + test("Simulation CreateSoleProprietorApplicationRequest with requestedProducts - test structure", () => { + const req: CreateSoleProprietorApplicationRequest = { + "type": "individualApplication", + "attributes": { + "ssn": "721074426", + "fullName": { + "first": "Peter", + "last": "Parker" + }, + "dateOfBirth": "2001-08-10", + "address": { + "street": "20 Ingram St", + "city": "Forest Hills", + "state": "NY", + "postalCode": "11375", + "country": "US" + }, + "email": "peter@oscorp.com", + "phone": { + "countryCode": "1", + "number": "5555555555" + }, + "soleProprietorship": true, + "ein": "123456789", + "dba": "Piedpiper Inc", + "requestedProducts": ["Banking"] + } + } + + expect(req.type).toBe("individualApplication") + expect(req.attributes.requestedProducts).toEqual(["Banking"]) + }) + test("Simulation UpdateBusinessApplicationRequest - test structure", async () => { const res = await createBusinessApplication(unit) diff --git a/types/application.ts b/types/application.ts index 8a90ed8b..263cd3fa 100644 --- a/types/application.ts +++ b/types/application.ts @@ -16,6 +16,8 @@ export type Application = IndividualApplication | BusinessApplication export type ApplicationType = "businessApplication" | "individualApplication" +export type Product = "Banking" | "BillPay" | "Capital" + export type Occupation = "ArchitectOrEngineer" | "BusinessAnalystAccountantOrFinancialAdvisor" | @@ -202,6 +204,11 @@ export interface BaseApplicationAttributes extends UnimplementedFields { * See [Tags](https://developers.unit.co/#tags). */ tags?: object + + /** + * Optional. The products being applied for. One or more of Banking, BillPay, or Capital. + */ + requestedProducts?: Product[] } export interface BaseApplicationRelationships extends UnimplementedRelationships { @@ -553,6 +560,11 @@ interface BaseCreateApplicationRequestAttributes { * Optional. A list of device fingerprints for fraud and risk prevention [See Device Fingerprints](https://developers.unit.co/applications/#device-fingerprints). */ deviceFingerprints?: DeviceFingerprint[] + + /** + * Optional. The products being applied for. One or more of Banking, BillPay, or Capital. + */ + requestedProducts?: Product[] } diff --git a/types/applicationForm.ts b/types/applicationForm.ts index 7a6e23c9..e3709e7f 100644 --- a/types/applicationForm.ts +++ b/types/applicationForm.ts @@ -6,6 +6,7 @@ import { CashFlow, NumberOfEmployees, Occupation, + Product, SourceOfIncome } from "./application" import {Address, BusinessContact, EntityType, FullName, Officer, Phone, Relationship, Tags} from "./common" @@ -89,6 +90,11 @@ export interface CreateApplicationFormV2 { */ jwtSubject?: string + + /** + * Optional. The products being applied for. One or more of Banking, BillPay, or Capital. + */ + requestedProducts?: Product[] } relationships?: { /** @@ -160,6 +166,11 @@ export type ApplicationFormV2 = { applicationFormSettings: ApplicationFormSettingsOverride + /** + * Optional. The products being applied for. One or more of Banking, BillPay, or Capital. + */ + requestedProducts?: Product[] + } links: {