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

import Foundation
import JSONUtilities

public class AppConfigGeneral: JSONDecodable, JSONEncodable, PrettyPrintable {

    /** 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
    }

    public required init(jsonDictionary: JSONDictionary) throws {
        currencyCode = jsonDictionary.json(atKeyPath: "currencyCode")
        customFields = jsonDictionary.json(atKeyPath: "customFields")
        gaToken = jsonDictionary.json(atKeyPath: "gaToken")
        itemImageTypes = jsonDictionary.json(atKeyPath: "itemImageTypes")
        stripeKey = jsonDictionary.json(atKeyPath: "stripeKey")
        websiteUrl = jsonDictionary.json(atKeyPath: "websiteUrl")
    }

    public func encode() -> JSONDictionary {
        var dictionary: JSONDictionary = [:]
        if let currencyCode = currencyCode {
            dictionary["currencyCode"] = currencyCode
        }
        if let customFields = customFields {
            dictionary["customFields"] = customFields
        }
        if let gaToken = gaToken {
            dictionary["gaToken"] = gaToken
        }
        if let itemImageTypes = itemImageTypes {
            dictionary["itemImageTypes"] = itemImageTypes
        }
        if let stripeKey = stripeKey {
            dictionary["stripeKey"] = stripeKey
        }
        if let websiteUrl = websiteUrl?.encode() {
            dictionary["websiteUrl"] = websiteUrl
        }
        return dictionary
    }

    /// pretty prints all properties including nested models
    public var prettyPrinted: String {
        return "\(type(of: self)):\n\(encode().recursivePrint(indentIndex: 1))"
    }
}
