com.cardpay.sdk.model.SubscriptionUpdateRequestSubscriptionData Maven / Gradle / Ivy
/*
* CardPay REST API
* Welcome to the CardPay REST API. The CardPay API uses HTTP verbs and a [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) resources endpoint structure (see more info about REST). Request and response payloads are formatted as JSON. Merchant uses API to create payments, refunds, payouts or recurrings, check or update transaction status and get information about created transactions. In API authentication process based on [OAuth 2.0](https://oauth.net/2/) standard. For recent changes see changelog section.
*
* OpenAPI spec version: 3.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.cardpay.sdk.model;
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 java.io.IOException;
import java.math.BigDecimal;
import java.time.OffsetDateTime;
import lombok.Data;
@Data
public class SubscriptionUpdateRequestSubscriptionData {
@SerializedName("amount")
private BigDecimal amount = null;
@SerializedName("next_payment_date")
private OffsetDateTime nextPaymentDate = null;
@SerializedName("plan")
private Plan plan = null;
/**
* Set status and action on subscription. Mandatory for `CHANGE_STATUS` operation only: `CANCELLED` - cancels and ends `INACTIVE` - **for scheduled only**; suspends `ACTIVE` - **for scheduled only**; resumes after suspend
*/
@JsonAdapter(StatusToEnum.Adapter.class)
public enum StatusToEnum {
ACTIVE("ACTIVE"),
INACTIVE("INACTIVE"),
CANCELLED("CANCELLED"),
PAST_DUE("PAST_DUE"),
PENDING("PENDING"),
COMPLETED("COMPLETED"),
CARD_EXPIRED("CARD_EXPIRED"),
ACTIVATION_FAILED("ACTIVATION_FAILED"),
UNPAID("UNPAID"),
WAITING("WAITING");
private String value;
StatusToEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static StatusToEnum fromValue(String text) {
for (StatusToEnum b : StatusToEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final StatusToEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public StatusToEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return StatusToEnum.fromValue(String.valueOf(value));
}
}
}
@SerializedName("status_to")
private StatusToEnum statusTo = null;
@SerializedName("units")
private Integer units = null;
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
/**
* @param amount Set amount of repayment with dot as a decimal separator. Skip this attribute from request to repay the rest of subscription's amount and complete it. Mandatory for `REPAYMENT` operation only with exact payment amount.
* @return bean instance
**/
public SubscriptionUpdateRequestSubscriptionData amount(BigDecimal amount) {
this.amount = amount;
return this;
}
public void setNextPaymentDate(OffsetDateTime nextPaymentDate) {
this.nextPaymentDate = nextPaymentDate;
}
/**
* @param nextPaymentDate nextPaymentDate
* @return bean instance
**/
public SubscriptionUpdateRequestSubscriptionData nextPaymentDate(OffsetDateTime nextPaymentDate) {
this.nextPaymentDate = nextPaymentDate;
return this;
}
public void setPlan(Plan plan) {
this.plan = plan;
}
/**
* @param plan Plan data to which the subscription will be changed
* @return bean instance
**/
public SubscriptionUpdateRequestSubscriptionData plan(Plan plan) {
this.plan = plan;
return this;
}
public void setStatusTo(StatusToEnum statusTo) {
this.statusTo = statusTo;
}
/**
* @param statusTo Set status and action on subscription. Mandatory for `CHANGE_STATUS` operation only: `CANCELLED` - cancels and ends `INACTIVE` - **for scheduled only**; suspends `ACTIVE` - **for scheduled only**; resumes after suspend
* @return bean instance
**/
public SubscriptionUpdateRequestSubscriptionData statusTo(StatusToEnum statusTo) {
this.statusTo = statusTo;
return this;
}
public void setUnits(Integer units) {
this.units = units;
}
/**
* @param units New quantity of subscription units
* @return bean instance
**/
public SubscriptionUpdateRequestSubscriptionData units(Integer units) {
this.units = units;
return this;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("SubscriptionUpdateRequestSubscriptionData( ");
if (amount != null) sb.append("amount=").append(amount.toString()).append("; ");
if (nextPaymentDate != null) sb.append("nextPaymentDate=").append(nextPaymentDate.toString()).append("; ");
if (plan != null) sb.append("plan=").append(plan.toString()).append("; ");
if (statusTo != null) sb.append("statusTo=").append(statusTo.toString()).append("; ");
if (units != null) sb.append("units=").append(units.toString()).append("; ");
sb.append(")");
return sb.toString();
}
}