Skip to content

Commit ab49de5

Browse files
committed
feat(api): add payment and external bank accounts resource (#37)
1 parent 2233014 commit ab49de5

44 files changed

Lines changed: 8511 additions & 32 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 74
1+
configured_endpoints: 83

lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ interface LithicClient {
4040

4141
fun webhooks(): WebhookService
4242

43+
fun externalBankAccounts(): ExternalBankAccountService
44+
4345
/** API status check */
4446
@JvmOverloads
4547
fun apiStatus(

lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface LithicClientAsync {
4141

4242
fun webhooks(): WebhookServiceAsync
4343

44+
fun externalBankAccounts(): ExternalBankAccountServiceAsync
45+
4446
/** API status check */
4547
@JvmOverloads
4648
fun apiStatus(

lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ constructor(
6666

6767
private val webhooks: WebhookServiceAsync by lazy { WebhookServiceAsyncImpl(clientOptions) }
6868

69+
private val externalBankAccounts: ExternalBankAccountServiceAsync by lazy {
70+
ExternalBankAccountServiceAsyncImpl(clientOptions)
71+
}
72+
6973
override fun sync(): LithicClient = sync
7074

7175
override fun accounts(): AccountServiceAsync = accounts
@@ -99,6 +103,8 @@ constructor(
99103

100104
override fun webhooks(): WebhookServiceAsync = webhooks
101105

106+
override fun externalBankAccounts(): ExternalBankAccountServiceAsync = externalBankAccounts
107+
102108
private val apiStatusHandler: Handler<ApiStatus> =
103109
jsonHandler<ApiStatus>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
104110

lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ constructor(
6363

6464
private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptions) }
6565

66+
private val externalBankAccounts: ExternalBankAccountService by lazy {
67+
ExternalBankAccountServiceImpl(clientOptions)
68+
}
69+
6670
override fun async(): LithicClientAsync = async
6771

6872
override fun accounts(): AccountService = accounts
@@ -95,6 +99,8 @@ constructor(
9599

96100
override fun webhooks(): WebhookService = webhooks
97101

102+
override fun externalBankAccounts(): ExternalBankAccountService = externalBankAccounts
103+
98104
private val apiStatusHandler: Handler<ApiStatus> =
99105
jsonHandler<ApiStatus>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
100106

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
package com.lithic.api.models
2+
3+
import com.fasterxml.jackson.annotation.JsonAnyGetter
4+
import com.fasterxml.jackson.annotation.JsonAnySetter
5+
import com.fasterxml.jackson.annotation.JsonProperty
6+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
7+
import com.lithic.api.core.ExcludeMissing
8+
import com.lithic.api.core.JsonField
9+
import com.lithic.api.core.JsonMissing
10+
import com.lithic.api.core.JsonValue
11+
import com.lithic.api.core.NoAutoDetect
12+
import com.lithic.api.core.toUnmodifiable
13+
import java.util.Objects
14+
import java.util.Optional
15+
16+
/**
17+
* Address used during Address Verification Service (AVS) checks during transactions if enabled via
18+
* Auth Rules.
19+
*/
20+
@JsonDeserialize(builder = ExternalBankAccountAddress.Builder::class)
21+
@NoAutoDetect
22+
class ExternalBankAccountAddress
23+
private constructor(
24+
private val address1: JsonField<String>,
25+
private val address2: JsonField<String>,
26+
private val city: JsonField<String>,
27+
private val state: JsonField<String>,
28+
private val postalCode: JsonField<String>,
29+
private val country: JsonField<String>,
30+
private val additionalProperties: Map<String, JsonValue>,
31+
) {
32+
33+
private var validated: Boolean = false
34+
35+
private var hashCode: Int = 0
36+
37+
fun address1(): String = address1.getRequired("address1")
38+
39+
fun address2(): Optional<String> = Optional.ofNullable(address2.getNullable("address2"))
40+
41+
fun city(): String = city.getRequired("city")
42+
43+
fun state(): String = state.getRequired("state")
44+
45+
fun postalCode(): String = postalCode.getRequired("postal_code")
46+
47+
fun country(): String = country.getRequired("country")
48+
49+
@JsonProperty("address1") @ExcludeMissing fun _address1() = address1
50+
51+
@JsonProperty("address2") @ExcludeMissing fun _address2() = address2
52+
53+
@JsonProperty("city") @ExcludeMissing fun _city() = city
54+
55+
@JsonProperty("state") @ExcludeMissing fun _state() = state
56+
57+
@JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode
58+
59+
@JsonProperty("country") @ExcludeMissing fun _country() = country
60+
61+
@JsonAnyGetter
62+
@ExcludeMissing
63+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
64+
65+
fun validate(): ExternalBankAccountAddress = apply {
66+
if (!validated) {
67+
address1()
68+
address2()
69+
city()
70+
state()
71+
postalCode()
72+
country()
73+
validated = true
74+
}
75+
}
76+
77+
fun toBuilder() = Builder().from(this)
78+
79+
override fun equals(other: Any?): Boolean {
80+
if (this === other) {
81+
return true
82+
}
83+
84+
return other is ExternalBankAccountAddress &&
85+
this.address1 == other.address1 &&
86+
this.address2 == other.address2 &&
87+
this.city == other.city &&
88+
this.state == other.state &&
89+
this.postalCode == other.postalCode &&
90+
this.country == other.country &&
91+
this.additionalProperties == other.additionalProperties
92+
}
93+
94+
override fun hashCode(): Int {
95+
if (hashCode == 0) {
96+
hashCode =
97+
Objects.hash(
98+
address1,
99+
address2,
100+
city,
101+
state,
102+
postalCode,
103+
country,
104+
additionalProperties,
105+
)
106+
}
107+
return hashCode
108+
}
109+
110+
override fun toString() =
111+
"ExternalBankAccountAddress{address1=$address1, address2=$address2, city=$city, state=$state, postalCode=$postalCode, country=$country, additionalProperties=$additionalProperties}"
112+
113+
companion object {
114+
115+
@JvmStatic fun builder() = Builder()
116+
}
117+
118+
class Builder {
119+
120+
private var address1: JsonField<String> = JsonMissing.of()
121+
private var address2: JsonField<String> = JsonMissing.of()
122+
private var city: JsonField<String> = JsonMissing.of()
123+
private var state: JsonField<String> = JsonMissing.of()
124+
private var postalCode: JsonField<String> = JsonMissing.of()
125+
private var country: JsonField<String> = JsonMissing.of()
126+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
127+
128+
@JvmSynthetic
129+
internal fun from(externalBankAccountAddress: ExternalBankAccountAddress) = apply {
130+
this.address1 = externalBankAccountAddress.address1
131+
this.address2 = externalBankAccountAddress.address2
132+
this.city = externalBankAccountAddress.city
133+
this.state = externalBankAccountAddress.state
134+
this.postalCode = externalBankAccountAddress.postalCode
135+
this.country = externalBankAccountAddress.country
136+
additionalProperties(externalBankAccountAddress.additionalProperties)
137+
}
138+
139+
fun address1(address1: String) = address1(JsonField.of(address1))
140+
141+
@JsonProperty("address1")
142+
@ExcludeMissing
143+
fun address1(address1: JsonField<String>) = apply { this.address1 = address1 }
144+
145+
fun address2(address2: String) = address2(JsonField.of(address2))
146+
147+
@JsonProperty("address2")
148+
@ExcludeMissing
149+
fun address2(address2: JsonField<String>) = apply { this.address2 = address2 }
150+
151+
fun city(city: String) = city(JsonField.of(city))
152+
153+
@JsonProperty("city")
154+
@ExcludeMissing
155+
fun city(city: JsonField<String>) = apply { this.city = city }
156+
157+
fun state(state: String) = state(JsonField.of(state))
158+
159+
@JsonProperty("state")
160+
@ExcludeMissing
161+
fun state(state: JsonField<String>) = apply { this.state = state }
162+
163+
fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode))
164+
165+
@JsonProperty("postal_code")
166+
@ExcludeMissing
167+
fun postalCode(postalCode: JsonField<String>) = apply { this.postalCode = postalCode }
168+
169+
fun country(country: String) = country(JsonField.of(country))
170+
171+
@JsonProperty("country")
172+
@ExcludeMissing
173+
fun country(country: JsonField<String>) = apply { this.country = country }
174+
175+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
176+
this.additionalProperties.clear()
177+
this.additionalProperties.putAll(additionalProperties)
178+
}
179+
180+
@JsonAnySetter
181+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
182+
this.additionalProperties.put(key, value)
183+
}
184+
185+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
186+
this.additionalProperties.putAll(additionalProperties)
187+
}
188+
189+
fun build(): ExternalBankAccountAddress =
190+
ExternalBankAccountAddress(
191+
address1,
192+
address2,
193+
city,
194+
state,
195+
postalCode,
196+
country,
197+
additionalProperties.toUnmodifiable(),
198+
)
199+
}
200+
}

0 commit comments

Comments
 (0)