All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.recurly.v3.Client Maven / Gradle / Ivy

There is a newer version: 4.59.1
Show newest version
/**
 * 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;

import com.google.gson.reflect.TypeToken;
import com.recurly.v3.requests.*;
import com.recurly.v3.resources.*;
import okhttp3.OkHttpClient;
import org.joda.time.DateTime;

import java.lang.reflect.Type;
import java.util.HashMap;

public class Client extends BaseClient {
  public static final String API_VERSION = "v2021-02-25";

  public Client(final String apiKey) {
    super(apiKey);
  }

  public Client(final String apiKey, final ClientOptions clientOptions) {
    super(apiKey, clientOptions);
  }


  /**
   * List sites
   *
   * @see list_sites api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of sites.
   */
  public Pager listSites(QueryParams queryParams) {
    final String url = "/sites";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Site.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a site
   *
   * @see get_site api documentation
   * @param siteId Site ID or subdomain. For ID no prefix is used e.g. `e28zov4fw0v2`. For subdomain use prefix `subdomain-`, e.g. `subdomain-recurly`.
     * @return A site.
   */
  public Site getSite(String siteId) {
    final String url = "/sites/{site_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("site_id", siteId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Site.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List a site's accounts
   *
   * @see list_accounts api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's accounts.
   */
  public Pager listAccounts(QueryParams queryParams) {
    final String url = "/accounts";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Account.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create an account
   *
   * @see create_account api documentation
   * @param body The body of the request.
     * @return An account.
   */
  public Account createAccount(AccountCreate body) {
    final String url = "/accounts";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Account.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch an account
   *
   * @see get_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account.
   */
  public Account getAccount(String accountId) {
    final String url = "/accounts/{account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Account.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an account
   *
   * @see update_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return An account.
   */
  public Account updateAccount(String accountId, AccountUpdate body) {
    final String url = "/accounts/{account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Account.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Deactivate an account
   *
   * @see deactivate_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account.
   */
  public Account deactivateAccount(String accountId) {
    final String url = "/accounts/{account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Account.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * Fetch an account's acquisition data
   *
   * @see get_account_acquisition api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account's acquisition data.
   */
  public AccountAcquisition getAccountAcquisition(String accountId) {
    final String url = "/accounts/{account_id}/acquisition";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AccountAcquisition.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an account's acquisition data
   *
   * @see update_account_acquisition api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return An account's updated acquisition data.
   */
  public AccountAcquisition updateAccountAcquisition(String accountId, AccountAcquisitionUpdate body) {
    final String url = "/accounts/{account_id}/acquisition";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AccountAcquisition.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove an account's acquisition data
   *
   * @see remove_account_acquisition api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   */
  public void removeAccountAcquisition(String accountId) {
    final String url = "/accounts/{account_id}/acquisition";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * Reactivate an inactive account
   *
   * @see reactivate_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account.
   */
  public Account reactivateAccount(String accountId) {
    final String url = "/accounts/{account_id}/reactivate";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Account.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Fetch an account's balance and past due status
   *
   * @see get_account_balance api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account's balance.
   */
  public AccountBalance getAccountBalance(String accountId) {
    final String url = "/accounts/{account_id}/balance";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AccountBalance.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Fetch an account's billing information
   *
   * @see get_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return An account's billing information.
   */
  public BillingInfo getBillingInfo(String accountId) {
    final String url = "/accounts/{account_id}/billing_info";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BillingInfo.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Set an account's billing information
   *
   * @see update_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Updated billing information.
   */
  public BillingInfo updateBillingInfo(String accountId, BillingInfoCreate body) {
    final String url = "/accounts/{account_id}/billing_info";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BillingInfo.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove an account's billing information
   *
   * @see remove_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   */
  public void removeBillingInfo(String accountId) {
    final String url = "/accounts/{account_id}/billing_info";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * Verify an account's credit card billing information
   *
   * @see verify_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return Transaction information from verify.
   */
  public Transaction verifyBillingInfo(String accountId) {
    final String url = "/accounts/{account_id}/billing_info/verify";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Transaction.class;
    return this.makeRequest("POST", path, returnType);
  }

  /**
   * Verify an account's credit card billing information
   *
   * @see verify_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Transaction information from verify.
   */
  public Transaction verifyBillingInfo(String accountId, BillingInfoVerify body) {
    final String url = "/accounts/{account_id}/billing_info/verify";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Transaction.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Verify an account's credit card billing cvv
   *
   * @see verify_billing_info_cvv api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Transaction information from verify.
   */
  public Transaction verifyBillingInfoCvv(String accountId, BillingInfoVerifyCVV body) {
    final String url = "/accounts/{account_id}/billing_info/verify_cvv";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Transaction.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Get the list of billing information associated with an account
   *
   * @see list_billing_infos api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the billing information for an account's
   */
  public Pager listBillingInfos(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/billing_infos";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, BillingInfo.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Add new billing information on an account
   *
   * @see create_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Updated billing information.
   */
  public BillingInfo createBillingInfo(String accountId, BillingInfoCreate body) {
    final String url = "/accounts/{account_id}/billing_infos";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BillingInfo.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a billing info
   *
   * @see get_a_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param billingInfoId Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
     * @return A billing info.
   */
  public BillingInfo getABillingInfo(String accountId, String billingInfoId) {
    final String url = "/accounts/{account_id}/billing_infos/{billing_info_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("billing_info_id", billingInfoId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BillingInfo.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an account's billing information
   *
   * @see update_a_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param billingInfoId Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
   * @param body The body of the request.
     * @return Updated billing information.
   */
  public BillingInfo updateABillingInfo(String accountId, String billingInfoId, BillingInfoCreate body) {
    final String url = "/accounts/{account_id}/billing_infos/{billing_info_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("billing_info_id", billingInfoId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BillingInfo.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove an account's billing information
   *
   * @see remove_a_billing_info api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param billingInfoId Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
   */
  public void removeABillingInfo(String accountId, String billingInfoId) {
    final String url = "/accounts/{account_id}/billing_infos/{billing_info_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("billing_info_id", billingInfoId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * List the coupon redemptions for an account
   *
   * @see list_account_coupon_redemptions api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the coupon redemptions on an account.
   */
  public Pager listAccountCouponRedemptions(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/coupon_redemptions";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CouponRedemption.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List the coupon redemptions that are active on an account
   *
   * @see list_active_coupon_redemptions api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return Active coupon redemptions on an account.
   */
  public Pager listActiveCouponRedemptions(String accountId) {
    final String url = "/accounts/{account_id}/coupon_redemptions/active";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CouponRedemption.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * Generate an active coupon redemption on an account or subscription
   *
   * @see create_coupon_redemption api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Returns the new coupon redemption.
   */
  public CouponRedemption createCouponRedemption(String accountId, CouponRedemptionCreate body) {
    final String url = "/accounts/{account_id}/coupon_redemptions/active";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = CouponRedemption.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Delete the active coupon redemption from an account
   *
   * @see remove_coupon_redemption api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return Coupon redemption deleted.
   */
  public CouponRedemption removeCouponRedemption(String accountId) {
    final String url = "/accounts/{account_id}/coupon_redemptions/active";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = CouponRedemption.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List an account's credit payments
   *
   * @see list_account_credit_payments api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the account's credit payments.
   */
  public Pager listAccountCreditPayments(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/credit_payments";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CreditPayment.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List external accounts for an account
   *
   * @see list_account_external_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return A list of external accounts on an account.
   */
  public Pager listAccountExternalAccount(String accountId) {
    final String url = "/accounts/{account_id}/external_accounts";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalAccount.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * Create an external account
   *
   * @see create_account_external_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return A representation of the created external_account.
   */
  public ExternalAccount createAccountExternalAccount(String accountId, ExternalAccountCreate body) {
    final String url = "/accounts/{account_id}/external_accounts";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalAccount.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Get an external account for an account
   *
   * @see get_account_external_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param externalAccountId External account ID, e.g. `s28zov4fw0cb`.
     * @return A external account on an account.
   */
  public ExternalAccount getAccountExternalAccount(String accountId, String externalAccountId) {
    final String url = "/accounts/{account_id}/external_accounts/{external_account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("external_account_id", externalAccountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalAccount.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an external account
   *
   * @see update_account_external_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param externalAccountId External account ID, e.g. `s28zov4fw0cb`.
   * @param body The body of the request.
     * @return A representation of the updated external_account.
   */
  public ExternalAccount updateAccountExternalAccount(String accountId, String externalAccountId, ExternalAccountUpdate body) {
    final String url = "/accounts/{account_id}/external_accounts/{external_account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("external_account_id", externalAccountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalAccount.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Delete an external account for an account
   *
   * @see delete_account_external_account api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param externalAccountId External account ID, e.g. `s28zov4fw0cb`.
     * @return Successful Delete
   */
  public ExternalAccount deleteAccountExternalAccount(String accountId, String externalAccountId) {
    final String url = "/accounts/{account_id}/external_accounts/{external_account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("external_account_id", externalAccountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalAccount.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List the external invoices on an account
   *
   * @see list_account_external_invoices api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_invoices on an account.
   */
  public Pager listAccountExternalInvoices(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/external_invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalInvoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List an account's invoices
   *
   * @see list_account_invoices api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the account's invoices.
   */
  public Pager listAccountInvoices(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Invoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create an invoice for pending line items
   *
   * @see create_invoice api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Returns the new invoices.
   */
  public InvoiceCollection createInvoice(String accountId, InvoiceCreate body) {
    final String url = "/accounts/{account_id}/invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Preview new invoice for pending line items
   *
   * @see preview_invoice api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Returns the invoice previews.
   */
  public InvoiceCollection previewInvoice(String accountId, InvoiceCreate body) {
    final String url = "/accounts/{account_id}/invoices/preview";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List an account's line items
   *
   * @see list_account_line_items api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the account's line items.
   */
  public Pager listAccountLineItems(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/line_items";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, LineItem.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new line item for the account
   *
   * @see create_line_item api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Returns the new line item.
   */
  public LineItem createLineItem(String accountId, LineItemCreate body) {
    final String url = "/accounts/{account_id}/line_items";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = LineItem.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List an account's notes
   *
   * @see list_account_notes api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of an account's notes.
   */
  public Pager listAccountNotes(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/notes";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, AccountNote.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an account note
   *
   * @see get_account_note api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param accountNoteId Account Note ID.
     * @return An account note.
   */
  public AccountNote getAccountNote(String accountId, String accountNoteId) {
    final String url = "/accounts/{account_id}/notes/{account_note_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("account_note_id", accountNoteId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AccountNote.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Fetch a list of an account's shipping addresses
   *
   * @see list_shipping_addresses api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of an account's shipping addresses.
   */
  public Pager listShippingAddresses(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/shipping_addresses";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ShippingAddress.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new shipping address for the account
   *
   * @see create_shipping_address api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param body The body of the request.
     * @return Returns the new shipping address.
   */
  public ShippingAddress createShippingAddress(String accountId, ShippingAddressCreate body) {
    final String url = "/accounts/{account_id}/shipping_addresses";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingAddress.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch an account's shipping address
   *
   * @see get_shipping_address api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param shippingAddressId Shipping Address ID.
     * @return A shipping address.
   */
  public ShippingAddress getShippingAddress(String accountId, String shippingAddressId) {
    final String url = "/accounts/{account_id}/shipping_addresses/{shipping_address_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("shipping_address_id", shippingAddressId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingAddress.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an account's shipping address
   *
   * @see update_shipping_address api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param shippingAddressId Shipping Address ID.
   * @param body The body of the request.
     * @return The updated shipping address.
   */
  public ShippingAddress updateShippingAddress(String accountId, String shippingAddressId, ShippingAddressUpdate body) {
    final String url = "/accounts/{account_id}/shipping_addresses/{shipping_address_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("shipping_address_id", shippingAddressId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingAddress.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove an account's shipping address
   *
   * @see remove_shipping_address api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param shippingAddressId Shipping Address ID.
   */
  public void removeShippingAddress(String accountId, String shippingAddressId) {
    final String url = "/accounts/{account_id}/shipping_addresses/{shipping_address_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    urlParams.put("shipping_address_id", shippingAddressId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * List an account's subscriptions
   *
   * @see list_account_subscriptions api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the account's subscriptions.
   */
  public Pager listAccountSubscriptions(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/subscriptions";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Subscription.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List an account's transactions
   *
   * @see list_account_transactions api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the account's transactions.
   */
  public Pager listAccountTransactions(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/transactions";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Transaction.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List an account's child accounts
   *
   * @see list_child_accounts api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of an account's child accounts.
   */
  public Pager listChildAccounts(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/accounts";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Account.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a site's account acquisition data
   *
   * @see list_account_acquisition api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's account acquisition data.
   */
  public Pager listAccountAcquisition(QueryParams queryParams) {
    final String url = "/acquisitions";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, AccountAcquisition.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a site's coupons
   *
   * @see list_coupons api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's coupons.
   */
  public Pager listCoupons(QueryParams queryParams) {
    final String url = "/coupons";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Coupon.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new coupon
   *
   * @see create_coupon api documentation
   * @param body The body of the request.
     * @return A new coupon.
   */
  public Coupon createCoupon(CouponCreate body) {
    final String url = "/coupons";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Coupon.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a coupon
   *
   * @see get_coupon api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
     * @return A coupon.
   */
  public Coupon getCoupon(String couponId) {
    final String url = "/coupons/{coupon_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Coupon.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an active coupon
   *
   * @see update_coupon api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
   * @param body The body of the request.
     * @return The updated coupon.
   */
  public Coupon updateCoupon(String couponId, CouponUpdate body) {
    final String url = "/coupons/{coupon_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Coupon.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Expire a coupon
   *
   * @see deactivate_coupon api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
     * @return The expired Coupon
   */
  public Coupon deactivateCoupon(String couponId) {
    final String url = "/coupons/{coupon_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Coupon.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * Generate unique coupon codes
   *
   * @see generate_unique_coupon_codes api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
   * @param body The body of the request.
     * @return A set of parameters that can be passed to the `list_unique_coupon_codes`
endpoint to obtain only the newly generated `UniqueCouponCodes`.

   */
  public UniqueCouponCodeParams generateUniqueCouponCodes(String couponId, CouponBulkCreate body) {
    final String url = "/coupons/{coupon_id}/generate";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = UniqueCouponCodeParams.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Restore an inactive coupon
   *
   * @see restore_coupon api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
   * @param body The body of the request.
     * @return The restored coupon.
   */
  public Coupon restoreCoupon(String couponId, CouponUpdate body) {
    final String url = "/coupons/{coupon_id}/restore";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Coupon.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * List unique coupon codes associated with a bulk coupon
   *
   * @see list_unique_coupon_codes api documentation
   * @param couponId Coupon ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-10off`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of unique coupon codes that were generated
   */
  public Pager listUniqueCouponCodes(String couponId, QueryParams queryParams) {
    final String url = "/coupons/{coupon_id}/unique_coupon_codes";
    final HashMap urlParams = new HashMap();
    urlParams.put("coupon_id", couponId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, UniqueCouponCode.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a site's credit payments
   *
   * @see list_credit_payments api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's credit payments.
   */
  public Pager listCreditPayments(QueryParams queryParams) {
    final String url = "/credit_payments";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CreditPayment.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a credit payment
   *
   * @see get_credit_payment api documentation
   * @param creditPaymentId Credit Payment ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A credit payment.
   */
  public CreditPayment getCreditPayment(String creditPaymentId) {
    final String url = "/credit_payments/{credit_payment_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("credit_payment_id", creditPaymentId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = CreditPayment.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List a site's custom field definitions
   *
   * @see list_custom_field_definitions api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's custom field definitions.
   */
  public Pager listCustomFieldDefinitions(QueryParams queryParams) {
    final String url = "/custom_field_definitions";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CustomFieldDefinition.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an custom field definition
   *
   * @see get_custom_field_definition api documentation
   * @param customFieldDefinitionId Custom Field Definition ID
     * @return A custom field definition.
   */
  public CustomFieldDefinition getCustomFieldDefinition(String customFieldDefinitionId) {
    final String url = "/custom_field_definitions/{custom_field_definition_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("custom_field_definition_id", customFieldDefinitionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = CustomFieldDefinition.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Create a new general ledger account
   *
   * @see create_general_ledger_account api documentation
   * @param body The body of the request.
     * @return A new general ledger account.
   */
  public GeneralLedgerAccount createGeneralLedgerAccount(GeneralLedgerAccountCreate body) {
    final String url = "/general_ledger_accounts";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GeneralLedgerAccount.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List a site's general ledger accounts
   *
   * @see list_general_ledger_accounts api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's general ledger accounts.
   */
  public Pager listGeneralLedgerAccounts(QueryParams queryParams) {
    final String url = "/general_ledger_accounts";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, GeneralLedgerAccount.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a general ledger account
   *
   * @see get_general_ledger_account api documentation
   * @param generalLedgerAccountId General Ledger Account ID
     * @return A general ledger account.
   */
  public GeneralLedgerAccount getGeneralLedgerAccount(String generalLedgerAccountId) {
    final String url = "/general_ledger_accounts/{general_ledger_account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("general_ledger_account_id", generalLedgerAccountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GeneralLedgerAccount.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update a general ledger account
   *
   * @see update_general_ledger_account api documentation
   * @param generalLedgerAccountId General Ledger Account ID
   * @param body The body of the request.
     * @return The updated general ledger account.
   */
  public GeneralLedgerAccount updateGeneralLedgerAccount(String generalLedgerAccountId, GeneralLedgerAccountUpdate body) {
    final String url = "/general_ledger_accounts/{general_ledger_account_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("general_ledger_account_id", generalLedgerAccountId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GeneralLedgerAccount.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Get a single Performance Obligation.
   *
   * @see get_performance_obligation api documentation
   * @param performanceObligationId Performance Obligation id.
     * @return A single Performance Obligation.
   */
  public PerformanceObligation getPerformanceObligation(String performanceObligationId) {
    final String url = "/performance_obligations/{performance_obligation_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("performance_obligation_id", performanceObligationId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = PerformanceObligation.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Get a site's Performance Obligations
   *
   * @see get_performance_obligations api documentation
     * @return A list of Performance Obligations.
   */
  public Pager getPerformanceObligations() {
    final String url = "/performance_obligations";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, PerformanceObligation.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * List an invoice template's associated accounts
   *
   * @see list_invoice_template_accounts api documentation
   * @param invoiceTemplateId Invoice template ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of an invoice template's associated accounts.
   */
  public Pager listInvoiceTemplateAccounts(String invoiceTemplateId, QueryParams queryParams) {
    final String url = "/invoice_templates/{invoice_template_id}/accounts";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_template_id", invoiceTemplateId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Account.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a site's items
   *
   * @see list_items api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's items.
   */
  public Pager listItems(QueryParams queryParams) {
    final String url = "/items";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Item.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new item
   *
   * @see create_item api documentation
   * @param body The body of the request.
     * @return A new item.
   */
  public Item createItem(ItemCreate body) {
    final String url = "/items";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Item.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch an item
   *
   * @see get_item api documentation
   * @param itemId Item ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-red`.
     * @return An item.
   */
  public Item getItem(String itemId) {
    final String url = "/items/{item_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("item_id", itemId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Item.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an active item
   *
   * @see update_item api documentation
   * @param itemId Item ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-red`.
   * @param body The body of the request.
     * @return The updated item.
   */
  public Item updateItem(String itemId, ItemUpdate body) {
    final String url = "/items/{item_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("item_id", itemId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Item.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Deactivate an item
   *
   * @see deactivate_item api documentation
   * @param itemId Item ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-red`.
     * @return An item.
   */
  public Item deactivateItem(String itemId) {
    final String url = "/items/{item_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("item_id", itemId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Item.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * Reactivate an inactive item
   *
   * @see reactivate_item api documentation
   * @param itemId Item ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-red`.
     * @return An item.
   */
  public Item reactivateItem(String itemId) {
    final String url = "/items/{item_id}/reactivate";
    final HashMap urlParams = new HashMap();
    urlParams.put("item_id", itemId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Item.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * List a site's measured units
   *
   * @see list_measured_unit api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's measured units.
   */
  public Pager listMeasuredUnit(QueryParams queryParams) {
    final String url = "/measured_units";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, MeasuredUnit.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new measured unit
   *
   * @see create_measured_unit api documentation
   * @param body The body of the request.
     * @return A new measured unit.
   */
  public MeasuredUnit createMeasuredUnit(MeasuredUnitCreate body) {
    final String url = "/measured_units";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = MeasuredUnit.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a measured unit
   *
   * @see get_measured_unit api documentation
   * @param measuredUnitId Measured unit ID or name. For ID no prefix is used e.g. `e28zov4fw0v2`. For name use prefix `name-`, e.g. `name-Storage`.
     * @return An item.
   */
  public MeasuredUnit getMeasuredUnit(String measuredUnitId) {
    final String url = "/measured_units/{measured_unit_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("measured_unit_id", measuredUnitId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = MeasuredUnit.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update a measured unit
   *
   * @see update_measured_unit api documentation
   * @param measuredUnitId Measured unit ID or name. For ID no prefix is used e.g. `e28zov4fw0v2`. For name use prefix `name-`, e.g. `name-Storage`.
   * @param body The body of the request.
     * @return The updated measured_unit.
   */
  public MeasuredUnit updateMeasuredUnit(String measuredUnitId, MeasuredUnitUpdate body) {
    final String url = "/measured_units/{measured_unit_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("measured_unit_id", measuredUnitId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = MeasuredUnit.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove a measured unit
   *
   * @see remove_measured_unit api documentation
   * @param measuredUnitId Measured unit ID or name. For ID no prefix is used e.g. `e28zov4fw0v2`. For name use prefix `name-`, e.g. `name-Storage`.
     * @return A measured unit.
   */
  public MeasuredUnit removeMeasuredUnit(String measuredUnitId) {
    final String url = "/measured_units/{measured_unit_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("measured_unit_id", measuredUnitId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = MeasuredUnit.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List a site's external products
   *
   * @see list_external_products api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_products on a site.
   */
  public Pager listExternalProducts(QueryParams queryParams) {
    final String url = "/external_products";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalProduct.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create an external product
   *
   * @see create_external_product api documentation
   * @param body The body of the request.
     * @return Returns the external product
   */
  public ExternalProduct createExternalProduct(ExternalProductCreate body) {
    final String url = "/external_products";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProduct.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch an external product
   *
   * @see get_external_product api documentation
   * @param externalProductId External product id
     * @return Settings for an external product.
   */
  public ExternalProduct getExternalProduct(String externalProductId) {
    final String url = "/external_products/{external_product_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProduct.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an external product
   *
   * @see update_external_product api documentation
   * @param externalProductId External product id
   * @param body The body of the request.
     * @return Settings for an external product.
   */
  public ExternalProduct updateExternalProduct(String externalProductId, ExternalProductUpdate body) {
    final String url = "/external_products/{external_product_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProduct.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Deactivate an external product
   *
   * @see deactivate_external_products api documentation
   * @param externalProductId External product id
     * @return Deactivated external product.
   */
  public ExternalProduct deactivateExternalProducts(String externalProductId) {
    final String url = "/external_products/{external_product_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProduct.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List the external product references for an external product
   *
   * @see list_external_product_external_product_references api documentation
   * @param externalProductId External product id
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external product references for an external product.
   */
  public Pager listExternalProductExternalProductReferences(String externalProductId, QueryParams queryParams) {
    final String url = "/external_products/{external_product_id}/external_product_references";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalProductReferenceCollection.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create an external product reference on an external product
   *
   * @see create_external_product_external_product_reference api documentation
   * @param externalProductId External product id
   * @param body The body of the request.
     * @return Details for the external product reference.
   */
  public ExternalProductReferenceMini createExternalProductExternalProductReference(String externalProductId, ExternalProductReferenceCreate body) {
    final String url = "/external_products/{external_product_id}/external_product_references";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProductReferenceMini.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch an external product reference
   *
   * @see get_external_product_external_product_reference api documentation
   * @param externalProductId External product id
   * @param externalProductReferenceId External product reference ID, e.g. `d39iun2fw1v4`.
     * @return Details for an external product reference.
   */
  public ExternalProductReferenceMini getExternalProductExternalProductReference(String externalProductId, String externalProductReferenceId) {
    final String url = "/external_products/{external_product_id}/external_product_references/{external_product_reference_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    urlParams.put("external_product_reference_id", externalProductReferenceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProductReferenceMini.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Deactivate an external product reference
   *
   * @see deactivate_external_product_external_product_reference api documentation
   * @param externalProductId External product id
   * @param externalProductReferenceId External product reference ID, e.g. `d39iun2fw1v4`.
     * @return Details for an external product reference.
   */
  public ExternalProductReferenceMini deactivateExternalProductExternalProductReference(String externalProductId, String externalProductReferenceId) {
    final String url = "/external_products/{external_product_id}/external_product_references/{external_product_reference_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_product_id", externalProductId);
    urlParams.put("external_product_reference_id", externalProductReferenceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalProductReferenceMini.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List a site's external subscriptions
   *
   * @see list_external_subscriptions api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_subscriptions on a site.
   */
  public Pager listExternalSubscriptions(QueryParams queryParams) {
    final String url = "/external_subscriptions";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalSubscription.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an external subscription
   *
   * @see get_external_subscription api documentation
   * @param externalSubscriptionId External subscription ID, external_id or uuid. For ID no prefix is used e.g. `e28zov4fw0v2`. For external_id use prefix `external-id-`, e.g. `external-id-123456` and for uuid use prefix `uuid-` e.g. `uuid-7293239bae62777d8c1ae044a9843633`.
     * @return Settings for an external subscription.
   */
  public ExternalSubscription getExternalSubscription(String externalSubscriptionId) {
    final String url = "/external_subscriptions/{external_subscription_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_subscription_id", externalSubscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalSubscription.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List the external invoices on an external subscription
   *
   * @see list_external_subscription_external_invoices api documentation
   * @param externalSubscriptionId External subscription id
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_invoices on a site.
   */
  public Pager listExternalSubscriptionExternalInvoices(String externalSubscriptionId, QueryParams queryParams) {
    final String url = "/external_subscriptions/{external_subscription_id}/external_invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_subscription_id", externalSubscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalInvoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a site's invoices
   *
   * @see list_invoices api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's invoices.
   */
  public Pager listInvoices(QueryParams queryParams) {
    final String url = "/invoices";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Invoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an invoice
   *
   * @see get_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return An invoice.
   */
  public Invoice getInvoice(String invoiceId) {
    final String url = "/invoices/{invoice_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an invoice
   *
   * @see update_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param body The body of the request.
     * @return An invoice.
   */
  public Invoice updateInvoice(String invoiceId, InvoiceUpdate body) {
    final String url = "/invoices/{invoice_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Fetch an invoice as a PDF
   *
   * @see get_invoice_pdf api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return An invoice as a PDF.
   */
  public BinaryFile getInvoicePdf(String invoiceId) {
    final String url = "/invoices/{invoice_id}.pdf";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BinaryFile.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Apply available credit to a pending or past due charge invoice
   *
   * @see apply_credit_balance api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice applyCreditBalance(String invoiceId) {
    final String url = "/invoices/{invoice_id}/apply_credit_balance";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Collect a pending or past due, automatic invoice
   *
   * @see collect_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice collectInvoice(String invoiceId) {
    final String url = "/invoices/{invoice_id}/collect";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Collect a pending or past due, automatic invoice
   *
   * @see collect_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param body The body of the request.
     * @return The updated invoice.
   */
  public Invoice collectInvoice(String invoiceId, InvoiceCollect body) {
    final String url = "/invoices/{invoice_id}/collect";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Mark an open invoice as failed
   *
   * @see mark_invoice_failed api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice markInvoiceFailed(String invoiceId) {
    final String url = "/invoices/{invoice_id}/mark_failed";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Mark an open invoice as successful
   *
   * @see mark_invoice_successful api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice markInvoiceSuccessful(String invoiceId) {
    final String url = "/invoices/{invoice_id}/mark_successful";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Reopen a closed, manual invoice
   *
   * @see reopen_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice reopenInvoice(String invoiceId) {
    final String url = "/invoices/{invoice_id}/reopen";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Void a credit invoice.
   *
   * @see void_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return The updated invoice.
   */
  public Invoice voidInvoice(String invoiceId) {
    final String url = "/invoices/{invoice_id}/void";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Record an external payment for a manual invoices.
   *
   * @see record_external_transaction api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param body The body of the request.
     * @return The recorded transaction.
   */
  public Transaction recordExternalTransaction(String invoiceId, ExternalTransaction body) {
    final String url = "/invoices/{invoice_id}/transactions";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Transaction.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List an invoice's line items
   *
   * @see list_invoice_line_items api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the invoice's line items.
   */
  public Pager listInvoiceLineItems(String invoiceId, QueryParams queryParams) {
    final String url = "/invoices/{invoice_id}/line_items";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, LineItem.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List the coupon redemptions applied to an invoice
   *
   * @see list_invoice_coupon_redemptions api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the coupon redemptions associated with the invoice.
   */
  public Pager listInvoiceCouponRedemptions(String invoiceId, QueryParams queryParams) {
    final String url = "/invoices/{invoice_id}/coupon_redemptions";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CouponRedemption.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List an invoice's related credit or charge invoices
   *
   * @see list_related_invoices api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
     * @return A list of the credit or charge invoices associated with the invoice.
   */
  public Pager listRelatedInvoices(String invoiceId) {
    final String url = "/invoices/{invoice_id}/related_invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Invoice.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * Refund an invoice
   *
   * @see refund_invoice api documentation
   * @param invoiceId Invoice ID or number. For ID no prefix is used e.g. `e28zov4fw0v2`. For number use prefix `number-`, e.g. `number-1000`.
   * @param body The body of the request.
     * @return Returns the new credit invoice.
   */
  public Invoice refundInvoice(String invoiceId, InvoiceRefund body) {
    final String url = "/invoices/{invoice_id}/refund";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_id", invoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Invoice.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List a site's line items
   *
   * @see list_line_items api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's line items.
   */
  public Pager listLineItems(QueryParams queryParams) {
    final String url = "/line_items";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, LineItem.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a line item
   *
   * @see get_line_item api documentation
   * @param lineItemId Line Item ID.
     * @return A line item.
   */
  public LineItem getLineItem(String lineItemId) {
    final String url = "/line_items/{line_item_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("line_item_id", lineItemId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = LineItem.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Delete an uninvoiced line item
   *
   * @see remove_line_item api documentation
   * @param lineItemId Line Item ID.
   */
  public void removeLineItem(String lineItemId) {
    final String url = "/line_items/{line_item_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("line_item_id", lineItemId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * List a site's plans
   *
   * @see list_plans api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of plans.
   */
  public Pager listPlans(QueryParams queryParams) {
    final String url = "/plans";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Plan.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a plan
   *
   * @see create_plan api documentation
   * @param body The body of the request.
     * @return A plan.
   */
  public Plan createPlan(PlanCreate body) {
    final String url = "/plans";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Plan.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a plan
   *
   * @see get_plan api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
     * @return A plan.
   */
  public Plan getPlan(String planId) {
    final String url = "/plans/{plan_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Plan.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update a plan
   *
   * @see update_plan api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param body The body of the request.
     * @return A plan.
   */
  public Plan updatePlan(String planId, PlanUpdate body) {
    final String url = "/plans/{plan_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Plan.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove a plan
   *
   * @see remove_plan api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
     * @return Plan deleted
   */
  public Plan removePlan(String planId) {
    final String url = "/plans/{plan_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Plan.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List a plan's add-ons
   *
   * @see list_plan_add_ons api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of add-ons.
   */
  public Pager listPlanAddOns(String planId, QueryParams queryParams) {
    final String url = "/plans/{plan_id}/add_ons";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, AddOn.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create an add-on
   *
   * @see create_plan_add_on api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param body The body of the request.
     * @return An add-on.
   */
  public AddOn createPlanAddOn(String planId, AddOnCreate body) {
    final String url = "/plans/{plan_id}/add_ons";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AddOn.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a plan's add-on
   *
   * @see get_plan_add_on api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
     * @return An add-on.
   */
  public AddOn getPlanAddOn(String planId, String addOnId) {
    final String url = "/plans/{plan_id}/add_ons/{add_on_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    urlParams.put("add_on_id", addOnId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AddOn.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an add-on
   *
   * @see update_plan_add_on api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param body The body of the request.
     * @return An add-on.
   */
  public AddOn updatePlanAddOn(String planId, String addOnId, AddOnUpdate body) {
    final String url = "/plans/{plan_id}/add_ons/{add_on_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    urlParams.put("add_on_id", addOnId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AddOn.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Remove an add-on
   *
   * @see remove_plan_add_on api documentation
   * @param planId Plan ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
     * @return Add-on deleted
   */
  public AddOn removePlanAddOn(String planId, String addOnId) {
    final String url = "/plans/{plan_id}/add_ons/{add_on_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("plan_id", planId);
    urlParams.put("add_on_id", addOnId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AddOn.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List a site's add-ons
   *
   * @see list_add_ons api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of add-ons.
   */
  public Pager listAddOns(QueryParams queryParams) {
    final String url = "/add_ons";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, AddOn.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an add-on
   *
   * @see get_add_on api documentation
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
     * @return An add-on.
   */
  public AddOn getAddOn(String addOnId) {
    final String url = "/add_ons/{add_on_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("add_on_id", addOnId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = AddOn.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List a site's shipping methods
   *
   * @see list_shipping_methods api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's shipping methods.
   */
  public Pager listShippingMethods(QueryParams queryParams) {
    final String url = "/shipping_methods";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ShippingMethod.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new shipping method
   *
   * @see create_shipping_method api documentation
   * @param body The body of the request.
     * @return A new shipping method.
   */
  public ShippingMethod createShippingMethod(ShippingMethodCreate body) {
    final String url = "/shipping_methods";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingMethod.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a shipping method
   *
   * @see get_shipping_method api documentation
   * @param shippingMethodId Shipping Method ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-usps_2-day`.
     * @return A shipping method.
   */
  public ShippingMethod getShippingMethod(String shippingMethodId) {
    final String url = "/shipping_methods/{shipping_method_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("shipping_method_id", shippingMethodId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingMethod.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update an active Shipping Method
   *
   * @see update_shipping_method api documentation
   * @param shippingMethodId Shipping Method ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-usps_2-day`.
   * @param body The body of the request.
     * @return The updated shipping method.
   */
  public ShippingMethod updateShippingMethod(String shippingMethodId, ShippingMethodUpdate body) {
    final String url = "/shipping_methods/{shipping_method_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("shipping_method_id", shippingMethodId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingMethod.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Deactivate a shipping method
   *
   * @see deactivate_shipping_method api documentation
   * @param shippingMethodId Shipping Method ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-usps_2-day`.
     * @return A shipping method.
   */
  public ShippingMethod deactivateShippingMethod(String shippingMethodId) {
    final String url = "/shipping_methods/{shipping_method_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("shipping_method_id", shippingMethodId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ShippingMethod.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * List a site's subscriptions
   *
   * @see list_subscriptions api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's subscriptions.
   */
  public Pager listSubscriptions(QueryParams queryParams) {
    final String url = "/subscriptions";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Subscription.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Create a new subscription
   *
   * @see create_subscription api documentation
   * @param body The body of the request.
     * @return A subscription.
   */
  public Subscription createSubscription(SubscriptionCreate body) {
    final String url = "/subscriptions";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a subscription
   *
   * @see get_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A subscription.
   */
  public Subscription getSubscription(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update a subscription
   *
   * @see update_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param body The body of the request.
     * @return A subscription.
   */
  public Subscription updateSubscription(String subscriptionId, SubscriptionUpdate body) {
    final String url = "/subscriptions/{subscription_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Terminate a subscription
   *
   * @see terminate_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return An expired subscription.
   */
  public Subscription terminateSubscription(String subscriptionId, QueryParams queryParams) {
    final String url = "/subscriptions/{subscription_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("DELETE", path, paramsMap, returnType);
  }

  /**
   * Cancel a subscription
   *
   * @see cancel_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A canceled or failed subscription.
   */
  public Subscription cancelSubscription(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/cancel";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Cancel a subscription
   *
   * @see cancel_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param body The body of the request.
     * @return A canceled or failed subscription.
   */
  public Subscription cancelSubscription(String subscriptionId, SubscriptionCancel body) {
    final String url = "/subscriptions/{subscription_id}/cancel";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Reactivate a canceled subscription
   *
   * @see reactivate_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return An active subscription.
   */
  public Subscription reactivateSubscription(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/reactivate";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Pause subscription
   *
   * @see pause_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param body The body of the request.
     * @return A subscription.
   */
  public Subscription pauseSubscription(String subscriptionId, SubscriptionPause body) {
    final String url = "/subscriptions/{subscription_id}/pause";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Resume subscription
   *
   * @see resume_subscription api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A subscription.
   */
  public Subscription resumeSubscription(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/resume";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Convert trial subscription
   *
   * @see convert_trial api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A subscription.
   */
  public Subscription convertTrial(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/convert_trial";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Subscription.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Fetch a preview of a subscription's renewal invoice(s)
   *
   * @see get_preview_renewal api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A preview of the subscription's renewal invoice(s).
   */
  public InvoiceCollection getPreviewRenewal(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/preview_renewal";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Fetch a subscription's pending change
   *
   * @see get_subscription_change api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A subscription's pending change.
   */
  public SubscriptionChange getSubscriptionChange(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/change";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = SubscriptionChange.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Create a new subscription change
   *
   * @see create_subscription_change api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param body The body of the request.
     * @return A subscription change.
   */
  public SubscriptionChange createSubscriptionChange(String subscriptionId, SubscriptionChangeCreate body) {
    final String url = "/subscriptions/{subscription_id}/change";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = SubscriptionChange.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Delete the pending subscription change
   *
   * @see remove_subscription_change api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   */
  public void removeSubscriptionChange(String subscriptionId) {
    final String url = "/subscriptions/{subscription_id}/change";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * Preview a new subscription change
   *
   * @see preview_subscription_change api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param body The body of the request.
     * @return A subscription change.
   */
  public SubscriptionChange previewSubscriptionChange(String subscriptionId, SubscriptionChangeCreate body) {
    final String url = "/subscriptions/{subscription_id}/change/preview";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = SubscriptionChange.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List a subscription's invoices
   *
   * @see list_subscription_invoices api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the subscription's invoices.
   */
  public Pager listSubscriptionInvoices(String subscriptionId, QueryParams queryParams) {
    final String url = "/subscriptions/{subscription_id}/invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Invoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a subscription's line items
   *
   * @see list_subscription_line_items api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the subscription's line items.
   */
  public Pager listSubscriptionLineItems(String subscriptionId, QueryParams queryParams) {
    final String url = "/subscriptions/{subscription_id}/line_items";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, LineItem.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List the coupon redemptions for a subscription
   *
   * @see list_subscription_coupon_redemptions api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the coupon redemptions on a subscription.
   */
  public Pager listSubscriptionCouponRedemptions(String subscriptionId, QueryParams queryParams) {
    final String url = "/subscriptions/{subscription_id}/coupon_redemptions";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, CouponRedemption.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List a subscription add-on's usage records
   *
   * @see list_usage api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the subscription add-on's usage records.
   */
  public Pager listUsage(String subscriptionId, String addOnId, QueryParams queryParams) {
    final String url = "/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    urlParams.put("add_on_id", addOnId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Usage.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Log a usage record on this subscription add-on
   *
   * @see create_usage api documentation
   * @param subscriptionId Subscription ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
   * @param addOnId Add-on ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-gold`.
   * @param body The body of the request.
     * @return The created usage record.
   */
  public Usage createUsage(String subscriptionId, String addOnId, UsageCreate body) {
    final String url = "/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage";
    final HashMap urlParams = new HashMap();
    urlParams.put("subscription_id", subscriptionId);
    urlParams.put("add_on_id", addOnId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Usage.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Get a usage record
   *
   * @see get_usage api documentation
   * @param usageId Usage Record ID.
     * @return The usage record.
   */
  public Usage getUsage(String usageId) {
    final String url = "/usage/{usage_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("usage_id", usageId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Usage.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Update a usage record
   *
   * @see update_usage api documentation
   * @param usageId Usage Record ID.
   * @param body The body of the request.
     * @return The updated usage record.
   */
  public Usage updateUsage(String usageId, UsageCreate body) {
    final String url = "/usage/{usage_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("usage_id", usageId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Usage.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Delete a usage record.
   *
   * @see remove_usage api documentation
   * @param usageId Usage Record ID.
   */
  public void removeUsage(String usageId) {
    final String url = "/usage/{usage_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("usage_id", usageId);
    final String path = this.interpolatePath(url, urlParams);
    this.makeRequest("DELETE", path);
  }

  /**
   * List a site's transactions
   *
   * @see list_transactions api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the site's transactions.
   */
  public Pager listTransactions(QueryParams queryParams) {
    final String url = "/transactions";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Transaction.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a transaction
   *
   * @see get_transaction api documentation
   * @param transactionId Transaction ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return A transaction.
   */
  public Transaction getTransaction(String transactionId) {
    final String url = "/transactions/{transaction_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("transaction_id", transactionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = Transaction.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Fetch a unique coupon code
   *
   * @see get_unique_coupon_code api documentation
   * @param uniqueCouponCodeId Unique Coupon Code ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-abc-8dh2-def`.
     * @return A unique coupon code.
   */
  public UniqueCouponCode getUniqueCouponCode(String uniqueCouponCodeId) {
    final String url = "/unique_coupon_codes/{unique_coupon_code_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("unique_coupon_code_id", uniqueCouponCodeId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = UniqueCouponCode.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Deactivate a unique coupon code
   *
   * @see deactivate_unique_coupon_code api documentation
   * @param uniqueCouponCodeId Unique Coupon Code ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-abc-8dh2-def`.
     * @return A unique coupon code.
   */
  public UniqueCouponCode deactivateUniqueCouponCode(String uniqueCouponCodeId) {
    final String url = "/unique_coupon_codes/{unique_coupon_code_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("unique_coupon_code_id", uniqueCouponCodeId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = UniqueCouponCode.class;
    return this.makeRequest("DELETE", path, returnType);
  }

  /**
   * Restore a unique coupon code
   *
   * @see reactivate_unique_coupon_code api documentation
   * @param uniqueCouponCodeId Unique Coupon Code ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-abc-8dh2-def`.
     * @return A unique coupon code.
   */
  public UniqueCouponCode reactivateUniqueCouponCode(String uniqueCouponCodeId) {
    final String url = "/unique_coupon_codes/{unique_coupon_code_id}/restore";
    final HashMap urlParams = new HashMap();
    urlParams.put("unique_coupon_code_id", uniqueCouponCodeId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = UniqueCouponCode.class;
    return this.makeRequest("PUT", path, returnType);
  }

  /**
   * Create a new purchase
   *
   * @see create_purchase api documentation
   * @param body The body of the request.
     * @return Returns the new invoices
   */
  public InvoiceCollection createPurchase(PurchaseCreate body) {
    final String url = "/purchases";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Preview a new purchase
   *
   * @see preview_purchase api documentation
   * @param body The body of the request.
     * @return Returns preview of the new invoices
   */
  public InvoiceCollection previewPurchase(PurchaseCreate body) {
    final String url = "/purchases/preview";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Create a pending purchase
   *
   * @see create_pending_purchase api documentation
   * @param body The body of the request.
     * @return Returns the pending invoice
   */
  public InvoiceCollection createPendingPurchase(PurchaseCreate body) {
    final String url = "/purchases/pending";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Authorize a purchase
   *
   * @see create_authorize_purchase api documentation
   * @param body The body of the request.
     * @return Returns the authorize invoice
   */
  public InvoiceCollection createAuthorizePurchase(PurchaseCreate body) {
    final String url = "/purchases/authorize";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Capture a purchase
   *
   * @see create_capture_purchase api documentation
   * @param transactionId Transaction ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return Returns the captured invoice
   */
  public InvoiceCollection createCapturePurchase(String transactionId) {
    final String url = "/purchases/{transaction_id}/capture";
    final HashMap urlParams = new HashMap();
    urlParams.put("transaction_id", transactionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, returnType);
  }

  /**
   * Cancel Purchase
   *
   * @see cancelPurchase api documentation
   * @param transactionId Transaction ID or UUID. For ID no prefix is used e.g. `e28zov4fw0v2`. For UUID use prefix `uuid-`, e.g. `uuid-123457890`.
     * @return Returns the cancelled invoice
   */
  public InvoiceCollection cancelpurchase(String transactionId) {
    final String url = "/purchases/{transaction_id}/cancel/";
    final HashMap urlParams = new HashMap();
    urlParams.put("transaction_id", transactionId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceCollection.class;
    return this.makeRequest("POST", path, returnType);
  }

  /**
   * List the dates that have an available export to download.
   *
   * @see get_export_dates api documentation
     * @return Returns a list of dates.
   */
  public ExportDates getExportDates() {
    final String url = "/export_dates";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExportDates.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List of the export files that are available to download.
   *
   * @see get_export_files api documentation
   * @param exportDate Date for which to get a list of available automated export files. Date must be in YYYY-MM-DD format.
     * @return Returns a list of export files to download.
   */
  public ExportFiles getExportFiles(String exportDate) {
    final String url = "/export_dates/{export_date}/export_files";
    final HashMap urlParams = new HashMap();
    urlParams.put("export_date", exportDate);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExportFiles.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List the dunning campaigns for a site
   *
   * @see list_dunning_campaigns api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the dunning_campaigns on an account.
   */
  public Pager listDunningCampaigns(QueryParams queryParams) {
    final String url = "/dunning_campaigns";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, DunningCampaign.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a dunning campaign
   *
   * @see get_dunning_campaign api documentation
   * @param dunningCampaignId Dunning Campaign ID, e.g. `e28zov4fw0v2`.
     * @return Settings for a dunning campaign.
   */
  public DunningCampaign getDunningCampaign(String dunningCampaignId) {
    final String url = "/dunning_campaigns/{dunning_campaign_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("dunning_campaign_id", dunningCampaignId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = DunningCampaign.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Assign a dunning campaign to multiple plans
   *
   * @see put_dunning_campaign_bulk_update api documentation
   * @param dunningCampaignId Dunning Campaign ID, e.g. `e28zov4fw0v2`.
   * @param body The body of the request.
     * @return A list of updated plans.
   */
  public DunningCampaignsBulkUpdateResponse putDunningCampaignBulkUpdate(String dunningCampaignId, DunningCampaignsBulkUpdate body) {
    final String url = "/dunning_campaigns/{dunning_campaign_id}/bulk_update";
    final HashMap urlParams = new HashMap();
    urlParams.put("dunning_campaign_id", dunningCampaignId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = DunningCampaignsBulkUpdateResponse.class;
    return this.makeRequest("PUT", path, body, returnType);
  }

  /**
   * Show the invoice templates for a site
   *
   * @see list_invoice_templates api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the invoice templates on a site.
   */
  public Pager listInvoiceTemplates(QueryParams queryParams) {
    final String url = "/invoice_templates";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, InvoiceTemplate.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an invoice template
   *
   * @see get_invoice_template api documentation
   * @param invoiceTemplateId Invoice template ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
     * @return Settings for an invoice template.
   */
  public InvoiceTemplate getInvoiceTemplate(String invoiceTemplateId) {
    final String url = "/invoice_templates/{invoice_template_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("invoice_template_id", invoiceTemplateId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = InvoiceTemplate.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List the external invoices on a site
   *
   * @see list_external_invoices api documentation
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_invoices on a site.
   */
  public Pager listExternalInvoices(QueryParams queryParams) {
    final String url = "/external_invoices";
    final HashMap urlParams = new HashMap();
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalInvoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an external invoice
   *
   * @see show_external_invoice api documentation
   * @param externalInvoiceId External invoice ID, e.g. `e28zov4fw0v2`.
     * @return Returns the external invoice
   */
  public ExternalInvoice showExternalInvoice(String externalInvoiceId) {
    final String url = "/external_invoices/{external_invoice_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_invoice_id", externalInvoiceId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalInvoice.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List the external payment phases on an external subscription
   *
   * @see list_external_subscription_external_payment_phases api documentation
   * @param externalSubscriptionId External subscription id
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_payment_phases on a site.
   */
  public Pager listExternalSubscriptionExternalPaymentPhases(String externalSubscriptionId, QueryParams queryParams) {
    final String url = "/external_subscriptions/{external_subscription_id}/external_payment_phases";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_subscription_id", externalSubscriptionId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalPaymentPhase.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch an external payment phase
   *
   * @see get_external_subscription_external_payment_phase api documentation
   * @param externalSubscriptionId External subscription id
   * @param externalPaymentPhaseId External payment phase ID, e.g. `a34ypb2ef9w1`.
     * @return Details for an external payment phase.
   */
  public ExternalPaymentPhase getExternalSubscriptionExternalPaymentPhase(String externalSubscriptionId, String externalPaymentPhaseId) {
    final String url = "/external_subscriptions/{external_subscription_id}/external_payment_phases/{external_payment_phase_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("external_subscription_id", externalSubscriptionId);
    urlParams.put("external_payment_phase_id", externalPaymentPhaseId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = ExternalPaymentPhase.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List entitlements granted to an account
   *
   * @see list_entitlements api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the entitlements granted to an account.
   */
  public Pager listEntitlements(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/entitlements";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Entitlements.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * List an account's external subscriptions
   *
   * @see list_account_external_subscriptions api documentation
   * @param accountId Account ID or code. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-bob`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the the external_subscriptions on an account.
   */
  public Pager listAccountExternalSubscriptions(String accountId, QueryParams queryParams) {
    final String url = "/accounts/{account_id}/external_subscriptions";
    final HashMap urlParams = new HashMap();
    urlParams.put("account_id", accountId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, ExternalSubscription.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }

  /**
   * Fetch a business entity
   *
   * @see get_business_entity api documentation
   * @param businessEntityId Business Entity ID. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-entity1`.
     * @return Business entity details
   */
  public BusinessEntity getBusinessEntity(String businessEntityId) {
    final String url = "/business_entities/{business_entity_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("business_entity_id", businessEntityId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = BusinessEntity.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * List business entities
   *
   * @see list_business_entities api documentation
     * @return List of all business entities on your site.
   */
  public Pager listBusinessEntities() {
    final String url = "/business_entities";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, BusinessEntity.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * List gift cards
   *
   * @see list_gift_cards api documentation
     * @return List of all created gift cards on your site.
   */
  public Pager listGiftCards() {
    final String url = "/gift_cards";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, GiftCard.class).getType();
    return new Pager<>(path, null, this, parameterizedType);
  }

  /**
   * Create gift card
   *
   * @see create_gift_card api documentation
   * @param body The body of the request.
     * @return Returns the gift card
   */
  public GiftCard createGiftCard(GiftCardCreate body) {
    final String url = "/gift_cards";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GiftCard.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Fetch a gift card
   *
   * @see get_gift_card api documentation
   * @param giftCardId Gift Card ID, e.g. `e28zov4fw0v2`.
     * @return Gift card details
   */
  public GiftCard getGiftCard(String giftCardId) {
    final String url = "/gift_cards/{gift_card_id}";
    final HashMap urlParams = new HashMap();
    urlParams.put("gift_card_id", giftCardId);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GiftCard.class;
    return this.makeRequest("GET", path, returnType);
  }

  /**
   * Preview gift card
   *
   * @see preview_gift_card api documentation
   * @param body The body of the request.
     * @return Returns the gift card
   */
  public GiftCard previewGiftCard(GiftCardCreate body) {
    final String url = "/gift_cards/preview";
    final HashMap urlParams = new HashMap();
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GiftCard.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * Redeem gift card
   *
   * @see redeem_gift_card api documentation
   * @param redemptionCode Gift Card redemption code, e.g., `N1A2T8IRXSCMO40V`.
   * @param body The body of the request.
     * @return Redeems and returns the gift card
   */
  public GiftCard redeemGiftCard(String redemptionCode, GiftCardRedeem body) {
    final String url = "/gift_cards/{redemption_code}/redeem";
    final HashMap urlParams = new HashMap();
    urlParams.put("redemption_code", redemptionCode);
    final String path = this.interpolatePath(url, urlParams);
    Type returnType = GiftCard.class;
    return this.makeRequest("POST", path, body, returnType);
  }

  /**
   * List a business entity's invoices
   *
   * @see list_business_entity_invoices api documentation
   * @param businessEntityId Business Entity ID. For ID no prefix is used e.g. `e28zov4fw0v2`. For code use prefix `code-`, e.g. `code-entity1`.
   * @param queryParams The {@link QueryParams} for this endpoint.
     * @return A list of the business entity's invoices.
   */
  public Pager listBusinessEntityInvoices(String businessEntityId, QueryParams queryParams) {
    final String url = "/business_entities/{business_entity_id}/invoices";
    final HashMap urlParams = new HashMap();
    urlParams.put("business_entity_id", businessEntityId);
    if (queryParams == null) queryParams = new QueryParams();
    final HashMap paramsMap = queryParams.getParams();
    final String path = this.interpolatePath(url, urlParams);
    Type parameterizedType = TypeToken.getParameterized(Pager.class, Invoice.class).getType();
    return new Pager<>(path, paramsMap, this, parameterizedType);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy