Skip to content

Commit

Permalink
Add application to V2 application form relationships (#501)
Browse files Browse the repository at this point in the history
* fix: application relationship for form v2

* 1.2.4

* fix: test fixes
  • Loading branch information
YegorZh authored Jan 14, 2025
1 parent a583e38 commit 0077ada
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unit-finance/unit-node-sdk",
"version": "1.2.3",
"version": "1.2.4",
"description": "",
"main": "dist/unit.js",
"types": "dist/unit.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions resources/counterparty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseListParams, UnitConfig, UnitResponse, NoContent, Tags} from "../types/common"
import {BaseListParams, UnitConfig, UnitResponse, Tags} from "../types/common"
import { AchCounterparty, CounterpartyBalance, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty"
import { BaseResource } from "./baseResource"

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

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

public async get(id: string): Promise<UnitResponse<AchCounterparty>> {
Expand Down
7 changes: 4 additions & 3 deletions tests/applications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,11 @@ describe("Business Applications", () => {
expect(req.type).toBe("businessApplication")
})

test("Simulation UpdateBusinessApplicationRequest - test structure", () => {
test("Simulation UpdateBusinessApplicationRequest - test structure", async () => {
const res = await createBusinessApplication(unit)

const req: PatchApplicationRequest = {
applicationId: "123",
applicationId: res.data.id,
data: {
"type": "businessApplication",
"attributes": {
Expand Down Expand Up @@ -627,7 +629,6 @@ describe("Business Applications", () => {

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

const attributes: PatchBusinessApplicationAttributes = {
website: "https://www.piedpiper.com"
Expand Down
2 changes: 1 addition & 1 deletion tests/counterparties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("Delete Counterparty", () => {
const res = await unit.counterparties.get(createRes.data.id)
expect(res.data.type === "achCounterparty").toBeTruthy()
const deleteRes = await unit.counterparties.delete(res.data.id)
expect(deleteRes === "").toBeTruthy() // NoContent
expect(deleteRes.data.type === "achCounterparty").toBeTruthy()
})
})

Expand Down
4 changes: 2 additions & 2 deletions tests/creditApplications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const unit = new Unit(process.env.UNIT_TOKEN || "test", process.env.UNIT_API_URL

describe("Get Credit Applications", () => {
test("Test Get endpoint", async () => {
const res = await unit.creditApplications.list()
const res = await unit.creditApplications.list({limit: 20})
expect(res.data).toBeInstanceOf(Array)
res.data.forEach(async element => {
expect(element.type).toContain("CreditApplication")
const app = await (await unit.creditApplications.get(element.id)).data
const app = (await unit.creditApplications.get(element.id)).data
expect(element.type).toBe(app.type)
expect(element.id).toBe(app.id)
})
Expand Down
6 changes: 6 additions & 0 deletions types/applicationForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ export type ApplicationFormV2 = {
href: string
}
}
relationships?: {
/**
* The application.
*/
application?: Relationship
}
}


Expand Down

0 comments on commit 0077ada

Please sign in to comment.