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

tech.carpentum.sdk.payment.internal.generated.model.BalanceJsonJsonAdapter.kt Maven / Gradle / Ivy

There is a newer version: 2.1021.0
Show newest version
// Code generated by moshi-kotlin-codegen. Do not edit.
@file:Suppress("DEPRECATION", "unused", "UNUSED_PARAMETER", "ClassName", "REDUNDANT_PROJECTION",
    "RedundantExplicitType", "LocalVariableName", "RedundantVisibilityModifier",
    "PLATFORM_CLASS_MAPPED_TO_KOTLIN", "IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION")

package tech.carpentum.sdk.payment.`internal`.generated.model

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.lang.NullPointerException
import java.math.BigDecimal
import java.time.OffsetDateTime
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.emptySet
import kotlin.text.buildString
import tech.carpentum.sdk.payment.model.CurrencyCode

public class BalanceJsonJsonAdapter(
  moshi: Moshi,
) : JsonAdapter() {
  private val options: JsonReader.Options = JsonReader.Options.of("currencyCode", "balance",
      "availableBalance", "pendingSettlementAmount", "pendingPayoutAmount", "lastBalanceMovement")

  private val nullableCurrencyCodeAdapter: JsonAdapter =
      moshi.adapter(CurrencyCode::class.java, emptySet(), "currencyCode")

  private val nullableBigDecimalAdapter: JsonAdapter =
      moshi.adapter(BigDecimal::class.java, emptySet(), "balance")

  private val nullableOffsetDateTimeAdapter: JsonAdapter =
      moshi.adapter(OffsetDateTime::class.java, emptySet(), "lastBalanceMovement")

  public override fun toString(): String = buildString(33) {
      append("GeneratedJsonAdapter(").append("BalanceJson").append(')') }

  public override fun fromJson(reader: JsonReader): BalanceJson {
    var currencyCode: CurrencyCode? = null
    var currencyCodeSet: Boolean = false
    var balance: BigDecimal? = null
    var balanceSet: Boolean = false
    var availableBalance: BigDecimal? = null
    var availableBalanceSet: Boolean = false
    var pendingSettlementAmount: BigDecimal? = null
    var pendingSettlementAmountSet: Boolean = false
    var pendingPayoutAmount: BigDecimal? = null
    var pendingPayoutAmountSet: Boolean = false
    var lastBalanceMovement: OffsetDateTime? = null
    var lastBalanceMovementSet: Boolean = false
    reader.beginObject()
    while (reader.hasNext()) {
      when (reader.selectName(options)) {
        0 -> {
          currencyCode = nullableCurrencyCodeAdapter.fromJson(reader)
          currencyCodeSet = true
        }
        1 -> {
          balance = nullableBigDecimalAdapter.fromJson(reader)
          balanceSet = true
        }
        2 -> {
          availableBalance = nullableBigDecimalAdapter.fromJson(reader)
          availableBalanceSet = true
        }
        3 -> {
          pendingSettlementAmount = nullableBigDecimalAdapter.fromJson(reader)
          pendingSettlementAmountSet = true
        }
        4 -> {
          pendingPayoutAmount = nullableBigDecimalAdapter.fromJson(reader)
          pendingPayoutAmountSet = true
        }
        5 -> {
          lastBalanceMovement = nullableOffsetDateTimeAdapter.fromJson(reader)
          lastBalanceMovementSet = true
        }
        -1 -> {
          // Unknown name, skip it.
          reader.skipName()
          reader.skipValue()
        }
      }
    }
    reader.endObject()
    val result: BalanceJson
    result = BalanceJson(
    )
    if (currencyCodeSet) {
      result.currencyCode = currencyCode
    }
    if (balanceSet) {
      result.balance = balance
    }
    if (availableBalanceSet) {
      result.availableBalance = availableBalance
    }
    if (pendingSettlementAmountSet) {
      result.pendingSettlementAmount = pendingSettlementAmount
    }
    if (pendingPayoutAmountSet) {
      result.pendingPayoutAmount = pendingPayoutAmount
    }
    if (lastBalanceMovementSet) {
      result.lastBalanceMovement = lastBalanceMovement
    }
    return result
  }

  public override fun toJson(writer: JsonWriter, value_: BalanceJson?): Unit {
    if (value_ == null) {
      throw NullPointerException("value_ was null! Wrap in .nullSafe() to write nullable values.")
    }
    writer.beginObject()
    writer.name("currencyCode")
    nullableCurrencyCodeAdapter.toJson(writer, value_.currencyCode)
    writer.name("balance")
    nullableBigDecimalAdapter.toJson(writer, value_.balance)
    writer.name("availableBalance")
    nullableBigDecimalAdapter.toJson(writer, value_.availableBalance)
    writer.name("pendingSettlementAmount")
    nullableBigDecimalAdapter.toJson(writer, value_.pendingSettlementAmount)
    writer.name("pendingPayoutAmount")
    nullableBigDecimalAdapter.toJson(writer, value_.pendingPayoutAmount)
    writer.name("lastBalanceMovement")
    nullableOffsetDateTimeAdapter.toJson(writer, value_.lastBalanceMovement)
    writer.endObject()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy