Skip to content

Commit f80eaa8

Browse files
axshaniilyamerman
andauthored
get counterparty balance (#83)
Co-authored-by: Ilya Merman <[email protected]>
1 parent 8711a05 commit f80eaa8

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

resources/counterparty.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { UnitConfig, UnitResponse } from "../types/common"
2-
import { AchCounterparty, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty"
2+
import { AchCounterparty, CounterpartyBalance, CreateCounterpartyRequest, PatchCounterpartyRequest } from "../types/counterparty"
33
import { BaseResource } from "./baseResource"
44

55
export class Counterparties extends BaseResource {
@@ -33,6 +33,10 @@ export class Counterparties extends BaseResource {
3333
public async update(id: string, request: PatchCounterpartyRequest): Promise<UnitResponse<AchCounterparty>> {
3434
return this.httpPatch<Promise<UnitResponse<AchCounterparty>>>(`/${id}`, { data: request })
3535
}
36+
37+
public async getBalance(id: string): Promise<UnitResponse<CounterpartyBalance>> {
38+
return this.httpGet<Promise<UnitResponse<CounterpartyBalance>>>(`/${id}/balance`)
39+
}
3640
}
3741

3842
export interface CounterpartyListParams {

types/counterparty.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,52 @@ export interface PatchCounterpartyRequest {
146146
* Plaid integration token
147147
* See Plaid processor token
148148
*/
149-
plaidProcessorToken: string
149+
plaidProcessorToken: string
150150

151151
/**
152152
* Optional, default to false. Verify the name of the counterparty, if the name verification fails the request will fail with code field set to NameVerificationFailed.
153153
*/
154154
verifyName?: boolean
155+
}
156+
157+
export interface CounterpartyBalance {
158+
/**
159+
* Identifier of the Counterparty.
160+
*/
161+
id: string
162+
163+
/**
164+
* Type of the balance. for counterparty balance the value is always counterpartyBalance.
165+
*/
166+
type: "counterpartyBalance"
167+
168+
/**
169+
* JSON object representing the counterparty balance resource.
170+
*/
171+
attributes: {
172+
/**
173+
* The current balance amount (in cents) of the counterparty.
174+
*/
175+
balance: number
176+
177+
/**
178+
* Optional. The available balance amount (in cents) of the counterparty.
179+
*/
180+
available?: number
181+
}
182+
183+
/**
184+
* Describes relationships between the counterparty balance and the customer and counterparty.
185+
*/
186+
relationships: {
187+
/**
188+
* The customer the counterparty belongs to.
189+
*/
190+
counterparty: Relationship
191+
192+
/**
193+
* The customer the counterparty belongs to.
194+
*/
195+
customer: Relationship
196+
}
155197
}

0 commit comments

Comments
 (0)