mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
Swift
50 lines
1.5 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
extension OpenGroupAPI {
|
|
public struct SendMessageRequest: Codable {
|
|
enum CodingKeys: String, CodingKey {
|
|
case data
|
|
case signature
|
|
case whisperTo = "whisper_to"
|
|
case whisperMods = "whisper_mods"
|
|
case fileIds = "files"
|
|
}
|
|
|
|
let data: Data
|
|
let signature: Data
|
|
let whisperTo: String?
|
|
let whisperMods: Bool
|
|
let fileIds: [Int64]?
|
|
|
|
// MARK: - Initialization
|
|
|
|
init(
|
|
data: Data,
|
|
signature: Data,
|
|
whisperTo: String? = nil,
|
|
whisperMods: Bool = false,
|
|
fileIds: [Int64]? = nil
|
|
) {
|
|
self.data = data
|
|
self.signature = signature
|
|
self.whisperTo = whisperTo
|
|
self.whisperMods = whisperMods
|
|
self.fileIds = fileIds
|
|
}
|
|
|
|
// MARK: - Encodable
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container: KeyedEncodingContainer<CodingKeys> = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
try container.encode(data.base64EncodedString(), forKey: .data)
|
|
try container.encode(signature.base64EncodedString(), forKey: .signature)
|
|
try container.encodeIfPresent(whisperTo, forKey: .whisperTo)
|
|
try container.encode(whisperMods, forKey: .whisperMods)
|
|
try container.encodeIfPresent(fileIds, forKey: .fileIds)
|
|
}
|
|
}
|
|
}
|