VolvoCarsConfig

data class VolvoCarsConfig(val apiKey: String, val oauth: OAuthConfig? = null, val token: String? = null, val logging: LoggingConfig = LoggingConfig(), val timeout: Timeout = Timeout(socket = 30.seconds), val headers: Map<String, String> = emptyMap(), val proxy: ProxyConfig? = null, val retry: RetryStrategy = RetryStrategy(), val circuitBreaker: CircuitBreakerConfig? = null, val engine: HttpClientEngine? = null, val httpClientConfig: HttpClientConfig<*>.() -> Unit = {})(source)

Volvo API client configuration.

Supports two authentication modes:

1. OAuth2 with automatic refresh (recommended):

VolvoCarsConfig(
apiKey = "your-vcc-api-key",
oauth = OAuthConfig(
accessToken = storedAccessToken,
refreshToken = storedRefreshToken,
clientId = "your-client-id",
clientSecret = "your-client-secret",
onTokensRefreshed = { access, refresh -> save(access, refresh) }
)
)

2. Static token (for testing or short-lived scripts):

VolvoCarsConfig(
apiKey = "your-vcc-api-key",
token = "your-access-token"
)

Throws

if neither oauth nor token is provided, or if both are provided

Constructors

Link copied to clipboard
constructor(apiKey: String, oauth: OAuthConfig? = null, token: String? = null, logging: LoggingConfig = LoggingConfig(), timeout: Timeout = Timeout(socket = 30.seconds), headers: Map<String, String> = emptyMap(), proxy: ProxyConfig? = null, retry: RetryStrategy = RetryStrategy(), circuitBreaker: CircuitBreakerConfig? = null, engine: HttpClientEngine? = null, httpClientConfig: HttpClientConfig<*>.() -> Unit = {})

Properties

Link copied to clipboard

VCC API key from the Volvo Developer Portal

Link copied to clipboard

Optional circuit breaker to stop retries after sustained failures. When open, requests fail immediately without hitting the server. See CircuitBreakerConfig.

Link copied to clipboard
val engine: HttpClientEngine?

Explicit Ktor HttpClientEngine (useful for testing with mock engines)

Link copied to clipboard

Additional HTTP headers to include in every request

Link copied to clipboard
val httpClientConfig: HttpClientConfig<*>.() -> Unit

Additional Ktor HttpClient configuration block for advanced customization

Link copied to clipboard

HTTP request/response logging configuration

Link copied to clipboard

OAuth2 configuration with automatic token refresh. Mutually exclusive with token.

Link copied to clipboard

Proxy configuration (ProxyConfig.Http or ProxyConfig.Socks)

Link copied to clipboard

Retry strategy with exponential backoff for transient errors (429, 5xx). Honors Retry-After headers from 429 responses when present.

Link copied to clipboard

HTTP timeout configuration for request, connect, and socket timeouts

Link copied to clipboard

Static Bearer access token. Use oauth instead for production apps.