package no.svorka.mcms.core

/** Builds and holds the networking stack for one MCMS connection. */
class McmsConnection(val config: ApiConfiguration) {
    val session = SessionStore(config)
    val client = ApiClient(config, session)

    val auth = AuthRepository(client, session, config)
    val onu = OnuRepository(client)
    val olt = OltRepository(client)
    val controller = ControllerRepository(client)

    /** Fired when a request returns 401, so the app can route back to login. */
    var onAuthExpired: (() -> Unit)?
        get() = client.onAuthExpired
        set(value) { client.onAuthExpired = value }
}
