Initiate User
Initializes a user session in the community. This method creates a user session and provides an access token for the user to interact with the community.
Steps to Initiate a User
- Call the
initiateUser()
method using an instance ofLMChatClient
. - Pass the necessary
InitiateUserRequest
object containing the user details. - Handle the response using the completion handler to check for success or errors.
let request = InitiateUserRequest.builder()
.userName("YOUR_USER_NAME")
.uuid("YOUR_UUID")
.isGuest(false)
.apiKey("YOUR_API_KEY")
.build()
LMChatClient.shared.initiateUser(request) { response in
switch response {
case .success(let result):
print("User successfully initiated. Access Token: \(result.accessToken)")
case .failure(let error):
print("Failed to initiate user: \(error.localizedDescription)")
default:
print("No response received")
}
}
Parameters
InitiateUserRequest
The InitiateUserRequest
model encapsulates the necessary details to initialize a user.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
isGuest | Bool? | Indicates if the user is a guest | ✔️ |
uuid | String? | Unique identifier for the user | ✔️ |
userName | String? | Name of the user | ✔️ |
apiKey | String? | API key for authentication | ✔️ |
Response
The method returns an LMResponse<InitiateUserResponse>
object.
InitiateUserResponse
This model contains the details of the initialized user.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
accessToken | String | Access token for the user session | ❌ |
appAccess | Bool? | Indicates if the user has app access | ✔️ |
community | Community? | Community details of the user | ✔️ |
hasAnswers | Bool? | Indicates if the user answered prompts | ✔️ |
refreshToken | String? | Refresh token for the user session | ✔️ |
user | User? | Details of the initialized user | ✔️ |