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

Update SingleUseSendReport model

parent 68887b74
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!30Update Bindings
...@@ -3,35 +3,24 @@ import Foundation ...@@ -3,35 +3,24 @@ import Foundation
public struct SingleUseSendReport: Equatable { public struct SingleUseSendReport: Equatable {
public init( public init(
rounds: [Int], rounds: [Int],
ephId: EphId ephId: Int64,
receptionId: Data
) { ) {
self.rounds = rounds self.rounds = rounds
self.ephId = ephId self.ephId = ephId
self.receptionId = receptionId
} }
public var rounds: [Int] public var rounds: [Int]
public var ephId: EphId public var ephId: Int64
} public var receptionId: Data
extension SingleUseSendReport {
public struct EphId: Equatable {
public init(
ephId: [Int],
source: Data
) {
self.ephId = ephId
self.source = source
}
public var ephId: [Int]
public var source: Data
}
} }
extension SingleUseSendReport: Codable { extension SingleUseSendReport: Codable {
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case rounds = "Rounds" case rounds = "Rounds"
case ephId = "EphID" case ephId = "EphID"
case receptionId = "ReceptionID"
} }
public static func decode(_ data: Data) throws -> Self { public static func decode(_ data: Data) throws -> Self {
...@@ -42,10 +31,3 @@ extension SingleUseSendReport: Codable { ...@@ -42,10 +31,3 @@ extension SingleUseSendReport: Codable {
try JSONEncoder().encode(self) try JSONEncoder().encode(self)
} }
} }
extension SingleUseSendReport.EphId: Codable {
enum CodingKeys: String, CodingKey {
case ephId = "EphId"
case source = "Source"
}
}
...@@ -5,15 +5,13 @@ import XCTest ...@@ -5,15 +5,13 @@ import XCTest
final class SingleUseSendReportTests: XCTestCase { final class SingleUseSendReportTests: XCTestCase {
func testCoding() throws { func testCoding() throws {
let rounds: [Int] = [1, 5, 9] let rounds: [Int] = [1, 5, 9]
let ephId: [Int] = [0, 0, 0, 0, 0, 0, 3, 89] let ephId: Int64 = 1_655_533
let ephIdSourceB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD" let receptionIdB64 = "emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"
let jsonString = """ let jsonString = """
{ {
"Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))],
"EphID": { "EphID": \(ephId),
"EphId": [\(ephId.map { "\($0)" }.joined(separator: ", "))], "ReceptionID": "\(receptionIdB64)"
"Source": "\(ephIdSourceB64)"
}
} }
""" """
let jsonData = jsonString.data(using: .utf8)! let jsonData = jsonString.data(using: .utf8)!
...@@ -21,10 +19,8 @@ final class SingleUseSendReportTests: XCTestCase { ...@@ -21,10 +19,8 @@ final class SingleUseSendReportTests: XCTestCase {
XCTAssertNoDifference(model, SingleUseSendReport( XCTAssertNoDifference(model, SingleUseSendReport(
rounds: rounds, rounds: rounds,
ephId: .init( ephId: ephId,
ephId: ephId, receptionId: Data(base64Encoded: receptionIdB64)!
source: Data(base64Encoded: ephIdSourceB64)!
)
)) ))
let encodedModel = try model.encode() 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