mirror of
https://github.com/hub-team/OnlineChatSdk-SwiftPM.git
synced 2026-04-15 00:54:05 +00:00
update
This commit is contained in:
@@ -2,7 +2,50 @@ import Foundation
|
||||
|
||||
class ChatApiMessagesWrapper {
|
||||
|
||||
init(_ response: Dictionary<String, Any>) {
|
||||
print("ChatApiMessagesWrapper : \(response.debugDescription)")
|
||||
private var result: Dictionary<String, Any>?
|
||||
private var dataArray: Array<Dictionary<String, Any>>?
|
||||
private var data: Dictionary<String, Any>?
|
||||
private var messages: Array<Dictionary<String, Any>>?
|
||||
|
||||
init(_ response: NSDictionary) {
|
||||
self.result = response as? Dictionary<String, Any>
|
||||
self.dataArray = []
|
||||
self.data = [:]
|
||||
self.messages = []
|
||||
if response["result"] == nil {
|
||||
return
|
||||
}
|
||||
self.dataArray = response["result"] as? Array<Dictionary<String, Any>>
|
||||
if self.dataArray == nil || self.dataArray?.count == 0 {
|
||||
return
|
||||
}
|
||||
self.data = dataArray![0]
|
||||
if self.data == nil || self.data!["messages"] == nil {
|
||||
self.data = [:]
|
||||
return
|
||||
}
|
||||
self.messages = self.data!["messages"] as? Array<Dictionary<String, Any>>
|
||||
if self.messages == nil {
|
||||
self.messages = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func getMessages() -> NSArray {
|
||||
self.messages! as NSArray
|
||||
}
|
||||
|
||||
public func setMessages(_ messages: NSArray) {
|
||||
self.messages = messages as? Array<Dictionary<String, Any>>
|
||||
}
|
||||
|
||||
public func getResult() -> NSDictionary {
|
||||
self.data!["messages"] = self.messages
|
||||
if self.dataArray?.count == 0 {
|
||||
self.dataArray = [self.data!]
|
||||
} else {
|
||||
self.dataArray![0] = self.data!
|
||||
}
|
||||
self.result?["result"] = self.dataArray
|
||||
return self.result! as NSDictionary
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user