//
// Copyright © 2024 Nevis Security AG. All rights reserved.
//

import NevisMobileAuthentication

struct TypedDeviceInformationCheckResult: Encodable {
	// MARK: Properties

	let wrapped: DeviceInformationCheckResult

	// MARK: Initialization

	init(wrapped: DeviceInformationCheckResult) {
		self.wrapped = wrapped
	}

	// MARK: Coding Keys

	enum CodingKeys: String, CodingKey {
		case mismatches
		case errors
	}

	// MARK: Encodable

	func encode(to encoder: Encoder) throws {
		var container = encoder.container(keyedBy: CodingKeys.self)
		let mismatches = wrapped.mismatches.map { TypedDeviceInformationMismatch(wrapped: $0) }
		try container.encode(mismatches, forKey: .mismatches)
		let errors = wrapped.errors.map { $0.asChannelError() }
		try container.encode(errors, forKey: .errors)
	}
}
