Skip to content

Commit b7b2d1b

Browse files
authored
Include param and export bookPayment (#170)
* fix include param to get method * fix lint warning * fix lint warning * export bookPayment interface
1 parent e1ef28e commit b7b2d1b

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

resources/payments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Payments extends BaseResource {
2727
* Related resources include: customer, account, transaction. See Getting Related Resources
2828
*/
2929
public async get(id: string, include?: string): Promise<UnitResponse<Payment & Include<Account[] | Customer[] | Transaction[]>>> {
30-
const params = { include: include ? `include=${include}` : "" }
30+
const params = {...(include && { include })}
3131
return this.httpGet<UnitResponse<Payment & Include<Account[] | Customer[] | Transaction[]>>>(`/${id}`, { params })
3232
}
3333

resources/receivedPayments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ReceivedPayments extends BaseResource {
2424
* Related resources include: customer, account. See Getting Related Resources
2525
*/
2626
public async get(id: string, include?: string): Promise<UnitResponse<AchReceivedPayment & Include<Account[] | Customer[]>>> {
27-
const params = { include: include ? `include=${include}` : "" }
27+
const params = {...(include && { include })}
2828
return this.httpGet<UnitResponse<AchReceivedPayment & Include<Account[] | Customer[]>>>(`/${id}`, { params })
2929
}
3030

resources/rewards.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class Rewards extends BaseResource {
1717
* Related resources include: customer, account, transaction. See [Getting Related Resources](https://developers.unit.co/about-jsonapi/#intro-getting-related-resources)
1818
*/
1919
public async get(id: string, include?: string): Promise<UnitResponse<Reward & Include<Account[] | Customer[] | Transaction[]>>> {
20-
const params = { include: include ? `include=${include}` : "" }
20+
const params = {...(include && { include })}
2121
return this.httpGet<UnitResponse<Reward & Include<Account[] | Customer[] | Transaction[]>>>(`/${id}`, { params })
2222
}
2323

resources/transactions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class Transactions extends BaseResource {
2222
public async get(accountId: string, transactionId: string, customerId?: string, include?: string): Promise<UnitResponse<Transaction> & Include<Account[] | Customer[]>> {
2323
const parameters = {
2424
...(customerId && { "filter[customerId]": customerId }),
25-
"include": include ? include : ""
25+
...(include && { include })
2626
}
2727

2828
return await this.httpGet<UnitResponse<Transaction> & Include<Account[] | Customer[]>>(`/accounts/${accountId}/transactions/${transactionId}`, { params: parameters })

tests/payments.spec.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { CreateBookPaymentRequest, CreateLinkedPaymentRequest, Unit } from "../unit"
1+
import { CreateBookPaymentRequest, Unit } from "../unit" //CreateLinkedPaymentRequest
22
import { createIndividualAccount } from "./accounts.spec"
3-
import { createCounterpartyForTest } from "./counterparties.spec"
3+
// import { createCounterpartyForTest } from "./counterparties.spec"
44

55
import dotenv from "dotenv"
66
dotenv.config()
@@ -60,32 +60,32 @@ describe("Create BookPayment", () => {
6060
})
6161
})
6262

63-
async function createPayment() : Promise<CreateLinkedPaymentRequest> {
64-
const createCounterpartRes = await createCounterpartyForTest("22603")
63+
// async function createPayment() : Promise<CreateLinkedPaymentRequest> {
64+
// const createCounterpartRes = await createCounterpartyForTest("22603")
6565

66-
return {
67-
"type": "achPayment",
68-
"attributes": {
69-
"amount": 200,
70-
"direction": "Debit",
71-
"description": "ACH PYMT"
72-
},
73-
"relationships": {
74-
"account": {
75-
"data": {
76-
"type": "depositAccount",
77-
"id": "27573"
78-
}
79-
},
80-
"counterparty": {
81-
"data": {
82-
"type": "counterparty",
83-
"id": createCounterpartRes.data.id
84-
}
85-
}
86-
}
87-
}
88-
}
66+
// return {
67+
// "type": "achPayment",
68+
// "attributes": {
69+
// "amount": 200,
70+
// "direction": "Debit",
71+
// "description": "ACH PYMT"
72+
// },
73+
// "relationships": {
74+
// "account": {
75+
// "data": {
76+
// "type": "depositAccount",
77+
// "id": "27573"
78+
// }
79+
// },
80+
// "counterparty": {
81+
// "data": {
82+
// "type": "counterparty",
83+
// "id": createCounterpartRes.data.id
84+
// }
85+
// }
86+
// }
87+
// }
88+
// }
8989

9090
// describe("Create LinkedPayment", () => {
9191
// test("create linked payment", async () => {

types/payments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export interface AchPayment {
108108
} & BasePaymentRelationships
109109
}
110110

111-
interface BookPayment {
111+
export interface BookPayment {
112112
/**
113113
* Identifier of the book payment resource.
114114
*/

0 commit comments

Comments
 (0)