Skip to content

Commit 53c3147

Browse files
feat(api): api update
1 parent 30df955 commit 53c3147

File tree

11 files changed

+139
-81
lines changed

11 files changed

+139
-81
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-d31af54a2b29a3535df6342584c2511b59a10a7c11c9c983f1cf209199c6ed0e.yml
3-
openapi_spec_hash: 6643320491f28a8bca49846e1b718c70
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-47c01c819b97af4a1a342357c958d7072f88f43bfdc5885462f9330dcf99773c.yml
3+
openapi_spec_hash: 15b236a1f536d8fb2e4356ea57de0836
44
config_hash: 53778a0b839c4f6ad34fbba051f5e8a6

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

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.tryfinch.api.core.ExcludeMissing
1010
import com.tryfinch.api.core.JsonField
1111
import com.tryfinch.api.core.JsonMissing
1212
import com.tryfinch.api.core.JsonValue
13+
import com.tryfinch.api.core.checkRequired
1314
import com.tryfinch.api.errors.FinchInvalidDataException
1415
import java.util.Collections
1516
import java.util.Objects
@@ -46,10 +47,10 @@ private constructor(
4647
/**
4748
* A stable Finch `id` (UUID v4) for an individual in the company.
4849
*
49-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
50-
* server responded with an unexpected value).
50+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
51+
* missing or null (e.g. if the server responded with an unexpected value).
5152
*/
52-
fun id(): Optional<String> = id.getOptional("id")
53+
fun id(): String = id.getRequired("id")
5354

5455
/**
5556
* The department object.
@@ -164,20 +165,33 @@ private constructor(
164165

165166
companion object {
166167

167-
/** Returns a mutable builder for constructing an instance of [IndividualInDirectory]. */
168+
/**
169+
* Returns a mutable builder for constructing an instance of [IndividualInDirectory].
170+
*
171+
* The following fields are required:
172+
* ```java
173+
* .id()
174+
* .department()
175+
* .firstName()
176+
* .isActive()
177+
* .lastName()
178+
* .manager()
179+
* .middleName()
180+
* ```
181+
*/
168182
@JvmStatic fun builder() = Builder()
169183
}
170184

171185
/** A builder for [IndividualInDirectory]. */
172186
class Builder internal constructor() {
173187

174-
private var id: JsonField<String> = JsonMissing.of()
175-
private var department: JsonField<Department> = JsonMissing.of()
176-
private var firstName: JsonField<String> = JsonMissing.of()
177-
private var isActive: JsonField<Boolean> = JsonMissing.of()
178-
private var lastName: JsonField<String> = JsonMissing.of()
179-
private var manager: JsonField<Manager> = JsonMissing.of()
180-
private var middleName: JsonField<String> = JsonMissing.of()
188+
private var id: JsonField<String>? = null
189+
private var department: JsonField<Department>? = null
190+
private var firstName: JsonField<String>? = null
191+
private var isActive: JsonField<Boolean>? = null
192+
private var lastName: JsonField<String>? = null
193+
private var manager: JsonField<Manager>? = null
194+
private var middleName: JsonField<String>? = null
181195
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
182196

183197
@JvmSynthetic
@@ -321,16 +335,29 @@ private constructor(
321335
* Returns an immutable instance of [IndividualInDirectory].
322336
*
323337
* Further updates to this [Builder] will not mutate the returned instance.
338+
*
339+
* The following fields are required:
340+
* ```java
341+
* .id()
342+
* .department()
343+
* .firstName()
344+
* .isActive()
345+
* .lastName()
346+
* .manager()
347+
* .middleName()
348+
* ```
349+
*
350+
* @throws IllegalStateException if any required field is unset.
324351
*/
325352
fun build(): IndividualInDirectory =
326353
IndividualInDirectory(
327-
id,
328-
department,
329-
firstName,
330-
isActive,
331-
lastName,
332-
manager,
333-
middleName,
354+
checkRequired("id", id),
355+
checkRequired("department", department),
356+
checkRequired("firstName", firstName),
357+
checkRequired("isActive", isActive),
358+
checkRequired("lastName", lastName),
359+
checkRequired("manager", manager),
360+
checkRequired("middleName", middleName),
334361
additionalProperties.toMutableMap(),
335362
)
336363
}
@@ -534,10 +561,10 @@ private constructor(
534561
/**
535562
* A stable Finch `id` (UUID v4) for an individual in the company.
536563
*
537-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
538-
* server responded with an unexpected value).
564+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is
565+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
539566
*/
540-
fun id(): Optional<String> = id.getOptional("id")
567+
fun id(): String = id.getRequired("id")
541568

542569
/**
543570
* Returns the raw JSON value of [id].
@@ -560,14 +587,21 @@ private constructor(
560587

561588
companion object {
562589

563-
/** Returns a mutable builder for constructing an instance of [Manager]. */
590+
/**
591+
* Returns a mutable builder for constructing an instance of [Manager].
592+
*
593+
* The following fields are required:
594+
* ```java
595+
* .id()
596+
* ```
597+
*/
564598
@JvmStatic fun builder() = Builder()
565599
}
566600

567601
/** A builder for [Manager]. */
568602
class Builder internal constructor() {
569603

570-
private var id: JsonField<String> = JsonMissing.of()
604+
private var id: JsonField<String>? = null
571605
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
572606

573607
@JvmSynthetic
@@ -611,8 +645,16 @@ private constructor(
611645
* Returns an immutable instance of [Manager].
612646
*
613647
* Further updates to this [Builder] will not mutate the returned instance.
648+
*
649+
* The following fields are required:
650+
* ```java
651+
* .id()
652+
* ```
653+
*
654+
* @throws IllegalStateException if any required field is unset.
614655
*/
615-
fun build(): Manager = Manager(id, additionalProperties.toMutableMap())
656+
fun build(): Manager =
657+
Manager(checkRequired("id", id), additionalProperties.toMutableMap())
616658
}
617659

618660
private var validated: Boolean = false

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

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,32 @@ import com.tryfinch.api.core.ExcludeMissing
1010
import com.tryfinch.api.core.JsonField
1111
import com.tryfinch.api.core.JsonMissing
1212
import com.tryfinch.api.core.JsonValue
13+
import com.tryfinch.api.core.checkRequired
1314
import com.tryfinch.api.errors.FinchInvalidDataException
1415
import java.util.Collections
1516
import java.util.Objects
1617
import java.util.Optional
1718

1819
class Paging
1920
private constructor(
20-
private val count: JsonField<Long>,
2121
private val offset: JsonField<Long>,
22+
private val count: JsonField<Long>,
2223
private val additionalProperties: MutableMap<String, JsonValue>,
2324
) {
2425

2526
@JsonCreator
2627
private constructor(
27-
@JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(),
2828
@JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(),
29-
) : this(count, offset, mutableMapOf())
29+
@JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(),
30+
) : this(offset, count, mutableMapOf())
31+
32+
/**
33+
* The current start index of the returned list of elements
34+
*
35+
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
36+
* missing or null (e.g. if the server responded with an unexpected value).
37+
*/
38+
fun offset(): Long = offset.getRequired("offset")
3039

3140
/**
3241
* The total number of elements for the entire query (not just the given page)
@@ -37,12 +46,11 @@ private constructor(
3746
fun count(): Optional<Long> = count.getOptional("count")
3847

3948
/**
40-
* The current start index of the returned list of elements
49+
* Returns the raw JSON value of [offset].
4150
*
42-
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
43-
* server responded with an unexpected value).
51+
* Unlike [offset], this method doesn't throw if the JSON field has an unexpected type.
4452
*/
45-
fun offset(): Optional<Long> = offset.getOptional("offset")
53+
@JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset
4654

4755
/**
4856
* Returns the raw JSON value of [count].
@@ -51,13 +59,6 @@ private constructor(
5159
*/
5260
@JsonProperty("count") @ExcludeMissing fun _count(): JsonField<Long> = count
5361

54-
/**
55-
* Returns the raw JSON value of [offset].
56-
*
57-
* Unlike [offset], this method doesn't throw if the JSON field has an unexpected type.
58-
*/
59-
@JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset
60-
6162
@JsonAnySetter
6263
private fun putAdditionalProperty(key: String, value: JsonValue) {
6364
additionalProperties.put(key, value)
@@ -72,45 +73,52 @@ private constructor(
7273

7374
companion object {
7475

75-
/** Returns a mutable builder for constructing an instance of [Paging]. */
76+
/**
77+
* Returns a mutable builder for constructing an instance of [Paging].
78+
*
79+
* The following fields are required:
80+
* ```java
81+
* .offset()
82+
* ```
83+
*/
7684
@JvmStatic fun builder() = Builder()
7785
}
7886

7987
/** A builder for [Paging]. */
8088
class Builder internal constructor() {
8189

90+
private var offset: JsonField<Long>? = null
8291
private var count: JsonField<Long> = JsonMissing.of()
83-
private var offset: JsonField<Long> = JsonMissing.of()
8492
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
8593

8694
@JvmSynthetic
8795
internal fun from(paging: Paging) = apply {
88-
count = paging.count
8996
offset = paging.offset
97+
count = paging.count
9098
additionalProperties = paging.additionalProperties.toMutableMap()
9199
}
92100

93-
/** The total number of elements for the entire query (not just the given page) */
94-
fun count(count: Long) = count(JsonField.of(count))
101+
/** The current start index of the returned list of elements */
102+
fun offset(offset: Long) = offset(JsonField.of(offset))
95103

96104
/**
97-
* Sets [Builder.count] to an arbitrary JSON value.
105+
* Sets [Builder.offset] to an arbitrary JSON value.
98106
*
99-
* You should usually call [Builder.count] with a well-typed [Long] value instead. This
107+
* You should usually call [Builder.offset] with a well-typed [Long] value instead. This
100108
* method is primarily for setting the field to an undocumented or not yet supported value.
101109
*/
102-
fun count(count: JsonField<Long>) = apply { this.count = count }
110+
fun offset(offset: JsonField<Long>) = apply { this.offset = offset }
103111

104-
/** The current start index of the returned list of elements */
105-
fun offset(offset: Long) = offset(JsonField.of(offset))
112+
/** The total number of elements for the entire query (not just the given page) */
113+
fun count(count: Long) = count(JsonField.of(count))
106114

107115
/**
108-
* Sets [Builder.offset] to an arbitrary JSON value.
116+
* Sets [Builder.count] to an arbitrary JSON value.
109117
*
110-
* You should usually call [Builder.offset] with a well-typed [Long] value instead. This
118+
* You should usually call [Builder.count] with a well-typed [Long] value instead. This
111119
* method is primarily for setting the field to an undocumented or not yet supported value.
112120
*/
113-
fun offset(offset: JsonField<Long>) = apply { this.offset = offset }
121+
fun count(count: JsonField<Long>) = apply { this.count = count }
114122

115123
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
116124
this.additionalProperties.clear()
@@ -135,8 +143,16 @@ private constructor(
135143
* Returns an immutable instance of [Paging].
136144
*
137145
* Further updates to this [Builder] will not mutate the returned instance.
146+
*
147+
* The following fields are required:
148+
* ```java
149+
* .offset()
150+
* ```
151+
*
152+
* @throws IllegalStateException if any required field is unset.
138153
*/
139-
fun build(): Paging = Paging(count, offset, additionalProperties.toMutableMap())
154+
fun build(): Paging =
155+
Paging(checkRequired("offset", offset), count, additionalProperties.toMutableMap())
140156
}
141157

142158
private var validated: Boolean = false
@@ -146,8 +162,8 @@ private constructor(
146162
return@apply
147163
}
148164

149-
count()
150165
offset()
166+
count()
151167
validated = true
152168
}
153169

@@ -166,22 +182,22 @@ private constructor(
166182
*/
167183
@JvmSynthetic
168184
internal fun validity(): Int =
169-
(if (count.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0)
185+
(if (offset.asKnown().isPresent) 1 else 0) + (if (count.asKnown().isPresent) 1 else 0)
170186

171187
override fun equals(other: Any?): Boolean {
172188
if (this === other) {
173189
return true
174190
}
175191

176-
return /* spotless:off */ other is Paging && count == other.count && offset == other.offset && additionalProperties == other.additionalProperties /* spotless:on */
192+
return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */
177193
}
178194

179195
/* spotless:off */
180-
private val hashCode: Int by lazy { Objects.hash(count, offset, additionalProperties) }
196+
private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) }
181197
/* spotless:on */
182198

183199
override fun hashCode(): Int = hashCode
184200

185201
override fun toString() =
186-
"Paging{count=$count, offset=$offset, additionalProperties=$additionalProperties}"
202+
"Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}"
187203
}

finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class DocumentListResponseTest {
2222
.year(0.0)
2323
.build()
2424
)
25-
.paging(Paging.builder().count(0L).offset(0L).build())
25+
.paging(Paging.builder().offset(0L).count(0L).build())
2626
.build()
2727

2828
assertThat(documentListResponse.documents())
@@ -36,7 +36,7 @@ internal class DocumentListResponseTest {
3636
.build()
3737
)
3838
assertThat(documentListResponse.paging())
39-
.isEqualTo(Paging.builder().count(0L).offset(0L).build())
39+
.isEqualTo(Paging.builder().offset(0L).count(0L).build())
4040
}
4141

4242
@Test
@@ -53,7 +53,7 @@ internal class DocumentListResponseTest {
5353
.year(0.0)
5454
.build()
5555
)
56-
.paging(Paging.builder().count(0L).offset(0L).build())
56+
.paging(Paging.builder().offset(0L).count(0L).build())
5757
.build()
5858

5959
val roundtrippedDocumentListResponse =

0 commit comments

Comments
 (0)