package org.knowm.xchange.ftx.service;

import org.knowm.xchange.Exchange;
import org.knowm.xchange.ftx.FtxException;
import org.knowm.xchange.ftx.dto.FtxResponse;
import org.knowm.xchange.ftx.dto.account.*;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;

public class FtxAccountServiceRaw extends FtxBaseService {

  public FtxAccountServiceRaw(Exchange exchange) {
    super(exchange);
  }

  public FtxResponse<FtxAccountDto> getFtxAccountInformation() throws FtxException, IOException {

    try {
      return ftx.getAccountInformation(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          null);
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxWalletBalanceDto>> getFtxWalletBalances()
      throws FtxException, IOException {

    try {
      return ftx.getWalletBalances(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator);
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<FtxSubAccountBalanceDto> getFtxSubAccountBalances(String nickname)
      throws FtxException, IOException {
    try {
      return ftx.getSubAccountBalances(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          null,
          nickname);
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<FtxSubAccountDto> createFtxSubAccount(String nickname)
      throws FtxException, IOException {
    try {
      return ftx.createSubAccount(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          null,
          new FtxSubAccountRequestPOJO(nickname));
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<FtxSubAccountTranferDto> transferBetweenFtxSubAccount(
      FtxSubAccountTransferPOJO payload) throws FtxException, IOException {
    try {
      return ftx.transferBetweenSubAccounts(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          null,
          payload);
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<FtxLeverageDto> changeLeverage(String subaccount, int leverage)
      throws FtxException, IOException {
    try {
      return ftx.changeLeverage(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          URLEncoder.encode(subaccount, "UTF-8"),
          new FtxLeverageDto(leverage));
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxLendingInfoDto>> getFtxLendingInfos(String subaccount)
      throws FtxException, IOException {
    try {
      return ftx.getLendingInfos(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxLendingRatesDto>> getFtxLendingRates(String subaccount)
      throws FtxException, IOException {
    try {
      return ftx.getLendingRates(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxLendingHistoryDto>> getFtxLendingHistories(String subaccount)
      throws FtxException, IOException {
    try {
      return ftx.getlendingHistories(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse submitLendingOffer(String subaccount, String coin, double size, double rate)
      throws FtxException, IOException {
    try {
      return ftx.submitLendingOffer(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount,
          new FtxSubmitLendingOfferParams(coin, size, rate)
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxBorrowingsDto>> getFtxBorrowHistory(String subaccount)
      throws FtxException, IOException {
    try {
      return ftx.getBorrowHistory(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxBorrowingInfoDto>> getFtxBorrowInfos(String subaccount)
      throws FtxException, IOException {
    try {
      return ftx.getBorrowingInfos(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxBorrowingRatesDto>> getFtxBorrowRates(String subaccount) throws FtxException, IOException {
    try {
      return ftx.getBorrowRates(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount
      );
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }

  public FtxResponse<List<FtxFundingPaymentsDto>> getFtxFundingPayments(String subaccount, Long startTime, Long endTime, String future)
      throws FtxException, IOException {
    try {
      return ftx.getFundingPayments(
          exchange.getExchangeSpecification().getApiKey(),
          exchange.getNonceFactory().createValue(),
          signatureCreator,
          subaccount,
          startTime,
          endTime,
          future);
    } catch (FtxException e) {
      throw new FtxException(e.getMessage());
    }
  }
}

@@ -3059,3079 +3059,8 @@
  %7D%0A%0A
-  public FtxResponse%3CList%3CFtxLendingInfoDto%3E%3E getFtxLendingInfos(String subaccount)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getLendingInfos(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse%3CList%3CFtxLendingRatesDto%3E%3E getFtxLendingRates(String subaccount)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getLendingRates(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse%3CList%3CFtxLendingHistoryDto%3E%3E getFtxLendingHistories(String subaccount)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getlendingHistories(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse submitLendingOffer(String subaccount, String coin, double size, double rate)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.submitLendingOffer(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount,%0A          new FtxSubmitLendingOfferParams(coin, size, rate)%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse%3CList%3CFtxBorrowingsDto%3E%3E getFtxBorrowHistory(String subaccount)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getBorrowHistory(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse%3CList%3CFtxBorrowingInfoDto%3E%3E getFtxBorrowInfos(String subaccount)%0A      throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getBorrowingInfos(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A  public FtxResponse%3CList%3CFtxBorrowingRatesDto%3E%3E getFtxBorrowRates(String subaccount) throws FtxException, IOException %7B%0A    try %7B%0A      return ftx.getBorrowRates(%0A          exchange.getExchangeSpecification().getApiKey(),%0A          exchange.getNonceFactory().createValue(),%0A          signatureCreator,%0A          subaccount%0A      );%0A    %7D catch (FtxException e) %7B%0A      throw new FtxException(e.getMessage());%0A    %7D%0A  %7D%0A%0A
   pu

Remove request from FtxAccountServiceRaw