com.recurly.v3.Client Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-client Show documentation
Show all versions of api-client Show documentation
The official Java client for Recurly's V3 API.
/**
* 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