import Foundation
import ComplyCubeMobileSDK

public final class AddressStageParser: StageParser {
    public init() {}

    public func canParse(_ input: Any) -> Bool {
        (input as? [String: Any]).map { $0["name"] as? String == "addressCapture" } ?? false
    }

    public func parse(_ input: Any) throws -> ComplyCubeMobileSDKStage? {
        let s = input as! [String: Any]
        return AddressCaptureStageBuilder()
            .withCountries(countries: s["allowedCountries"] as? [String] ?? [])
            .withAutoComplete(enable: s["useAutoComplete"] as? Bool ?? false)
            .build()
    }
}
