api-swift / Sources / IrdAPI / Core / Configuration.swift
121 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Foundation

/// Everything an `IrdClient` needs. Every field has a default; tests inject the
/// transport and clock, apps inject a credential store.
public struct Configuration: Sendable {
    /// Base URL of the API; trailing slashes are ignored.
    public var apiURL: URL = URL(string: "https://api.ird.ro")!
    /// Where the bearer comes from, consulted on every request.
    public var credential: any CredentialProvider = NoCredential()
    /// Extra headers merged last, so they override the computed ones.
    public var headers: [String: String] = [:]
    /// Per-request timeout; nil keeps the session default.
    public var timeout: TimeInterval? = nil
    public var transport: any HTTPTransport = URLSessionHTTPTransport()
    public var clock: any IrdClock = SystemClock()

    public init() {}

    public init(apiKey: String) {
        self.credential = StaticCredential(apiKey)
    }
}

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/api-swift.git