Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.86.0"
".": "0.87.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 157
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-18973e063e9e9233433290bb4d641df8e17e1f21f5b1ec57e00182f0a48dbdec.yml
openapi_spec_hash: ab503dc3772f962b603ade7b91b8534c
config_hash: fb5cfdd28a12d32853f8b8be1126af6b
config_hash: 6729d695e399d14fff4891b6b82ec86c
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 0.87.0 (2025-04-09)

Full Changelog: [v0.86.0...v0.87.0](https://github.com/lithic-com/lithic-java/compare/v0.86.0...v0.87.0)

### Features

* **api:** manual updates ([841cf07](https://github.com/lithic-com/lithic-java/commit/841cf07b79d6577789bae8b82668504ea508a0f3))
* **client:** make pagination robust to missing data ([44acc8e](https://github.com/lithic-com/lithic-java/commit/44acc8efd7511d741d27cdbc305732a406ddc489))


### Documentation

* add comments for page methods ([44acc8e](https://github.com/lithic-com/lithic-java/commit/44acc8efd7511d741d27cdbc305732a406ddc489))


### Refactors

* **client:** deduplicate page response classes ([#596](https://github.com/lithic-com/lithic-java/issues/596)) ([44acc8e](https://github.com/lithic-com/lithic-java/commit/44acc8efd7511d741d27cdbc305732a406ddc489))

## 0.86.0 (2025-04-09)

Full Changelog: [v0.85.0...v0.86.0](https://github.com/lithic-com/lithic-java/compare/v0.85.0...v0.86.0)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.86.0)
[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.86.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.86.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.87.0)
[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.87.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.87.0)

<!-- x-release-please-end -->

Expand All @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc

<!-- x-release-please-start-version -->

The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.86.0).
The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.87.0).

<!-- x-release-please-end -->

Expand All @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic
### Gradle

```kotlin
implementation("com.lithic.api:lithic-java:0.86.0")
implementation("com.lithic.api:lithic-java:0.87.0")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.86.0")
<dependency>
<groupId>com.lithic.api</groupId>
<artifactId>lithic-java</artifactId>
<version>0.86.0</version>
<version>0.87.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.lithic.api"
version = "0.86.0" // x-release-please-version
version = "0.87.0" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

package com.lithic.api.models

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.lithic.api.core.ExcludeMissing
import com.lithic.api.core.JsonField
import com.lithic.api.core.JsonMissing
import com.lithic.api.core.JsonValue
import com.lithic.api.errors.LithicInvalidDataException
import com.lithic.api.services.blocking.AccountHolderService
import java.util.Collections
import java.util.Objects
import java.util.Optional
import java.util.stream.Stream
Expand All @@ -24,14 +14,26 @@ class AccountHolderListPage
private constructor(
private val accountHoldersService: AccountHolderService,
private val params: AccountHolderListParams,
private val response: Response,
private val response: AccountHolderListPageResponse,
) {

fun response(): Response = response
/** Returns the response that this page was parsed from. */
fun response(): AccountHolderListPageResponse = response

fun data(): List<AccountHolder> = response().data()
/**
* Delegates to [AccountHolderListPageResponse], but gracefully handles missing data.
*
* @see [AccountHolderListPageResponse.data]
*/
fun data(): List<AccountHolder> =
response._data().getOptional("data").getOrNull() ?: emptyList()

fun hasMore(): Boolean = response().hasMore()
/**
* Delegates to [AccountHolderListPageResponse], but gracefully handles missing data.
*
* @see [AccountHolderListPageResponse.hasMore]
*/
fun hasMore(): Optional<Boolean> = response._hasMore().getOptional("has_more")

override fun equals(other: Any?): Boolean {
if (this === other) {
Expand All @@ -46,13 +48,9 @@ private constructor(
override fun toString() =
"AccountHolderListPage{accountHoldersService=$accountHoldersService, params=$params, response=$response}"

fun hasNextPage(): Boolean {
return !data().isEmpty()
}
fun hasNextPage(): Boolean = data().isNotEmpty()

fun getNextPageParams(): Optional<AccountHolderListParams> {
return Optional.empty()
}
fun getNextPageParams(): Optional<AccountHolderListParams> = Optional.empty()

fun getNextPage(): Optional<AccountHolderListPage> {
return getNextPageParams().map { accountHoldersService.list(it) }
Expand All @@ -66,119 +64,10 @@ private constructor(
fun of(
accountHoldersService: AccountHolderService,
params: AccountHolderListParams,
response: Response,
response: AccountHolderListPageResponse,
) = AccountHolderListPage(accountHoldersService, params, response)
}

class Response(
private val data: JsonField<List<AccountHolder>>,
private val hasMore: JsonField<Boolean>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {

@JsonCreator
private constructor(
@JsonProperty("data") data: JsonField<List<AccountHolder>> = JsonMissing.of(),
@JsonProperty("has_more") hasMore: JsonField<Boolean> = JsonMissing.of(),
) : this(data, hasMore, mutableMapOf())

fun data(): List<AccountHolder> = data.getOptional("data").getOrNull() ?: listOf()

fun hasMore(): Boolean = hasMore.getRequired("has_more")

@JsonProperty("data")
fun _data(): Optional<JsonField<List<AccountHolder>>> = Optional.ofNullable(data)

@JsonProperty("has_more")
fun _hasMore(): Optional<JsonField<Boolean>> = Optional.ofNullable(hasMore)

@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
}

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> =
Collections.unmodifiableMap(additionalProperties)

private var validated: Boolean = false

fun validate(): Response = apply {
if (validated) {
return@apply
}

data().map { it.validate() }
hasMore()
validated = true
}

fun isValid(): Boolean =
try {
validate()
true
} catch (e: LithicInvalidDataException) {
false
}

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

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is Response && data == other.data && hasMore == other.hasMore && additionalProperties == other.additionalProperties /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, hasMore, additionalProperties) /* spotless:on */

override fun toString() =
"Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}"

companion object {

/**
* Returns a mutable builder for constructing an instance of [AccountHolderListPage].
*/
@JvmStatic fun builder() = Builder()
}

class Builder {

private var data: JsonField<List<AccountHolder>> = JsonMissing.of()
private var hasMore: JsonField<Boolean> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(page: Response) = apply {
this.data = page.data
this.hasMore = page.hasMore
this.additionalProperties.putAll(page.additionalProperties)
}

fun data(data: List<AccountHolder>) = data(JsonField.of(data))

fun data(data: JsonField<List<AccountHolder>>) = apply { this.data = data }

fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore))

fun hasMore(hasMore: JsonField<Boolean>) = apply { this.hasMore = hasMore }

fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

/**
* Returns an immutable instance of [Response].
*
* Further updates to this [Builder] will not mutate the returned instance.
*/
fun build(): Response = Response(data, hasMore, additionalProperties.toMutableMap())
}
}

class AutoPager(private val firstPage: AccountHolderListPage) : Iterable<AccountHolder> {

override fun iterator(): Iterator<AccountHolder> = iterator {
Expand Down
Loading