import Foundation
import GenAPI

public struct SubscriptionPageContentResponse: Codable, Equatable {
    public var billingPeriodToggle: BillingPeriodToggleResponse
    public var countdown: CountdownResponse?
    public var featureComparison: FeatureComparisonResponse
    public var plans: [String: PlanMarketingResponse]
    public var salesBadge: ColoredBadgeResponse?

    public init(billingPeriodToggle: BillingPeriodToggleResponse, countdown: CountdownResponse? = nil, featureComparison: FeatureComparisonResponse, plans: [String: PlanMarketingResponse], salesBadge: ColoredBadgeResponse? = nil) {
        self.billingPeriodToggle = billingPeriodToggle
        self.countdown = countdown
        self.featureComparison = featureComparison
        self.plans = plans
        self.salesBadge = salesBadge
    }

    init(_ remote: GenAPI.SubscriptionPageContentResponse) {
        self.billingPeriodToggle = BillingPeriodToggleResponse(remote.billingPeriodToggle)
        self.countdown = remote.countdown.map { CountdownResponse($0) }
        self.featureComparison = FeatureComparisonResponse(remote.featureComparison)
        self.plans = remote.plans
        self.salesBadge = remote.salesBadge.map { ColoredBadgeResponse($0) }
    }
}
