com.increase.api.models.BookkeepingEntrySet.kt Maven / Gradle / Ivy
// File generated from our OpenAPI spec by Stainless.
package com.increase.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.increase.api.core.Enum
import com.increase.api.core.ExcludeMissing
import com.increase.api.core.JsonField
import com.increase.api.core.JsonMissing
import com.increase.api.core.JsonValue
import com.increase.api.core.NoAutoDetect
import com.increase.api.core.toImmutable
import com.increase.api.errors.IncreaseInvalidDataException
import java.time.OffsetDateTime
import java.util.Objects
/**
* Entry Sets are accounting entries that are transactionally applied. Your compliance setup might
* require annotating money movements using this API. Learn more in our
* [guide to Bookkeeping](https://increase.com/documentation/bookkeeping#bookkeeping).
*/
@JsonDeserialize(builder = BookkeepingEntrySet.Builder::class)
@NoAutoDetect
class BookkeepingEntrySet
private constructor(
private val createdAt: JsonField,
private val date: JsonField,
private val entries: JsonField>,
private val id: JsonField,
private val idempotencyKey: JsonField,
private val transactionId: JsonField,
private val type: JsonField,
private val additionalProperties: Map,
) {
private var validated: Boolean = false
/** When the entry set was created. */
fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")
/** The timestamp of the entry set. */
fun date(): OffsetDateTime = date.getRequired("date")
/** The entries. */
fun entries(): List = entries.getRequired("entries")
/** The entry set identifier. */
fun id(): String = id.getRequired("id")
/**
* The idempotency key you chose for this object. This value is unique across Increase and is
* used to ensure that a request is only processed once. Learn more about
* [idempotency](https://increase.com/documentation/idempotency-keys).
*/
fun idempotencyKey(): String? = idempotencyKey.getNullable("idempotency_key")
/** The transaction identifier, if any. */
fun transactionId(): String? = transactionId.getNullable("transaction_id")
/**
* A constant representing the object's type. For this resource it will always be
* `bookkeeping_entry_set`.
*/
fun type(): Type = type.getRequired("type")
/** When the entry set was created. */
@JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt
/** The timestamp of the entry set. */
@JsonProperty("date") @ExcludeMissing fun _date() = date
/** The entries. */
@JsonProperty("entries") @ExcludeMissing fun _entries() = entries
/** The entry set identifier. */
@JsonProperty("id") @ExcludeMissing fun _id() = id
/**
* The idempotency key you chose for this object. This value is unique across Increase and is
* used to ensure that a request is only processed once. Learn more about
* [idempotency](https://increase.com/documentation/idempotency-keys).
*/
@JsonProperty("idempotency_key") @ExcludeMissing fun _idempotencyKey() = idempotencyKey
/** The transaction identifier, if any. */
@JsonProperty("transaction_id") @ExcludeMissing fun _transactionId() = transactionId
/**
* A constant representing the object's type. For this resource it will always be
* `bookkeeping_entry_set`.
*/
@JsonProperty("type") @ExcludeMissing fun _type() = type
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
fun validate(): BookkeepingEntrySet = apply {
if (!validated) {
createdAt()
date()
entries().forEach { it.validate() }
id()
idempotencyKey()
transactionId()
type()
validated = true
}
}
fun toBuilder() = Builder().from(this)
companion object {
fun builder() = Builder()
}
class Builder {
private var createdAt: JsonField = JsonMissing.of()
private var date: JsonField = JsonMissing.of()
private var entries: JsonField> = JsonMissing.of()
private var id: JsonField = JsonMissing.of()
private var idempotencyKey: JsonField = JsonMissing.of()
private var transactionId: JsonField = JsonMissing.of()
private var type: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
internal fun from(bookkeepingEntrySet: BookkeepingEntrySet) = apply {
this.createdAt = bookkeepingEntrySet.createdAt
this.date = bookkeepingEntrySet.date
this.entries = bookkeepingEntrySet.entries
this.id = bookkeepingEntrySet.id
this.idempotencyKey = bookkeepingEntrySet.idempotencyKey
this.transactionId = bookkeepingEntrySet.transactionId
this.type = bookkeepingEntrySet.type
additionalProperties(bookkeepingEntrySet.additionalProperties)
}
/** When the entry set was created. */
fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))
/** When the entry set was created. */
@JsonProperty("created_at")
@ExcludeMissing
fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }
/** The timestamp of the entry set. */
fun date(date: OffsetDateTime) = date(JsonField.of(date))
/** The timestamp of the entry set. */
@JsonProperty("date")
@ExcludeMissing
fun date(date: JsonField) = apply { this.date = date }
/** The entries. */
fun entries(entries: List) = entries(JsonField.of(entries))
/** The entries. */
@JsonProperty("entries")
@ExcludeMissing
fun entries(entries: JsonField>) = apply { this.entries = entries }
/** The entry set identifier. */
fun id(id: String) = id(JsonField.of(id))
/** The entry set identifier. */
@JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id }
/**
* The idempotency key you chose for this object. This value is unique across Increase and
* is used to ensure that a request is only processed once. Learn more about
* [idempotency](https://increase.com/documentation/idempotency-keys).
*/
fun idempotencyKey(idempotencyKey: String) = idempotencyKey(JsonField.of(idempotencyKey))
/**
* The idempotency key you chose for this object. This value is unique across Increase and
* is used to ensure that a request is only processed once. Learn more about
* [idempotency](https://increase.com/documentation/idempotency-keys).
*/
@JsonProperty("idempotency_key")
@ExcludeMissing
fun idempotencyKey(idempotencyKey: JsonField) = apply {
this.idempotencyKey = idempotencyKey
}
/** The transaction identifier, if any. */
fun transactionId(transactionId: String) = transactionId(JsonField.of(transactionId))
/** The transaction identifier, if any. */
@JsonProperty("transaction_id")
@ExcludeMissing
fun transactionId(transactionId: JsonField) = apply {
this.transactionId = transactionId
}
/**
* A constant representing the object's type. For this resource it will always be
* `bookkeeping_entry_set`.
*/
fun type(type: Type) = type(JsonField.of(type))
/**
* A constant representing the object's type. For this resource it will always be
* `bookkeeping_entry_set`.
*/
@JsonProperty("type")
@ExcludeMissing
fun type(type: JsonField) = apply { this.type = type }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}
@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.putAll(additionalProperties)
}
fun build(): BookkeepingEntrySet =
BookkeepingEntrySet(
createdAt,
date,
entries.map { it.toImmutable() },
id,
idempotencyKey,
transactionId,
type,
additionalProperties.toImmutable(),
)
}
@JsonDeserialize(builder = Entry.Builder::class)
@NoAutoDetect
class Entry
private constructor(
private val accountId: JsonField,
private val amount: JsonField,
private val id: JsonField,
private val additionalProperties: Map,
) {
private var validated: Boolean = false
/** The bookkeeping account impacted by the entry. */
fun accountId(): String = accountId.getRequired("account_id")
/** The amount of the entry in minor units. */
fun amount(): Long = amount.getRequired("amount")
/** The entry identifier. */
fun id(): String = id.getRequired("id")
/** The bookkeeping account impacted by the entry. */
@JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId
/** The amount of the entry in minor units. */
@JsonProperty("amount") @ExcludeMissing fun _amount() = amount
/** The entry identifier. */
@JsonProperty("id") @ExcludeMissing fun _id() = id
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
fun validate(): Entry = apply {
if (!validated) {
accountId()
amount()
id()
validated = true
}
}
fun toBuilder() = Builder().from(this)
companion object {
fun builder() = Builder()
}
class Builder {
private var accountId: JsonField = JsonMissing.of()
private var amount: JsonField = JsonMissing.of()
private var id: JsonField = JsonMissing.of()
private var additionalProperties: MutableMap = mutableMapOf()
internal fun from(entry: Entry) = apply {
this.accountId = entry.accountId
this.amount = entry.amount
this.id = entry.id
additionalProperties(entry.additionalProperties)
}
/** The bookkeeping account impacted by the entry. */
fun accountId(accountId: String) = accountId(JsonField.of(accountId))
/** The bookkeeping account impacted by the entry. */
@JsonProperty("account_id")
@ExcludeMissing
fun accountId(accountId: JsonField) = apply { this.accountId = accountId }
/** The amount of the entry in minor units. */
fun amount(amount: Long) = amount(JsonField.of(amount))
/** The amount of the entry in minor units. */
@JsonProperty("amount")
@ExcludeMissing
fun amount(amount: JsonField) = apply { this.amount = amount }
/** The entry identifier. */
fun id(id: String) = id(JsonField.of(id))
/** The entry identifier. */
@JsonProperty("id")
@ExcludeMissing
fun id(id: JsonField) = apply { this.id = id }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}
@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.putAll(additionalProperties)
}
fun build(): Entry =
Entry(
accountId,
amount,
id,
additionalProperties.toImmutable(),
)
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is Entry && this.accountId == other.accountId && this.amount == other.amount && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */
}
private var hashCode: Int = 0
override fun hashCode(): Int {
if (hashCode == 0) {
hashCode = /* spotless:off */ Objects.hash(accountId, amount, id, additionalProperties) /* spotless:on */
}
return hashCode
}
override fun toString() =
"Entry{accountId=$accountId, amount=$amount, id=$id, additionalProperties=$additionalProperties}"
}
class Type
@JsonCreator
private constructor(
private val value: JsonField,
) : Enum {
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
companion object {
val BOOKKEEPING_ENTRY_SET = Type(JsonField.of("bookkeeping_entry_set"))
fun of(value: String) = Type(JsonField.of(value))
}
enum class Known {
BOOKKEEPING_ENTRY_SET,
}
enum class Value {
BOOKKEEPING_ENTRY_SET,
_UNKNOWN,
}
fun value(): Value =
when (this) {
BOOKKEEPING_ENTRY_SET -> Value.BOOKKEEPING_ENTRY_SET
else -> Value._UNKNOWN
}
fun known(): Known =
when (this) {
BOOKKEEPING_ENTRY_SET -> Known.BOOKKEEPING_ENTRY_SET
else -> throw IncreaseInvalidDataException("Unknown Type: $value")
}
fun asString(): String = _value().asStringOrThrow()
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is BookkeepingEntrySet && this.createdAt == other.createdAt && this.date == other.date && this.entries == other.entries && this.id == other.id && this.idempotencyKey == other.idempotencyKey && this.transactionId == other.transactionId && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */
}
private var hashCode: Int = 0
override fun hashCode(): Int {
if (hashCode == 0) {
hashCode = /* spotless:off */ Objects.hash(createdAt, date, entries, id, idempotencyKey, transactionId, type, additionalProperties) /* spotless:on */
}
return hashCode
}
override fun toString() =
"BookkeepingEntrySet{createdAt=$createdAt, date=$date, entries=$entries, id=$id, idempotencyKey=$idempotencyKey, transactionId=$transactionId, type=$type, additionalProperties=$additionalProperties}"
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy