package com.stripe.model;

import com.stripe.exception.StripeException;
import com.stripe.net.ApiResource;
import com.stripe.net.RequestOptions;

import java.util.Map;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Coupon extends ApiResource implements MetadataStore<Coupon>, HasId {
  @Getter(onMethod = @__({@Override})) String id;
  String object;
  Long amountOff;
  Long created;
  String currency;
  String duration;
  Long durationInMonths;
  Boolean livemode;
  Long maxRedemptions;
  @Getter(onMethod = @__({@Override})) Map<String, String> metadata;
  String name;
  Long percentOff;
  Long redeemBy;
  Long timesRedeemed;
  Boolean valid;
  Boolean deleted;

  // <editor-fold desc="create">
  /**
   * Create a coupon.
   */
  public static Coupon create(Map<String, Object> params) throws StripeException {
    return create(params, (RequestOptions) null);
  }

  /**
   * Create a coupon.
   */
  public static Coupon create(Map<String, Object> params, RequestOptions options)
      throws StripeException {
    return request(RequestMethod.POST, classUrl(Coupon.class), params, Coupon.class, options);
  }
  // </editor-fold>

  // <editor-fold desc="delete">
  /**
   * Delete a coupon.
   */
  public Coupon delete() throws StripeException {
    return delete((RequestOptions) null);
  }

  /**
   * Delete a coupon.
   */
  public Coupon delete(RequestOptions options) throws StripeException {
    return request(RequestMethod.DELETE, instanceUrl(Coupon.class, this.id), null,
        Coupon.class, options);
  }
  // </editor-fold>

  // <editor-fold desc="list">
  /**
   * List all coupons.
   */
  public static CouponCollection list(Map<String, Object> params) throws StripeException {
    return list(params, null);
  }

  /**
   * List all coupons.
   */
  public static CouponCollection list(Map<String, Object> params, RequestOptions options)
      throws StripeException {
    return requestCollection(classUrl(Coupon.class), params, CouponCollection.class, options);
  }
  // </editor-fold>

  // <editor-fold desc="retrieve">
  /**
   * Retrieve a coupon.
   */
  public static Coupon retrieve(String id) throws StripeException {
    return retrieve(id, (RequestOptions) null);
  }

  /**
   * Retrieve a coupon.
   */
  public static Coupon retrieve(String id, RequestOptions options) throws StripeException {
    return retrieve(id, null, options);
  }

  /**
   * Retrieve a coupon.
   */
  public static Coupon retrieve(String id, Map<String, Object> params, RequestOptions options)
      throws StripeException {
    return request(RequestMethod.GET, instanceUrl(Coupon.class, id), params, Coupon.class, options);
  }
  // </editor-fold>

  // <editor-fold desc="update">
  /**
   * Update a coupon.
   */
  @Override
  public Coupon update(Map<String, Object> params) throws StripeException {
    return update(params, (RequestOptions) null);
  }

  /**
   * Update a coupon.
   */
  @Override
  public Coupon update(Map<String, Object> params, RequestOptions options) throws StripeException {
    return request(RequestMethod.POST, instanceUrl(Coupon.class, this.id), params, Coupon.class,
        options);
  }
  // </editor-fold>
}

@@ -139,16 +139,45 @@
 tions;%0A%0A
+import java.math.BigDecimal;%0A
 import j
@@ -190,16 +190,16 @@
 il.Map;%0A
-
 %0Aimport 
@@ -525,16 +525,35 @@
 rrency;%0A
+  Boolean deleted;%0A
   String
@@ -717,20 +717,26 @@
 name;%0A  
-Long
+BigDecimal
  percent
@@ -796,33 +796,345 @@
  valid;%0A
+%0A
   
-Boolean deleted
+/**%0A   * The %7B@code percent_off_precise%7D attribute.%0A   *%0A   * @return the %7B@code percent_off_precise%7D attribute%0A   * @deprecated Prefer using the %7B@link #percentOff%7D attribute instead.%0A   * @see %3Ca href=%22https://stripe.com/docs/upgrades#2018-07-27%22%3EAPI version 2018-07-27%3C/a%3E%0A   */%0A  @Deprecated%0A  BigDecimal percentOffPrecise
 ;%0A%0A  // 

Change percentOff to BigDecimal, and add percentOffPrecise