Skip to content

Commit ff49b09

Browse files
feat(api): api update
1 parent c1d1685 commit ff49b09

File tree

3 files changed

+233
-3
lines changed

3 files changed

+233
-3
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-6d0c6a1feba5ccb895a6779cd98c2a0ae87d6394f5e98a9da51f17258c4eb297.yml
3-
openapi_spec_hash: ac3be0c8a992103e5f467fe1bcb20a81
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bf86910e96e83e583689cf5d1a5c583268754026ec68288994fa6a969dc248f2.yml
3+
openapi_spec_hash: 195038e056891afec204c49dadce3b95
44
config_hash: 5146b12344dae76238940989dac1e8a0

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

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ private constructor(
4848
private val customerEmail: JsonField<String>,
4949
private val customerId: JsonField<String>,
5050
private val customerName: JsonField<String>,
51+
private val entityIds: JsonField<List<String>>,
52+
private val entityMode: JsonField<EntityMode>,
5153
private val manual: JsonField<Boolean>,
5254
private val payrollProviderId: JsonField<String>,
5355
private val username: JsonField<String>,
@@ -90,6 +92,12 @@ private constructor(
9092
@JsonProperty("customer_name")
9193
@ExcludeMissing
9294
customerName: JsonField<String> = JsonMissing.of(),
95+
@JsonProperty("entity_ids")
96+
@ExcludeMissing
97+
entityIds: JsonField<List<String>> = JsonMissing.of(),
98+
@JsonProperty("entity_mode")
99+
@ExcludeMissing
100+
entityMode: JsonField<EntityMode> = JsonMissing.of(),
93101
@JsonProperty("manual") @ExcludeMissing manual: JsonField<Boolean> = JsonMissing.of(),
94102
@JsonProperty("payroll_provider_id")
95103
@ExcludeMissing
@@ -110,6 +118,8 @@ private constructor(
110118
customerEmail,
111119
customerId,
112120
customerName,
121+
entityIds,
122+
entityMode,
113123
manual,
114124
payrollProviderId,
115125
username,
@@ -235,6 +245,22 @@ private constructor(
235245
*/
236246
fun customerName(): Optional<String> = customerName.getOptional("customer_name")
237247

248+
/**
249+
* Array of entity IDs associated with this connection.
250+
*
251+
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
252+
* server responded with an unexpected value).
253+
*/
254+
fun entityIds(): Optional<List<String>> = entityIds.getOptional("entity_ids")
255+
256+
/**
257+
* Indicates whether this connection manages a single entity or multiple entities.
258+
*
259+
* @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the
260+
* server responded with an unexpected value).
261+
*/
262+
fun entityMode(): Optional<EntityMode> = entityMode.getOptional("entity_mode")
263+
238264
/**
239265
* Whether the connection associated with the `access_token` uses the Assisted Connect Flow.
240266
* (`true` if using Assisted Connect, `false` if connection is automated)
@@ -382,6 +408,24 @@ private constructor(
382408
@ExcludeMissing
383409
fun _customerName(): JsonField<String> = customerName
384410

411+
/**
412+
* Returns the raw JSON value of [entityIds].
413+
*
414+
* Unlike [entityIds], this method doesn't throw if the JSON field has an unexpected type.
415+
*/
416+
@JsonProperty("entity_ids")
417+
@ExcludeMissing
418+
fun _entityIds(): JsonField<List<String>> = entityIds
419+
420+
/**
421+
* Returns the raw JSON value of [entityMode].
422+
*
423+
* Unlike [entityMode], this method doesn't throw if the JSON field has an unexpected type.
424+
*/
425+
@JsonProperty("entity_mode")
426+
@ExcludeMissing
427+
fun _entityMode(): JsonField<EntityMode> = entityMode
428+
385429
/**
386430
* Returns the raw JSON value of [manual].
387431
*
@@ -457,6 +501,8 @@ private constructor(
457501
private var customerEmail: JsonField<String> = JsonMissing.of()
458502
private var customerId: JsonField<String> = JsonMissing.of()
459503
private var customerName: JsonField<String> = JsonMissing.of()
504+
private var entityIds: JsonField<MutableList<String>>? = null
505+
private var entityMode: JsonField<EntityMode> = JsonMissing.of()
460506
private var manual: JsonField<Boolean> = JsonMissing.of()
461507
private var payrollProviderId: JsonField<String> = JsonMissing.of()
462508
private var username: JsonField<String> = JsonMissing.of()
@@ -478,6 +524,8 @@ private constructor(
478524
customerEmail = introspection.customerEmail
479525
customerId = introspection.customerId
480526
customerName = introspection.customerName
527+
entityIds = introspection.entityIds.map { it.toMutableList() }
528+
entityMode = introspection.entityMode
481529
manual = introspection.manual
482530
payrollProviderId = introspection.payrollProviderId
483531
username = introspection.username
@@ -723,6 +771,44 @@ private constructor(
723771
this.customerName = customerName
724772
}
725773

774+
/** Array of entity IDs associated with this connection. */
775+
fun entityIds(entityIds: List<String>) = entityIds(JsonField.of(entityIds))
776+
777+
/**
778+
* Sets [Builder.entityIds] to an arbitrary JSON value.
779+
*
780+
* You should usually call [Builder.entityIds] with a well-typed `List<String>` value
781+
* instead. This method is primarily for setting the field to an undocumented or not yet
782+
* supported value.
783+
*/
784+
fun entityIds(entityIds: JsonField<List<String>>) = apply {
785+
this.entityIds = entityIds.map { it.toMutableList() }
786+
}
787+
788+
/**
789+
* Adds a single [String] to [entityIds].
790+
*
791+
* @throws IllegalStateException if the field was previously set to a non-list.
792+
*/
793+
fun addEntityId(entityId: String) = apply {
794+
entityIds =
795+
(entityIds ?: JsonField.of(mutableListOf())).also {
796+
checkKnown("entityIds", it).add(entityId)
797+
}
798+
}
799+
800+
/** Indicates whether this connection manages a single entity or multiple entities. */
801+
fun entityMode(entityMode: EntityMode) = entityMode(JsonField.of(entityMode))
802+
803+
/**
804+
* Sets [Builder.entityMode] to an arbitrary JSON value.
805+
*
806+
* You should usually call [Builder.entityMode] with a well-typed [EntityMode] value
807+
* instead. This method is primarily for setting the field to an undocumented or not yet
808+
* supported value.
809+
*/
810+
fun entityMode(entityMode: JsonField<EntityMode>) = apply { this.entityMode = entityMode }
811+
726812
/**
727813
* Whether the connection associated with the `access_token` uses the Assisted Connect Flow.
728814
* (`true` if using Assisted Connect, `false` if connection is automated)
@@ -825,6 +911,8 @@ private constructor(
825911
customerEmail,
826912
customerId,
827913
customerName,
914+
(entityIds ?: JsonMissing.of()).map { it.toImmutable() },
915+
entityMode,
828916
manual,
829917
payrollProviderId,
830918
username,
@@ -853,6 +941,8 @@ private constructor(
853941
customerEmail()
854942
customerId()
855943
customerName()
944+
entityIds()
945+
entityMode().ifPresent { it.validate() }
856946
manual()
857947
payrollProviderId()
858948
username()
@@ -888,6 +978,8 @@ private constructor(
888978
(if (customerEmail.asKnown().isPresent) 1 else 0) +
889979
(if (customerId.asKnown().isPresent) 1 else 0) +
890980
(if (customerName.asKnown().isPresent) 1 else 0) +
981+
(entityIds.asKnown().getOrNull()?.size ?: 0) +
982+
(entityMode.asKnown().getOrNull()?.validity() ?: 0) +
891983
(if (manual.asKnown().isPresent) 1 else 0) +
892984
(if (payrollProviderId.asKnown().isPresent) 1 else 0) +
893985
(if (username.asKnown().isPresent) 1 else 0)
@@ -2446,6 +2538,133 @@ private constructor(
24462538
"AuthenticationMethodDetail{type=$type, connectionStatus=$connectionStatus, products=$products, additionalProperties=$additionalProperties}"
24472539
}
24482540

2541+
/** Indicates whether this connection manages a single entity or multiple entities. */
2542+
class EntityMode @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
2543+
2544+
/**
2545+
* Returns this class instance's raw value.
2546+
*
2547+
* This is usually only useful if this instance was deserialized from data that doesn't
2548+
* match any known member, and you want to know that value. For example, if the SDK is on an
2549+
* older version than the API, then the API may respond with new members that the SDK is
2550+
* unaware of.
2551+
*/
2552+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
2553+
2554+
companion object {
2555+
2556+
@JvmField val SINGLE = of("single")
2557+
2558+
@JvmField val MULTI = of("multi")
2559+
2560+
@JvmStatic fun of(value: String) = EntityMode(JsonField.of(value))
2561+
}
2562+
2563+
/** An enum containing [EntityMode]'s known values. */
2564+
enum class Known {
2565+
SINGLE,
2566+
MULTI,
2567+
}
2568+
2569+
/**
2570+
* An enum containing [EntityMode]'s known values, as well as an [_UNKNOWN] member.
2571+
*
2572+
* An instance of [EntityMode] can contain an unknown value in a couple of cases:
2573+
* - It was deserialized from data that doesn't match any known member. For example, if the
2574+
* SDK is on an older version than the API, then the API may respond with new members that
2575+
* the SDK is unaware of.
2576+
* - It was constructed with an arbitrary value using the [of] method.
2577+
*/
2578+
enum class Value {
2579+
SINGLE,
2580+
MULTI,
2581+
/**
2582+
* An enum member indicating that [EntityMode] was instantiated with an unknown value.
2583+
*/
2584+
_UNKNOWN,
2585+
}
2586+
2587+
/**
2588+
* Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
2589+
* if the class was instantiated with an unknown value.
2590+
*
2591+
* Use the [known] method instead if you're certain the value is always known or if you want
2592+
* to throw for the unknown case.
2593+
*/
2594+
fun value(): Value =
2595+
when (this) {
2596+
SINGLE -> Value.SINGLE
2597+
MULTI -> Value.MULTI
2598+
else -> Value._UNKNOWN
2599+
}
2600+
2601+
/**
2602+
* Returns an enum member corresponding to this class instance's value.
2603+
*
2604+
* Use the [value] method instead if you're uncertain the value is always known and don't
2605+
* want to throw for the unknown case.
2606+
*
2607+
* @throws FinchInvalidDataException if this class instance's value is a not a known member.
2608+
*/
2609+
fun known(): Known =
2610+
when (this) {
2611+
SINGLE -> Known.SINGLE
2612+
MULTI -> Known.MULTI
2613+
else -> throw FinchInvalidDataException("Unknown EntityMode: $value")
2614+
}
2615+
2616+
/**
2617+
* Returns this class instance's primitive wire representation.
2618+
*
2619+
* This differs from the [toString] method because that method is primarily for debugging
2620+
* and generally doesn't throw.
2621+
*
2622+
* @throws FinchInvalidDataException if this class instance's value does not have the
2623+
* expected primitive type.
2624+
*/
2625+
fun asString(): String =
2626+
_value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") }
2627+
2628+
private var validated: Boolean = false
2629+
2630+
fun validate(): EntityMode = apply {
2631+
if (validated) {
2632+
return@apply
2633+
}
2634+
2635+
known()
2636+
validated = true
2637+
}
2638+
2639+
fun isValid(): Boolean =
2640+
try {
2641+
validate()
2642+
true
2643+
} catch (e: FinchInvalidDataException) {
2644+
false
2645+
}
2646+
2647+
/**
2648+
* Returns a score indicating how many valid values are contained in this object
2649+
* recursively.
2650+
*
2651+
* Used for best match union deserialization.
2652+
*/
2653+
@JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
2654+
2655+
override fun equals(other: Any?): Boolean {
2656+
if (this === other) {
2657+
return true
2658+
}
2659+
2660+
return other is EntityMode && value == other.value
2661+
}
2662+
2663+
override fun hashCode() = value.hashCode()
2664+
2665+
override fun toString() = value.toString()
2666+
}
2667+
24492668
override fun equals(other: Any?): Boolean {
24502669
if (this === other) {
24512670
return true
@@ -2466,6 +2685,8 @@ private constructor(
24662685
customerEmail == other.customerEmail &&
24672686
customerId == other.customerId &&
24682687
customerName == other.customerName &&
2688+
entityIds == other.entityIds &&
2689+
entityMode == other.entityMode &&
24692690
manual == other.manual &&
24702691
payrollProviderId == other.payrollProviderId &&
24712692
username == other.username &&
@@ -2488,6 +2709,8 @@ private constructor(
24882709
customerEmail,
24892710
customerId,
24902711
customerName,
2712+
entityIds,
2713+
entityMode,
24912714
manual,
24922715
payrollProviderId,
24932716
username,
@@ -2498,5 +2721,5 @@ private constructor(
24982721
override fun hashCode(): Int = hashCode
24992722

25002723
override fun toString() =
2501-
"Introspection{id=$id, clientId=$clientId, clientType=$clientType, connectionId=$connectionId, connectionStatus=$connectionStatus, connectionType=$connectionType, products=$products, providerId=$providerId, accountId=$accountId, authenticationMethods=$authenticationMethods, companyId=$companyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, manual=$manual, payrollProviderId=$payrollProviderId, username=$username, additionalProperties=$additionalProperties}"
2724+
"Introspection{id=$id, clientId=$clientId, clientType=$clientType, connectionId=$connectionId, connectionStatus=$connectionStatus, connectionType=$connectionType, products=$products, providerId=$providerId, accountId=$accountId, authenticationMethods=$authenticationMethods, companyId=$companyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, entityIds=$entityIds, entityMode=$entityMode, manual=$manual, payrollProviderId=$payrollProviderId, username=$username, additionalProperties=$additionalProperties}"
25022725
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ internal class IntrospectionTest {
5050
.customerEmail("customer_email")
5151
.customerId("customer_id")
5252
.customerName("customer_name")
53+
.addEntityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
54+
.entityMode(Introspection.EntityMode.SINGLE)
5355
.manual(true)
5456
.payrollProviderId("payroll_provider_id")
5557
.username("username")
@@ -89,6 +91,9 @@ internal class IntrospectionTest {
8991
assertThat(introspection.customerEmail()).contains("customer_email")
9092
assertThat(introspection.customerId()).contains("customer_id")
9193
assertThat(introspection.customerName()).contains("customer_name")
94+
assertThat(introspection.entityIds().getOrNull())
95+
.containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
96+
assertThat(introspection.entityMode()).contains(Introspection.EntityMode.SINGLE)
9297
assertThat(introspection.manual()).contains(true)
9398
assertThat(introspection.payrollProviderId()).contains("payroll_provider_id")
9499
assertThat(introspection.username()).contains("username")
@@ -134,6 +139,8 @@ internal class IntrospectionTest {
134139
.customerEmail("customer_email")
135140
.customerId("customer_id")
136141
.customerName("customer_name")
142+
.addEntityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
143+
.entityMode(Introspection.EntityMode.SINGLE)
137144
.manual(true)
138145
.payrollProviderId("payroll_provider_id")
139146
.username("username")

0 commit comments

Comments
 (0)