<|start_filename|>src/main/java/com/recurly/v3/resources/ShippingMethodMini.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;

public class ShippingMethodMini extends Resource {

  /** The internal name used identify the shipping method. */
  @SerializedName("code")
  @Expose
  private String code;

  /** Shipping Method ID */
  @SerializedName("id")
  @Expose
  private String id;

  /** The name of the shipping method displayed to customers. */
  @SerializedName("name")
  @Expose
  private String name;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  /** The internal name used identify the shipping method. */
  public String getCode() {
    return this.code;
  }

  /** @param code The internal name used identify the shipping method. */
  public void setCode(final String code) {
    this.code = code;
  }

  /** Shipping Method ID */
  public String getId() {
    return this.id;
  }

  /** @param id Shipping Method ID */
  public void setId(final String id) {
    this.id = id;
  }

  /** The name of the shipping method displayed to customers. */
  public String getName() {
    return this.name;
  }

  /** @param name The name of the shipping method displayed to customers. */
  public void setName(final String name) {
    this.name = name;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/TransactionPaymentGateway.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;

public class TransactionPaymentGateway extends Resource {

  @SerializedName("id")
  @Expose
  private String id;

  @SerializedName("name")
  @Expose
  private String name;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  @SerializedName("type")
  @Expose
  private String type;

  public String getId() {
    return this.id;
  }

  /** @param id */
  public void setId(final String id) {
    this.id = id;
  }

  public String getName() {
    return this.name;
  }

  /** @param name */
  public void setName(final String name) {
    this.name = name;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }

  public String getType() {
    return this.type;
  }

  /** @param type */
  public void setType(final String type) {
    this.type = type;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/Request.java<|end_filename|>
package com.recurly.v3;

public class Request {}


<|start_filename|>src/main/java/com/recurly/v3/resources/PlanHostedPages.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;

public class PlanHostedPages extends Resource {

  /**
   * If `true`, the customer will be sent directly to your `success_url` after a successful signup,
   * bypassing Recurly's hosted confirmation page.
   */
  @SerializedName("bypass_confirmation")
  @Expose
  private Boolean bypassConfirmation;

  /** URL to redirect to on canceled signup on the hosted payment pages. */
  @SerializedName("cancel_url")
  @Expose
  private String cancelUrl;

  /** Determines if the quantity field is displayed on the hosted pages for the plan. */
  @SerializedName("display_quantity")
  @Expose
  private Boolean displayQuantity;

  /** URL to redirect to after signup on the hosted payment pages. */
  @SerializedName("success_url")
  @Expose
  private String successUrl;

  /**
   * If `true`, the customer will be sent directly to your `success_url` after a successful signup,
   * bypassing Recurly's hosted confirmation page.
   */
  public Boolean getBypassConfirmation() {
    return this.bypassConfirmation;
  }

  /**
   * @param bypassConfirmation If `true`, the customer will be sent directly to your `success_url`
   *     after a successful signup, bypassing Recurly's hosted confirmation page.
   */
  public void setBypassConfirmation(final Boolean bypassConfirmation) {
    this.bypassConfirmation = bypassConfirmation;
  }

  /** URL to redirect to on canceled signup on the hosted payment pages. */
  public String getCancelUrl() {
    return this.cancelUrl;
  }

  /** @param cancelUrl URL to redirect to on canceled signup on the hosted payment pages. */
  public void setCancelUrl(final String cancelUrl) {
    this.cancelUrl = cancelUrl;
  }

  /** Determines if the quantity field is displayed on the hosted pages for the plan. */
  public Boolean getDisplayQuantity() {
    return this.displayQuantity;
  }

  /**
   * @param displayQuantity Determines if the quantity field is displayed on the hosted pages for
   *     the plan.
   */
  public void setDisplayQuantity(final Boolean displayQuantity) {
    this.displayQuantity = displayQuantity;
  }

  /** URL to redirect to after signup on the hosted payment pages. */
  public String getSuccessUrl() {
    return this.successUrl;
  }

  /** @param successUrl URL to redirect to after signup on the hosted payment pages. */
  public void setSuccessUrl(final String successUrl) {
    this.successUrl = successUrl;
  }
}


<|start_filename|>src/test/java/com/recurly/v3/fixtures/NestedResource.java<|end_filename|>
package com.recurly.v3.fixtures;

import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;

public class NestedResource extends Resource {
  @SerializedName("my_nested_string")
  private String myNestedString;
}


<|start_filename|>src/main/java/com/recurly/v3/FileSerializer.java<|end_filename|>
package com.recurly.v3;

import com.recurly.v3.resources.BinaryFile;
import java.lang.reflect.Type;

public class FileSerializer {
  public <T> T deserialize(byte[] responseBody, final Type resourceClass) {
    BinaryFile file = new BinaryFile();
    file.setData(responseBody);
    return (T) file;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/User.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;
import org.joda.time.DateTime;

public class User extends Resource {

  @SerializedName("created_at")
  @Expose
  private DateTime createdAt;

  @SerializedName("deleted_at")
  @Expose
  private DateTime deletedAt;

  @SerializedName("email")
  @Expose
  private String email;

  @SerializedName("first_name")
  @Expose
  private String firstName;

  @SerializedName("id")
  @Expose
  private String id;

  @SerializedName("last_name")
  @Expose
  private String lastName;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  @SerializedName("time_zone")
  @Expose
  private String timeZone;

  public DateTime getCreatedAt() {
    return this.createdAt;
  }

  /** @param createdAt */
  public void setCreatedAt(final DateTime createdAt) {
    this.createdAt = createdAt;
  }

  public DateTime getDeletedAt() {
    return this.deletedAt;
  }

  /** @param deletedAt */
  public void setDeletedAt(final DateTime deletedAt) {
    this.deletedAt = deletedAt;
  }

  public String getEmail() {
    return this.email;
  }

  /** @param email */
  public void setEmail(final String email) {
    this.email = email;
  }

  public String getFirstName() {
    return this.firstName;
  }

  /** @param firstName */
  public void setFirstName(final String firstName) {
    this.firstName = firstName;
  }

  public String getId() {
    return this.id;
  }

  /** @param id */
  public void setId(final String id) {
    this.id = id;
  }

  public String getLastName() {
    return this.lastName;
  }

  /** @param lastName */
  public void setLastName(final String lastName) {
    this.lastName = lastName;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }

  public String getTimeZone() {
    return this.timeZone;
  }

  /** @param timeZone */
  public void setTimeZone(final String timeZone) {
    this.timeZone = timeZone;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/NetworkException.java<|end_filename|>
package com.recurly.v3;

public class NetworkException extends RecurlyException {

  public NetworkException(Throwable cause) {
    super(cause);
  }
}


<|start_filename|>src/main/java/com/recurly/v3/requests/SubscriptionShippingUpdate.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.requests;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;
import com.recurly.v3.resources.*;

public class SubscriptionShippingUpdate extends Request {

  @SerializedName("address")
  @Expose
  private ShippingAddressCreate address;

  /** Assign a shipping address from the account's existing shipping addresses. */
  @SerializedName("address_id")
  @Expose
  private String addressId;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  public ShippingAddressCreate getAddress() {
    return this.address;
  }

  /** @param address */
  public void setAddress(final ShippingAddressCreate address) {
    this.address = address;
  }

  /** Assign a shipping address from the account's existing shipping addresses. */
  public String getAddressId() {
    return this.addressId;
  }

  /** @param addressId Assign a shipping address from the account's existing shipping addresses. */
  public void setAddressId(final String addressId) {
    this.addressId = addressId;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/ApiException.java<|end_filename|>
package com.recurly.v3;

import com.google.gson.annotations.Expose;
import com.recurly.v3.resources.ErrorMayHaveTransaction;

public class ApiException extends RecurlyException {

  @Expose public ErrorMayHaveTransaction error;
  private String message;

  public ApiException(final String message, final ErrorMayHaveTransaction e) {
    super(message);
    this.message = message;
    this.error = e;
  }

  public ErrorMayHaveTransaction getError() {
    return this.error;
  }

  public void setError(final ErrorMayHaveTransaction error) {
    this.error = error;
  }

  @Override
  public String getMessage() {
    final StringBuilder sb = new StringBuilder();
    sb.append(this.message);
    if (this.error != null && this.error.getParams() != null && this.error.getParams().size() > 0) {
      sb.append(" ");
      sb.append(this.error.getParams().toString());
    }
    return sb.toString();
  }
}


<|start_filename|>src/main/java/com/recurly/v3/http/HeaderInterceptor.java<|end_filename|>
package com.recurly.v3.http;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class HeaderInterceptor implements Interceptor {

  private final String apiVersion;
  private final String authToken;
  private static String USER_AGENT = buildUserAgent();

  public HeaderInterceptor(final String authToken, final String apiVersion) {
    this.apiVersion = apiVersion;
    this.authToken = authToken;
  }

  public Response intercept(final Chain chain) throws IOException {
    Request original = chain.request();

    Request.Builder builder =
        original
            .newBuilder()
            .header("Authorization", authToken)
            .header("Accept", "application/vnd.recurly." + apiVersion)
            .header("Content-Type", "application/json")
            .header("User-Agent", USER_AGENT);

    Request request = builder.build();
    return chain.proceed(request);
  }

  private static String buildUserAgent() {
    final String defaultVersion = "3.?.?";
    final String defaultJvmInfo = "?";
    final Properties properties = new Properties();

    try {
      final InputStream inputStream =
          HeaderInterceptor.class.getResourceAsStream("/version.properties");
      if (inputStream != null) {
        properties.load(inputStream);
        final String version = properties.getProperty("version", defaultVersion);
        final String jvmInfo = System.getProperty("java.version", defaultJvmInfo);
        return String.format("Recurly/%s; java %s", version, jvmInfo);
      }
    } catch (Exception e) {
      // TODO rethrow exception in strict-mode
      System.out.println("[Recurly][WARNING] " + e.getStackTrace().toString());
    }

    System.out.println("[Recurly][WARNING] Could not set user agent header.");
    return String.format("Recurly/%s; java %s", defaultVersion, defaultJvmInfo);
  }
}


<|start_filename|>src/test/java/com/recurly/v3/QueryParamsTest.java<|end_filename|>
package com.recurly.v3;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashMap;
import org.junit.jupiter.api.Test;

public class QueryParamsTest {
  @Test
  public void testConstructor() {
    QueryParams qp = new QueryParams();
    assertEquals(qp.getParams(), new HashMap<String, Object>());
  }

  @Test
  public void testSetLimit() {
    QueryParams qp = new QueryParams();
    qp.setLimit(200);
    assertEquals(qp.getParams().get("limit"), 200);
  }
}


<|start_filename|>src/test/java/com/recurly/v3/fixtures/NestedRequest.java<|end_filename|>
package com.recurly.v3.fixtures;

import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;

public class NestedRequest extends Request {
  @SerializedName("my_nested_string")
  private String myNestedString;
}


<|start_filename|>src/test/resources/errors/validationError.json<|end_filename|>
{
  "error": {
    "type": "validation",
    "message": "Purchase could not be completed.",
    "params": [
      {
        "param": "account.billing_info.amazon_billing_agreement_id",
        "message": "BillingAgreement C01-0167876-5257595 is currently in Suspended state. ValidateBillingAgreement can only be requested in the OPEN state."
      }
    ]
  }
}

<|start_filename|>src/main/java/com/recurly/v3/RecurlyException.java<|end_filename|>
package com.recurly.v3;

public class RecurlyException extends RuntimeException {

  public RecurlyException(String message) {
    super(message);
  }

  public RecurlyException(Throwable cause) {
    super(cause);
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/InvoiceCollection.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;
import java.util.List;

public class InvoiceCollection extends Resource {

  @SerializedName("charge_invoice")
  @Expose
  private Invoice chargeInvoice;

  /** Credit invoices */
  @SerializedName("credit_invoices")
  @Expose
  private List<Invoice> creditInvoices;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  public Invoice getChargeInvoice() {
    return this.chargeInvoice;
  }

  /** @param chargeInvoice */
  public void setChargeInvoice(final Invoice chargeInvoice) {
    this.chargeInvoice = chargeInvoice;
  }

  /** Credit invoices */
  public List<Invoice> getCreditInvoices() {
    return this.creditInvoices;
  }

  /** @param creditInvoices Credit invoices */
  public void setCreditInvoices(final List<Invoice> creditInvoices) {
    this.creditInvoices = creditInvoices;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/BinaryFile.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;

public class BinaryFile extends Resource {

  @SerializedName("data")
  @Expose
  private byte[] data;

  public byte[] getData() {
    return this.data;
  }

  /** @param data */
  public void setData(final byte[] data) {
    this.data = data;
  }
}


<|start_filename|>src/test/java/com/recurly/v3/ClientTest.java<|end_filename|>
package com.recurly.v3;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

public class ClientTest {
  private static final String apiKey = "myapikey";

  @Test
  public void testCantInitializeWithoutApiKey() {
    assertThrows(
        IllegalArgumentException.class,
        () -> {
          new Client(null);
        });
    assertThrows(
        IllegalArgumentException.class,
        () -> {
          new Client("");
        });
  }

  @Test
  public void testRespondsWithValidApiVersion() {
    assertThat(Client.API_VERSION, matchesPattern("v\\d{4}-\\d{2}-\\d{2}"));
  }
}


<|start_filename|>src/main/java/com/recurly/v3/requests/CouponBulkCreate.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.requests;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;
import com.recurly.v3.resources.*;

public class CouponBulkCreate extends Request {

  /** The quantity of unique coupon codes to generate */
  @SerializedName("number_of_unique_codes")
  @Expose
  private Integer numberOfUniqueCodes;

  /** The quantity of unique coupon codes to generate */
  public Integer getNumberOfUniqueCodes() {
    return this.numberOfUniqueCodes;
  }

  /** @param numberOfUniqueCodes The quantity of unique coupon codes to generate */
  public void setNumberOfUniqueCodes(final Integer numberOfUniqueCodes) {
    this.numberOfUniqueCodes = numberOfUniqueCodes;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/AccountNote.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;
import org.joda.time.DateTime;

public class AccountNote extends Resource {

  @SerializedName("account_id")
  @Expose
  private String accountId;

  @SerializedName("created_at")
  @Expose
  private DateTime createdAt;

  @SerializedName("id")
  @Expose
  private String id;

  @SerializedName("message")
  @Expose
  private String message;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  @SerializedName("user")
  @Expose
  private User user;

  public String getAccountId() {
    return this.accountId;
  }

  /** @param accountId */
  public void setAccountId(final String accountId) {
    this.accountId = accountId;
  }

  public DateTime getCreatedAt() {
    return this.createdAt;
  }

  /** @param createdAt */
  public void setCreatedAt(final DateTime createdAt) {
    this.createdAt = createdAt;
  }

  public String getId() {
    return this.id;
  }

  /** @param id */
  public void setId(final String id) {
    this.id = id;
  }

  public String getMessage() {
    return this.message;
  }

  /** @param message */
  public void setMessage(final String message) {
    this.message = message;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }

  public User getUser() {
    return this.user;
  }

  /** @param user */
  public void setUser(final User user) {
    this.user = user;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/requests/LineItemRefund.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.requests;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;
import com.recurly.v3.resources.*;

public class LineItemRefund extends Request {

  /** Line item ID */
  @SerializedName("id")
  @Expose
  private String id;

  /**
   * Set to `true` if the line item should be prorated; set to `false` if not. This can only be used
   * on line items that have a start and end date.
   */
  @SerializedName("prorate")
  @Expose
  private Boolean prorate;

  /** Line item quantity to be refunded. */
  @SerializedName("quantity")
  @Expose
  private Integer quantity;

  /** Line item ID */
  public String getId() {
    return this.id;
  }

  /** @param id Line item ID */
  public void setId(final String id) {
    this.id = id;
  }

  /**
   * Set to `true` if the line item should be prorated; set to `false` if not. This can only be used
   * on line items that have a start and end date.
   */
  public Boolean getProrate() {
    return this.prorate;
  }

  /**
   * @param prorate Set to `true` if the line item should be prorated; set to `false` if not. This
   *     can only be used on line items that have a start and end date.
   */
  public void setProrate(final Boolean prorate) {
    this.prorate = prorate;
  }

  /** Line item quantity to be refunded. */
  public Integer getQuantity() {
    return this.quantity;
  }

  /** @param quantity Line item quantity to be refunded. */
  public void setQuantity(final Integer quantity) {
    this.quantity = quantity;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/Pager.java<|end_filename|>
package com.recurly.v3;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.lang.reflect.Type;
import java.util.*;
import java.util.function.Consumer;

public class Pager<T extends Resource> implements Iterable<T> {
  public Pager(
      String path, HashMap<String, Object> queryParams, BaseClient client, Type parameterizedType) {
    this.next = path;
    this.queryParams = queryParams;
    this.client = client;
    this.data = new ArrayList<>();
    this.parameterizedType = parameterizedType;
    this.more = true;
  }

  @SerializedName("has_more")
  @Expose
  private boolean more;

  @SerializedName("next")
  @Expose
  private String next;

  @Expose private List<T> data;

  private BaseClient client;

  private Type parameterizedType;

  private HashMap<String, Object> queryParams;

  private boolean paramsConsumed;

  public Pager<T>.PagerIterator iterator() {
    if (data.size() == 0 && this.hasMore()) this.getNextPage();
    return new PagerIterator(data.toArray(), this);
  }

  public void forEach(Consumer<? super T> action) {
    while (this.next != null) {
      this.getNextPage();
      for (T t : this) action.accept(t);
    }
  }

  public void eachItem(Consumer<? super T> action) {
    this.forEach(action);
  }

  public boolean hasMore() {
    return more;
  }

  public String getNext() {
    return next;
  }

  public List<T> getData() {
    return data;
  }

  public T getFirst() {
    HashMap<String, Object> firstParams = (HashMap<String, Object>)this.queryParams.clone();
    firstParams.put("limit", 1);
    Pager<T> pager =
        this.client.makeRequest("GET", this.next, firstParams, this.parameterizedType);
    PagerIterator iterator = pager.iterator();
    if (iterator.hasNext()) {
      return (T)iterator.next();
    } else {
      return null;
    }
  }

  public int getCount() {
    return this.client.getRecordCount(this.next, this.queryParams);
  }

  public void getNextPage() {
    if (this.next == null) {
      throw new NoSuchElementException();
    }
    Pager<T> pager =
        this.client.makeRequest("GET", this.next, this.consumeParams(), this.parameterizedType);
    this.clone(pager);
  }

  private void clone(Pager<T> pager) {
    this.next = pager.getNext();
    this.more = pager.hasMore();
    this.data = pager.getData();
  }

  private HashMap<String, Object> consumeParams() {
    if (this.paramsConsumed) return null;
    this.paramsConsumed = true;
    return this.queryParams;
  }

  private class PagerIterator implements Iterator {
    public PagerIterator(Object[] data, Pager<T> pager) {
      this.data = data;
      this.pager = pager;
    }

    private int position = 0;
    private Object[] data;
    private Pager<T> pager;

    public boolean hasNext() {
      return position < this.data.length || pager.hasMore();
    }

    public Object next() {
      if (position == this.data.length && pager.hasMore()) {
        pager.getNextPage();
        this.data = pager.getData().toArray();
        position = 0;
      }
      return this.data[position++];
    }
  }
}


<|start_filename|>src/main/java/com/recurly/v3/resources/AccountBalance.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.resources;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Resource;
import java.util.List;

public class AccountBalance extends Resource {

  /** Account mini details */
  @SerializedName("account")
  @Expose
  private AccountMini account;

  @SerializedName("balances")
  @Expose
  private List<AccountBalanceAmount> balances;

  /** Object type */
  @SerializedName("object")
  @Expose
  private String object;

  @SerializedName("past_due")
  @Expose
  private Boolean pastDue;

  /** Account mini details */
  public AccountMini getAccount() {
    return this.account;
  }

  /** @param account Account mini details */
  public void setAccount(final AccountMini account) {
    this.account = account;
  }

  public List<AccountBalanceAmount> getBalances() {
    return this.balances;
  }

  /** @param balances */
  public void setBalances(final List<AccountBalanceAmount> balances) {
    this.balances = balances;
  }

  /** Object type */
  public String getObject() {
    return this.object;
  }

  /** @param object Object type */
  public void setObject(final String object) {
    this.object = object;
  }

  public Boolean getPastDue() {
    return this.pastDue;
  }

  /** @param pastDue */
  public void setPastDue(final Boolean pastDue) {
    this.pastDue = pastDue;
  }
}


<|start_filename|>src/test/resources/errors/transactionError.json<|end_filename|>
{
  "error": {
    "type": "transaction",
    "message": "Your transaction was declined. Please contact your bank for further details or try another card.",
    "transaction_error": {
      "object": "transaction_error",
      "transaction_id": "mbca9aaao6xr",
      "category": "hard",
      "code": "invalid_payment_method_hard",
      "message": "Your transaction was declined. Please contact your bank for further details or try another card.",
      "merchant_advice": "The transaction was declined by the payment gateway. Contact the payment gateway for more details.",
      "three_d_secure_action_token_id": null
    }
  }
}

<|start_filename|>src/main/java/com/recurly/v3/Resource.java<|end_filename|>
package com.recurly.v3;

public class Resource {}


<|start_filename|>src/test/java/com/recurly/v3/fixtures/DateTimeTestClass.java<|end_filename|>
package com.recurly.v3.fixtures;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import org.joda.time.DateTime;

public class DateTimeTestClass {
  @SerializedName("date1")
  @Expose
  private DateTime date1;

  @SerializedName("date2")
  @Expose
  private DateTime date2;

  @SerializedName("date3")
  @Expose
  private DateTime date3;

  @SerializedName("date4")
  @Expose
  private DateTime date4;

  @SerializedName("date5")
  @Expose
  private DateTime date5;

  @SerializedName("date6")
  @Expose
  private DateTime date6;

  public DateTime getDate1() {
    return this.date1;
  }

  public void setDate1(final DateTime date1) {
    this.date1 = date1;
  }

  public DateTime getDate2() {
    return this.date2;
  }

  public void setDate2(final DateTime date) {
    this.date2 = date2;
  }

  public DateTime getDate3() {
    return this.date3;
  }

  public void setDate3(final DateTime date3) {
    this.date3 = date3;
  }

  public DateTime getDate4() {
    return this.date4;
  }

  public void setDate4(final DateTime date4) {
    this.date4 = date4;
  }

  public DateTime getDate5() {
    return this.date5;
  }

  public void setDate5(final DateTime date5) {
    this.date5 = date5;
  }

  public DateTime getDate6() {
    return this.date6;
  }

  public void setDate6(final DateTime date6) {
    this.date6 = date6;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/requests/CustomField.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.requests;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;
import com.recurly.v3.resources.*;

public class CustomField extends Request {

  /** Fields must be created in the UI before values can be assigned to them. */
  @SerializedName("name")
  @Expose
  private String name;

  /** Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. */
  @SerializedName("value")
  @Expose
  private String value;

  /** Fields must be created in the UI before values can be assigned to them. */
  public String getName() {
    return this.name;
  }

  /** @param name Fields must be created in the UI before values can be assigned to them. */
  public void setName(final String name) {
    this.name = name;
  }

  /** Any values that resemble a credit card number or security code (CVV/CVC) will be rejected. */
  public String getValue() {
    return this.value;
  }

  /**
   * @param value Any values that resemble a credit card number or security code (CVV/CVC) will be
   *     rejected.
   */
  public void setValue(final String value) {
    this.value = value;
  }
}


<|start_filename|>src/main/java/com/recurly/v3/requests/CouponUpdate.java<|end_filename|>
/**
 * This file is automatically created by Recurly's OpenAPI generation process and thus any edits you
 * make by hand will be lost. If you wish to make a change to this file, please create a Github
 * issue explaining the changes you need and we will usher them to the appropriate places.
 */
package com.recurly.v3.requests;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.recurly.v3.Request;
import com.recurly.v3.resources.*;

public class CouponUpdate extends Request {

  /**
   * This description will show up when a customer redeems a coupon on your Hosted Payment Pages, or
   * if you choose to show the description on your own checkout page.
   */
  @SerializedName("hosted_description")
  @Expose
  private String hostedDescription;

  /** Description of the coupon on the invoice. */
  @SerializedName("invoice_description")
  @Expose
  private String invoiceDescription;

  /**
   * A maximum number of redemptions for the coupon. The coupon will expire when it hits its maximum
   * redemptions.
   */
  @SerializedName("max_redemptions")
  @Expose
  private Integer maxRedemptions;

  /**
   * Redemptions per account is the number of times a specific account can redeem the coupon. Set
   * redemptions per account to `1` if you want to keep customers from gaming the system and getting
   * more than one discount from the coupon campaign.
   */
  @SerializedName("max_redemptions_per_account")
  @Expose
  private Integer maxRedemptionsPerAccount;

  /** The internal name for the coupon. */
  @SerializedName("name")
  @Expose
  private String name;

  /**
   * The date and time the coupon will expire and can no longer be redeemed. Time is always
   * 11:59:59, the end-of-day Pacific time.
   */
  @SerializedName("redeem_by_date")
  @Expose
  private String redeemByDate;

  /**
   * This description will show up when a customer redeems a coupon on your Hosted Payment Pages, or
   * if you choose to show the description on your own checkout page.
   */
  public String getHostedDescription() {
    return this.hostedDescription;
  }

  /**
   * @param hostedDescription This description will show up when a customer redeems a coupon on your
   *     Hosted Payment Pages, or if you choose to show the description on your own checkout page.
   */
  public void setHostedDescription(final String hostedDescription) {
    this.hostedDescription = hostedDescription;
  }

  /** Description of the coupon on the invoice. */
  public String getInvoiceDescription() {
    return this.invoiceDescription;
  }

  /** @param invoiceDescription Description of the coupon on the invoice. */
  public void setInvoiceDescription(final String invoiceDescription) {
    this.invoiceDescription = invoiceDescription;
  }

  /**
   * A maximum number of redemptions for the coupon. The coupon will expire when it hits its maximum
   * redemptions.
   */
  public Integer getMaxRedemptions() {
    return this.maxRedemptions;
  }

  /**
   * @param maxRedemptions A maximum number of redemptions for the coupon. The coupon will expire
   *     when it hits its maximum redemptions.
   */
  public void setMaxRedemptions(final Integer maxRedemptions) {
    this.maxRedemptions = maxRedemptions;
  }

  /**
   * Redemptions per account is the number of times a specific account can redeem the coupon. Set
   * redemptions per account to `1` if you want to keep customers from gaming the system and getting
   * more than one discount from the coupon campaign.
   */
  public Integer getMaxRedemptionsPerAccount() {
    return this.maxRedemptionsPerAccount;
  }

  /**
   * @param maxRedemptionsPerAccount Redemptions per account is the number of times a specific
   *     account can redeem the coupon. Set redemptions per account to `1` if you want to keep
   *     customers from gaming the system and getting more than one discount from the coupon
   *     campaign.
   */
  public void setMaxRedemptionsPerAccount(final Integer maxRedemptionsPerAccount) {
    this.maxRedemptionsPerAccount = maxRedemptionsPerAccount;
  }

  /** The internal name for the coupon. */
  public String getName() {
    return this.name;
  }

  /** @param name The internal name for the coupon. */
  public void setName(final String name) {
    this.name = name;
  }

  /**
   * The date and time the coupon will expire and can no longer be redeemed. Time is always
   * 11:59:59, the end-of-day Pacific time.
   */
  public String getRedeemByDate() {
    return this.redeemByDate;
  }

  /**
   * @param redeemByDate The date and time the coupon will expire and can no longer be redeemed.
   *     Time is always 11:59:59, the end-of-day Pacific time.
   */
  public void setRedeemByDate(final String redeemByDate) {
    this.redeemByDate = redeemByDate;
  }
}
