All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tryfinch.api.models.PaymentCreateResponse.kt Maven / Gradle / Ivy

// File generated from our OpenAPI spec by Stainless.

package com.tryfinch.api.models

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.tryfinch.api.core.ExcludeMissing
import com.tryfinch.api.core.JsonField
import com.tryfinch.api.core.JsonMissing
import com.tryfinch.api.core.JsonValue
import com.tryfinch.api.core.NoAutoDetect
import com.tryfinch.api.core.toImmutable
import java.util.Objects

@JsonDeserialize(builder = PaymentCreateResponse.Builder::class)
@NoAutoDetect
class PaymentCreateResponse
private constructor(
    private val paymentId: JsonField,
    private val payDate: JsonField,
    private val additionalProperties: Map,
) {

    private var validated: Boolean = false

    /** The ID of the payment. */
    fun paymentId(): String = paymentId.getRequired("payment_id")

    /** The date of the payment. */
    fun payDate(): String = payDate.getRequired("pay_date")

    /** The ID of the payment. */
    @JsonProperty("payment_id") @ExcludeMissing fun _paymentId() = paymentId

    /** The date of the payment. */
    @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate

    @JsonAnyGetter
    @ExcludeMissing
    fun _additionalProperties(): Map = additionalProperties

    fun validate(): PaymentCreateResponse = apply {
        if (!validated) {
            paymentId()
            payDate()
            validated = true
        }
    }

    fun toBuilder() = Builder().from(this)

    companion object {

        fun builder() = Builder()
    }

    class Builder {

        private var paymentId: JsonField = JsonMissing.of()
        private var payDate: JsonField = JsonMissing.of()
        private var additionalProperties: MutableMap = mutableMapOf()

        internal fun from(paymentCreateResponse: PaymentCreateResponse) = apply {
            this.paymentId = paymentCreateResponse.paymentId
            this.payDate = paymentCreateResponse.payDate
            additionalProperties(paymentCreateResponse.additionalProperties)
        }

        /** The ID of the payment. */
        fun paymentId(paymentId: String) = paymentId(JsonField.of(paymentId))

        /** The ID of the payment. */
        @JsonProperty("payment_id")
        @ExcludeMissing
        fun paymentId(paymentId: JsonField) = apply { this.paymentId = paymentId }

        /** The date of the payment. */
        fun payDate(payDate: String) = payDate(JsonField.of(payDate))

        /** The date of the payment. */
        @JsonProperty("pay_date")
        @ExcludeMissing
        fun payDate(payDate: JsonField) = apply { this.payDate = payDate }

        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(): PaymentCreateResponse =
            PaymentCreateResponse(
                paymentId,
                payDate,
                additionalProperties.toImmutable(),
            )
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) {
            return true
        }

        return /* spotless:off */ other is PaymentCreateResponse && paymentId == other.paymentId && payDate == other.payDate && additionalProperties == other.additionalProperties /* spotless:on */
    }

    /* spotless:off */
    private val hashCode: Int by lazy { Objects.hash(paymentId, payDate, additionalProperties) }
    /* spotless:on */

    override fun hashCode(): Int = hashCode

    override fun toString() =
        "PaymentCreateResponse{paymentId=$paymentId, payDate=$payDate, additionalProperties=$additionalProperties}"
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy