Skip to content

Commit

Permalink
fix(client): add some missing validate() calls (#306)
Browse files Browse the repository at this point in the history
chore(internal): refactor `validate` methods
  • Loading branch information
stainless-app[bot] committed Jan 14, 2025
1 parent 0e08d79 commit 9fe1b97
Show file tree
Hide file tree
Showing 186 changed files with 4,996 additions and 3,864 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,22 @@ private constructor(
private var validated: Boolean = false

fun validate(): AccountCollectionFlow = apply {
if (!validated) {
counterpartyId()
paymentTypes()
id()
clientToken()
createdAt()
externalAccountId()
liveMode()
object_()
receivingCountries()
status()
updatedAt()
validated = true
if (validated) {
return@apply
}

counterpartyId()
paymentTypes()
id()
clientToken()
createdAt()
externalAccountId()
liveMode()
object_()
receivingCountries()
status()
updatedAt()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ constructor(
private var validated: Boolean = false

fun validate(): AccountCollectionFlowCreateBody = apply {
if (!validated) {
counterpartyId()
paymentTypes()
receivingCountries()
validated = true
if (validated) {
return@apply
}

counterpartyId()
paymentTypes()
receivingCountries()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

private var validated: Boolean = false

fun items(): List<AccountCollectionFlow> = items.getNullable("items") ?: listOf()

fun perPage(): String = perPage
Expand All @@ -112,11 +110,15 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): Response = apply {
if (!validated) {
items().map { it.validate() }
validated = true
if (validated) {
return@apply
}

items().map { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

private var validated: Boolean = false

fun items(): List<AccountCollectionFlow> = items.getNullable("items") ?: listOf()

fun perPage(): String = perPage
Expand All @@ -115,11 +113,15 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): Response = apply {
if (!validated) {
items().map { it.validate() }
validated = true
if (validated) {
return@apply
}

items().map { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ constructor(
private var validated: Boolean = false

fun validate(): AccountCollectionFlowUpdateBody = apply {
if (!validated) {
status()
validated = true
if (validated) {
return@apply
}

status()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,20 @@ private constructor(
private var validated: Boolean = false

fun validate(): AccountDetail = apply {
if (!validated) {
id()
accountNumberSafe()
accountNumberType()
createdAt()
discardedAt()
liveMode()
object_()
updatedAt()
accountNumber()
validated = true
if (validated) {
return@apply
}

id()
accountNumberSafe()
accountNumberType()
createdAt()
discardedAt()
liveMode()
object_()
updatedAt()
accountNumber()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ constructor(
private var validated: Boolean = false

fun validate(): AccountDetailCreateBody = apply {
if (!validated) {
accountNumber()
accountNumberType()
validated = true
if (validated) {
return@apply
}

accountNumber()
accountNumberType()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

private var validated: Boolean = false

fun items(): List<AccountDetail> = items.getNullable("items") ?: listOf()

fun perPage(): String = perPage
Expand All @@ -108,11 +106,15 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): Response = apply {
if (!validated) {
items().map { it.validate() }
validated = true
if (validated) {
return@apply
}

items().map { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

private var validated: Boolean = false

fun items(): List<AccountDetail> = items.getNullable("items") ?: listOf()

fun perPage(): String = perPage
Expand All @@ -111,11 +109,15 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): Response = apply {
if (!validated) {
items().map { it.validate() }
validated = true
if (validated) {
return@apply
}

items().map { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ private constructor(
private var validated: Boolean = false

fun validate(): AsyncResponse = apply {
if (!validated) {
id()
object_()
validated = true
if (validated) {
return@apply
}

id()
object_()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,21 @@ private constructor(
private var validated: Boolean = false

fun validate(): BalanceReport = apply {
if (!validated) {
id()
asOfDate()
asOfTime()
balanceReportType()
balances().forEach { it.validate() }
createdAt()
internalAccountId()
liveMode()
object_()
updatedAt()
validated = true
if (validated) {
return@apply
}

id()
asOfDate()
asOfTime()
balanceReportType()
balances().forEach { it.validate() }
createdAt()
internalAccountId()
liveMode()
object_()
updatedAt()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -544,22 +546,24 @@ private constructor(
private var validated: Boolean = false

fun validate(): Balance = apply {
if (!validated) {
id()
amount()
asOfDate()
asOfTime()
balanceType()
createdAt()
currency()
liveMode()
object_()
updatedAt()
valueDate()
vendorCode()
vendorCodeType()
validated = true
if (validated) {
return@apply
}

id()
amount()
asOfDate()
asOfTime()
balanceType()
createdAt()
currency()
liveMode()
object_()
updatedAt()
valueDate()
vendorCode()
vendorCodeType()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ constructor(
private var validated: Boolean = false

fun validate(): BalanceReportCreateBody = apply {
if (!validated) {
asOfDate()
asOfTime()
balanceReportType()
balances().forEach { it.validate() }
validated = true
if (validated) {
return@apply
}

asOfDate()
asOfTime()
balanceReportType()
balances().forEach { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -613,13 +615,15 @@ constructor(
private var validated: Boolean = false

fun validate(): BalanceCreateRequest = apply {
if (!validated) {
amount()
balanceType()
vendorCode()
vendorCodeType()
validated = true
if (validated) {
return@apply
}

amount()
balanceType()
vendorCode()
vendorCodeType()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ private constructor(
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

private var validated: Boolean = false

fun items(): List<BalanceReport> = items.getNullable("items") ?: listOf()

fun perPage(): String = perPage
Expand All @@ -108,11 +106,15 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

private var validated: Boolean = false

fun validate(): Response = apply {
if (!validated) {
items().map { it.validate() }
validated = true
if (validated) {
return@apply
}

items().map { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down
Loading

0 comments on commit 9fe1b97

Please sign in to comment.