Skip to content

Commit 0629cae

Browse files
chore(api): add business_account_token param for listing Balances (#385)
1 parent 0cdafb6 commit 0629cae

6 files changed

Lines changed: 24 additions & 7 deletions

File tree

lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListParams.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class BalanceListParams
2020
constructor(
2121
private val accountToken: String?,
2222
private val balanceDate: OffsetDateTime?,
23+
private val businessAccountToken: String?,
2324
private val financialAccountType: FinancialAccountType?,
2425
private val additionalHeaders: Headers,
2526
private val additionalQueryParams: QueryParams,
@@ -29,6 +30,8 @@ constructor(
2930

3031
fun balanceDate(): Optional<OffsetDateTime> = Optional.ofNullable(balanceDate)
3132

33+
fun businessAccountToken(): Optional<String> = Optional.ofNullable(businessAccountToken)
34+
3235
fun financialAccountType(): Optional<FinancialAccountType> =
3336
Optional.ofNullable(financialAccountType)
3437

@@ -44,6 +47,9 @@ constructor(
4447
listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))
4548
)
4649
}
50+
this.businessAccountToken?.let {
51+
queryParams.put("business_account_token", listOf(it.toString()))
52+
}
4753
this.financialAccountType?.let {
4854
queryParams.put("financial_account_type", listOf(it.toString()))
4955
}
@@ -60,15 +66,15 @@ constructor(
6066
return true
6167
}
6268

63-
return /* spotless:off */ other is BalanceListParams && this.accountToken == other.accountToken && this.balanceDate == other.balanceDate && this.financialAccountType == other.financialAccountType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */
69+
return /* spotless:off */ other is BalanceListParams && this.accountToken == other.accountToken && this.balanceDate == other.balanceDate && this.businessAccountToken == other.businessAccountToken && this.financialAccountType == other.financialAccountType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */
6470
}
6571

6672
override fun hashCode(): Int {
67-
return /* spotless:off */ Objects.hash(accountToken, balanceDate, financialAccountType, additionalHeaders, additionalQueryParams) /* spotless:on */
73+
return /* spotless:off */ Objects.hash(accountToken, balanceDate, businessAccountToken, financialAccountType, additionalHeaders, additionalQueryParams) /* spotless:on */
6874
}
6975

7076
override fun toString() =
71-
"BalanceListParams{accountToken=$accountToken, balanceDate=$balanceDate, financialAccountType=$financialAccountType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
77+
"BalanceListParams{accountToken=$accountToken, balanceDate=$balanceDate, businessAccountToken=$businessAccountToken, financialAccountType=$financialAccountType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
7278

7379
fun toBuilder() = Builder().from(this)
7480

@@ -82,6 +88,7 @@ constructor(
8288

8389
private var accountToken: String? = null
8490
private var balanceDate: OffsetDateTime? = null
91+
private var businessAccountToken: String? = null
8592
private var financialAccountType: FinancialAccountType? = null
8693
private var additionalHeaders: Headers.Builder = Headers.builder()
8794
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -90,6 +97,7 @@ constructor(
9097
internal fun from(balanceListParams: BalanceListParams) = apply {
9198
this.accountToken = balanceListParams.accountToken
9299
this.balanceDate = balanceListParams.balanceDate
100+
this.businessAccountToken = balanceListParams.businessAccountToken
93101
this.financialAccountType = balanceListParams.financialAccountType
94102
additionalHeaders(balanceListParams.additionalHeaders)
95103
additionalQueryParams(balanceListParams.additionalQueryParams)
@@ -101,6 +109,11 @@ constructor(
101109
/** UTC date and time of the balances to retrieve. Defaults to latest available balances */
102110
fun balanceDate(balanceDate: OffsetDateTime) = apply { this.balanceDate = balanceDate }
103111

112+
/** List balances for all financial accounts of a given business_account_token. */
113+
fun businessAccountToken(businessAccountToken: String) = apply {
114+
this.businessAccountToken = businessAccountToken
115+
}
116+
104117
/** List balances for a given Financial Account type. */
105118
fun financialAccountType(financialAccountType: FinancialAccountType) = apply {
106119
this.financialAccountType = financialAccountType
@@ -208,6 +221,7 @@ constructor(
208221
BalanceListParams(
209222
accountToken,
210223
balanceDate,
224+
businessAccountToken,
211225
financialAccountType,
212226
additionalHeaders.build(),
213227
additionalQueryParams.build(),

lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsync.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.util.concurrent.CompletableFuture
1111

1212
interface BalanceServiceAsync {
1313

14-
/** Get the balances for a program or a given end-user account */
14+
/** Get the balances for a program, business, or a given end-user account */
1515
@JvmOverloads
1616
fun list(
1717
params: BalanceListParams,

lithic-java-core/src/main/kotlin/com/lithic/api/services/async/BalanceServiceAsyncImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ constructor(
2626
jsonHandler<BalanceListPageAsync.Response>(clientOptions.jsonMapper)
2727
.withErrorHandler(errorHandler)
2828

29-
/** Get the balances for a program or a given end-user account */
29+
/** Get the balances for a program, business, or a given end-user account */
3030
override fun list(
3131
params: BalanceListParams,
3232
requestOptions: RequestOptions

lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.lithic.api.models.BalanceListParams
1010

1111
interface BalanceService {
1212

13-
/** Get the balances for a program or a given end-user account */
13+
/** Get the balances for a program, business, or a given end-user account */
1414
@JvmOverloads
1515
fun list(
1616
params: BalanceListParams,

lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/BalanceServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ constructor(
2525
jsonHandler<BalanceListPage.Response>(clientOptions.jsonMapper)
2626
.withErrorHandler(errorHandler)
2727

28-
/** Get the balances for a program or a given end-user account */
28+
/** Get the balances for a program, business, or a given end-user account */
2929
override fun list(params: BalanceListParams, requestOptions: RequestOptions): BalanceListPage {
3030
val request =
3131
HttpRequest.builder()

lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceListParamsTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class BalanceListParamsTest {
1515
BalanceListParams.builder()
1616
.accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1717
.balanceDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
18+
.businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1819
.financialAccountType(BalanceListParams.FinancialAccountType.ISSUING)
1920
.build()
2021
}
@@ -25,11 +26,13 @@ class BalanceListParamsTest {
2526
BalanceListParams.builder()
2627
.accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
2728
.balanceDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
29+
.businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
2830
.financialAccountType(BalanceListParams.FinancialAccountType.ISSUING)
2931
.build()
3032
val expected = QueryParams.builder()
3133
expected.put("account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3234
expected.put("balance_date", "2019-12-27T18:11:19.117Z")
35+
expected.put("business_account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3336
expected.put(
3437
"financial_account_type",
3538
BalanceListParams.FinancialAccountType.ISSUING.toString()

0 commit comments

Comments
 (0)