deleteAuthorized function
Future<Response>
deleteAuthorized(
- String endpoint, {
- Client? client,
- required Credential credential,
- bool isSandbox = false,
Makes an authorized DELETE request to the Coinbase Advanced Trade API.
This function generates a JWT, and then makes a DELETE request to the specified endpoint with the JWT in the Authorization header.
endpoint - The API endpoint to make the request to.
client - Optional http.Client to use for the request.
credential - The user's API credentials.
isSandbox - Whether to use the sandbox environment.
Returns an http.Response object.
Implementation
Future<http.Response> deleteAuthorized(String endpoint,
{http.Client? client,
required Credential credential,
bool isSandbox = false}) async {
String coinbaseApi = isSandbox ? coinbaseApiSandbox : coinbaseApiProduction;
client ??= http.Client();
String fullEndpoint = '/api/v3/brokerage$endpoint';
String jwtToken = await generateCoinbaseJwt(credential.apiKeyName,
credential.privateKeyPEM, "DELETE $coinbaseApi$fullEndpoint");
var url = Uri.https(coinbaseApi, fullEndpoint);
Map<String, String> requestHeaders = {
HttpHeaders.acceptHeader: 'application/json',
"Authorization": "Bearer $jwtToken",
};
return await client.delete(url, headers: requestHeaders);
}