Skip to content

Commit

Permalink
adds swift docs
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Jul 20, 2024
1 parent 2f2040f commit d4b9c54
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Sources/oramacloud-client/answer-session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct AnswerParams<Doc: Codable> {
let related: Related?
}

struct Interaction<T: Decodable & Encodable> {
struct Interaction<T: Codable> {
var interactionId: String
var query: String
var response: String
Expand Down Expand Up @@ -108,6 +108,20 @@ class AnswerSession<Doc: Codable> {
searchEndpoint = params.oramaClient.endpoint
}

public func getState() -> [AnswerParams<Doc>.Interaction<Doc>] {
return state
}

public func getMessages() -> [AnswerParams<Doc>.Message] {
return messages
}

public func clearSession() -> Void {
abortController?.cancel()
state = []
messages = []
}

public func on(event: AnswerParams<Doc>.Event, callback: @escaping AnswerParams<Doc>.Events.Callback) -> AnswerSession<Doc> {
eventEmitter.on(event.rawValue) { data in
callback(data)
Expand Down

0 comments on commit d4b9c54

Please sign in to comment.