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

com.zuora.model.PaymentSchedule Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
/*
 * Zuora API Reference
 * REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
 *
 * The version of the OpenAPI document: 2024-05-20
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.zuora.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.zuora.model.PaymentScheduleBillingDocument;
import com.zuora.model.PaymentScheduleItem;
import com.zuora.model.PaymentSchedulePaymentOptionFields;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.zuora.JSON;

/**
 * PaymentSchedule
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class PaymentSchedule {
  public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
  private String accountId;

  public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER)
  private String accountNumber;

  public static final String SERIALIZED_NAME_BILLING_DOCUMENT = "billingDocument";
  @SerializedName(SERIALIZED_NAME_BILLING_DOCUMENT)
  private PaymentScheduleBillingDocument billingDocument;

  public static final String SERIALIZED_NAME_CANCEL_DATE = "cancelDate";
  @SerializedName(SERIALIZED_NAME_CANCEL_DATE)
  private String cancelDate;

  public static final String SERIALIZED_NAME_CANCELLED_BY_ID = "cancelledById";
  @SerializedName(SERIALIZED_NAME_CANCELLED_BY_ID)
  private String cancelledById;

  public static final String SERIALIZED_NAME_CANCELLED_ON = "cancelledOn";
  @SerializedName(SERIALIZED_NAME_CANCELLED_ON)
  private String cancelledOn;

  public static final String SERIALIZED_NAME_CREATED_BY_ID = "createdById";
  @SerializedName(SERIALIZED_NAME_CREATED_BY_ID)
  private String createdById;

  public static final String SERIALIZED_NAME_CREATED_DATE = "createdDate";
  @SerializedName(SERIALIZED_NAME_CREATED_DATE)
  private String createdDate;

  public static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private String id;

  public static final String SERIALIZED_NAME_IS_CUSTOM = "isCustom";
  @SerializedName(SERIALIZED_NAME_IS_CUSTOM)
  private Boolean isCustom;

  public static final String SERIALIZED_NAME_ITEMS = "items";
  @SerializedName(SERIALIZED_NAME_ITEMS)
  private List items;

  public static final String SERIALIZED_NAME_NEXT_PAYMENT_DATE = "nextPaymentDate";
  @SerializedName(SERIALIZED_NAME_NEXT_PAYMENT_DATE)
  private String nextPaymentDate;

  public static final String SERIALIZED_NAME_OCCURRENCES = "occurrences";
  @SerializedName(SERIALIZED_NAME_OCCURRENCES)
  private Integer occurrences;

  public static final String SERIALIZED_NAME_PAYMENT_OPTION = "paymentOption";
  @SerializedName(SERIALIZED_NAME_PAYMENT_OPTION)
  private List paymentOption;

  public static final String SERIALIZED_NAME_PAYMENT_SCHEDULE_NUMBER = "paymentScheduleNumber";
  @SerializedName(SERIALIZED_NAME_PAYMENT_SCHEDULE_NUMBER)
  private String paymentScheduleNumber;

  public static final String SERIALIZED_NAME_PERIOD = "period";
  @SerializedName(SERIALIZED_NAME_PERIOD)
  private String period;

  public static final String SERIALIZED_NAME_PREPAYMENT = "prepayment";
  @SerializedName(SERIALIZED_NAME_PREPAYMENT)
  private Boolean prepayment;

  public static final String SERIALIZED_NAME_RECENT_PAYMENT_DATE = "recentPaymentDate";
  @SerializedName(SERIALIZED_NAME_RECENT_PAYMENT_DATE)
  private LocalDate recentPaymentDate;

  public static final String SERIALIZED_NAME_RUN_HOUR = "runHour";
  @SerializedName(SERIALIZED_NAME_RUN_HOUR)
  private Integer runHour;

  public static final String SERIALIZED_NAME_STANDALONE = "standalone";
  @SerializedName(SERIALIZED_NAME_STANDALONE)
  private Boolean standalone;

  public static final String SERIALIZED_NAME_START_DATE = "startDate";
  @SerializedName(SERIALIZED_NAME_START_DATE)
  private String startDate;

  /**
   * The status of the payment schedule.  - Active: There is still payment schedule item to process. - Canceled: After a payment schedule is canceled by the user, the schedule is marked as `Canceled`. - Completed: After all payment schedule items are processed, the schedule is marked as `Completed`. 
   */
  @JsonAdapter(StatusEnum.Adapter.class)
  public enum StatusEnum {
    ACTIVE("Active"),
    
    CANCELED("Canceled"),
    
    COMPLETED("Completed");

    private String value;

    StatusEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static StatusEnum fromValue(String value) {
      for (StatusEnum b : StatusEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

    public static class Adapter extends TypeAdapter {
      @Override
      public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public StatusEnum read(final JsonReader jsonReader) throws IOException {
        String value =  jsonReader.nextString();
        return StatusEnum.fromValue(value);
      }
    }

    public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      String value = jsonElement.getAsString();
      StatusEnum.fromValue(value);
    }
  }

  public static final String SERIALIZED_NAME_STATUS = "status";
  @SerializedName(SERIALIZED_NAME_STATUS)
  private StatusEnum status;

  public static final String SERIALIZED_NAME_SUCCESS = "success";
  @SerializedName(SERIALIZED_NAME_SUCCESS)
  private Boolean success;

  public static final String SERIALIZED_NAME_TOTAL_AMOUNT = "totalAmount";
  @SerializedName(SERIALIZED_NAME_TOTAL_AMOUNT)
  private BigDecimal totalAmount;

  public static final String SERIALIZED_NAME_TOTAL_PAYMENTS_ERRORED = "totalPaymentsErrored";
  @SerializedName(SERIALIZED_NAME_TOTAL_PAYMENTS_ERRORED)
  private Integer totalPaymentsErrored;

  public static final String SERIALIZED_NAME_TOTAL_PAYMENTS_PROCESSED = "totalPaymentsProcessed";
  @SerializedName(SERIALIZED_NAME_TOTAL_PAYMENTS_PROCESSED)
  private Integer totalPaymentsProcessed;

  public static final String SERIALIZED_NAME_UPDATED_BY_ID = "updatedById";
  @SerializedName(SERIALIZED_NAME_UPDATED_BY_ID)
  private String updatedById;

  public static final String SERIALIZED_NAME_UPDATED_DATE = "updatedDate";
  @SerializedName(SERIALIZED_NAME_UPDATED_DATE)
  private String updatedDate;

  public PaymentSchedule() {
  }

  public PaymentSchedule accountId(String accountId) {
    this.accountId = accountId;
    return this;
  }

  /**
   * ID of the account that owns the payment schedule. 
   * @return accountId
   */
  @javax.annotation.Nullable
  public String getAccountId() {
    return accountId;
  }

  public void setAccountId(String accountId) {
    this.accountId = accountId;
  }


  public PaymentSchedule accountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
    return this;
  }

  /**
   * Number of the account that owns the payment schedule. 
   * @return accountNumber
   */
  @javax.annotation.Nullable
  public String getAccountNumber() {
    return accountNumber;
  }

  public void setAccountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
  }


  public PaymentSchedule billingDocument(PaymentScheduleBillingDocument billingDocument) {
    this.billingDocument = billingDocument;
    return this;
  }

  /**
   * Get billingDocument
   * @return billingDocument
   */
  @javax.annotation.Nullable
  public PaymentScheduleBillingDocument getBillingDocument() {
    return billingDocument;
  }

  public void setBillingDocument(PaymentScheduleBillingDocument billingDocument) {
    this.billingDocument = billingDocument;
  }


  public PaymentSchedule cancelDate(String cancelDate) {
    this.cancelDate = cancelDate;
    return this;
  }

  /**
   * The date when the payment schedule item was cancelled. 
   * @return cancelDate
   */
  @javax.annotation.Nullable
  public String getCancelDate() {
    return cancelDate;
  }

  public void setCancelDate(String cancelDate) {
    this.cancelDate = cancelDate;
  }


  public PaymentSchedule cancelledById(String cancelledById) {
    this.cancelledById = cancelledById;
    return this;
  }

  /**
   * The ID of the user who cancel the payment schedule item. 
   * @return cancelledById
   */
  @javax.annotation.Nullable
  public String getCancelledById() {
    return cancelledById;
  }

  public void setCancelledById(String cancelledById) {
    this.cancelledById = cancelledById;
  }


  public PaymentSchedule cancelledOn(String cancelledOn) {
    this.cancelledOn = cancelledOn;
    return this;
  }

  /**
   * The date and time when the payment schedule item was cancelled. 
   * @return cancelledOn
   */
  @javax.annotation.Nullable
  public String getCancelledOn() {
    return cancelledOn;
  }

  public void setCancelledOn(String cancelledOn) {
    this.cancelledOn = cancelledOn;
  }


  public PaymentSchedule createdById(String createdById) {
    this.createdById = createdById;
    return this;
  }

  /**
   * The ID of the user who created this payment schedule. 
   * @return createdById
   */
  @javax.annotation.Nullable
  public String getCreatedById() {
    return createdById;
  }

  public void setCreatedById(String createdById) {
    this.createdById = createdById;
  }


  public PaymentSchedule createdDate(String createdDate) {
    this.createdDate = createdDate;
    return this;
  }

  /**
   * The date and time the payment schedule is created. 
   * @return createdDate
   */
  @javax.annotation.Nullable
  public String getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(String createdDate) {
    this.createdDate = createdDate;
  }


  public PaymentSchedule description(String description) {
    this.description = description;
    return this;
  }

  /**
   * The description of the payment schedule. 
   * @return description
   */
  @javax.annotation.Nullable
  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }


  public PaymentSchedule id(String id) {
    this.id = id;
    return this;
  }

  /**
   * ID of the payment schedule. 
   * @return id
   */
  @javax.annotation.Nullable
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }


  public PaymentSchedule isCustom(Boolean isCustom) {
    this.isCustom = isCustom;
    return this;
  }

  /**
   * Indicates if the payment schedule is a custom payment schedule. 
   * @return isCustom
   */
  @javax.annotation.Nullable
  public Boolean getIsCustom() {
    return isCustom;
  }

  public void setIsCustom(Boolean isCustom) {
    this.isCustom = isCustom;
  }


  public PaymentSchedule items(List items) {
    this.items = items;
    return this;
  }

  public PaymentSchedule addItemsItem(PaymentScheduleItem itemsItem) {
    if (this.items == null) {
      this.items = new ArrayList<>();
    }
    this.items.add(itemsItem);
    return this;
  }

  /**
   * Container for payment schedule items. 
   * @return items
   */
  @javax.annotation.Nullable
  public List getItems() {
    return items;
  }

  public void setItems(List items) {
    this.items = items;
  }


  public PaymentSchedule nextPaymentDate(String nextPaymentDate) {
    this.nextPaymentDate = nextPaymentDate;
    return this;
  }

  /**
   * The date the next payment will be processed. 
   * @return nextPaymentDate
   */
  @javax.annotation.Nullable
  public String getNextPaymentDate() {
    return nextPaymentDate;
  }

  public void setNextPaymentDate(String nextPaymentDate) {
    this.nextPaymentDate = nextPaymentDate;
  }


  public PaymentSchedule occurrences(Integer occurrences) {
    this.occurrences = occurrences;
    return this;
  }

  /**
   * The number of payment schedule items that are created by this payment schedule. 
   * @return occurrences
   */
  @javax.annotation.Nullable
  public Integer getOccurrences() {
    return occurrences;
  }

  public void setOccurrences(Integer occurrences) {
    this.occurrences = occurrences;
  }


  public PaymentSchedule paymentOption(List paymentOption) {
    this.paymentOption = paymentOption;
    return this;
  }

  public PaymentSchedule addPaymentOptionItem(PaymentSchedulePaymentOptionFields paymentOptionItem) {
    if (this.paymentOption == null) {
      this.paymentOption = new ArrayList<>();
    }
    this.paymentOption.add(paymentOptionItem);
    return this;
  }

  /**
   * Container for the paymentOption items, which describe the transactional level rules for processing payments. Currently, only the Gateway Options type is supported.  `paymentOption` of the payment schedule takes precedence over `paymentOption` of the payment schedule item.  This field is only available if `zuora-version` is set to `337.0` or later. 
   * @return paymentOption
   */
  @javax.annotation.Nullable
  public List getPaymentOption() {
    return paymentOption;
  }

  public void setPaymentOption(List paymentOption) {
    this.paymentOption = paymentOption;
  }


  public PaymentSchedule paymentScheduleNumber(String paymentScheduleNumber) {
    this.paymentScheduleNumber = paymentScheduleNumber;
    return this;
  }

  /**
   * Number of the payment schedule. 
   * @return paymentScheduleNumber
   */
  @javax.annotation.Nullable
  public String getPaymentScheduleNumber() {
    return paymentScheduleNumber;
  }

  public void setPaymentScheduleNumber(String paymentScheduleNumber) {
    this.paymentScheduleNumber = paymentScheduleNumber;
  }


  public PaymentSchedule period(String period) {
    this.period = period;
    return this;
  }

  /**
   * For recurring payment schedule only. The period of payment generation. Available values include: `Monthly`, `Weekly`, `BiWeekly`.  Return `null` for custom payment schedules. 
   * @return period
   */
  @javax.annotation.Nullable
  public String getPeriod() {
    return period;
  }

  public void setPeriod(String period) {
    this.period = period;
  }


  public PaymentSchedule prepayment(Boolean prepayment) {
    this.prepayment = prepayment;
    return this;
  }

  /**
   * Indicates whether the payments created by the payment schedule are used as a reserved payment. This field is available only if the prepaid cash drawdown permission is enabled. See [Prepaid Cash with Drawdown](https://knowledgecenter.zuora.com/Zuora_Billing/Billing_and_Invoicing/JA_Advanced_Consumption_Billing/Prepaid_Cash_with_Drawdown) for more information. 
   * @return prepayment
   */
  @javax.annotation.Nullable
  public Boolean getPrepayment() {
    return prepayment;
  }

  public void setPrepayment(Boolean prepayment) {
    this.prepayment = prepayment;
  }


  public PaymentSchedule recentPaymentDate(LocalDate recentPaymentDate) {
    this.recentPaymentDate = recentPaymentDate;
    return this;
  }

  /**
   * The date the last payment was processed. 
   * @return recentPaymentDate
   */
  @javax.annotation.Nullable
  public LocalDate getRecentPaymentDate() {
    return recentPaymentDate;
  }

  public void setRecentPaymentDate(LocalDate recentPaymentDate) {
    this.recentPaymentDate = recentPaymentDate;
  }


  public PaymentSchedule runHour(Integer runHour) {
    this.runHour = runHour;
    return this;
  }

  /**
   * [0,1,2,~,22,23]  At which hour in the day in the tenant’s timezone this payment will be collected.  Return `0` for custom payment schedules. 
   * @return runHour
   */
  @javax.annotation.Nullable
  public Integer getRunHour() {
    return runHour;
  }

  public void setRunHour(Integer runHour) {
    this.runHour = runHour;
  }


  public PaymentSchedule standalone(Boolean standalone) {
    this.standalone = standalone;
    return this;
  }

  /**
   * Indicates if the payments that the payment schedule created are standalone payments. 
   * @return standalone
   */
  @javax.annotation.Nullable
  public Boolean getStandalone() {
    return standalone;
  }

  public void setStandalone(Boolean standalone) {
    this.standalone = standalone;
  }


  public PaymentSchedule startDate(String startDate) {
    this.startDate = startDate;
    return this;
  }

  /**
   * The date when the first payment of this payment schedule is proccessed. 
   * @return startDate
   */
  @javax.annotation.Nullable
  public String getStartDate() {
    return startDate;
  }

  public void setStartDate(String startDate) {
    this.startDate = startDate;
  }


  public PaymentSchedule status(StatusEnum status) {
    this.status = status;
    return this;
  }

  /**
   * The status of the payment schedule.  - Active: There is still payment schedule item to process. - Canceled: After a payment schedule is canceled by the user, the schedule is marked as `Canceled`. - Completed: After all payment schedule items are processed, the schedule is marked as `Completed`. 
   * @return status
   */
  @javax.annotation.Nullable
  public StatusEnum getStatus() {
    return status;
  }

  public void setStatus(StatusEnum status) {
    this.status = status;
  }


  public PaymentSchedule success(Boolean success) {
    this.success = success;
    return this;
  }

  /**
   * Returns `true` if the request was processed successfully. 
   * @return success
   */
  @javax.annotation.Nullable
  public Boolean getSuccess() {
    return success;
  }

  public void setSuccess(Boolean success) {
    this.success = success;
  }


  public PaymentSchedule totalAmount(BigDecimal totalAmount) {
    this.totalAmount = totalAmount;
    return this;
  }

  /**
   * The total amount that will be collected by the payment schedule. 
   * @return totalAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getTotalAmount() {
    return totalAmount;
  }

  public void setTotalAmount(BigDecimal totalAmount) {
    this.totalAmount = totalAmount;
  }


  public PaymentSchedule totalPaymentsErrored(Integer totalPaymentsErrored) {
    this.totalPaymentsErrored = totalPaymentsErrored;
    return this;
  }

  /**
   * The number of errored payments. 
   * @return totalPaymentsErrored
   */
  @javax.annotation.Nullable
  public Integer getTotalPaymentsErrored() {
    return totalPaymentsErrored;
  }

  public void setTotalPaymentsErrored(Integer totalPaymentsErrored) {
    this.totalPaymentsErrored = totalPaymentsErrored;
  }


  public PaymentSchedule totalPaymentsProcessed(Integer totalPaymentsProcessed) {
    this.totalPaymentsProcessed = totalPaymentsProcessed;
    return this;
  }

  /**
   * The number of processed payments. 
   * @return totalPaymentsProcessed
   */
  @javax.annotation.Nullable
  public Integer getTotalPaymentsProcessed() {
    return totalPaymentsProcessed;
  }

  public void setTotalPaymentsProcessed(Integer totalPaymentsProcessed) {
    this.totalPaymentsProcessed = totalPaymentsProcessed;
  }


  public PaymentSchedule updatedById(String updatedById) {
    this.updatedById = updatedById;
    return this;
  }

  /**
   * The ID of the user who last updated this payment schedule. 
   * @return updatedById
   */
  @javax.annotation.Nullable
  public String getUpdatedById() {
    return updatedById;
  }

  public void setUpdatedById(String updatedById) {
    this.updatedById = updatedById;
  }


  public PaymentSchedule updatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
    return this;
  }

  /**
   * The date and time the payment schedule is last updated. 
   * @return updatedDate
   */
  @javax.annotation.Nullable
  public String getUpdatedDate() {
    return updatedDate;
  }

  public void setUpdatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the PaymentSchedule instance itself
   */
  public PaymentSchedule putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    PaymentSchedule paymentSchedule = (PaymentSchedule) o;
    return Objects.equals(this.accountId, paymentSchedule.accountId) &&
        Objects.equals(this.accountNumber, paymentSchedule.accountNumber) &&
        Objects.equals(this.billingDocument, paymentSchedule.billingDocument) &&
        Objects.equals(this.cancelDate, paymentSchedule.cancelDate) &&
        Objects.equals(this.cancelledById, paymentSchedule.cancelledById) &&
        Objects.equals(this.cancelledOn, paymentSchedule.cancelledOn) &&
        Objects.equals(this.createdById, paymentSchedule.createdById) &&
        Objects.equals(this.createdDate, paymentSchedule.createdDate) &&
        Objects.equals(this.description, paymentSchedule.description) &&
        Objects.equals(this.id, paymentSchedule.id) &&
        Objects.equals(this.isCustom, paymentSchedule.isCustom) &&
        Objects.equals(this.items, paymentSchedule.items) &&
        Objects.equals(this.nextPaymentDate, paymentSchedule.nextPaymentDate) &&
        Objects.equals(this.occurrences, paymentSchedule.occurrences) &&
        Objects.equals(this.paymentOption, paymentSchedule.paymentOption) &&
        Objects.equals(this.paymentScheduleNumber, paymentSchedule.paymentScheduleNumber) &&
        Objects.equals(this.period, paymentSchedule.period) &&
        Objects.equals(this.prepayment, paymentSchedule.prepayment) &&
        Objects.equals(this.recentPaymentDate, paymentSchedule.recentPaymentDate) &&
        Objects.equals(this.runHour, paymentSchedule.runHour) &&
        Objects.equals(this.standalone, paymentSchedule.standalone) &&
        Objects.equals(this.startDate, paymentSchedule.startDate) &&
        Objects.equals(this.status, paymentSchedule.status) &&
        Objects.equals(this.success, paymentSchedule.success) &&
        Objects.equals(this.totalAmount, paymentSchedule.totalAmount) &&
        Objects.equals(this.totalPaymentsErrored, paymentSchedule.totalPaymentsErrored) &&
        Objects.equals(this.totalPaymentsProcessed, paymentSchedule.totalPaymentsProcessed) &&
        Objects.equals(this.updatedById, paymentSchedule.updatedById) &&
        Objects.equals(this.updatedDate, paymentSchedule.updatedDate)&&
        Objects.equals(this.additionalProperties, paymentSchedule.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(accountId, accountNumber, billingDocument, cancelDate, cancelledById, cancelledOn, createdById, createdDate, description, id, isCustom, items, nextPaymentDate, occurrences, paymentOption, paymentScheduleNumber, period, prepayment, recentPaymentDate, runHour, standalone, startDate, status, success, totalAmount, totalPaymentsErrored, totalPaymentsProcessed, updatedById, updatedDate, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class PaymentSchedule {\n");
    sb.append("    accountId: ").append(toIndentedString(accountId)).append("\n");
    sb.append("    accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
    sb.append("    billingDocument: ").append(toIndentedString(billingDocument)).append("\n");
    sb.append("    cancelDate: ").append(toIndentedString(cancelDate)).append("\n");
    sb.append("    cancelledById: ").append(toIndentedString(cancelledById)).append("\n");
    sb.append("    cancelledOn: ").append(toIndentedString(cancelledOn)).append("\n");
    sb.append("    createdById: ").append(toIndentedString(createdById)).append("\n");
    sb.append("    createdDate: ").append(toIndentedString(createdDate)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    isCustom: ").append(toIndentedString(isCustom)).append("\n");
    sb.append("    items: ").append(toIndentedString(items)).append("\n");
    sb.append("    nextPaymentDate: ").append(toIndentedString(nextPaymentDate)).append("\n");
    sb.append("    occurrences: ").append(toIndentedString(occurrences)).append("\n");
    sb.append("    paymentOption: ").append(toIndentedString(paymentOption)).append("\n");
    sb.append("    paymentScheduleNumber: ").append(toIndentedString(paymentScheduleNumber)).append("\n");
    sb.append("    period: ").append(toIndentedString(period)).append("\n");
    sb.append("    prepayment: ").append(toIndentedString(prepayment)).append("\n");
    sb.append("    recentPaymentDate: ").append(toIndentedString(recentPaymentDate)).append("\n");
    sb.append("    runHour: ").append(toIndentedString(runHour)).append("\n");
    sb.append("    standalone: ").append(toIndentedString(standalone)).append("\n");
    sb.append("    startDate: ").append(toIndentedString(startDate)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    success: ").append(toIndentedString(success)).append("\n");
    sb.append("    totalAmount: ").append(toIndentedString(totalAmount)).append("\n");
    sb.append("    totalPaymentsErrored: ").append(toIndentedString(totalPaymentsErrored)).append("\n");
    sb.append("    totalPaymentsProcessed: ").append(toIndentedString(totalPaymentsProcessed)).append("\n");
    sb.append("    updatedById: ").append(toIndentedString(updatedById)).append("\n");
    sb.append("    updatedDate: ").append(toIndentedString(updatedDate)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("accountId");
    openapiFields.add("accountNumber");
    openapiFields.add("billingDocument");
    openapiFields.add("cancelDate");
    openapiFields.add("cancelledById");
    openapiFields.add("cancelledOn");
    openapiFields.add("createdById");
    openapiFields.add("createdDate");
    openapiFields.add("description");
    openapiFields.add("id");
    openapiFields.add("isCustom");
    openapiFields.add("items");
    openapiFields.add("nextPaymentDate");
    openapiFields.add("occurrences");
    openapiFields.add("paymentOption");
    openapiFields.add("paymentScheduleNumber");
    openapiFields.add("period");
    openapiFields.add("prepayment");
    openapiFields.add("recentPaymentDate");
    openapiFields.add("runHour");
    openapiFields.add("standalone");
    openapiFields.add("startDate");
    openapiFields.add("status");
    openapiFields.add("success");
    openapiFields.add("totalAmount");
    openapiFields.add("totalPaymentsErrored");
    openapiFields.add("totalPaymentsProcessed");
    openapiFields.add("updatedById");
    openapiFields.add("updatedDate");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
  }

  /**
   * Validates the JSON Element and throws an exception if issues found
   *
   * @param jsonElement JSON Element
   * @throws IOException if the JSON Element is invalid with respect to PaymentSchedule
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!PaymentSchedule.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in PaymentSchedule is not found in the empty JSON string", PaymentSchedule.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("accountId") != null && !jsonObj.get("accountId").isJsonNull()) && !jsonObj.get("accountId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountId").toString()));
      }
      if ((jsonObj.get("accountNumber") != null && !jsonObj.get("accountNumber").isJsonNull()) && !jsonObj.get("accountNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountNumber").toString()));
      }
      // validate the optional field `billingDocument`
      if (jsonObj.get("billingDocument") != null && !jsonObj.get("billingDocument").isJsonNull()) {
        PaymentScheduleBillingDocument.validateJsonElement(jsonObj.get("billingDocument"));
      }
      if ((jsonObj.get("cancelDate") != null && !jsonObj.get("cancelDate").isJsonNull()) && !jsonObj.get("cancelDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `cancelDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cancelDate").toString()));
      }
      if ((jsonObj.get("cancelledById") != null && !jsonObj.get("cancelledById").isJsonNull()) && !jsonObj.get("cancelledById").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `cancelledById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cancelledById").toString()));
      }
      if ((jsonObj.get("cancelledOn") != null && !jsonObj.get("cancelledOn").isJsonNull()) && !jsonObj.get("cancelledOn").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `cancelledOn` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cancelledOn").toString()));
      }
      if ((jsonObj.get("createdById") != null && !jsonObj.get("createdById").isJsonNull()) && !jsonObj.get("createdById").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `createdById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdById").toString()));
      }
      if ((jsonObj.get("createdDate") != null && !jsonObj.get("createdDate").isJsonNull()) && !jsonObj.get("createdDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `createdDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdDate").toString()));
      }
      if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
      }
      // ensure the optional json data is an array if present
      if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull() && !jsonObj.get("items").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString()));
      }
      if ((jsonObj.get("nextPaymentDate") != null && !jsonObj.get("nextPaymentDate").isJsonNull()) && !jsonObj.get("nextPaymentDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `nextPaymentDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nextPaymentDate").toString()));
      }
      if (jsonObj.get("paymentOption") != null && !jsonObj.get("paymentOption").isJsonNull()) {
        JsonArray jsonArraypaymentOption = jsonObj.getAsJsonArray("paymentOption");
        if (jsonArraypaymentOption != null) {
          // ensure the json data is an array
          if (!jsonObj.get("paymentOption").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `paymentOption` to be an array in the JSON string but got `%s`", jsonObj.get("paymentOption").toString()));
          }

          // validate the optional field `paymentOption` (array)
          for (int i = 0; i < jsonArraypaymentOption.size(); i++) {
            PaymentSchedulePaymentOptionFields.validateJsonElement(jsonArraypaymentOption.get(i));
          };
        }
      }
      if ((jsonObj.get("paymentScheduleNumber") != null && !jsonObj.get("paymentScheduleNumber").isJsonNull()) && !jsonObj.get("paymentScheduleNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `paymentScheduleNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentScheduleNumber").toString()));
      }
      if ((jsonObj.get("period") != null && !jsonObj.get("period").isJsonNull()) && !jsonObj.get("period").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `period` to be a primitive type in the JSON string but got `%s`", jsonObj.get("period").toString()));
      }
      if ((jsonObj.get("startDate") != null && !jsonObj.get("startDate").isJsonNull()) && !jsonObj.get("startDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `startDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("startDate").toString()));
      }
      if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
      }
      // validate the optional field `status`
      if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
        StatusEnum.validateJsonElement(jsonObj.get("status"));
      }
      if ((jsonObj.get("updatedById") != null && !jsonObj.get("updatedById").isJsonNull()) && !jsonObj.get("updatedById").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `updatedById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedById").toString()));
      }
      if ((jsonObj.get("updatedDate") != null && !jsonObj.get("updatedDate").isJsonNull()) && !jsonObj.get("updatedDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `updatedDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedDate").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!PaymentSchedule.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'PaymentSchedule' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(PaymentSchedule.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, PaymentSchedule value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");

             // support null values
             out.beginObject();
             Iterator iterator = obj.entrySet().iterator();
             while(iterator.hasNext()) {
                 Map.Entry e = (Map.Entry) iterator.next();
                 out.name((String)e.getKey());
                 elementAdapter.write(out, e.getValue());
             }

             // end

             // serialize additional properties
             if (value.getAdditionalProperties() != null) {
               // support null values
               boolean oldSerializeNulls = out.getSerializeNulls();
               out.setSerializeNulls(true); //force serialize
               // end
               for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else if (entry.getValue() == null)
                    obj.add(entry.getKey(), null);
                 else {
                   JsonElement jsonElement = gson.toJsonTree(entry.getValue());
                   if (jsonElement.isJsonArray()) {
                     obj.add(entry.getKey(), jsonElement.getAsJsonArray());
                   } else {
                     obj.add(entry.getKey(), jsonElement.getAsJsonObject());
                   }
                 }
                 out.name((String)entry.getKey());
                 elementAdapter.write(out, obj.get(entry.getKey()));
               }
               out.setSerializeNulls(oldSerializeNulls); //restore
             }
             out.endObject();

           }

           @Override
           public PaymentSchedule read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             PaymentSchedule instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

  /**
   * Create an instance of PaymentSchedule given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of PaymentSchedule
   * @throws IOException if the JSON string is invalid with respect to PaymentSchedule
   */
  public static PaymentSchedule fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, PaymentSchedule.class);
  }

  /**
   * Convert an instance of PaymentSchedule to an JSON string
   *
   * @return JSON string
   */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy