get method

Future<Response> get(
  1. String endpoint, {
  2. Map<String, String>? queryParameters,
  3. Map<String, String>? headers,
})

Make GET request

Implementation

Future<http.Response> get(
  String endpoint, {
  Map<String, String>? queryParameters,
  Map<String, String>? headers,
}) async {
  try {
    var uri = Uri.parse('${_config.baseUrl}$endpoint');
    if (queryParameters != null && queryParameters.isNotEmpty) {
      uri = uri.replace(queryParameters: queryParameters);
    }

    if (_config.enableLogging) {
      debugPrint('[ApexKYC] GET $uri');
    }

    final response = await _client
        .get(uri, headers: _getHeaders(additionalHeaders: headers))
        .timeout(Duration(seconds: _config.timeoutSeconds));

    if (_config.enableLogging) {
      debugPrint(
        '[ApexKYC] Response: ${response.statusCode} ${response.body}',
      );
    }

    return _handleResponse(response);
  } catch (e) {
    if (e is ApexKycException) {
      rethrow;
    }
    throw ApexKycException(
      'Unexpected error: ${e.toString()}',
      originalError: e,
    );
  }
}