Skip to content

Commit

Permalink
feat(client): put body field in params, add more convenience methods,…
Browse files Browse the repository at this point in the history
… and add missing docs (#287)
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jan 3, 2025
1 parent 5c1fcfc commit c3037e7
Show file tree
Hide file tree
Showing 113 changed files with 5,723 additions and 6,591 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,25 @@ import java.util.Objects

class AccountCollectionFlowCreateParams
constructor(
private val counterpartyId: String,
private val paymentTypes: List<String>,
private val receivingCountries: List<ReceivingCountry>?,
private val body: AccountCollectionFlowCreateBody,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map<String, JsonValue>,
) {

fun counterpartyId(): String = counterpartyId
/** Required. */
fun counterpartyId(): String = body.counterpartyId()

fun paymentTypes(): List<String> = paymentTypes
fun paymentTypes(): List<String> = body.paymentTypes()

fun receivingCountries(): List<ReceivingCountry>? = receivingCountries
fun receivingCountries(): List<ReceivingCountry>? = body.receivingCountries()

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties
fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties()

internal fun getBody(): AccountCollectionFlowCreateBody {
return AccountCollectionFlowCreateBody(
counterpartyId,
paymentTypes,
receivingCountries,
additionalBodyProperties,
)
}
internal fun getBody(): AccountCollectionFlowCreateBody = body

internal fun getHeaders(): Headers = additionalHeaders

Expand Down Expand Up @@ -87,8 +78,8 @@ constructor(
class Builder {

private var counterpartyId: String? = null
private var paymentTypes: List<String>? = null
private var receivingCountries: List<ReceivingCountry>? = null
private var paymentTypes: MutableList<String>? = null
private var receivingCountries: MutableList<ReceivingCountry>? = null
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

internal fun from(accountCollectionFlowCreateBody: AccountCollectionFlowCreateBody) =
Expand All @@ -107,11 +98,20 @@ constructor(
}

fun paymentTypes(paymentTypes: List<String>) = apply {
this.paymentTypes = paymentTypes
this.paymentTypes = paymentTypes.toMutableList()
}

fun addPaymentType(paymentType: String) = apply {
paymentTypes = (paymentTypes ?: mutableListOf()).apply { add(paymentType) }
}

fun receivingCountries(receivingCountries: List<ReceivingCountry>?) = apply {
this.receivingCountries = receivingCountries
fun receivingCountries(receivingCountries: List<ReceivingCountry>) = apply {
this.receivingCountries = receivingCountries.toMutableList()
}

fun addReceivingCountry(receivingCountry: ReceivingCountry) = apply {
receivingCountries =
(receivingCountries ?: mutableListOf()).apply { add(receivingCountry) }
}

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
Expand Down Expand Up @@ -171,44 +171,32 @@ constructor(
@NoAutoDetect
class Builder {

private var counterpartyId: String? = null
private var paymentTypes: MutableList<String> = mutableListOf()
private var receivingCountries: MutableList<ReceivingCountry> = mutableListOf()
private var body: AccountCollectionFlowCreateBody.Builder =
AccountCollectionFlowCreateBody.builder()
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()

internal fun from(accountCollectionFlowCreateParams: AccountCollectionFlowCreateParams) =
apply {
counterpartyId = accountCollectionFlowCreateParams.counterpartyId
paymentTypes = accountCollectionFlowCreateParams.paymentTypes.toMutableList()
receivingCountries =
accountCollectionFlowCreateParams.receivingCountries?.toMutableList()
?: mutableListOf()
body = accountCollectionFlowCreateParams.body.toBuilder()
additionalHeaders = accountCollectionFlowCreateParams.additionalHeaders.toBuilder()
additionalQueryParams =
accountCollectionFlowCreateParams.additionalQueryParams.toBuilder()
additionalBodyProperties =
accountCollectionFlowCreateParams.additionalBodyProperties.toMutableMap()
}

/** Required. */
fun counterpartyId(counterpartyId: String) = apply { this.counterpartyId = counterpartyId }
fun counterpartyId(counterpartyId: String) = apply { body.counterpartyId(counterpartyId) }

fun paymentTypes(paymentTypes: List<String>) = apply {
this.paymentTypes.clear()
this.paymentTypes.addAll(paymentTypes)
}
fun paymentTypes(paymentTypes: List<String>) = apply { body.paymentTypes(paymentTypes) }

fun addPaymentType(paymentType: String) = apply { this.paymentTypes.add(paymentType) }
fun addPaymentType(paymentType: String) = apply { body.addPaymentType(paymentType) }

fun receivingCountries(receivingCountries: List<ReceivingCountry>) = apply {
this.receivingCountries.clear()
this.receivingCountries.addAll(receivingCountries)
body.receivingCountries(receivingCountries)
}

fun addReceivingCountry(receivingCountry: ReceivingCountry) = apply {
this.receivingCountries.add(receivingCountry)
body.addReceivingCountry(receivingCountry)
}

fun additionalHeaders(additionalHeaders: Headers) = apply {
Expand Down Expand Up @@ -310,35 +298,29 @@ constructor(
}

fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
this.additionalBodyProperties.clear()
putAllAdditionalBodyProperties(additionalBodyProperties)
body.additionalProperties(additionalBodyProperties)
}

fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
additionalBodyProperties.put(key, value)
body.putAdditionalProperty(key, value)
}

fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) =
apply {
this.additionalBodyProperties.putAll(additionalBodyProperties)
body.putAllAdditionalProperties(additionalBodyProperties)
}

fun removeAdditionalBodyProperty(key: String) = apply {
additionalBodyProperties.remove(key)
}
fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) }

fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalBodyProperty)
body.removeAllAdditionalProperties(keys)
}

fun build(): AccountCollectionFlowCreateParams =
AccountCollectionFlowCreateParams(
checkNotNull(counterpartyId) { "`counterpartyId` is required but was not set" },
paymentTypes.toImmutable(),
receivingCountries.toImmutable().ifEmpty { null },
body.build(),
additionalHeaders.build(),
additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}

Expand Down Expand Up @@ -500,11 +482,11 @@ constructor(
return true
}

return /* spotless:off */ other is AccountCollectionFlowCreateParams && counterpartyId == other.counterpartyId && paymentTypes == other.paymentTypes && receivingCountries == other.receivingCountries && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
return /* spotless:off */ other is AccountCollectionFlowCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(counterpartyId, paymentTypes, receivingCountries, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */
override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"AccountCollectionFlowCreateParams{counterpartyId=$counterpartyId, paymentTypes=$paymentTypes, receivingCountries=$receivingCountries, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}"
"AccountCollectionFlowCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ import java.util.Objects
class AccountCollectionFlowUpdateParams
constructor(
private val id: String,
private val status: Status,
private val body: AccountCollectionFlowUpdateBody,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
private val additionalBodyProperties: Map<String, JsonValue>,
) {

fun id(): String = id

fun status(): Status = status
/**
* Required. The updated status of the account collection flow. Can only be used to mark a flow
* as `cancelled`.
*/
fun status(): Status = body.status()

fun _additionalHeaders(): Headers = additionalHeaders

fun _additionalQueryParams(): QueryParams = additionalQueryParams

fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties
fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties()

internal fun getBody(): AccountCollectionFlowUpdateBody {
return AccountCollectionFlowUpdateBody(status, additionalBodyProperties)
}
internal fun getBody(): AccountCollectionFlowUpdateBody = body

internal fun getHeaders(): Headers = additionalHeaders

Expand Down Expand Up @@ -151,20 +152,18 @@ constructor(
class Builder {

private var id: String? = null
private var status: Status? = null
private var body: AccountCollectionFlowUpdateBody.Builder =
AccountCollectionFlowUpdateBody.builder()
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()

internal fun from(accountCollectionFlowUpdateParams: AccountCollectionFlowUpdateParams) =
apply {
id = accountCollectionFlowUpdateParams.id
status = accountCollectionFlowUpdateParams.status
body = accountCollectionFlowUpdateParams.body.toBuilder()
additionalHeaders = accountCollectionFlowUpdateParams.additionalHeaders.toBuilder()
additionalQueryParams =
accountCollectionFlowUpdateParams.additionalQueryParams.toBuilder()
additionalBodyProperties =
accountCollectionFlowUpdateParams.additionalBodyProperties.toMutableMap()
}

fun id(id: String) = apply { this.id = id }
Expand All @@ -173,7 +172,7 @@ constructor(
* Required. The updated status of the account collection flow. Can only be used to mark a
* flow as `cancelled`.
*/
fun status(status: Status) = apply { this.status = status }
fun status(status: Status) = apply { body.status(status) }

fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
Expand Down Expand Up @@ -274,34 +273,30 @@ constructor(
}

fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
this.additionalBodyProperties.clear()
putAllAdditionalBodyProperties(additionalBodyProperties)
body.additionalProperties(additionalBodyProperties)
}

fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
additionalBodyProperties.put(key, value)
body.putAdditionalProperty(key, value)
}

fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) =
apply {
this.additionalBodyProperties.putAll(additionalBodyProperties)
body.putAllAdditionalProperties(additionalBodyProperties)
}

fun removeAdditionalBodyProperty(key: String) = apply {
additionalBodyProperties.remove(key)
}
fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) }

fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalBodyProperty)
body.removeAllAdditionalProperties(keys)
}

fun build(): AccountCollectionFlowUpdateParams =
AccountCollectionFlowUpdateParams(
checkNotNull(id) { "`id` is required but was not set" },
checkNotNull(status) { "`status` is required but was not set" },
body.build(),
additionalHeaders.build(),
additionalQueryParams.build(),
additionalBodyProperties.toImmutable(),
)
}

Expand Down Expand Up @@ -361,11 +356,11 @@ constructor(
return true
}

return /* spotless:off */ other is AccountCollectionFlowUpdateParams && id == other.id && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
return /* spotless:off */ other is AccountCollectionFlowUpdateParams && id == other.id && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(id, status, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */
override fun hashCode(): Int = /* spotless:off */ Objects.hash(id, body, additionalHeaders, additionalQueryParams) /* spotless:on */

override fun toString() =
"AccountCollectionFlowUpdateParams{id=$id, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}"
"AccountCollectionFlowUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
Loading

0 comments on commit c3037e7

Please sign in to comment.