com.unzer.payment.Basket Maven / Gradle / Ivy
package com.unzer.payment;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Currency;
import java.util.List;
import java.util.Objects;
public class Basket extends BaseResource implements Resource {
private String id;
private Currency currencyCode;
private String orderId;
private BigDecimal totalValueGross;
private List basketItems = new ArrayList();
private String note;
@Deprecated
private BigDecimal amountTotalGross;
@Deprecated
private BigDecimal amountTotalVat;
@Deprecated
private BigDecimal amountTotalDiscount;
/**
* Currency code in ISO_4217 format
*/
public Currency getCurrencyCode() {
return currencyCode;
}
public Basket setCurrencyCode(Currency currencyCode) {
this.currencyCode = currencyCode;
return this;
}
/**
* A basket or shop reference ID sent from the shop’s back end.
* Must be equal to the orderID used for the authorization and/or charge trx belonging
* to the basket.
* If no value is provided, an order ID is automatically generated by the Unzer system.
*/
public String getOrderId() {
return orderId;
}
public Basket setOrderId(String orderId) {
this.orderId = orderId;
return this;
}
/**
* The total basket value (including VAT) of all basket items reduced/deducted by all discounts
* and vouchers.
*/
public BigDecimal getTotalValueGross() {
return totalValueGross;
}
/**
* The total basket value (including VAT) of all basket items reduced/deducted by all discounts
* and vouchers.
*/
public Basket setTotalValueGross(BigDecimal totalValueGross) {
this.totalValueGross = totalValueGross;
return this;
}
/**
* Get additional details of the basket.
*/
public String getNote() {
return note;
}
/**
* Set additional details for the basket.
*/
public Basket setNote(String note) {
this.note = note;
return this;
}
public Basket addBasketItem(BasketItem basketItem) {
getBasketItems().add(basketItem);
return this;
}
/**
* List of items in the basket
*/
public List getBasketItems() {
return basketItems;
}
public Basket setBasketItems(List basketItems) {
this.basketItems = basketItems;
return this;
}
/**
* Get generated unique id
*/
public String getId() {
return id;
}
/**
* Get basket id
*/
public Basket setId(String id) {
this.id = id;
return this;
}
@Deprecated
public BigDecimal getAmountTotalDiscount() {
return amountTotalDiscount;
}
@Deprecated
public Basket setAmountTotalDiscount(BigDecimal amountTotalDiscount) {
this.amountTotalDiscount = amountTotalDiscount;
return this;
}
@Deprecated
public BigDecimal getAmountTotalVat() {
return amountTotalVat;
}
@Deprecated
public Basket setAmountTotalVat(BigDecimal amountTotalVat) {
this.amountTotalVat = amountTotalVat;
return this;
}
@Deprecated
public BigDecimal getAmountTotalGross() {
return amountTotalGross;
}
@Deprecated
public Basket setAmountTotalGross(BigDecimal amountTotalGross) {
this.amountTotalGross = amountTotalGross;
return this;
}
@Override
protected String getResourceUrl() {
return Objects.isNull(this.totalValueGross)
? "/v1/baskets/"
: "/v2/baskets/";
}
}