Skip to content

Commit

Permalink
fix(client): add some missing validate() calls (#30)
Browse files Browse the repository at this point in the history
chore(internal): refactor `validate` methods
  • Loading branch information
stainless-app[bot] committed Jan 10, 2025
1 parent 297d3f6 commit 1849964
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,18 @@ constructor(
private var validated: Boolean = false

fun validate(): TransactionalSendBody = apply {
if (!validated) {
templateId()
to()
callbackUrl()
correlationId()
expiresAt()
from()
variables().map { it.validate() }
validated = true
if (validated) {
return@apply
}

templateId()
to()
callbackUrl()
correlationId()
expiresAt()
from()
variables().ifPresent { it.validate() }
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -511,9 +513,11 @@ constructor(
private var validated: Boolean = false

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

validated = true
}

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

fun validate(): TransactionalSendResponse = apply {
if (!validated) {
id()
createdAt()
expiresAt()
templateId()
to()
variables().validate()
callbackUrl()
correlationId()
from()
validated = true
if (validated) {
return@apply
}

id()
createdAt()
expiresAt()
templateId()
to()
variables().validate()
callbackUrl()
correlationId()
from()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -270,9 +272,11 @@ private constructor(
private var validated: Boolean = false

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

validated = true
}

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

fun validate(): VerificationCheckBody = apply {
if (!validated) {
code()
target().validate()
validated = true
if (validated) {
return@apply
}

code()
target().validate()
validated = true
}

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

fun validate(): Target = apply {
if (!validated) {
type()
value()
validated = true
if (validated) {
return@apply
}

type()
value()
validated = true
}

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

fun validate(): VerificationCheckResponse = apply {
if (!validated) {
status()
id()
metadata().map { it.validate() }
requestId()
validated = true
if (validated) {
return@apply
}

status()
id()
metadata().ifPresent { it.validate() }
requestId()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -237,10 +239,12 @@ private constructor(
private var validated: Boolean = false

fun validate(): Metadata = apply {
if (!validated) {
correlationId()
validated = true
if (validated) {
return@apply
}

correlationId()
validated = true
}

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

fun validate(): VerificationCreateBody = apply {
if (!validated) {
target().validate()
metadata().map { it.validate() }
options().map { it.validate() }
signals().map { it.validate() }
validated = true
if (validated) {
return@apply
}

target().validate()
metadata().ifPresent { it.validate() }
options().ifPresent { it.validate() }
signals().ifPresent { it.validate() }
validated = true
}

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

fun validate(): Target = apply {
if (!validated) {
type()
value()
validated = true
if (validated) {
return@apply
}

type()
value()
validated = true
}

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

fun validate(): Metadata = apply {
if (!validated) {
correlationId()
validated = true
if (validated) {
return@apply
}

correlationId()
validated = true
}

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

fun validate(): Options = apply {
if (!validated) {
appRealm().map { it.validate() }
codeSize()
customCode()
locale()
senderId()
templateId()
validated = true
if (validated) {
return@apply
}

appRealm().ifPresent { it.validate() }
codeSize()
customCode()
locale()
senderId()
templateId()
validated = true
}

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

fun validate(): AppRealm = apply {
if (!validated) {
platform()
value()
validated = true
if (validated) {
return@apply
}

platform()
value()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -1241,16 +1251,18 @@ constructor(
private var validated: Boolean = false

fun validate(): Signals = apply {
if (!validated) {
appVersion()
deviceId()
deviceModel()
devicePlatform()
ip()
isTrustedUser()
osVersion()
validated = true
if (validated) {
return@apply
}

appVersion()
deviceId()
deviceModel()
devicePlatform()
ip()
isTrustedUser()
osVersion()
validated = true
}

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

fun validate(): VerificationCreateResponse = apply {
if (!validated) {
id()
method()
status()
metadata().map { it.validate() }
requestId()
validated = true
if (validated) {
return@apply
}

id()
method()
status()
metadata().ifPresent { it.validate() }
requestId()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -307,10 +309,12 @@ private constructor(
private var validated: Boolean = false

fun validate(): Metadata = apply {
if (!validated) {
correlationId()
validated = true
if (validated) {
return@apply
}

correlationId()
validated = true
}

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

fun validate(): WatchFeedBackBody = apply {
if (!validated) {
feedback().validate()
target().validate()
validated = true
if (validated) {
return@apply
}

feedback().validate()
target().validate()
validated = true
}

fun toBuilder() = Builder().from(this)
Expand Down Expand Up @@ -385,10 +387,12 @@ constructor(
private var validated: Boolean = false

fun validate(): Feedback = apply {
if (!validated) {
type()
validated = true
if (validated) {
return@apply
}

type()
validated = true
}

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

fun validate(): Target = apply {
if (!validated) {
type()
value()
validated = true
if (validated) {
return@apply
}

type()
value()
validated = true
}

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

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

id()
validated = true
}

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

0 comments on commit 1849964

Please sign in to comment.