Skip to content

Commit

Permalink
feat: generate addXxx methods for array types (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Aug 14, 2023
1 parent cef91ca commit e18bccd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ constructor(

private var date: OffsetDateTime? = null
private var transactionId: String? = null
private var entries: List<Entry>? = null
private var entries: MutableList<Entry> = mutableListOf()
private var additionalQueryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalHeaders: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
Expand All @@ -217,7 +217,7 @@ constructor(
apply {
this.date = bookkeepingEntrySetCreateParams.date
this.transactionId = bookkeepingEntrySetCreateParams.transactionId
this.entries = bookkeepingEntrySetCreateParams.entries
this.entries(bookkeepingEntrySetCreateParams.entries)
additionalQueryParams(bookkeepingEntrySetCreateParams.additionalQueryParams)
additionalHeaders(bookkeepingEntrySetCreateParams.additionalHeaders)
additionalBodyProperties(bookkeepingEntrySetCreateParams.additionalBodyProperties)
Expand All @@ -233,7 +233,13 @@ constructor(
fun transactionId(transactionId: String) = apply { this.transactionId = transactionId }

/** The bookkeeping entries. */
fun entries(entries: List<Entry>) = apply { this.entries = entries }
fun entries(entries: List<Entry>) = apply {
this.entries.clear()
this.entries.addAll(entries)
}

/** The bookkeeping entries. */
fun addEntry(entry: Entry) = apply { this.entries.add(entry) }

fun additionalQueryParams(additionalQueryParams: Map<String, List<String>>) = apply {
this.additionalQueryParams.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ constructor(
private var trust: Trust? = null
private var description: String? = null
private var relationship: Relationship? = null
private var supplementalDocuments: List<SupplementalDocument>? = null
private var supplementalDocuments: MutableList<SupplementalDocument> = mutableListOf()
private var additionalQueryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalHeaders: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
Expand All @@ -343,7 +343,7 @@ constructor(
this.trust = entityCreateParams.trust
this.description = entityCreateParams.description
this.relationship = entityCreateParams.relationship
this.supplementalDocuments = entityCreateParams.supplementalDocuments
this.supplementalDocuments(entityCreateParams.supplementalDocuments ?: listOf())
additionalQueryParams(entityCreateParams.additionalQueryParams)
additionalHeaders(entityCreateParams.additionalHeaders)
additionalBodyProperties(entityCreateParams.additionalBodyProperties)
Expand Down Expand Up @@ -382,7 +382,13 @@ constructor(

/** Additional documentation associated with the entity. */
fun supplementalDocuments(supplementalDocuments: List<SupplementalDocument>) = apply {
this.supplementalDocuments = supplementalDocuments
this.supplementalDocuments.clear()
this.supplementalDocuments.addAll(supplementalDocuments)
}

/** Additional documentation associated with the entity. */
fun addSupplementalDocument(supplementalDocument: SupplementalDocument) = apply {
this.supplementalDocuments.add(supplementalDocument)
}

fun additionalQueryParams(additionalQueryParams: Map<String, List<String>>) = apply {
Expand Down Expand Up @@ -448,7 +454,8 @@ constructor(
trust,
description,
checkNotNull(relationship) { "`relationship` is required but was not set" },
supplementalDocuments?.toUnmodifiable(),
if (supplementalDocuments.size == 0) null
else supplementalDocuments.toUnmodifiable(),
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalBodyProperties.toUnmodifiable(),
Expand Down

0 comments on commit e18bccd

Please sign in to comment.