BloomRpcClient constructor

BloomRpcClient({
  1. BloomHttpClient? httpClient,
  2. String? baseUrl,
  3. Duration timeout = const Duration(seconds: 15),
  4. Map<String, String>? defaultHeaders,
  5. String? authToken,
  6. String? authTokenProvider()?,
})

Creates a BloomRpcClient configured with baseUrl, timeout, and authentication options.

If httpClient is omitted, automatically creates a new BloomHttpClient.

Implementation

BloomRpcClient({
  BloomHttpClient? httpClient,
  String? baseUrl,
  this.timeout = const Duration(seconds: 15),
  Map<String, String>? defaultHeaders,
  this.authToken,
  this.authTokenProvider,
})  : baseUrl = baseUrl ??
          BloomEnv.getOrNull('API_BASE_URL') ??
          BloomEnv.getOrNull('API_URL'),
      defaultHeaders = defaultHeaders ?? const {},
      httpClient = httpClient ??
          BloomHttpClient(
            baseUrl: baseUrl,
            timeout: timeout,
            authToken: authToken,
            authTokenProvider: authTokenProvider,
          ) {
  if (authToken != null) this.httpClient.authToken = authToken;
  if (authTokenProvider != null) {
    this.httpClient.authTokenProvider = authTokenProvider;
  }
}