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

Update BroadcastReport model

parent 804fa0eb
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!78Update Bindings
......@@ -2,21 +2,25 @@ import Foundation
public struct BroadcastReport: Equatable {
public init(
roundId: Int,
ephId: [Int]
rounds: [Int],
ephId: [Int],
roundURL: String
) {
self.roundId = roundId
self.rounds = rounds
self.ephId = ephId
self.roundURL = roundURL
}
public var roundId: Int
public var rounds: [Int]
public var ephId: [Int]
public var roundURL: String
}
extension BroadcastReport: Codable {
enum CodingKeys: String, CodingKey {
case roundId = "RoundID"
case rounds = "Rounds"
case ephId = "EphID"
case roundURL = "RoundURL"
}
public static func decode(_ data: Data) throws -> Self {
......
......@@ -4,20 +4,23 @@ import XCTest
final class BroadcastReportTests: XCTestCase {
func testCoding() throws {
let roundId: Int = 42
let rounds: [Int] = [25, 26, 29]
let ephId: [Int] = [0, 0, 0, 0, 0, 0, 24, 61]
let roundURL = "https://dashboard.xx.network/rounds/25?xxmessenger=true"
let jsonString = """
{
"RoundID": \(roundId),
"EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))]
"Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))],
"EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))],
"RoundURL": "\(roundURL)"
}
"""
let jsonData = jsonString.data(using: .utf8)!
let model = try BroadcastReport.decode(jsonData)
XCTAssertNoDifference(model, BroadcastReport(
roundId: roundId,
ephId: ephId
rounds: rounds,
ephId: ephId,
roundURL: roundURL
))
let encodedModel = try model.encode()
......
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