I'm making an API wrapper library for an API that ...
# codereview
z
I'm making an API wrapper library for an API that has several permission levels In order from greatest to least permission admin > vip > user > guest Each one has all the permissions as the one before I'm not really sure how to design this in a typesafe way in Kotlin
c
maybe something like?
Copy code
interface AdminOperations {
    // specific to admins
}

interface VIPOperations {
    // specific to VIPs
}

…

class GuestApi : GuestOperations {
    // …
}

class UserApi : UserOperations, GuestOperations by GestApi()

// …
z
I was thinking delegation might be useful here I'm more concerned about how users of the library would create the client. I'm just unsure how well having a specific class to instantiate would work in practice
c
In the past I had a situation like this, and I had an object named after the library to instantiate that:
Copy code
object YourProject {

    fun connectAsGuest(): GuestApi

    fun connectAsUser(authToken: String): UserApi

    // … 

}
z
interesting, I may go with that approach