Skip to content

Commit ad4e392

Browse files
feat(api): api update
1 parent 1682cab commit ad4e392

File tree

7 files changed

+278
-284
lines changed

7 files changed

+278
-284
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 45
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bfcb61384672f485be2ee4e2ae2938ef8c57c063c2ea5d0e7890e68098300579.yml
3-
openapi_spec_hash: 5d75581b91b95d16f0fae017a36b4ea9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-199a2fd8b7387b0648e88b5942a8248895373a561aff663389982073e55c8eb5.yml
3+
openapi_spec_hash: 7415c1faca5f2e873824893b140650f1
44
config_hash: 6d3585c0032e08d723d077d660fc8448

finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.tryfinch.api.core.ExcludeMissing
1111
import com.tryfinch.api.core.JsonField
1212
import com.tryfinch.api.core.JsonMissing
1313
import com.tryfinch.api.core.JsonValue
14+
import com.tryfinch.api.core.checkRequired
1415
import com.tryfinch.api.errors.FinchInvalidDataException
1516
import java.util.Collections
1617
import java.util.Objects
@@ -42,10 +43,10 @@ private constructor(
4243
/**
4344
* A stable Finch id for the document.
4445
*
45-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
46-
* server responded with an unexpected value).
46+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
47+
* missing or null (e.g. if the server responded with an unexpected value).
4748
*/
48-
fun id(): Optional<String> = id.getOptional("id")
49+
fun id(): String = id.getRequired("id")
4950

5051
/**
5152
* The ID of the individual associated with the document. This will be null for employer-level
@@ -59,27 +60,27 @@ private constructor(
5960
/**
6061
* The type of document.
6162
*
62-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
63-
* server responded with an unexpected value).
63+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
64+
* missing or null (e.g. if the server responded with an unexpected value).
6465
*/
65-
fun type(): Optional<Type> = type.getOptional("type")
66+
fun type(): Type = type.getRequired("type")
6667

6768
/**
6869
* A URL to access the document. Format:
6970
* `https://api.tryfinch.com/employer/documents/:document_id`.
7071
*
71-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
72-
* server responded with an unexpected value).
72+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
73+
* missing or null (e.g. if the server responded with an unexpected value).
7374
*/
74-
fun url(): Optional<String> = url.getOptional("url")
75+
fun url(): String = url.getRequired("url")
7576

7677
/**
7778
* The year the document applies to, if available.
7879
*
79-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
80-
* server responded with an unexpected value).
80+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
81+
* missing or null (e.g. if the server responded with an unexpected value).
8182
*/
82-
fun year(): Optional<Double> = year.getOptional("year")
83+
fun year(): Double = year.getRequired("year")
8384

8485
/**
8586
* Returns the raw JSON value of [id].
@@ -132,18 +133,29 @@ private constructor(
132133

133134
companion object {
134135

135-
/** Returns a mutable builder for constructing an instance of [DocumentResponse]. */
136+
/**
137+
* Returns a mutable builder for constructing an instance of [DocumentResponse].
138+
*
139+
* The following fields are required:
140+
* ```java
141+
* .id()
142+
* .individualId()
143+
* .type()
144+
* .url()
145+
* .year()
146+
* ```
147+
*/
136148
@JvmStatic fun builder() = Builder()
137149
}
138150

139151
/** A builder for [DocumentResponse]. */
140152
class Builder internal constructor() {
141153

142-
private var id: JsonField<String> = JsonMissing.of()
143-
private var individualId: JsonField<String> = JsonMissing.of()
144-
private var type: JsonField<Type> = JsonMissing.of()
145-
private var url: JsonField<String> = JsonMissing.of()
146-
private var year: JsonField<Double> = JsonMissing.of()
154+
private var id: JsonField<String>? = null
155+
private var individualId: JsonField<String>? = null
156+
private var type: JsonField<Type>? = null
157+
private var url: JsonField<String>? = null
158+
private var year: JsonField<Double>? = null
147159
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
148160

149161
@JvmSynthetic
@@ -213,17 +225,7 @@ private constructor(
213225
fun url(url: JsonField<String>) = apply { this.url = url }
214226

215227
/** The year the document applies to, if available. */
216-
fun year(year: Double?) = year(JsonField.ofNullable(year))
217-
218-
/**
219-
* Alias for [Builder.year].
220-
*
221-
* This unboxed primitive overload exists for backwards compatibility.
222-
*/
223-
fun year(year: Double) = year(year as Double?)
224-
225-
/** Alias for calling [Builder.year] with `year.orElse(null)`. */
226-
fun year(year: Optional<Double>) = year(year.getOrNull())
228+
fun year(year: Double) = year(JsonField.of(year))
227229

228230
/**
229231
* Sets [Builder.year] to an arbitrary JSON value.
@@ -256,9 +258,27 @@ private constructor(
256258
* Returns an immutable instance of [DocumentResponse].
257259
*
258260
* Further updates to this [Builder] will not mutate the returned instance.
261+
*
262+
* The following fields are required:
263+
* ```java
264+
* .id()
265+
* .individualId()
266+
* .type()
267+
* .url()
268+
* .year()
269+
* ```
270+
*
271+
* @throws IllegalStateException if any required field is unset.
259272
*/
260273
fun build(): DocumentResponse =
261-
DocumentResponse(id, individualId, type, url, year, additionalProperties.toMutableMap())
274+
DocumentResponse(
275+
checkRequired("id", id),
276+
checkRequired("individualId", individualId),
277+
checkRequired("type", type),
278+
checkRequired("url", url),
279+
checkRequired("year", year),
280+
additionalProperties.toMutableMap(),
281+
)
262282
}
263283

264284
private var validated: Boolean = false
@@ -270,7 +290,7 @@ private constructor(
270290

271291
id()
272292
individualId()
273-
type().ifPresent { it.validate() }
293+
type().validate()
274294
url()
275295
year()
276296
validated = true

0 commit comments

Comments
 (0)