Skip to content

Commit 0077ada

Browse files
authored
Add application to V2 application form relationships (#501)
* fix: application relationship for form v2 * 1.2.4 * fix: test fixes
1 parent a583e38 commit 0077ada

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@unit-finance/unit-node-sdk",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "",
55
"main": "dist/unit.js",
66
"types": "dist/unit.d.ts",

resources/counterparty.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {BaseListParams, UnitConfig, UnitResponse, NoContent, Tags} from "../types/common"
1+
import {BaseListParams, UnitConfig, UnitResponse, Tags} from "../types/common"
22
import { AchCounterparty, CounterpartyBalance, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty"
33
import { BaseResource } from "./baseResource"
44

@@ -12,8 +12,8 @@ export class Counterparties extends BaseResource {
1212
return await this.httpPost<UnitResponse<AchCounterparty>>("", { data: request })
1313
}
1414

15-
public async delete(id: string): Promise<NoContent> {
16-
return await this.httpDelete<NoContent>(`/${id}`)
15+
public async delete(id: string): Promise<UnitResponse<AchCounterparty>> {
16+
return await this.httpDelete<UnitResponse<AchCounterparty>>(`/${id}`)
1717
}
1818

1919
public async get(id: string): Promise<UnitResponse<AchCounterparty>> {

tests/applications.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,11 @@ describe("Business Applications", () => {
535535
expect(req.type).toBe("businessApplication")
536536
})
537537

538-
test("Simulation UpdateBusinessApplicationRequest - test structure", () => {
538+
test("Simulation UpdateBusinessApplicationRequest - test structure", async () => {
539+
const res = await createBusinessApplication(unit)
540+
539541
const req: PatchApplicationRequest = {
540-
applicationId: "123",
542+
applicationId: res.data.id,
541543
data: {
542544
"type": "businessApplication",
543545
"attributes": {
@@ -627,7 +629,6 @@ describe("Business Applications", () => {
627629

628630
test("Test UpdateBusinessApplicationRequest - Update website", async () => {
629631
const res = await createBusinessApplication(unit)
630-
expect(res.data.type).toBe("businessApplication")
631632

632633
const attributes: PatchBusinessApplicationAttributes = {
633634
website: "https://www.piedpiper.com"

tests/counterparties.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("Delete Counterparty", () => {
6262
const res = await unit.counterparties.get(createRes.data.id)
6363
expect(res.data.type === "achCounterparty").toBeTruthy()
6464
const deleteRes = await unit.counterparties.delete(res.data.id)
65-
expect(deleteRes === "").toBeTruthy() // NoContent
65+
expect(deleteRes.data.type === "achCounterparty").toBeTruthy()
6666
})
6767
})
6868

tests/creditApplications.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const unit = new Unit(process.env.UNIT_TOKEN || "test", process.env.UNIT_API_URL
88

99
describe("Get Credit Applications", () => {
1010
test("Test Get endpoint", async () => {
11-
const res = await unit.creditApplications.list()
11+
const res = await unit.creditApplications.list({limit: 20})
1212
expect(res.data).toBeInstanceOf(Array)
1313
res.data.forEach(async element => {
1414
expect(element.type).toContain("CreditApplication")
15-
const app = await (await unit.creditApplications.get(element.id)).data
15+
const app = (await unit.creditApplications.get(element.id)).data
1616
expect(element.type).toBe(app.type)
1717
expect(element.id).toBe(app.id)
1818
})

types/applicationForm.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ export type ApplicationFormV2 = {
174174
href: string
175175
}
176176
}
177+
relationships?: {
178+
/**
179+
* The application.
180+
*/
181+
application?: Relationship
182+
}
177183
}
178184

179185

0 commit comments

Comments
 (0)