getKeyPermissions function

Future<KeyPermissions?> getKeyPermissions({
  1. Client? client,
  2. required Credential credential,
  3. bool isSandbox = false,
})

Gets the key permissions.

GET /api/v3/brokerage/key_permissions https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/data-api/get-api-key-permissions

credential - The user's API credentials. isSandbox - Whether to use the sandbox environment.

Returns a KeyPermissions object.

Implementation

Future<KeyPermissions?> getKeyPermissions(
    {http.Client? client,
    required Credential credential,
    bool isSandbox = false}) async {
  http.Response response = await getAuthorized('/key_permissions',
      client: client, credential: credential, isSandbox: isSandbox);

  if (response.statusCode == 200) {
    var jsonResponse = jsonDecode(response.body);
    return KeyPermissions.fromCBJson(jsonResponse);
  } else {
    throw CoinbaseException(
        'Failed to get key permissions', response.statusCode, response.body);
  }
}