Skip to content

Commit 69c6b67

Browse files
committed
feat(api): updates (#141)
1 parent 897cd42 commit 69c6b67

16 files changed

Lines changed: 743 additions & 7 deletions

.stats.yml

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private constructor(
147147
Optional.ofNullable(statusReasons.getNullable("status_reasons"))
148148

149149
/** Globally unique identifier for the account holder. */
150-
fun token(): Optional<String> = Optional.ofNullable(token.getNullable("token"))
150+
fun token(): String = token.getRequired("token")
151151

152152
/**
153153
* The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.lithic.api.models
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter
6+
import com.fasterxml.jackson.annotation.JsonAnySetter
7+
import com.fasterxml.jackson.annotation.JsonProperty
8+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
9+
import com.lithic.api.core.ExcludeMissing
10+
import com.lithic.api.core.JsonField
11+
import com.lithic.api.core.JsonMissing
12+
import com.lithic.api.core.JsonValue
13+
import com.lithic.api.core.NoAutoDetect
14+
import com.lithic.api.core.toUnmodifiable
15+
import com.lithic.api.services.blocking.AccountHolderService
16+
import java.util.Objects
17+
import java.util.Optional
18+
import java.util.stream.Stream
19+
import java.util.stream.StreamSupport
20+
21+
class AccountHolderListPage
22+
private constructor(
23+
private val accountHoldersService: AccountHolderService,
24+
private val params: AccountHolderListParams,
25+
private val response: Response,
26+
) {
27+
28+
fun response(): Response = response
29+
30+
fun data(): List<AccountHolder> = response().data()
31+
32+
fun hasMore(): Boolean = response().hasMore()
33+
34+
override fun equals(other: Any?): Boolean {
35+
if (this === other) {
36+
return true
37+
}
38+
39+
return other is AccountHolderListPage &&
40+
this.accountHoldersService == other.accountHoldersService &&
41+
this.params == other.params &&
42+
this.response == other.response
43+
}
44+
45+
override fun hashCode(): Int {
46+
return Objects.hash(
47+
accountHoldersService,
48+
params,
49+
response,
50+
)
51+
}
52+
53+
override fun toString() =
54+
"AccountHolderListPage{accountHoldersService=$accountHoldersService, params=$params, response=$response}"
55+
56+
fun hasNextPage(): Boolean {
57+
return data().isEmpty()
58+
}
59+
60+
fun getNextPageParams(): Optional<AccountHolderListParams> {
61+
return Optional.empty()
62+
}
63+
64+
fun getNextPage(): Optional<AccountHolderListPage> {
65+
return getNextPageParams().map { accountHoldersService.list(it) }
66+
}
67+
68+
fun autoPager(): AutoPager = AutoPager(this)
69+
70+
companion object {
71+
72+
@JvmStatic
73+
fun of(
74+
accountHoldersService: AccountHolderService,
75+
params: AccountHolderListParams,
76+
response: Response
77+
) =
78+
AccountHolderListPage(
79+
accountHoldersService,
80+
params,
81+
response,
82+
)
83+
}
84+
85+
@JsonDeserialize(builder = Response.Builder::class)
86+
@NoAutoDetect
87+
class Response
88+
constructor(
89+
private val data: JsonField<List<AccountHolder>>,
90+
private val hasMore: JsonField<Boolean>,
91+
private val additionalProperties: Map<String, JsonValue>,
92+
) {
93+
94+
private var validated: Boolean = false
95+
96+
fun data(): List<AccountHolder> = data.getNullable("data") ?: listOf()
97+
98+
fun hasMore(): Boolean = hasMore.getRequired("has_more")
99+
100+
@JsonProperty("data")
101+
fun _data(): Optional<JsonField<List<AccountHolder>>> = Optional.ofNullable(data)
102+
103+
@JsonProperty("has_more")
104+
fun _hasMore(): Optional<JsonField<Boolean>> = Optional.ofNullable(hasMore)
105+
106+
@JsonAnyGetter
107+
@ExcludeMissing
108+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
109+
110+
fun validate(): Response = apply {
111+
if (!validated) {
112+
data().map { it.validate() }
113+
hasMore()
114+
validated = true
115+
}
116+
}
117+
118+
fun toBuilder() = Builder().from(this)
119+
120+
override fun equals(other: Any?): Boolean {
121+
if (this === other) {
122+
return true
123+
}
124+
125+
return other is Response &&
126+
this.data == other.data &&
127+
this.hasMore == other.hasMore &&
128+
this.additionalProperties == other.additionalProperties
129+
}
130+
131+
override fun hashCode(): Int {
132+
return Objects.hash(
133+
data,
134+
hasMore,
135+
additionalProperties,
136+
)
137+
}
138+
139+
override fun toString() =
140+
"AccountHolderListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}"
141+
142+
companion object {
143+
144+
@JvmStatic fun builder() = Builder()
145+
}
146+
147+
class Builder {
148+
149+
private var data: JsonField<List<AccountHolder>> = JsonMissing.of()
150+
private var hasMore: JsonField<Boolean> = JsonMissing.of()
151+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
152+
153+
@JvmSynthetic
154+
internal fun from(page: Response) = apply {
155+
this.data = page.data
156+
this.hasMore = page.hasMore
157+
this.additionalProperties.putAll(page.additionalProperties)
158+
}
159+
160+
fun data(data: List<AccountHolder>) = data(JsonField.of(data))
161+
162+
@JsonProperty("data")
163+
fun data(data: JsonField<List<AccountHolder>>) = apply { this.data = data }
164+
165+
fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore))
166+
167+
@JsonProperty("has_more")
168+
fun hasMore(hasMore: JsonField<Boolean>) = apply { this.hasMore = hasMore }
169+
170+
@JsonAnySetter
171+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
172+
this.additionalProperties.put(key, value)
173+
}
174+
175+
fun build() =
176+
Response(
177+
data,
178+
hasMore,
179+
additionalProperties.toUnmodifiable(),
180+
)
181+
}
182+
}
183+
184+
class AutoPager
185+
constructor(
186+
private val firstPage: AccountHolderListPage,
187+
) : Iterable<AccountHolder> {
188+
189+
override fun iterator(): Iterator<AccountHolder> = iterator {
190+
var page = firstPage
191+
var index = 0
192+
while (true) {
193+
while (index < page.data().size) {
194+
yield(page.data()[index++])
195+
}
196+
page = page.getNextPage().orElse(null) ?: break
197+
index = 0
198+
}
199+
}
200+
201+
fun stream(): Stream<AccountHolder> {
202+
return StreamSupport.stream(spliterator(), false)
203+
}
204+
}
205+
}

0 commit comments

Comments
 (0)