NorbixConfig class

Base configuration for any Norbix SDK client.

Carries the host URL, the API version, credentials (API key and/or bearer token), HTTP timeout and retry policy. Extended by the per-host configs in norbix_api and norbix_hub.

Three ways to construct one:

// 1) Defaults — points at the public norbix.ai endpoint.
final cfg = NorbixConfig(baseUrl: 'https://api.norbix.ai');

// 2) Explicit overrides for self-hosted deployments.
final cfg = NorbixConfig(
  baseUrl: 'http://localhost:5000',
  apiKey: 'nbx_dev_...',
);

// 3) Read everything from environment variables.
final cfg = NorbixConfig.fromEnv(
  baseUrlVar: 'NORBIX_API_URL',
  apiKeyVar:  'NORBIX_API_KEY',
  defaultBaseUrl: 'https://api.norbix.ai',
);
Annotations
  • @immutable

Constructors

NorbixConfig({required String baseUrl, String apiVersion = 'v3', String? apiKey, String? bearerToken, Duration timeout = const Duration(seconds: 30), int maxRetries = 0, Map<String, String>? defaultHeaders, String env = 'PROD', String? region, String? language})
NorbixConfig.fromEnv({required String defaultBaseUrl, String baseUrlVar = 'NORBIX_BASE_URL', String apiVersionVar = 'NORBIX_API_VERSION', String apiKeyVar = 'NORBIX_API_KEY', String bearerTokenVar = 'NORBIX_BEARER_TOKEN', String timeoutMsVar = 'NORBIX_TIMEOUT_MS', String maxRetriesVar = 'NORBIX_MAX_RETRIES', String envVar = 'NORBIX_ENV', String regionVar = 'NORBIX_REGION', String languageVar = 'NORBIX_LANGUAGE', Map<String, String>? overrides})
Build a config from environment variables. Falls back to defaultBaseUrl when the URL var is not set, so callers always get a usable client.
factory

Properties

apiKey → String?
Static API key, sent as x-api-key. Optional.
final
apiVersion → String
API version segment injected into routes that contain {version}.
final
baseUrl → String
Base URL of the host, e.g. https://api.norbix.ai, https://api.norbix.isidos.lt or http://localhost:5000. Trailing slashes are stripped.
final
bearerToken → String?
Bearer JWT token, sent as Authorization: Bearer .... Optional. Wins over apiKey when both are set.
final
defaultHeaders → Map<String, String>
Extra headers added to every request.
final
env → String
Project environment every request targets, sent as the norbix-env header. PROD (the default) sends no header; a non-PROD env (e.g. TEST, STAGING) scopes every read and write to that environment's integrations. There is no cross-env fallback.
final
hashCode → int
The hash code for this object.
no setterinherited
language → String?
Preferred response language, sent verbatim as the standard Accept-Language header — a single tag (lt, lt-LT) or a full q-weighted list (lt-LT, en;q=0.8). The gateway honours the q-values and falls back to the project default language when nothing matches; the language it answered in comes back in Content-Language. Like region there is NO default: when null (the default) no header is sent.
final
maxRetries → int
How many times to retry transient (5xx, 429, network) failures. Defaults to 0 (no retry). Set to 2–3 for production.
final
region → String?
Norbix region every request targets (a region code such as nb-eu-germany), sent as the nb-region header. Unlike env there is NO default region: when null (the default) no header is sent. When set and baseUrl is an SDK default host, requests are routed to the regional host (https://{region}.api.norbix.ai); a user-supplied custom baseUrl is never rewritten.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeout → Duration
HTTP request timeout. Defaults to 30 s.
final

Methods

copyWith({String? baseUrl, String? apiVersion, String? apiKey, String? bearerToken, Duration? timeout, int? maxRetries, Map<String, String>? defaultHeaders, String? env, String? region, String? language}) → NorbixConfig
Returns a copy with selected fields replaced. Useful for runtime token rotation without mutating shared state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited