diff --git a/Sources/EventStoreDB/Event/EventData.swift b/Sources/EventStoreDB/Event/EventData.swift index b81c26b..d5a33e6 100644 --- a/Sources/EventStoreDB/Event/EventData.swift +++ b/Sources/EventStoreDB/Event/EventData.swift @@ -67,41 +67,10 @@ public struct EventData: EventStoreEvent, Codable, Equatable { // MARK: - construction methods extension EventData { - public static func events(fromJSONString jsonString: String, encoding: String.Encoding = .utf8, customMetadata _: Data? = nil) throws -> [Self] { - guard let data = jsonString.data(using: encoding) else { - throw ClientError.eventDataError(message: "The jsonString can't be encoded into binary data. \(jsonString)") - } - - return try events(fromJSONData: data) - } - - public static func event(fromJSONString jsonString: String, encoding: String.Encoding = .utf8, customMetadata _: [String: Codable] = [:]) throws -> Self { - guard let data = jsonString.data(using: encoding) else { - throw ClientError.eventDataError(message: "The jsonString can't be encoded into binary data. \(jsonString)") - } - - return try event(fromJSONData: data) - } - - public static func events(fromJSONData jsonData: Data, encoding _: String.Encoding = .utf8, customMetadata: Data? = nil) throws -> [Self] { - let decoder = JSONDecoder() - return try decoder.decode([Self].self, from: jsonData).map { - var event = $0 - event.customMetadata = customMetadata - return event - } - } - - public static func event(fromJSONData jsonData: Data, encoding _: String.Encoding = .utf8, customMetadata: Data? = nil) throws -> Self { - let decoder = JSONDecoder() - var event = try decoder.decode(Self.self, from: jsonData) - event.customMetadata = customMetadata - return event - } - public static func == (lhs: Self, rhs: Self) -> Bool { lhs.id == rhs.id && lhs.contentType == rhs.contentType && lhs.eventType == rhs.eventType + && lhs.data == rhs.data } } diff --git a/Tests/EventStoreDBTests/EventStoreDBTests.swift b/Tests/EventStoreDBTests/EventStoreDBTests.swift index 58e75f4..284b9c2 100644 --- a/Tests/EventStoreDBTests/EventStoreDBTests.swift +++ b/Tests/EventStoreDBTests/EventStoreDBTests.swift @@ -9,9 +9,9 @@ final class EventStoreDBTests: XCTestCase { // Defining Test Cases and Test Methods // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods - let jsonFileURL = Bundle.module.url(forResource: "multiple-events", withExtension: "json") - let jsonData = try Data(contentsOf: jsonFileURL!) - _ = try EventData.events(fromJSONData: jsonData) + // let jsonFileURL = Bundle.module.url(forResource: "multiple-events", withExtension: "json") + // let jsonData = try Data(contentsOf: jsonFileURL!) + // _ = try EventData.events(fromJSONData: jsonData) // try XCTAssertEqual(events, [ // .init(id: .init(uuidString: "fbf4b1a1-b4a3-4dfe-a01f-ec52c34e16e4")!, eventType: "event-type", data: "test".data(using: .utf8)!, contentType: .json, customMetadata: nil),