Skip to content

Commit 2893186

Browse files
chore(internal): codegen related update
1 parent fe1ec65 commit 2893186

10 files changed

Lines changed: 388 additions & 79 deletions

File tree

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.tryfinch.api.models
4+
5+
import com.tryfinch.api.core.AutoPager
6+
import com.tryfinch.api.core.Page
7+
import com.tryfinch.api.core.checkRequired
8+
import com.tryfinch.api.services.blocking.hris.DirectoryService
9+
import java.util.Objects
10+
import java.util.Optional
11+
import kotlin.jvm.optionals.getOrDefault
12+
import kotlin.jvm.optionals.getOrNull
13+
14+
/** @see DirectoryService.listIndividuals */
15+
@Deprecated("use `list` instead")
16+
class HrisDirectoryListIndividualsPage
17+
private constructor(
18+
private val service: DirectoryService,
19+
private val params: HrisDirectoryListIndividualsParams,
20+
private val response: HrisDirectoryListIndividualsPageResponse,
21+
) : Page<IndividualInDirectory> {
22+
23+
/**
24+
* Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data.
25+
*
26+
* @see HrisDirectoryListIndividualsPageResponse.individuals
27+
*/
28+
fun individuals(): List<IndividualInDirectory> =
29+
response._individuals().getOptional("individuals").getOrNull() ?: emptyList()
30+
31+
/**
32+
* Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data.
33+
*
34+
* @see HrisDirectoryListIndividualsPageResponse.paging
35+
*/
36+
fun paging(): Optional<Paging> = response._paging().getOptional("paging")
37+
38+
override fun items(): List<IndividualInDirectory> = individuals()
39+
40+
override fun hasNextPage(): Boolean {
41+
if (items().isEmpty()) {
42+
return false
43+
}
44+
45+
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
46+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
47+
return totalCount == null || offset + items().size < totalCount
48+
}
49+
50+
fun nextPageParams(): HrisDirectoryListIndividualsParams {
51+
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
52+
return params.toBuilder().offset(offset + items().size).build()
53+
}
54+
55+
override fun nextPage(): HrisDirectoryListIndividualsPage =
56+
service.listIndividuals(nextPageParams())
57+
58+
fun autoPager(): AutoPager<IndividualInDirectory> = AutoPager.from(this)
59+
60+
/** The parameters that were used to request this page. */
61+
fun params(): HrisDirectoryListIndividualsParams = params
62+
63+
/** The response that this page was parsed from. */
64+
fun response(): HrisDirectoryListIndividualsPageResponse = response
65+
66+
fun toBuilder() = Builder().from(this)
67+
68+
companion object {
69+
70+
/**
71+
* Returns a mutable builder for constructing an instance of
72+
* [HrisDirectoryListIndividualsPage].
73+
*
74+
* The following fields are required:
75+
* ```java
76+
* .service()
77+
* .params()
78+
* .response()
79+
* ```
80+
*/
81+
@JvmStatic fun builder() = Builder()
82+
}
83+
84+
/** A builder for [HrisDirectoryListIndividualsPage]. */
85+
class Builder internal constructor() {
86+
87+
private var service: DirectoryService? = null
88+
private var params: HrisDirectoryListIndividualsParams? = null
89+
private var response: HrisDirectoryListIndividualsPageResponse? = null
90+
91+
@JvmSynthetic
92+
internal fun from(hrisDirectoryListIndividualsPage: HrisDirectoryListIndividualsPage) =
93+
apply {
94+
service = hrisDirectoryListIndividualsPage.service
95+
params = hrisDirectoryListIndividualsPage.params
96+
response = hrisDirectoryListIndividualsPage.response
97+
}
98+
99+
fun service(service: DirectoryService) = apply { this.service = service }
100+
101+
/** The parameters that were used to request this page. */
102+
fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params }
103+
104+
/** The response that this page was parsed from. */
105+
fun response(response: HrisDirectoryListIndividualsPageResponse) = apply {
106+
this.response = response
107+
}
108+
109+
/**
110+
* Returns an immutable instance of [HrisDirectoryListIndividualsPage].
111+
*
112+
* Further updates to this [Builder] will not mutate the returned instance.
113+
*
114+
* The following fields are required:
115+
* ```java
116+
* .service()
117+
* .params()
118+
* .response()
119+
* ```
120+
*
121+
* @throws IllegalStateException if any required field is unset.
122+
*/
123+
fun build(): HrisDirectoryListIndividualsPage =
124+
HrisDirectoryListIndividualsPage(
125+
checkRequired("service", service),
126+
checkRequired("params", params),
127+
checkRequired("response", response),
128+
)
129+
}
130+
131+
override fun equals(other: Any?): Boolean {
132+
if (this === other) {
133+
return true
134+
}
135+
136+
return other is HrisDirectoryListIndividualsPage &&
137+
service == other.service &&
138+
params == other.params &&
139+
response == other.response
140+
}
141+
142+
override fun hashCode(): Int = Objects.hash(service, params, response)
143+
144+
override fun toString() =
145+
"HrisDirectoryListIndividualsPage{service=$service, params=$params, response=$response}"
146+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.tryfinch.api.models
4+
5+
import com.tryfinch.api.core.AutoPagerAsync
6+
import com.tryfinch.api.core.PageAsync
7+
import com.tryfinch.api.core.checkRequired
8+
import com.tryfinch.api.services.async.hris.DirectoryServiceAsync
9+
import java.util.Objects
10+
import java.util.Optional
11+
import java.util.concurrent.CompletableFuture
12+
import java.util.concurrent.Executor
13+
import kotlin.jvm.optionals.getOrDefault
14+
import kotlin.jvm.optionals.getOrNull
15+
16+
/** @see DirectoryServiceAsync.listIndividuals */
17+
@Deprecated("use `list` instead")
18+
class HrisDirectoryListIndividualsPageAsync
19+
private constructor(
20+
private val service: DirectoryServiceAsync,
21+
private val streamHandlerExecutor: Executor,
22+
private val params: HrisDirectoryListIndividualsParams,
23+
private val response: HrisDirectoryListIndividualsPageResponse,
24+
) : PageAsync<IndividualInDirectory> {
25+
26+
/**
27+
* Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data.
28+
*
29+
* @see HrisDirectoryListIndividualsPageResponse.individuals
30+
*/
31+
fun individuals(): List<IndividualInDirectory> =
32+
response._individuals().getOptional("individuals").getOrNull() ?: emptyList()
33+
34+
/**
35+
* Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data.
36+
*
37+
* @see HrisDirectoryListIndividualsPageResponse.paging
38+
*/
39+
fun paging(): Optional<Paging> = response._paging().getOptional("paging")
40+
41+
override fun items(): List<IndividualInDirectory> = individuals()
42+
43+
override fun hasNextPage(): Boolean {
44+
if (items().isEmpty()) {
45+
return false
46+
}
47+
48+
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
49+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
50+
return totalCount == null || offset + items().size < totalCount
51+
}
52+
53+
fun nextPageParams(): HrisDirectoryListIndividualsParams {
54+
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
55+
return params.toBuilder().offset(offset + items().size).build()
56+
}
57+
58+
override fun nextPage(): CompletableFuture<HrisDirectoryListIndividualsPageAsync> =
59+
service.listIndividuals(nextPageParams())
60+
61+
fun autoPager(): AutoPagerAsync<IndividualInDirectory> =
62+
AutoPagerAsync.from(this, streamHandlerExecutor)
63+
64+
/** The parameters that were used to request this page. */
65+
fun params(): HrisDirectoryListIndividualsParams = params
66+
67+
/** The response that this page was parsed from. */
68+
fun response(): HrisDirectoryListIndividualsPageResponse = response
69+
70+
fun toBuilder() = Builder().from(this)
71+
72+
companion object {
73+
74+
/**
75+
* Returns a mutable builder for constructing an instance of
76+
* [HrisDirectoryListIndividualsPageAsync].
77+
*
78+
* The following fields are required:
79+
* ```java
80+
* .service()
81+
* .streamHandlerExecutor()
82+
* .params()
83+
* .response()
84+
* ```
85+
*/
86+
@JvmStatic fun builder() = Builder()
87+
}
88+
89+
/** A builder for [HrisDirectoryListIndividualsPageAsync]. */
90+
class Builder internal constructor() {
91+
92+
private var service: DirectoryServiceAsync? = null
93+
private var streamHandlerExecutor: Executor? = null
94+
private var params: HrisDirectoryListIndividualsParams? = null
95+
private var response: HrisDirectoryListIndividualsPageResponse? = null
96+
97+
@JvmSynthetic
98+
internal fun from(
99+
hrisDirectoryListIndividualsPageAsync: HrisDirectoryListIndividualsPageAsync
100+
) = apply {
101+
service = hrisDirectoryListIndividualsPageAsync.service
102+
streamHandlerExecutor = hrisDirectoryListIndividualsPageAsync.streamHandlerExecutor
103+
params = hrisDirectoryListIndividualsPageAsync.params
104+
response = hrisDirectoryListIndividualsPageAsync.response
105+
}
106+
107+
fun service(service: DirectoryServiceAsync) = apply { this.service = service }
108+
109+
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
110+
this.streamHandlerExecutor = streamHandlerExecutor
111+
}
112+
113+
/** The parameters that were used to request this page. */
114+
fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params }
115+
116+
/** The response that this page was parsed from. */
117+
fun response(response: HrisDirectoryListIndividualsPageResponse) = apply {
118+
this.response = response
119+
}
120+
121+
/**
122+
* Returns an immutable instance of [HrisDirectoryListIndividualsPageAsync].
123+
*
124+
* Further updates to this [Builder] will not mutate the returned instance.
125+
*
126+
* The following fields are required:
127+
* ```java
128+
* .service()
129+
* .streamHandlerExecutor()
130+
* .params()
131+
* .response()
132+
* ```
133+
*
134+
* @throws IllegalStateException if any required field is unset.
135+
*/
136+
fun build(): HrisDirectoryListIndividualsPageAsync =
137+
HrisDirectoryListIndividualsPageAsync(
138+
checkRequired("service", service),
139+
checkRequired("streamHandlerExecutor", streamHandlerExecutor),
140+
checkRequired("params", params),
141+
checkRequired("response", response),
142+
)
143+
}
144+
145+
override fun equals(other: Any?): Boolean {
146+
if (this === other) {
147+
return true
148+
}
149+
150+
return other is HrisDirectoryListIndividualsPageAsync &&
151+
service == other.service &&
152+
streamHandlerExecutor == other.streamHandlerExecutor &&
153+
params == other.params &&
154+
response == other.response
155+
}
156+
157+
override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response)
158+
159+
override fun toString() =
160+
"HrisDirectoryListIndividualsPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}"
161+
}

0 commit comments

Comments
 (0)