@@ -27,11 +27,12 @@ class TokenService(
2727 * @param agentId The ID of the public agent to get a token for
2828 * @param source Optional source identifier (defaults to "android_sdk")
2929 * @param version Optional version string (defaults to SDK version)
30+ * @param environment Optional environment name (defaults to "production" on the server)
3031 * @return TokenResponse containing the token and connection details
3132 * @throws TokenServiceException if the request fails or returns an error
3233 */
33- suspend fun fetchPublicAgentToken (agentId : String , source : String , version : String ): TokenResponse = withContext(Dispatchers .IO ) {
34- val url = buildTokenUrl(agentId, source, version)
34+ suspend fun fetchPublicAgentToken (agentId : String , source : String , version : String , environment : String? = null ): TokenResponse = withContext(Dispatchers .IO ) {
35+ val url = buildTokenUrl(agentId, source, version, environment )
3536
3637 val request = Request .Builder ()
3738 .url(url)
@@ -69,10 +70,13 @@ class TokenService(
6970 * Build the URL for fetching conversation tokens
7071 *
7172 * @param agentId The agent ID to include in the request
73+ * @param environment Optional environment name
7274 * @return Complete URL for the token request
7375 */
74- private fun buildTokenUrl (agentId : String , source : String , version : String ): String {
75- return " $baseUrl /v1/convai/conversation/token?agent_id=$agentId &source=$source &version=$version "
76+ private fun buildTokenUrl (agentId : String , source : String , version : String , environment : String? = null): String {
77+ var url = " $baseUrl /v1/convai/conversation/token?agent_id=$agentId &source=$source &version=$version "
78+ environment?.let { url + = " &environment=$it " }
79+ return url
7680 }
7781}
7882
0 commit comments