get function

Future<Response> get(
  1. String endpoint, {
  2. Map<String, dynamic>? queryParameters,
  3. Client? client,
  4. bool isSandbox = false,
})

Makes a GET request to the Coinbase Advanced Trade API.

endpoint - The API endpoint to make the request to. queryParameters - Optional query parameters to include in the request. client - Optional http.Client to use for the request. isSandbox - Whether to use the sandbox environment.

Returns an http.Response object.

Implementation

Future<http.Response> get(String endpoint,
    {Map<String, dynamic>? queryParameters,
    http.Client? client,
    bool isSandbox = false}) async {
  String coinbaseApi = isSandbox ? coinbaseApiSandbox : coinbaseApiProduction;
  client ??= http.Client();

  String fullEndpoint = '/api/v3/brokerage$endpoint';

  var url = Uri.https(coinbaseApi, fullEndpoint, queryParameters);
  Map<String, String> requestHeaders = {
    HttpHeaders.acceptHeader: 'application/json',
  };

  return await client.get(url, headers: requestHeaders);
}