deletePortfolio function

Future<bool> deletePortfolio({
  1. required String uuid,
  2. Client? client,
  3. required Credential credential,
  4. bool isSandbox = false,
})

Deletes a portfolio.

DELETE /api/v3/brokerage/portfolios/{portfolio_uuid} https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/portfolios/delete-portfolio

This function makes a DELETE request to the /portfolios/{uuid} endpoint of the Coinbase Advanced Trade API.

uuid - The UUID of the portfolio to be deleted. credential - The user's API credentials. isSandbox - Whether to use the sandbox environment.

Returns true if the portfolio was deleted successfully.

Implementation

Future<bool> deletePortfolio(
    {required String uuid,
    http.Client? client,
    required Credential credential,
    bool isSandbox = false}) async {
  http.Response response = await deleteAuthorized('/portfolios/$uuid',
      client: client, credential: credential, isSandbox: isSandbox);

  if (response.statusCode == 200) {
    return true;
  } else {
    throw CoinbaseException(
        'Failed to delete portfolio', response.statusCode, response.body);
  }
}