Skip to content

Commit 21939b3

Browse files
feat(api): api update
1 parent a15c7b6 commit 21939b3

File tree

3 files changed

+82
-50
lines changed

3 files changed

+82
-50
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-f7e741bc6e0175fd96a9db5348092b90a77b0985154c0814bb681ad5dccdf19a.yml
3-
openapi_spec_hash: b348a9ef407a8e91dd770fcb219d4ac5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-46ed24a601021d59f2e481c290509da2c05ee7be34eba58448b78b035392cbc4.yml
3+
openapi_spec_hash: afe19f94bb37ddaf7344fac1b1e64730
44
config_hash: 5146b12344dae76238940989dac1e8a0

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

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ import com.tryfinch.api.core.checkRequired
1414
import com.tryfinch.api.errors.FinchInvalidDataException
1515
import java.util.Collections
1616
import java.util.Objects
17+
import java.util.Optional
1718

1819
class AutomatedCreateResponse
1920
private constructor(
2021
private val allowedRefreshes: JsonField<Long>,
22+
private val remainingRefreshes: JsonField<Long>,
2123
private val jobId: JsonField<String>,
2224
private val jobUrl: JsonField<String>,
23-
private val remainingRefreshes: JsonField<Long>,
25+
private val retryAt: JsonField<String>,
2426
private val additionalProperties: MutableMap<String, JsonValue>,
2527
) {
2628

@@ -29,12 +31,13 @@ private constructor(
2931
@JsonProperty("allowed_refreshes")
3032
@ExcludeMissing
3133
allowedRefreshes: JsonField<Long> = JsonMissing.of(),
32-
@JsonProperty("job_id") @ExcludeMissing jobId: JsonField<String> = JsonMissing.of(),
33-
@JsonProperty("job_url") @ExcludeMissing jobUrl: JsonField<String> = JsonMissing.of(),
3434
@JsonProperty("remaining_refreshes")
3535
@ExcludeMissing
3636
remainingRefreshes: JsonField<Long> = JsonMissing.of(),
37-
) : this(allowedRefreshes, jobId, jobUrl, remainingRefreshes, mutableMapOf())
37+
@JsonProperty("job_id") @ExcludeMissing jobId: JsonField<String> = JsonMissing.of(),
38+
@JsonProperty("job_url") @ExcludeMissing jobUrl: JsonField<String> = JsonMissing.of(),
39+
@JsonProperty("retry_at") @ExcludeMissing retryAt: JsonField<String> = JsonMissing.of(),
40+
) : this(allowedRefreshes, remainingRefreshes, jobId, jobUrl, retryAt, mutableMapOf())
3841

3942
/**
4043
* The number of allowed refreshes per hour (per hour, fixed window)
@@ -45,28 +48,36 @@ private constructor(
4548
fun allowedRefreshes(): Long = allowedRefreshes.getRequired("allowed_refreshes")
4649

4750
/**
48-
* The id of the job that has been created.
51+
* The number of remaining refreshes available (per hour, fixed window)
4952
*
5053
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
5154
* missing or null (e.g. if the server responded with an unexpected value).
5255
*/
53-
fun jobId(): String = jobId.getRequired("job_id")
56+
fun remainingRefreshes(): Long = remainingRefreshes.getRequired("remaining_refreshes")
57+
58+
/**
59+
* The id of the job that has been created.
60+
*
61+
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
62+
* server responded with an unexpected value).
63+
*/
64+
fun jobId(): Optional<String> = jobId.getOptional("job_id")
5465

5566
/**
5667
* The url that can be used to retrieve the job status
5768
*
58-
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
59-
* missing or null (e.g. if the server responded with an unexpected value).
69+
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
70+
* server responded with an unexpected value).
6071
*/
61-
fun jobUrl(): String = jobUrl.getRequired("job_url")
72+
fun jobUrl(): Optional<String> = jobUrl.getOptional("job_url")
6273

6374
/**
64-
* The number of remaining refreshes available (per hour, fixed window)
75+
* ISO 8601 timestamp indicating when to retry the request
6576
*
66-
* @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly
67-
* missing or null (e.g. if the server responded with an unexpected value).
77+
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
78+
* server responded with an unexpected value).
6879
*/
69-
fun remainingRefreshes(): Long = remainingRefreshes.getRequired("remaining_refreshes")
80+
fun retryAt(): Optional<String> = retryAt.getOptional("retry_at")
7081

7182
/**
7283
* Returns the raw JSON value of [allowedRefreshes].
@@ -78,6 +89,16 @@ private constructor(
7889
@ExcludeMissing
7990
fun _allowedRefreshes(): JsonField<Long> = allowedRefreshes
8091

92+
/**
93+
* Returns the raw JSON value of [remainingRefreshes].
94+
*
95+
* Unlike [remainingRefreshes], this method doesn't throw if the JSON field has an unexpected
96+
* type.
97+
*/
98+
@JsonProperty("remaining_refreshes")
99+
@ExcludeMissing
100+
fun _remainingRefreshes(): JsonField<Long> = remainingRefreshes
101+
81102
/**
82103
* Returns the raw JSON value of [jobId].
83104
*
@@ -93,14 +114,11 @@ private constructor(
93114
@JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField<String> = jobUrl
94115

95116
/**
96-
* Returns the raw JSON value of [remainingRefreshes].
117+
* Returns the raw JSON value of [retryAt].
97118
*
98-
* Unlike [remainingRefreshes], this method doesn't throw if the JSON field has an unexpected
99-
* type.
119+
* Unlike [retryAt], this method doesn't throw if the JSON field has an unexpected type.
100120
*/
101-
@JsonProperty("remaining_refreshes")
102-
@ExcludeMissing
103-
fun _remainingRefreshes(): JsonField<Long> = remainingRefreshes
121+
@JsonProperty("retry_at") @ExcludeMissing fun _retryAt(): JsonField<String> = retryAt
104122

105123
@JsonAnySetter
106124
private fun putAdditionalProperty(key: String, value: JsonValue) {
@@ -122,8 +140,6 @@ private constructor(
122140
* The following fields are required:
123141
* ```java
124142
* .allowedRefreshes()
125-
* .jobId()
126-
* .jobUrl()
127143
* .remainingRefreshes()
128144
* ```
129145
*/
@@ -134,17 +150,19 @@ private constructor(
134150
class Builder internal constructor() {
135151

136152
private var allowedRefreshes: JsonField<Long>? = null
137-
private var jobId: JsonField<String>? = null
138-
private var jobUrl: JsonField<String>? = null
139153
private var remainingRefreshes: JsonField<Long>? = null
154+
private var jobId: JsonField<String> = JsonMissing.of()
155+
private var jobUrl: JsonField<String> = JsonMissing.of()
156+
private var retryAt: JsonField<String> = JsonMissing.of()
140157
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
141158

142159
@JvmSynthetic
143160
internal fun from(automatedCreateResponse: AutomatedCreateResponse) = apply {
144161
allowedRefreshes = automatedCreateResponse.allowedRefreshes
162+
remainingRefreshes = automatedCreateResponse.remainingRefreshes
145163
jobId = automatedCreateResponse.jobId
146164
jobUrl = automatedCreateResponse.jobUrl
147-
remainingRefreshes = automatedCreateResponse.remainingRefreshes
165+
retryAt = automatedCreateResponse.retryAt
148166
additionalProperties = automatedCreateResponse.additionalProperties.toMutableMap()
149167
}
150168

@@ -163,6 +181,21 @@ private constructor(
163181
this.allowedRefreshes = allowedRefreshes
164182
}
165183

184+
/** The number of remaining refreshes available (per hour, fixed window) */
185+
fun remainingRefreshes(remainingRefreshes: Long) =
186+
remainingRefreshes(JsonField.of(remainingRefreshes))
187+
188+
/**
189+
* Sets [Builder.remainingRefreshes] to an arbitrary JSON value.
190+
*
191+
* You should usually call [Builder.remainingRefreshes] with a well-typed [Long] value
192+
* instead. This method is primarily for setting the field to an undocumented or not yet
193+
* supported value.
194+
*/
195+
fun remainingRefreshes(remainingRefreshes: JsonField<Long>) = apply {
196+
this.remainingRefreshes = remainingRefreshes
197+
}
198+
166199
/** The id of the job that has been created. */
167200
fun jobId(jobId: String) = jobId(JsonField.of(jobId))
168201

@@ -185,20 +218,16 @@ private constructor(
185218
*/
186219
fun jobUrl(jobUrl: JsonField<String>) = apply { this.jobUrl = jobUrl }
187220

188-
/** The number of remaining refreshes available (per hour, fixed window) */
189-
fun remainingRefreshes(remainingRefreshes: Long) =
190-
remainingRefreshes(JsonField.of(remainingRefreshes))
221+
/** ISO 8601 timestamp indicating when to retry the request */
222+
fun retryAt(retryAt: String) = retryAt(JsonField.of(retryAt))
191223

192224
/**
193-
* Sets [Builder.remainingRefreshes] to an arbitrary JSON value.
225+
* Sets [Builder.retryAt] to an arbitrary JSON value.
194226
*
195-
* You should usually call [Builder.remainingRefreshes] with a well-typed [Long] value
196-
* instead. This method is primarily for setting the field to an undocumented or not yet
197-
* supported value.
227+
* You should usually call [Builder.retryAt] with a well-typed [String] value instead. This
228+
* method is primarily for setting the field to an undocumented or not yet supported value.
198229
*/
199-
fun remainingRefreshes(remainingRefreshes: JsonField<Long>) = apply {
200-
this.remainingRefreshes = remainingRefreshes
201-
}
230+
fun retryAt(retryAt: JsonField<String>) = apply { this.retryAt = retryAt }
202231

203232
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
204233
this.additionalProperties.clear()
@@ -227,8 +256,6 @@ private constructor(
227256
* The following fields are required:
228257
* ```java
229258
* .allowedRefreshes()
230-
* .jobId()
231-
* .jobUrl()
232259
* .remainingRefreshes()
233260
* ```
234261
*
@@ -237,9 +264,10 @@ private constructor(
237264
fun build(): AutomatedCreateResponse =
238265
AutomatedCreateResponse(
239266
checkRequired("allowedRefreshes", allowedRefreshes),
240-
checkRequired("jobId", jobId),
241-
checkRequired("jobUrl", jobUrl),
242267
checkRequired("remainingRefreshes", remainingRefreshes),
268+
jobId,
269+
jobUrl,
270+
retryAt,
243271
additionalProperties.toMutableMap(),
244272
)
245273
}
@@ -252,9 +280,10 @@ private constructor(
252280
}
253281

254282
allowedRefreshes()
283+
remainingRefreshes()
255284
jobId()
256285
jobUrl()
257-
remainingRefreshes()
286+
retryAt()
258287
validated = true
259288
}
260289

@@ -274,24 +303,25 @@ private constructor(
274303
@JvmSynthetic
275304
internal fun validity(): Int =
276305
(if (allowedRefreshes.asKnown().isPresent) 1 else 0) +
306+
(if (remainingRefreshes.asKnown().isPresent) 1 else 0) +
277307
(if (jobId.asKnown().isPresent) 1 else 0) +
278308
(if (jobUrl.asKnown().isPresent) 1 else 0) +
279-
(if (remainingRefreshes.asKnown().isPresent) 1 else 0)
309+
(if (retryAt.asKnown().isPresent) 1 else 0)
280310

281311
override fun equals(other: Any?): Boolean {
282312
if (this === other) {
283313
return true
284314
}
285315

286-
return /* spotless:off */ other is AutomatedCreateResponse && allowedRefreshes == other.allowedRefreshes && jobId == other.jobId && jobUrl == other.jobUrl && remainingRefreshes == other.remainingRefreshes && additionalProperties == other.additionalProperties /* spotless:on */
316+
return /* spotless:off */ other is AutomatedCreateResponse && allowedRefreshes == other.allowedRefreshes && remainingRefreshes == other.remainingRefreshes && jobId == other.jobId && jobUrl == other.jobUrl && retryAt == other.retryAt && additionalProperties == other.additionalProperties /* spotless:on */
287317
}
288318

289319
/* spotless:off */
290-
private val hashCode: Int by lazy { Objects.hash(allowedRefreshes, jobId, jobUrl, remainingRefreshes, additionalProperties) }
320+
private val hashCode: Int by lazy { Objects.hash(allowedRefreshes, remainingRefreshes, jobId, jobUrl, retryAt, additionalProperties) }
291321
/* spotless:on */
292322

293323
override fun hashCode(): Int = hashCode
294324

295325
override fun toString() =
296-
"AutomatedCreateResponse{allowedRefreshes=$allowedRefreshes, jobId=$jobId, jobUrl=$jobUrl, remainingRefreshes=$remainingRefreshes, additionalProperties=$additionalProperties}"
326+
"AutomatedCreateResponse{allowedRefreshes=$allowedRefreshes, remainingRefreshes=$remainingRefreshes, jobId=$jobId, jobUrl=$jobUrl, retryAt=$retryAt, additionalProperties=$additionalProperties}"
297327
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ internal class AutomatedCreateResponseTest {
1414
val automatedCreateResponse =
1515
AutomatedCreateResponse.builder()
1616
.allowedRefreshes(0L)
17+
.remainingRefreshes(0L)
1718
.jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1819
.jobUrl("job_url")
19-
.remainingRefreshes(0L)
20+
.retryAt("retry_at")
2021
.build()
2122

2223
assertThat(automatedCreateResponse.allowedRefreshes()).isEqualTo(0L)
23-
assertThat(automatedCreateResponse.jobId())
24-
.isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
25-
assertThat(automatedCreateResponse.jobUrl()).isEqualTo("job_url")
2624
assertThat(automatedCreateResponse.remainingRefreshes()).isEqualTo(0L)
25+
assertThat(automatedCreateResponse.jobId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
26+
assertThat(automatedCreateResponse.jobUrl()).contains("job_url")
27+
assertThat(automatedCreateResponse.retryAt()).contains("retry_at")
2728
}
2829

2930
@Test
@@ -32,9 +33,10 @@ internal class AutomatedCreateResponseTest {
3233
val automatedCreateResponse =
3334
AutomatedCreateResponse.builder()
3435
.allowedRefreshes(0L)
36+
.remainingRefreshes(0L)
3537
.jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3638
.jobUrl("job_url")
37-
.remainingRefreshes(0L)
39+
.retryAt("retry_at")
3840
.build()
3941

4042
val roundtrippedAutomatedCreateResponse =

0 commit comments

Comments
 (0)