com.stripe.model.giftcards.Card Maven / Gradle / Ivy
// File generated from our OpenAPI spec
package com.stripe.model.giftcards;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.HasId;
import com.stripe.model.MetadataStore;
import com.stripe.model.StripeObject;
import com.stripe.net.ApiRequest;
import com.stripe.net.ApiRequestParams;
import com.stripe.net.ApiResource;
import com.stripe.net.BaseAddress;
import com.stripe.net.RequestOptions;
import com.stripe.net.StripeResponseGetter;
import com.stripe.param.giftcards.CardCreateParams;
import com.stripe.param.giftcards.CardListParams;
import com.stripe.param.giftcards.CardRetrieveParams;
import com.stripe.param.giftcards.CardUpdateParams;
import com.stripe.param.giftcards.CardValidateParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* A gift card represents a single gift card owned by a customer, including the remaining balance,
* gift card code, and whether or not it is active.
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Card extends ApiResource implements HasId, MetadataStore {
/** Whether this gift card can be used or not. */
@SerializedName("active")
Boolean active;
/** The amount of funds available for new transactions. */
@SerializedName("amount_available")
Long amountAvailable;
/** The amount of funds marked as held. */
@SerializedName("amount_held")
Long amountHeld;
/** Code used to redeem this gift card. */
@SerializedName("code")
String code;
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;
/** The related Stripe objects that created this gift card. */
@SerializedName("created_by")
CreatedBy createdBy;
/**
* Three-letter ISO currency code,
* in lowercase. Must be a supported currency.
*/
@SerializedName("currency")
String currency;
/** Unique identifier for the object. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/**
* Set of key-value pairs that you can attach
* to an object. This can be useful for storing additional information about the object in a
* structured format.
*/
@Getter(onMethod_ = {@Override})
@SerializedName("metadata")
Map metadata;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* Equal to {@code gift_cards.card}.
*/
@SerializedName("object")
String object;
/** Transactions on this gift card. */
@SerializedName("transactions")
TransactionCollection transactions;
/** Creates a new gift card object. */
public static Card create(Map params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Creates a new gift card object. */
public static Card create(Map params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards";
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
return getGlobalResponseGetter().request(request, Card.class);
}
/** Creates a new gift card object. */
public static Card create(CardCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Creates a new gift card object. */
public static Card create(CardCreateParams params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards";
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, Card.class);
}
/** List gift cards for an account. */
public static CardCollection list(Map params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** List gift cards for an account. */
public static CardCollection list(Map params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards";
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
return getGlobalResponseGetter().request(request, CardCollection.class);
}
/** List gift cards for an account. */
public static CardCollection list(CardListParams params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** List gift cards for an account. */
public static CardCollection list(CardListParams params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards";
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.GET,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, CardCollection.class);
}
/** Retrieve a gift card by id. */
public static Card retrieve(String id) throws StripeException {
return retrieve(id, (Map) null, (RequestOptions) null);
}
/** Retrieve a gift card by id. */
public static Card retrieve(String id, RequestOptions options) throws StripeException {
return retrieve(id, (Map) null, options);
}
/** Retrieve a gift card by id. */
public static Card retrieve(String id, Map params, RequestOptions options)
throws StripeException {
String path = String.format("/v1/gift_cards/cards/%s", ApiResource.urlEncodeId(id));
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
return getGlobalResponseGetter().request(request, Card.class);
}
/** Retrieve a gift card by id. */
public static Card retrieve(String id, CardRetrieveParams params, RequestOptions options)
throws StripeException {
String path = String.format("/v1/gift_cards/cards/%s", ApiResource.urlEncodeId(id));
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.GET,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, Card.class);
}
/** Update a gift card. */
@Override
public Card update(Map params) throws StripeException {
return update(params, (RequestOptions) null);
}
/** Update a gift card. */
@Override
public Card update(Map params, RequestOptions options) throws StripeException {
String path = String.format("/v1/gift_cards/cards/%s", ApiResource.urlEncodeId(this.getId()));
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
return getResponseGetter().request(request, Card.class);
}
/** Update a gift card. */
public Card update(CardUpdateParams params) throws StripeException {
return update(params, (RequestOptions) null);
}
/** Update a gift card. */
public Card update(CardUpdateParams params, RequestOptions options) throws StripeException {
String path = String.format("/v1/gift_cards/cards/%s", ApiResource.urlEncodeId(this.getId()));
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options);
return getResponseGetter().request(request, Card.class);
}
/** Validates a gift card code, returning the matching gift card object if it exists. */
public static Card validate(Map params) throws StripeException {
return validate(params, (RequestOptions) null);
}
/** Validates a gift card code, returning the matching gift card object if it exists. */
public static Card validate(Map params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards/validate";
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
return getGlobalResponseGetter().request(request, Card.class);
}
/** Validates a gift card code, returning the matching gift card object if it exists. */
public static Card validate(CardValidateParams params) throws StripeException {
return validate(params, (RequestOptions) null);
}
/** Validates a gift card code, returning the matching gift card object if it exists. */
public static Card validate(CardValidateParams params, RequestOptions options)
throws StripeException {
String path = "/v1/gift_cards/cards/validate";
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, Card.class);
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class CreatedBy extends StripeObject {
@SerializedName("checkout")
Checkout checkout;
@SerializedName("order")
Order order;
@SerializedName("payment")
Payment payment;
/**
* The type of event that created this object.
*
* One of {@code checkout}, {@code order}, or {@code payment}.
*/
@SerializedName("type")
String type;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Checkout extends StripeObject {
/** The Stripe CheckoutSession that created this object. */
@SerializedName("checkout_session")
String checkoutSession;
/** The Stripe CheckoutSession LineItem that created this object. */
@SerializedName("line_item")
String lineItem;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Order extends StripeObject {
/** The Stripe Order LineItem that created this object. */
@SerializedName("line_item")
String lineItem;
/** The Stripe Order that created this object. */
@SerializedName("order")
String order;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Payment extends StripeObject {
/** The PaymentIntent that created this object. */
@SerializedName("payment_intent")
String paymentIntent;
}
}
@Override
public void setResponseGetter(StripeResponseGetter responseGetter) {
super.setResponseGetter(responseGetter);
trySetResponseGetter(createdBy, responseGetter);
trySetResponseGetter(transactions, responseGetter);
}
}