//
// Generated by SwagGen
// https://github.com/yonaskolb/SwagGen
//

import Foundation

public class AppConfigGeneral: APIModel {

    /** The currency code to target. */
    public var currencyCode: String?

    /** A map of custom configuration fields. */
    public var customFields: [String: Any]?

    /** A Google Analytics token to track applicaton user events. */
    public var gaToken: String?

    /** A map of default item image types where the key is the item types. */
    public var itemImageTypes: [String: String]?

    /** The public Stripe key to use for payment transactions. */
    public var stripeKey: String?

    /** The url of the primary website. */
    public var websiteUrl: URL?

    public init(currencyCode: String? = nil, customFields: [String: Any]? = nil, gaToken: String? = nil, itemImageTypes: [String: String]? = nil, stripeKey: String? = nil, websiteUrl: URL? = nil) {
        self.currencyCode = currencyCode
        self.customFields = customFields
        self.gaToken = gaToken
        self.itemImageTypes = itemImageTypes
        self.stripeKey = stripeKey
        self.websiteUrl = websiteUrl
    }

    private enum CodingKeys: String, CodingKey {
        case currencyCode
        case customFields
        case gaToken
        case itemImageTypes
        case stripeKey
        case websiteUrl
    }

    public required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)

        currencyCode = try container.decodeIfPresent(.currencyCode)
        customFields = try container.decodeAnyIfPresent(.customFields)
        gaToken = try container.decodeIfPresent(.gaToken)
        itemImageTypes = try container.decodeIfPresent(.itemImageTypes)
        stripeKey = try container.decodeIfPresent(.stripeKey)
        websiteUrl = try container.decodeIfPresent(.websiteUrl)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)

        try container.encodeIfPresent(currencyCode, forKey: .currencyCode)
        try container.encodeAnyIfPresent(customFields, forKey: .customFields)
        try container.encodeIfPresent(gaToken, forKey: .gaToken)
        try container.encodeIfPresent(itemImageTypes, forKey: .itemImageTypes)
        try container.encodeIfPresent(stripeKey, forKey: .stripeKey)
        try container.encodeIfPresent(websiteUrl, forKey: .websiteUrl)
    }

    public func isEqual(to object: Any?) -> Bool {
      guard let object = object as? AppConfigGeneral else { return false }
      guard self.currencyCode == object.currencyCode else { return false }
      guard NSDictionary(dictionary: self.customFields ?? [:]).isEqual(to: object.customFields ?? [:]) else { return false }
      guard self.gaToken == object.gaToken else { return false }
      guard self.itemImageTypes == object.itemImageTypes else { return false }
      guard self.stripeKey == object.stripeKey else { return false }
      guard self.websiteUrl == object.websiteUrl else { return false }
      return true
    }

    public static func == (lhs: AppConfigGeneral, rhs: AppConfigGeneral) -> Bool {
        return lhs.isEqual(to: rhs)
    }
}
