Skip to content

Commit 5feba92

Browse files
fix(types): make data and has_more required in AccountActivityListPageResponse
1 parent c266aa2 commit 5feba92

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 190
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-7349acbc90f2ba5668e44039a8e16c678944a2e83281f78e54812ba45904f49a.yml
3-
openapi_spec_hash: d749723cb9a5dca308c467a01cfdc3e9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-8b222de46ecf164a1d6e47c5e677d6e1772c7b1726d0574d9322305c9af4eec6.yml
3+
openapi_spec_hash: f573dc729467c8c592750677f45a3ea4
44
config_hash: edbdfefeb0d3d927c2f9fe3402793215

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import com.lithic.api.core.JsonField
1111
import com.lithic.api.core.JsonMissing
1212
import com.lithic.api.core.JsonValue
1313
import com.lithic.api.core.checkKnown
14+
import com.lithic.api.core.checkRequired
1415
import com.lithic.api.core.toImmutable
1516
import com.lithic.api.errors.LithicInvalidDataException
1617
import java.util.Collections
1718
import java.util.Objects
18-
import java.util.Optional
1919
import kotlin.jvm.optionals.getOrNull
2020

2121
/** A response containing a list of transactions */
@@ -36,18 +36,18 @@ private constructor(
3636
) : this(data, hasMore, mutableMapOf())
3737

3838
/**
39-
* @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
40-
* server responded with an unexpected value).
39+
* @throws LithicInvalidDataException if the JSON field has an unexpected type or is
40+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
4141
*/
42-
fun data(): Optional<List<AccountActivityListResponse>> = data.getOptional("data")
42+
fun data(): List<AccountActivityListResponse> = data.getRequired("data")
4343

4444
/**
4545
* Indicates if there are more transactions available for pagination
4646
*
47-
* @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
48-
* server responded with an unexpected value).
47+
* @throws LithicInvalidDataException if the JSON field has an unexpected type or is
48+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
4949
*/
50-
fun hasMore(): Optional<Boolean> = hasMore.getOptional("has_more")
50+
fun hasMore(): Boolean = hasMore.getRequired("has_more")
5151

5252
/**
5353
* Returns the raw JSON value of [data].
@@ -82,6 +82,12 @@ private constructor(
8282
/**
8383
* Returns a mutable builder for constructing an instance of
8484
* [AccountActivityListPageResponse].
85+
*
86+
* The following fields are required:
87+
* ```java
88+
* .data()
89+
* .hasMore()
90+
* ```
8591
*/
8692
@JvmStatic fun builder() = Builder()
8793
}
@@ -90,7 +96,7 @@ private constructor(
9096
class Builder internal constructor() {
9197

9298
private var data: JsonField<MutableList<AccountActivityListResponse>>? = null
93-
private var hasMore: JsonField<Boolean> = JsonMissing.of()
99+
private var hasMore: JsonField<Boolean>? = null
94100
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
95101

96102
@JvmSynthetic
@@ -193,11 +199,19 @@ private constructor(
193199
* Returns an immutable instance of [AccountActivityListPageResponse].
194200
*
195201
* Further updates to this [Builder] will not mutate the returned instance.
202+
*
203+
* The following fields are required:
204+
* ```java
205+
* .data()
206+
* .hasMore()
207+
* ```
208+
*
209+
* @throws IllegalStateException if any required field is unset.
196210
*/
197211
fun build(): AccountActivityListPageResponse =
198212
AccountActivityListPageResponse(
199-
(data ?: JsonMissing.of()).map { it.toImmutable() },
200-
hasMore,
213+
checkRequired("data", data).map { it.toImmutable() },
214+
checkRequired("hasMore", hasMore),
201215
additionalProperties.toMutableMap(),
202216
)
203217
}
@@ -209,7 +223,7 @@ private constructor(
209223
return@apply
210224
}
211225

212-
data().ifPresent { it.forEach { it.validate() } }
226+
data().forEach { it.validate() }
213227
hasMore()
214228
validated = true
215229
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package com.lithic.api.models
55
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
66
import com.lithic.api.core.jsonMapper
77
import java.time.OffsetDateTime
8-
import kotlin.jvm.optionals.getOrNull
98
import org.assertj.core.api.Assertions.assertThat
109
import org.junit.jupiter.api.Test
1110

@@ -51,7 +50,7 @@ internal class AccountActivityListPageResponseTest {
5150
.hasMore(true)
5251
.build()
5352

54-
assertThat(accountActivityListPageResponse.data().getOrNull())
53+
assertThat(accountActivityListPageResponse.data())
5554
.containsExactly(
5655
AccountActivityListResponse.ofInternal(
5756
AccountActivityListResponse.FinancialTransaction.builder()
@@ -87,7 +86,7 @@ internal class AccountActivityListPageResponseTest {
8786
.build()
8887
)
8988
)
90-
assertThat(accountActivityListPageResponse.hasMore()).contains(true)
89+
assertThat(accountActivityListPageResponse.hasMore()).isEqualTo(true)
9190
}
9291

9392
@Test

0 commit comments

Comments
 (0)