Skip to content

Commit ba7deb7

Browse files
committed
feat(api): add sandbox APIs (#127)
1 parent b4c5b54 commit ba7deb7

108 files changed

Lines changed: 16999 additions & 48 deletions

File tree

Some content is hidden

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

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 23
1+
configured_endpoints: 33

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ interface FinchClient {
2626

2727
fun jobs(): JobService
2828

29+
fun auth(): AuthService
30+
31+
fun sandbox(): SandboxService
32+
2933
fun getAccessToken(
3034
clientId: String,
3135
clientSecret: String,

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ interface FinchClientAsync {
2727

2828
fun jobs(): JobServiceAsync
2929

30+
fun auth(): AuthServiceAsync
31+
32+
fun sandbox(): SandboxServiceAsync
33+
3034
fun getAccessToken(
3135
clientId: String,
3236
clientSecret: String,

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ constructor(
4545

4646
private val jobs: JobServiceAsync by lazy { JobServiceAsyncImpl(clientOptions) }
4747

48+
private val auth: AuthServiceAsync by lazy { AuthServiceAsyncImpl(clientOptions) }
49+
50+
private val sandbox: SandboxServiceAsync by lazy { SandboxServiceAsyncImpl(clientOptions) }
51+
4852
private val getAccessTokenHandler: Handler<GetAccessTokenResponse> =
4953
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
5054

@@ -64,6 +68,10 @@ constructor(
6468

6569
override fun jobs(): JobServiceAsync = jobs
6670

71+
override fun auth(): AuthServiceAsync = auth
72+
73+
override fun sandbox(): SandboxServiceAsync = sandbox
74+
6775
override fun getAccessToken(
6876
clientId: String,
6977
clientSecret: String,

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ constructor(
4242

4343
private val jobs: JobService by lazy { JobServiceImpl(clientOptions) }
4444

45+
private val auth: AuthService by lazy { AuthServiceImpl(clientOptions) }
46+
47+
private val sandbox: SandboxService by lazy { SandboxServiceImpl(clientOptions) }
48+
4549
private val getAccessTokenHandler: Handler<GetAccessTokenResponse> =
4650
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
4751

@@ -61,6 +65,10 @@ constructor(
6165

6266
override fun jobs(): JobService = jobs
6367

68+
override fun auth(): AuthService = auth
69+
70+
override fun sandbox(): SandboxService = sandbox
71+
6472
override fun getAccessToken(
6573
clientId: String,
6674
clientSecret: String,
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
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.fasterxml.jackson.databind.annotation.JsonDeserialize
10+
import com.tryfinch.api.core.ExcludeMissing
11+
import com.tryfinch.api.core.JsonField
12+
import com.tryfinch.api.core.JsonMissing
13+
import com.tryfinch.api.core.JsonValue
14+
import com.tryfinch.api.core.NoAutoDetect
15+
import com.tryfinch.api.core.toUnmodifiable
16+
import com.tryfinch.api.errors.FinchInvalidDataException
17+
import java.util.Objects
18+
19+
@JsonDeserialize(builder = AccountCreateResponse.Builder::class)
20+
@NoAutoDetect
21+
class AccountCreateResponse
22+
private constructor(
23+
private val companyId: JsonField<String>,
24+
private val providerId: JsonField<String>,
25+
private val accountId: JsonField<String>,
26+
private val authenticationType: JsonField<AuthenticationType>,
27+
private val products: JsonField<List<String>>,
28+
private val accessToken: JsonField<String>,
29+
private val additionalProperties: Map<String, JsonValue>,
30+
) {
31+
32+
private var validated: Boolean = false
33+
34+
private var hashCode: Int = 0
35+
36+
fun companyId(): String = companyId.getRequired("company_id")
37+
38+
fun providerId(): String = providerId.getRequired("provider_id")
39+
40+
fun accountId(): String = accountId.getRequired("account_id")
41+
42+
fun authenticationType(): AuthenticationType =
43+
authenticationType.getRequired("authentication_type")
44+
45+
fun products(): List<String> = products.getRequired("products")
46+
47+
fun accessToken(): String = accessToken.getRequired("access_token")
48+
49+
@JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId
50+
51+
@JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId
52+
53+
@JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId
54+
55+
@JsonProperty("authentication_type")
56+
@ExcludeMissing
57+
fun _authenticationType() = authenticationType
58+
59+
@JsonProperty("products") @ExcludeMissing fun _products() = products
60+
61+
@JsonProperty("access_token") @ExcludeMissing fun _accessToken() = accessToken
62+
63+
@JsonAnyGetter
64+
@ExcludeMissing
65+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
66+
67+
fun validate(): AccountCreateResponse = apply {
68+
if (!validated) {
69+
companyId()
70+
providerId()
71+
accountId()
72+
authenticationType()
73+
products()
74+
accessToken()
75+
validated = true
76+
}
77+
}
78+
79+
fun toBuilder() = Builder().from(this)
80+
81+
override fun equals(other: Any?): Boolean {
82+
if (this === other) {
83+
return true
84+
}
85+
86+
return other is AccountCreateResponse &&
87+
this.companyId == other.companyId &&
88+
this.providerId == other.providerId &&
89+
this.accountId == other.accountId &&
90+
this.authenticationType == other.authenticationType &&
91+
this.products == other.products &&
92+
this.accessToken == other.accessToken &&
93+
this.additionalProperties == other.additionalProperties
94+
}
95+
96+
override fun hashCode(): Int {
97+
if (hashCode == 0) {
98+
hashCode =
99+
Objects.hash(
100+
companyId,
101+
providerId,
102+
accountId,
103+
authenticationType,
104+
products,
105+
accessToken,
106+
additionalProperties,
107+
)
108+
}
109+
return hashCode
110+
}
111+
112+
override fun toString() =
113+
"AccountCreateResponse{companyId=$companyId, providerId=$providerId, accountId=$accountId, authenticationType=$authenticationType, products=$products, accessToken=$accessToken, additionalProperties=$additionalProperties}"
114+
115+
companion object {
116+
117+
@JvmStatic fun builder() = Builder()
118+
}
119+
120+
class Builder {
121+
122+
private var companyId: JsonField<String> = JsonMissing.of()
123+
private var providerId: JsonField<String> = JsonMissing.of()
124+
private var accountId: JsonField<String> = JsonMissing.of()
125+
private var authenticationType: JsonField<AuthenticationType> = JsonMissing.of()
126+
private var products: JsonField<List<String>> = JsonMissing.of()
127+
private var accessToken: JsonField<String> = JsonMissing.of()
128+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
129+
130+
@JvmSynthetic
131+
internal fun from(accountCreateResponse: AccountCreateResponse) = apply {
132+
this.companyId = accountCreateResponse.companyId
133+
this.providerId = accountCreateResponse.providerId
134+
this.accountId = accountCreateResponse.accountId
135+
this.authenticationType = accountCreateResponse.authenticationType
136+
this.products = accountCreateResponse.products
137+
this.accessToken = accountCreateResponse.accessToken
138+
additionalProperties(accountCreateResponse.additionalProperties)
139+
}
140+
141+
fun companyId(companyId: String) = companyId(JsonField.of(companyId))
142+
143+
@JsonProperty("company_id")
144+
@ExcludeMissing
145+
fun companyId(companyId: JsonField<String>) = apply { this.companyId = companyId }
146+
147+
fun providerId(providerId: String) = providerId(JsonField.of(providerId))
148+
149+
@JsonProperty("provider_id")
150+
@ExcludeMissing
151+
fun providerId(providerId: JsonField<String>) = apply { this.providerId = providerId }
152+
153+
fun accountId(accountId: String) = accountId(JsonField.of(accountId))
154+
155+
@JsonProperty("account_id")
156+
@ExcludeMissing
157+
fun accountId(accountId: JsonField<String>) = apply { this.accountId = accountId }
158+
159+
fun authenticationType(authenticationType: AuthenticationType) =
160+
authenticationType(JsonField.of(authenticationType))
161+
162+
@JsonProperty("authentication_type")
163+
@ExcludeMissing
164+
fun authenticationType(authenticationType: JsonField<AuthenticationType>) = apply {
165+
this.authenticationType = authenticationType
166+
}
167+
168+
fun products(products: List<String>) = products(JsonField.of(products))
169+
170+
@JsonProperty("products")
171+
@ExcludeMissing
172+
fun products(products: JsonField<List<String>>) = apply { this.products = products }
173+
174+
fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken))
175+
176+
@JsonProperty("access_token")
177+
@ExcludeMissing
178+
fun accessToken(accessToken: JsonField<String>) = apply { this.accessToken = accessToken }
179+
180+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
181+
this.additionalProperties.clear()
182+
this.additionalProperties.putAll(additionalProperties)
183+
}
184+
185+
@JsonAnySetter
186+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
187+
this.additionalProperties.put(key, value)
188+
}
189+
190+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
191+
this.additionalProperties.putAll(additionalProperties)
192+
}
193+
194+
fun build(): AccountCreateResponse =
195+
AccountCreateResponse(
196+
companyId,
197+
providerId,
198+
accountId,
199+
authenticationType,
200+
products.map { it.toUnmodifiable() },
201+
accessToken,
202+
additionalProperties.toUnmodifiable(),
203+
)
204+
}
205+
206+
class AuthenticationType
207+
@JsonCreator
208+
private constructor(
209+
private val value: JsonField<String>,
210+
) {
211+
212+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
213+
214+
override fun equals(other: Any?): Boolean {
215+
if (this === other) {
216+
return true
217+
}
218+
219+
return other is AuthenticationType && this.value == other.value
220+
}
221+
222+
override fun hashCode() = value.hashCode()
223+
224+
override fun toString() = value.toString()
225+
226+
companion object {
227+
228+
@JvmField val CREDENTIALS = AuthenticationType(JsonField.of("credentials"))
229+
230+
@JvmField val API_TOKEN = AuthenticationType(JsonField.of("api_token"))
231+
232+
@JvmField val OAUTH = AuthenticationType(JsonField.of("oauth"))
233+
234+
@JvmField val ASSISTED = AuthenticationType(JsonField.of("assisted"))
235+
236+
@JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value))
237+
}
238+
239+
enum class Known {
240+
CREDENTIALS,
241+
API_TOKEN,
242+
OAUTH,
243+
ASSISTED,
244+
}
245+
246+
enum class Value {
247+
CREDENTIALS,
248+
API_TOKEN,
249+
OAUTH,
250+
ASSISTED,
251+
_UNKNOWN,
252+
}
253+
254+
fun value(): Value =
255+
when (this) {
256+
CREDENTIALS -> Value.CREDENTIALS
257+
API_TOKEN -> Value.API_TOKEN
258+
OAUTH -> Value.OAUTH
259+
ASSISTED -> Value.ASSISTED
260+
else -> Value._UNKNOWN
261+
}
262+
263+
fun known(): Known =
264+
when (this) {
265+
CREDENTIALS -> Known.CREDENTIALS
266+
API_TOKEN -> Known.API_TOKEN
267+
OAUTH -> Known.OAUTH
268+
ASSISTED -> Known.ASSISTED
269+
else -> throw FinchInvalidDataException("Unknown AuthenticationType: $value")
270+
}
271+
272+
fun asString(): String = _value().asStringOrThrow()
273+
}
274+
}

0 commit comments

Comments
 (0)