Skip to content
Snippets Groups Projects
Commit 2342343e authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add GroupSendReport model

parent d98e0fa0
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!24Update Bindings
import Foundation
public struct GroupSendReport: Equatable {
public init(
roundId: UInt64,
timestamp: Int64,
messageId: Data
) {
self.roundId = roundId
self.timestamp = timestamp
self.messageId = messageId
}
public var roundId: UInt64
public var timestamp: Int64
public var messageId: Data
}
extension GroupSendReport: Codable {
enum CodingKeys: String, CodingKey {
case roundId = "RoundID"
case timestamp = "Timestamp"
case messageId = "MessageID"
}
public static func decode(_ data: Data) throws -> Self {
try JSONDecoder().decode(Self.self, from: data)
}
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
import CustomDump
import XCTest
@testable import ElixxirDAppsSDK
final class GroupSendReportTests: XCTestCase {
func testCoding() throws {
let roundId: UInt64 = 123
let timestamp: Int64 = 321
let messageIdB64 = "EB/70R5HYEw5htZ4Hg9ondrn3+cAc/lH2G0mjQMja3w="
let jsonString = """
{
"RoundID": \(roundId),
"Timestamp": \(timestamp),
"MessageID": "\(messageIdB64)"
}
"""
let jsonData = jsonString.data(using: .utf8)!
let model = try GroupSendReport.decode(jsonData)
XCTAssertNoDifference(model, GroupSendReport(
roundId: roundId,
timestamp: timestamp,
messageId: Data(base64Encoded: messageIdB64)!
))
let encodedModel = try model.encode()
let decodedModel = try GroupSendReport.decode(encodedModel)
XCTAssertNoDifference(decodedModel, model)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment