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

import NevisMobileAuthentication

struct TypedPendingOutOfBandOperationsResult: Encodable {
	// MARK: Properties

	let wrapped: PendingOutOfBandOperationsResult

	// MARK: Initialization

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

	// MARK: Coding Keys

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

	// MARK: Encodable

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