diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6e39864df..192d0fac2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.8.0" + ".": "7.8.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8358e3938..1920f9807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 7.8.1 (2026-05-13) + +Full Changelog: [v7.8.0...v7.8.1](https://github.com/Finch-API/finch-api-java/compare/v7.8.0...v7.8.1) + +### Chores + +* **internal:** codegen related update ([2893186](https://github.com/Finch-API/finch-api-java/commit/2893186dbe22a68d0997cf817420cb0ccc0450f4)) + ## 7.8.0 (2026-05-12) Full Changelog: [v7.7.0...v7.8.0](https://github.com/Finch-API/finch-api-java/compare/v7.7.0...v7.8.0) diff --git a/README.md b/README.md index 5bf309db6..ce2135e53 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.8.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.8.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.8.1) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.8.1/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.1) @@ -24,7 +24,7 @@ Use the Finch MCP Server to enable AI assistants to interact with this API, allo -The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.0). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.1). @@ -35,7 +35,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:7.8.0") +implementation("com.tryfinch.api:finch-java:7.8.1") ``` ### Maven @@ -44,7 +44,7 @@ implementation("com.tryfinch.api:finch-java:7.8.0") com.tryfinch.api finch-java - 7.8.0 + 7.8.1 ``` diff --git a/build.gradle.kts b/build.gradle.kts index e67a9fe5b..4ceaab8d4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "7.8.0" // x-release-please-version + version = "7.8.1" // x-release-please-version } subprojects { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt new file mode 100644 index 000000000..9d1d31c3d --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.tryfinch.api.core.AutoPager +import com.tryfinch.api.core.Page +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.services.blocking.hris.DirectoryService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see DirectoryService.listIndividuals */ +@Deprecated("use `list` instead") +class HrisDirectoryListIndividualsPage +private constructor( + private val service: DirectoryService, + private val params: HrisDirectoryListIndividualsParams, + private val response: HrisDirectoryListIndividualsPageResponse, +) : Page { + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see HrisDirectoryListIndividualsPageResponse.individuals + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see HrisDirectoryListIndividualsPageResponse.paging + */ + fun paging(): Optional = response._paging().getOptional("paging") + + override fun items(): List = individuals() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull() + return totalCount == null || offset + items().size < totalCount + } + + fun nextPageParams(): HrisDirectoryListIndividualsParams { + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return params.toBuilder().offset(offset + items().size).build() + } + + override fun nextPage(): HrisDirectoryListIndividualsPage = + service.listIndividuals(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListIndividualsPage]. */ + class Builder internal constructor() { + + private var service: DirectoryService? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null + + @JvmSynthetic + internal fun from(hrisDirectoryListIndividualsPage: HrisDirectoryListIndividualsPage) = + apply { + service = hrisDirectoryListIndividualsPage.service + params = hrisDirectoryListIndividualsPage.params + response = hrisDirectoryListIndividualsPage.response + } + + fun service(service: DirectoryService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [HrisDirectoryListIndividualsPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListIndividualsPage = + HrisDirectoryListIndividualsPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HrisDirectoryListIndividualsPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "HrisDirectoryListIndividualsPage{service=$service, params=$params, response=$response}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt new file mode 100644 index 000000000..73b7d8e52 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.tryfinch.api.core.AutoPagerAsync +import com.tryfinch.api.core.PageAsync +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.services.async.hris.DirectoryServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see DirectoryServiceAsync.listIndividuals */ +@Deprecated("use `list` instead") +class HrisDirectoryListIndividualsPageAsync +private constructor( + private val service: DirectoryServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: HrisDirectoryListIndividualsParams, + private val response: HrisDirectoryListIndividualsPageResponse, +) : PageAsync { + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see HrisDirectoryListIndividualsPageResponse.individuals + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see HrisDirectoryListIndividualsPageResponse.paging + */ + fun paging(): Optional = response._paging().getOptional("paging") + + override fun items(): List = individuals() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull() + return totalCount == null || offset + items().size < totalCount + } + + fun nextPageParams(): HrisDirectoryListIndividualsParams { + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return params.toBuilder().offset(offset + items().size).build() + } + + override fun nextPage(): CompletableFuture = + service.listIndividuals(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListIndividualsPageAsync]. */ + class Builder internal constructor() { + + private var service: DirectoryServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisDirectoryListIndividualsPageAsync: HrisDirectoryListIndividualsPageAsync + ) = apply { + service = hrisDirectoryListIndividualsPageAsync.service + streamHandlerExecutor = hrisDirectoryListIndividualsPageAsync.streamHandlerExecutor + params = hrisDirectoryListIndividualsPageAsync.params + response = hrisDirectoryListIndividualsPageAsync.response + } + + fun service(service: DirectoryServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [HrisDirectoryListIndividualsPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListIndividualsPageAsync = + HrisDirectoryListIndividualsPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HrisDirectoryListIndividualsPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "HrisDirectoryListIndividualsPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt similarity index 87% rename from finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponse.kt rename to finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt index 806d599f1..5e83ea8f6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt @@ -18,7 +18,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -class DirectoryListIndividualsResponse +class HrisDirectoryListIndividualsPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individuals: JsonField>, @@ -80,7 +80,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [DirectoryListIndividualsResponse]. + * [HrisDirectoryListIndividualsPageResponse]. * * The following fields are required: * ```java @@ -91,7 +91,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DirectoryListIndividualsResponse]. */ + /** A builder for [HrisDirectoryListIndividualsPageResponse]. */ class Builder internal constructor() { private var individuals: JsonField>? = null @@ -99,14 +99,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(directoryListIndividualsResponse: DirectoryListIndividualsResponse) = - apply { - individuals = - directoryListIndividualsResponse.individuals.map { it.toMutableList() } - paging = directoryListIndividualsResponse.paging - additionalProperties = - directoryListIndividualsResponse.additionalProperties.toMutableMap() - } + internal fun from( + hrisDirectoryListIndividualsPageResponse: HrisDirectoryListIndividualsPageResponse + ) = apply { + individuals = + hrisDirectoryListIndividualsPageResponse.individuals.map { it.toMutableList() } + paging = hrisDirectoryListIndividualsPageResponse.paging + additionalProperties = + hrisDirectoryListIndividualsPageResponse.additionalProperties.toMutableMap() + } /** The array of employees. */ fun individuals(individuals: List) = @@ -165,7 +166,7 @@ private constructor( } /** - * Returns an immutable instance of [DirectoryListIndividualsResponse]. + * Returns an immutable instance of [HrisDirectoryListIndividualsPageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -177,8 +178,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DirectoryListIndividualsResponse = - DirectoryListIndividualsResponse( + fun build(): HrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse( checkRequired("individuals", individuals).map { it.toImmutable() }, checkRequired("paging", paging), additionalProperties.toMutableMap(), @@ -195,7 +196,7 @@ private constructor( * @throws FinchInvalidDataException if any value type in this object doesn't match its expected * type. */ - fun validate(): DirectoryListIndividualsResponse = apply { + fun validate(): HrisDirectoryListIndividualsPageResponse = apply { if (validated) { return@apply } @@ -228,7 +229,7 @@ private constructor( return true } - return other is DirectoryListIndividualsResponse && + return other is HrisDirectoryListIndividualsPageResponse && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties @@ -239,5 +240,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DirectoryListIndividualsResponse{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" + "HrisDirectoryListIndividualsPageResponse{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt index 516d5e923..a898e5488 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt @@ -5,7 +5,7 @@ package com.tryfinch.api.services.async.hris import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor -import com.tryfinch.api.models.DirectoryListIndividualsResponse +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListParams @@ -46,7 +46,7 @@ interface DirectoryServiceAsync { /** Read company directory and organization structure */ @Deprecated("use `list` instead") - fun listIndividuals(): CompletableFuture = + fun listIndividuals(): CompletableFuture = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see listIndividuals */ @@ -54,20 +54,20 @@ interface DirectoryServiceAsync { fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see listIndividuals */ @Deprecated("use `list` instead") fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() - ): CompletableFuture = + ): CompletableFuture = listIndividuals(params, RequestOptions.none()) /** @see listIndividuals */ @Deprecated("use `list` instead") fun listIndividuals( requestOptions: RequestOptions - ): CompletableFuture = + ): CompletableFuture = listIndividuals(HrisDirectoryListIndividualsParams.none(), requestOptions) /** @@ -115,7 +115,7 @@ interface DirectoryServiceAsync { */ @Deprecated("use `list` instead") fun listIndividuals(): - CompletableFuture> = + CompletableFuture> = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see listIndividuals */ @@ -123,20 +123,20 @@ interface DirectoryServiceAsync { fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see listIndividuals */ @Deprecated("use `list` instead") fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() - ): CompletableFuture> = + ): CompletableFuture> = listIndividuals(params, RequestOptions.none()) /** @see listIndividuals */ @Deprecated("use `list` instead") fun listIndividuals( requestOptions: RequestOptions - ): CompletableFuture> = + ): CompletableFuture> = listIndividuals(HrisDirectoryListIndividualsParams.none(), requestOptions) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt index 47977c620..cb3231f40 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt @@ -15,7 +15,8 @@ import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync -import com.tryfinch.api.models.DirectoryListIndividualsResponse +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageResponse import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListPageResponse @@ -46,7 +47,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: override fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /employer/directory withRawResponse().listIndividuals(params, requestOptions).thenApply { it.parse() } @@ -105,14 +106,14 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: } } - private val listIndividualsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) @Deprecated("use `list` instead") override fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -136,6 +137,14 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: it.validate() } } + .let { + HrisDirectoryListIndividualsPageAsync.builder() + .service(DirectoryServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt index dcc1f03bb..ac7f08ea5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt @@ -6,7 +6,7 @@ import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor -import com.tryfinch.api.models.DirectoryListIndividualsResponse +import com.tryfinch.api.models.HrisDirectoryListIndividualsPage import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListParams @@ -46,7 +46,7 @@ interface DirectoryService { /** Read company directory and organization structure */ @Deprecated("use `list` instead") - fun listIndividuals(): DirectoryListIndividualsResponse = + fun listIndividuals(): HrisDirectoryListIndividualsPage = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see listIndividuals */ @@ -54,17 +54,17 @@ interface DirectoryService { fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): DirectoryListIndividualsResponse + ): HrisDirectoryListIndividualsPage /** @see listIndividuals */ @Deprecated("use `list` instead") fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() - ): DirectoryListIndividualsResponse = listIndividuals(params, RequestOptions.none()) + ): HrisDirectoryListIndividualsPage = listIndividuals(params, RequestOptions.none()) /** @see listIndividuals */ @Deprecated("use `list` instead") - fun listIndividuals(requestOptions: RequestOptions): DirectoryListIndividualsResponse = + fun listIndividuals(requestOptions: RequestOptions): HrisDirectoryListIndividualsPage = listIndividuals(HrisDirectoryListIndividualsParams.none(), requestOptions) /** A view of [DirectoryService] that provides access to raw HTTP responses for each method. */ @@ -108,7 +108,7 @@ interface DirectoryService { */ @Deprecated("use `list` instead") @MustBeClosed - fun listIndividuals(): HttpResponseFor = + fun listIndividuals(): HttpResponseFor = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see listIndividuals */ @@ -117,14 +117,14 @@ interface DirectoryService { fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see listIndividuals */ @Deprecated("use `list` instead") @MustBeClosed fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() - ): HttpResponseFor = + ): HttpResponseFor = listIndividuals(params, RequestOptions.none()) /** @see listIndividuals */ @@ -132,7 +132,7 @@ interface DirectoryService { @MustBeClosed fun listIndividuals( requestOptions: RequestOptions - ): HttpResponseFor = + ): HttpResponseFor = listIndividuals(HrisDirectoryListIndividualsParams.none(), requestOptions) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt index 243b719cc..c0e5e8531 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt @@ -15,7 +15,8 @@ import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare -import com.tryfinch.api.models.DirectoryListIndividualsResponse +import com.tryfinch.api.models.HrisDirectoryListIndividualsPage +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageResponse import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListPageResponse @@ -45,7 +46,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien override fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions, - ): DirectoryListIndividualsResponse = + ): HrisDirectoryListIndividualsPage = // get /employer/directory withRawResponse().listIndividuals(params, requestOptions).parse() @@ -100,14 +101,14 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien } } - private val listIndividualsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) @Deprecated("use `list` instead") override fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -129,6 +130,13 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien it.validate() } } + .let { + HrisDirectoryListIndividualsPage.builder() + .service(DirectoryServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt similarity index 77% rename from finch-java-core/src/test/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponseTest.kt rename to finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt index 59b7a4a3b..ba984c74d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DirectoryListIndividualsResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt @@ -7,12 +7,12 @@ import com.tryfinch.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DirectoryListIndividualsResponseTest { +internal class HrisDirectoryListIndividualsPageResponseTest { @Test fun create() { - val directoryListIndividualsResponse = - DirectoryListIndividualsResponse.builder() + val hrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse.builder() .addIndividual( IndividualInDirectory.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -31,7 +31,7 @@ internal class DirectoryListIndividualsResponseTest { .paging(Paging.builder().offset(0L).count(0L).build()) .build() - assertThat(directoryListIndividualsResponse.individuals()) + assertThat(hrisDirectoryListIndividualsPageResponse.individuals()) .containsExactly( IndividualInDirectory.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -47,15 +47,15 @@ internal class DirectoryListIndividualsResponseTest { .middleName("middle_name") .build() ) - assertThat(directoryListIndividualsResponse.paging()) + assertThat(hrisDirectoryListIndividualsPageResponse.paging()) .isEqualTo(Paging.builder().offset(0L).count(0L).build()) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val directoryListIndividualsResponse = - DirectoryListIndividualsResponse.builder() + val hrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse.builder() .addIndividual( IndividualInDirectory.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -74,13 +74,13 @@ internal class DirectoryListIndividualsResponseTest { .paging(Paging.builder().offset(0L).count(0L).build()) .build() - val roundtrippedDirectoryListIndividualsResponse = + val roundtrippedHrisDirectoryListIndividualsPageResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(directoryListIndividualsResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(hrisDirectoryListIndividualsPageResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedDirectoryListIndividualsResponse) - .isEqualTo(directoryListIndividualsResponse) + assertThat(roundtrippedHrisDirectoryListIndividualsPageResponse) + .isEqualTo(hrisDirectoryListIndividualsPageResponse) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncTest.kt index 57c303319..d6453a092 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.tryfinch.api.services.async.hris import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync -import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -35,16 +34,9 @@ internal class DirectoryServiceAsyncTest { .build() val directoryServiceAsync = client.hris().directory() - val responseFuture = - directoryServiceAsync.listIndividuals( - HrisDirectoryListIndividualsParams.builder() - .addEntityId("550e8400-e29b-41d4-a716-446655440000") - .limit(0L) - .offset(0L) - .build() - ) - - val response = responseFuture.get() - response.validate() + val pageFuture = directoryServiceAsync.listIndividuals() + + val page = pageFuture.get() + page.response().validate() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt index 762ceb24b..a5417bd6b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt @@ -4,7 +4,6 @@ package com.tryfinch.api.services.blocking.hris import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient -import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,15 +33,8 @@ internal class DirectoryServiceTest { .build() val directoryService = client.hris().directory() - val response = - directoryService.listIndividuals( - HrisDirectoryListIndividualsParams.builder() - .addEntityId("550e8400-e29b-41d4-a716-446655440000") - .limit(0L) - .offset(0L) - .build() - ) + val page = directoryService.listIndividuals() - response.validate() + page.response().validate() } }