Skip to content

Commit 1ab19a3

Browse files
feat(api): add new endpoints for pay statement items (#526)
1 parent 16616bf commit 1ab19a3

File tree

41 files changed

+11262
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+11262
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 40
1+
configured_endpoints: 45
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-972e563922dedeeb94dca9a3ca8bac536488fcee56b55fcf09e6af044d3740e3.yml
33
openapi_spec_hash: 08b86ecbec3323717d48e4aaee48ed54
4-
config_hash: 8303e755d3e16cf28542d5f0aec83851
4+
config_hash: b839955f81dcf0a060366274f202b185
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.tryfinch.api.models
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter
6+
import com.fasterxml.jackson.annotation.JsonAnySetter
7+
import com.fasterxml.jackson.annotation.JsonCreator
8+
import com.fasterxml.jackson.annotation.JsonProperty
9+
import com.tryfinch.api.core.ExcludeMissing
10+
import com.tryfinch.api.core.JsonField
11+
import com.tryfinch.api.core.JsonMissing
12+
import com.tryfinch.api.core.JsonValue
13+
import com.tryfinch.api.errors.FinchInvalidDataException
14+
import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService
15+
import java.util.Collections
16+
import java.util.Objects
17+
import java.util.Optional
18+
import java.util.stream.Stream
19+
import java.util.stream.StreamSupport
20+
import kotlin.jvm.optionals.getOrNull
21+
22+
/**
23+
* **Beta:** this endpoint currently serves employers onboarded after March 4th and historical
24+
* support will be added soon Retrieve a list of detailed pay statement items for the access token's
25+
* connection account.
26+
*/
27+
class HrisCompanyPayStatementItemListPage
28+
private constructor(
29+
private val payStatementItemService: PayStatementItemService,
30+
private val params: HrisCompanyPayStatementItemListParams,
31+
private val response: Response,
32+
) {
33+
34+
fun response(): Response = response
35+
36+
fun responses(): List<PayStatementItemListResponse> = response().responses()
37+
38+
override fun equals(other: Any?): Boolean {
39+
if (this === other) {
40+
return true
41+
}
42+
43+
return /* spotless:off */ other is HrisCompanyPayStatementItemListPage && payStatementItemService == other.payStatementItemService && params == other.params && response == other.response /* spotless:on */
44+
}
45+
46+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementItemService, params, response) /* spotless:on */
47+
48+
override fun toString() =
49+
"HrisCompanyPayStatementItemListPage{payStatementItemService=$payStatementItemService, params=$params, response=$response}"
50+
51+
fun hasNextPage(): Boolean {
52+
return !responses().isEmpty()
53+
}
54+
55+
fun getNextPageParams(): Optional<HrisCompanyPayStatementItemListParams> {
56+
return Optional.empty()
57+
}
58+
59+
fun getNextPage(): Optional<HrisCompanyPayStatementItemListPage> {
60+
return getNextPageParams().map { payStatementItemService.list(it) }
61+
}
62+
63+
fun autoPager(): AutoPager = AutoPager(this)
64+
65+
companion object {
66+
67+
@JvmStatic
68+
fun of(
69+
payStatementItemService: PayStatementItemService,
70+
params: HrisCompanyPayStatementItemListParams,
71+
response: Response,
72+
) = HrisCompanyPayStatementItemListPage(payStatementItemService, params, response)
73+
}
74+
75+
class Response(
76+
private val responses: JsonField<List<PayStatementItemListResponse>>,
77+
private val additionalProperties: MutableMap<String, JsonValue>,
78+
) {
79+
80+
@JsonCreator
81+
private constructor(
82+
@JsonProperty("responses")
83+
responses: JsonField<List<PayStatementItemListResponse>> = JsonMissing.of()
84+
) : this(responses, mutableMapOf())
85+
86+
fun responses(): List<PayStatementItemListResponse> =
87+
responses.getNullable("responses") ?: listOf()
88+
89+
@JsonProperty("responses")
90+
fun _responses(): Optional<JsonField<List<PayStatementItemListResponse>>> =
91+
Optional.ofNullable(responses)
92+
93+
@JsonAnySetter
94+
private fun putAdditionalProperty(key: String, value: JsonValue) {
95+
additionalProperties.put(key, value)
96+
}
97+
98+
@JsonAnyGetter
99+
@ExcludeMissing
100+
fun _additionalProperties(): Map<String, JsonValue> =
101+
Collections.unmodifiableMap(additionalProperties)
102+
103+
private var validated: Boolean = false
104+
105+
fun validate(): Response = apply {
106+
if (validated) {
107+
return@apply
108+
}
109+
110+
responses().map { it.validate() }
111+
validated = true
112+
}
113+
114+
fun isValid(): Boolean =
115+
try {
116+
validate()
117+
true
118+
} catch (e: FinchInvalidDataException) {
119+
false
120+
}
121+
122+
fun toBuilder() = Builder().from(this)
123+
124+
override fun equals(other: Any?): Boolean {
125+
if (this === other) {
126+
return true
127+
}
128+
129+
return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */
130+
}
131+
132+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */
133+
134+
override fun toString() =
135+
"Response{responses=$responses, additionalProperties=$additionalProperties}"
136+
137+
companion object {
138+
139+
/**
140+
* Returns a mutable builder for constructing an instance of
141+
* [HrisCompanyPayStatementItemListPage].
142+
*/
143+
@JvmStatic fun builder() = Builder()
144+
}
145+
146+
class Builder {
147+
148+
private var responses: JsonField<List<PayStatementItemListResponse>> = JsonMissing.of()
149+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
150+
151+
@JvmSynthetic
152+
internal fun from(page: Response) = apply {
153+
this.responses = page.responses
154+
this.additionalProperties.putAll(page.additionalProperties)
155+
}
156+
157+
fun responses(responses: List<PayStatementItemListResponse>) =
158+
responses(JsonField.of(responses))
159+
160+
fun responses(responses: JsonField<List<PayStatementItemListResponse>>) = apply {
161+
this.responses = responses
162+
}
163+
164+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
165+
this.additionalProperties.put(key, value)
166+
}
167+
168+
/**
169+
* Returns an immutable instance of [Response].
170+
*
171+
* Further updates to this [Builder] will not mutate the returned instance.
172+
*/
173+
fun build(): Response = Response(responses, additionalProperties.toMutableMap())
174+
}
175+
}
176+
177+
class AutoPager(private val firstPage: HrisCompanyPayStatementItemListPage) :
178+
Iterable<PayStatementItemListResponse> {
179+
180+
override fun iterator(): Iterator<PayStatementItemListResponse> = iterator {
181+
var page = firstPage
182+
var index = 0
183+
while (true) {
184+
while (index < page.responses().size) {
185+
yield(page.responses()[index++])
186+
}
187+
page = page.getNextPage().getOrNull() ?: break
188+
index = 0
189+
}
190+
}
191+
192+
fun stream(): Stream<PayStatementItemListResponse> {
193+
return StreamSupport.stream(spliterator(), false)
194+
}
195+
}
196+
}

0 commit comments

Comments
 (0)