Class CoinbaseAccountService

All Implemented Interfaces:
AccountService, BaseService

public final class CoinbaseAccountService
extends CoinbaseBaseService
implements AccountService
Author:
jamespedwards42
  • Constructor Details

    • CoinbaseAccountService

      public CoinbaseAccountService​(Exchange exchange)
      Constructor
      Parameters:
      exchange -
  • Method Details

    • getAccountInfo

      public AccountInfo getAccountInfo() throws IOException
      Description copied from interface: AccountService
      Get account info
      Specified by:
      getAccountInfo in interface AccountService
      Returns:
      the AccountInfo object, null if some sort of error occurred. Implementers should log the error.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • withdrawFunds

      public String withdrawFunds​(Currency currency, BigDecimal amount, String address) throws IOException
      Description copied from interface: AccountService
      Convenience method, typically just delegates to withdrawFunds(WithdrawFundsParams params)
      Specified by:
      withdrawFunds in interface AccountService
      Parameters:
      currency - The currency to withdraw
      amount - The amount to withdraw
      address - The destination address
      Returns:
      The Coinbase transaction id for the newly created withdrawal. See CoinbaseAccountServiceRaw.getCoinbaseTransaction(String transactionIdOrIdemField) to retrieve more information about the transaction, including the blockchain transaction hash.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • withdrawFunds

      public String withdrawFunds​(WithdrawFundsParams params) throws IOException
      Description copied from interface: AccountService
      Withdraw funds from this account. Allows to withdraw digital currency funds from the exchange account to an external address
      Specified by:
      withdrawFunds in interface AccountService
      Parameters:
      params - The withdrawl details
      Returns:
      The result of the withdrawal (usually a transaction ID)
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • requestDepositAddress

      public String requestDepositAddress​(Currency currency, String... arguments) throws IOException
      Description copied from interface: AccountService
      Request a digital currency address to fund this account. Allows to fund the exchange account with digital currency from an external address
      Specified by:
      requestDepositAddress in interface AccountService
      Parameters:
      currency - The digital currency that corresponds to the desired deposit address.
      arguments - Necessary argument(s) as a String
      Returns:
      the internal deposit address to send funds to
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • createFundingHistoryParams

      public TradeHistoryParams createFundingHistoryParams()
      Description copied from interface: AccountService
      Create TradeHistoryParams object specific to this exchange. Object created by this method may be used to discover supported and required AccountService.getFundingHistory(TradeHistoryParams) parameters and should be passed only to the method in the same class as the createFundingHistoryParams that created the object.
      Specified by:
      createFundingHistoryParams in interface AccountService
    • getCoinbaseUsers

      public CoinbaseUsers getCoinbaseUsers() throws IOException
      Authenticated resource that shows the current user and their settings.
      Returns:
      A CoinbaseUsers wrapper around the current CoinbaseUser containing account settings.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/users/index.html
    • updateCoinbaseUser

      public CoinbaseUser updateCoinbaseUser​(CoinbaseUser user) throws IOException
      Authenticated resource that lets you update account settings for the current user. Use getCoinbaseUsers() to retrieve the current user first.
      Parameters:
      user - CoinbaseUser with new information to be updated.
      Returns:
      The current CoinbaseUser with the requested updated account settings.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/users/update.html
    • redeemCoinbaseToken

      public boolean redeemCoinbaseToken​(String tokenId) throws IOException
      Authenticated resource which claims a redeemable token for its address and Bitcoin.
      Parameters:
      tokenId -
      Returns:
      True if the redemption was successful.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/tokens/redeem.html
    • getCoinbaseBalance

      public CoinbaseMoney getCoinbaseBalance() throws IOException
      Authenticated resource that returns the user’s current account balance in BTC.
      Returns:
      A CoinbaseAmount wrapper around a CoinbaseMoney object representing the current user's balance.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/accounts/balance.html
    • getCoinbaseReceiveAddress

      public CoinbaseAddress getCoinbaseReceiveAddress() throws IOException
      Authenticated resource that returns the user’s current Bitcoin receive address.
      Returns:
      The user’s current CoinbaseAddress.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/accounts/receive_address.html
    • getCoinbaseAddresses

      public CoinbaseAddresses getCoinbaseAddresses() throws IOException
      Authenticated resource that returns Bitcoin addresses a user has associated with their account. This is a paged resource and will return the first page by default.
      Returns:
      A CoinbaseAddresses wrapper around a collection of CoinbaseAddress's associated with the current user's account.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/addresses/index.html
    • getCoinbaseAddresses

      public CoinbaseAddresses getCoinbaseAddresses​(Integer page, Integer limit, String filter) throws IOException
      Authenticated resource that returns Bitcoin addresses a user has associated with their account.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      limit - Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1.
      filter - Optional String match to filter addresses. Matches the address itself and also if the use has set a ‘label’ on the address. No filter is applied if filter is null or empty.
      Returns:
      A CoinbaseAddresses wrapper around a collection of CoinbaseAddress's associated with the current user's account.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/addresses/index.html
    • generateCoinbaseReceiveAddress

      public CoinbaseAddress generateCoinbaseReceiveAddress() throws IOException
      Authenticated resource that generates a new Bitcoin receive address for the user.
      Returns:
      The user’s newly generated and current CoinbaseAddress.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/accounts/generate_receive_address .html
    • generateCoinbaseReceiveAddress

      public CoinbaseAddress generateCoinbaseReceiveAddress​(String callbackUrl, String label) throws IOException
      Authenticated resource that generates a new Bitcoin receive address for the user.
      Parameters:
      callbackUrl - Optional Callback URL to receive instant payment notifications whenever funds arrive to this address.
      label - Optional text label for the address which can be used to filter against when calling getCoinbaseAddresses().
      Returns:
      The user’s newly generated and current CoinbaseAddress.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/accounts/generate_receive_address .html
    • getCoinbaseAccountChanges

      public CoinbaseAccountChanges getCoinbaseAccountChanges() throws IOException
      Authenticated resource which returns all related changes to an account. This is an alternative to the getCoinbaseTransactions API call. It is designed to be faster and provide more detail so you can generate an overview/summary of individual account changes. This is a paged resource and will return 30 results representing the first page by default.
      Returns:
      The current user, balance, and the most recent account changes.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/account_changes/index.html
    • getCoinbaseAccountChanges

      public CoinbaseAccountChanges getCoinbaseAccountChanges​(Integer page) throws IOException
      Authenticated resource which returns all related changes to an account. This is an alternative to the getCoinbaseTransactions API call. It is designed to be faster and provide more detail so you can generate an overview/summary of individual account changes.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      Returns:
      The current user, balance, and the most recent account changes.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/account_changes/index.html
    • getCoinbaseContacts

      public CoinbaseContacts getCoinbaseContacts() throws IOException
      Authenticated resource that returns contacts the user has previously sent to or received from. This is a paged resource and will return the first page by default.
      Returns:
      CoinbaseContacts the user has previously sent to or received from.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/contacts/index.html
    • getCoinbaseContacts

      public CoinbaseContacts getCoinbaseContacts​(Integer page, Integer limit, String filter) throws IOException
      Authenticated resource that returns contacts the user has previously sent to or received from.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      limit - Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1.
      filter - Optional String match to filter addresses. Matches the address itself and also if the use has set a ‘label’ on the address. No filter is applied if filter is null or empty.
      Returns:
      CoinbaseContacts the user has previously sent to or received from.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/contacts/index.html
    • getCoinbaseTransactions

      public CoinbaseTransactions getCoinbaseTransactions() throws IOException
      Authenticated resource which returns the user’s most recent transactions. Sorted in descending order by creation date. This is a paged resource and will return the first page by default.
      Returns:
      The current user's most recent CoinbaseTransactions.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/index.html
    • getCoinbaseTransactions

      public CoinbaseTransactions getCoinbaseTransactions​(Integer page) throws IOException
      Authenticated resource which returns the user’s most recent transactions. Sorted in descending order by creation date.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      Returns:
      The current user's most recent CoinbaseTransactions.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/index.html
    • getCoinbaseTransaction

      public CoinbaseTransaction getCoinbaseTransaction​(String transactionIdOrIdemField) throws IOException
      Authenticated resource which returns the details of an individual transaction.
      Parameters:
      transactionIdOrIdemField -
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/show.html
    • requestMoneyCoinbaseRequest

      public CoinbaseTransaction requestMoneyCoinbaseRequest​(CoinbaseTransaction.CoinbaseRequestMoneyRequest transactionRequest) throws IOException
      Authenticated resource which lets the user request money from a Bitcoin address.
      Parameters:
      transactionRequest -
      Returns:
      A pending CoinbaseTransaction representing the desired CoinbaseRequestMoneyRequest.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/request_money.html
    • sendMoneyCoinbaseRequest

      public CoinbaseTransaction sendMoneyCoinbaseRequest​(CoinbaseTransaction.CoinbaseSendMoneyRequest transactionRequest) throws IOException
      Authenticated resource which lets you send money to an email or Bitcoin address.
      Parameters:
      transactionRequest -
      Returns:
      A completed CoinbaseTransaction representing the desired CoinbaseSendMoneyRequest.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/send_money.html
    • resendCoinbaseRequest

      public CoinbaseBaseResponse resendCoinbaseRequest​(String transactionId) throws IOException
      Authenticated resource which lets the user resend a money request.
      Parameters:
      transactionId -
      Returns:
      true if resending the request was successful.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/resend_request.html
    • completeCoinbaseRequest

      public CoinbaseTransaction completeCoinbaseRequest​(String transactionId) throws IOException
      Authenticated resource which lets a user complete a money request. Money requests can only be completed by the sender (not the recipient). Remember that the sender in this context is the user who is sending money (not sending the request itself).
      Parameters:
      transactionId -
      Returns:
      The CoinbaseTransaction representing the completed CoinbaseSendMoneyRequest.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/complete_request.html
    • cancelCoinbaseRequest

      public CoinbaseBaseResponse cancelCoinbaseRequest​(String transactionId) throws IOException
      Authenticated resource which lets a user cancel a money request. Money requests can be canceled by the sender or the recipient.
      Parameters:
      transactionId -
      Returns:
      true if canceling the request was successful.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/transactions/cancel_request.html
    • createCoinbaseButton

      public CoinbaseButton createCoinbaseButton​(CoinbaseButton button) throws IOException
      Authenticated resource that creates a payment button, page, or iFrame to accept Bitcoin on your website. This can be used to accept Bitcoin for an individual item or to integrate with your existing shopping cart solution. For example, you could create a new payment button for each shopping cart on your website, setting the total and order number in the button at checkout.
      Parameters:
      button - A CoinbaseButton containing the desired button configuration for Coinbase to create.
      Returns:
      newly created CoinbaseButton.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/buttons/create.html
    • getCoinbaseOrders

      public CoinbaseOrders getCoinbaseOrders() throws IOException
      Authenticated resource which returns a merchant’s orders that they have received. Sorted in descending order by creation date. This is a paged resource and will return the first page by default, use getCoinbaseOrders(Integer page) to retrieve additional pages.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/orders/index.html
    • getCoinbaseOrders

      public CoinbaseOrders getCoinbaseOrders​(Integer page) throws IOException
      Authenticated resource which returns a merchant’s orders that they have received. Sorted in descending order by creation date.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/orders/index.html
    • getCoinbaseOrder

      public CoinbaseOrder getCoinbaseOrder​(String orderIdOrCustom) throws IOException
      Authenticated resource which returns order details for a specific order id or merchant custom.
      Parameters:
      orderIdOrCustom -
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/orders/show.html
    • createCoinbaseOrder

      public CoinbaseOrder createCoinbaseOrder​(String code) throws IOException
      Authenticated resource which lets you generate an order associated with a button. After generating an order, you can send Bitcoin to the address associated with the order to complete the order. The status of this newly created order will be ‘new’.
      Parameters:
      code - The code of the button for which you wish to create an order.
      Returns:
      The newly created CoinbaseOrder.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/buttons/create_order.html
    • createCoinbaseOrder

      public CoinbaseOrder createCoinbaseOrder​(CoinbaseButton button) throws IOException
      Authenticated resource which returns an order for a new button.
      Parameters:
      button - A CoinbaseButton containing information to create a one time order.
      Returns:
      The newly created CoinbaseOrder.
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/orders/create.html
    • getCoinbaseRecurringPayments

      public CoinbaseRecurringPayments getCoinbaseRecurringPayments() throws IOException
      Authenticated resource that lets you list all your recurring payments (scheduled buys, sells, and subscriptions you’ve created with merchants). This is a paged resource and will return the first page by default.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/recurring_payments/index.html
    • getCoinbaseRecurringPayments

      public CoinbaseRecurringPayments getCoinbaseRecurringPayments​(Integer page, Integer limit) throws IOException
      Authenticated resource that lets you list all your recurring payments (scheduled buys, sells, and subscriptions you’ve created with merchants).
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      limit - Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/recurring_payments/index.html
    • getCoinbaseRecurringPayment

      public CoinbaseRecurringPayment getCoinbaseRecurringPayment​(String recurringPaymentId) throws IOException
      Authenticated resource that lets you show an individual recurring payment.
      Parameters:
      recurringPaymentId -
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/recurring_payments/show.html
    • getCoinbaseSubscriptions

      public CoinbaseSubscriptions getCoinbaseSubscriptions() throws IOException
      Authenticated resource that lets you (as a merchant) list all the subscriptions customers have made with you. This call returns CoinbaseSubscription objects where you are the merchant. This is a paged resource and will return the first page by default.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/subscribers/index.html
    • getCoinbaseSubscriptions

      public CoinbaseSubscriptions getCoinbaseSubscriptions​(Integer page, Integer limit) throws IOException
      Authenticated resource that lets you (as a merchant) list all the subscriptions customers have made with you. This call returns CoinbaseSubscription objects where you are the merchant.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      limit - Optional parameter to limit the maximum number of results to return. Will return up to 25 results by default if null or less than 1.
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/subscribers/index.html
    • getCoinbaseSubscription

      public CoinbaseSubscription getCoinbaseSubscription​(String subscriptionId) throws IOException
      Authenticated resource that lets you (as a merchant) show an individual subscription than a customer has created with you. This call returns a CoinbaseSubscription object where you are the merchant.
      Parameters:
      subscriptionId -
      Returns:
      Throws:
      IOException
      See Also:
      coinbase.com/api/doc/1.0/subscribers/show.html