@@ -10,6 +10,7 @@ import com.coder.toolbox.sdk.ex.APIResponseException
1010import com.coder.toolbox.sdk.interceptors.Interceptors
1111import com.coder.toolbox.sdk.v2.CoderV2RestFacade
1212import com.coder.toolbox.sdk.v2.models.ApiErrorResponse
13+ import com.coder.toolbox.sdk.v2.models.Appearance
1314import com.coder.toolbox.sdk.v2.models.BuildInfo
1415import com.coder.toolbox.sdk.v2.models.CreateWorkspaceBuildRequest
1516import com.coder.toolbox.sdk.v2.models.Template
@@ -45,6 +46,7 @@ open class CoderRestClient(
4546
4647 lateinit var me: User
4748 lateinit var buildVersion: String
49+ lateinit var appName: String
4850
4951 init {
5052 setupSession()
@@ -94,14 +96,15 @@ open class CoderRestClient(
9496 suspend fun initializeSession (): User {
9597 me = me()
9698 buildVersion = buildInfo().version
99+ appName = appearance().applicationName
97100 return me
98101 }
99102
100103 /* *
101104 * Retrieve the current user.
102105 * @throws [APIResponseException].
103106 */
104- suspend fun me (): User {
107+ internal suspend fun me (): User {
105108 val userResponse = retroRestClient.me()
106109 if (! userResponse.isSuccessful) {
107110 throw APIResponseException (
@@ -117,6 +120,25 @@ open class CoderRestClient(
117120 }
118121 }
119122
123+ /* *
124+ * Retrieves the visual dashboard configuration.
125+ */
126+ internal suspend fun appearance (): Appearance {
127+ val appearanceResponse = retroRestClient.appearance()
128+ if (! appearanceResponse.isSuccessful) {
129+ throw APIResponseException (
130+ " initializeSession" ,
131+ url,
132+ appearanceResponse.code(),
133+ appearanceResponse.parseErrorBody(moshi)
134+ )
135+ }
136+
137+ return requireNotNull(appearanceResponse.body()) {
138+ " Successful response returned null body or visual dashboard configuration"
139+ }
140+ }
141+
120142 /* *
121143 * Retrieves the available workspaces created by the user.
122144 * @throws [APIResponseException].
0 commit comments