//
//  DiscountCauses.swift
//  iPOS
//
//  Created by Zoran Albu on 6/27/18.
//  Copyright © 2018 BBC. All rights reserved.
//

import Foundation
import ObjectMapper

class DiscountCauses: Mappable, INameable {
    var discountCauseId: Int = 0
    var name: String = String()
    var isEnabled: Bool = false
    var countryId: String = String()
    var maxDiscount: Double = 1
    var isFixedDiscount: Bool = false
    var maxValoricDiscount: Double?
    var code: String = String()
    
    var customName: String {
        get {
            return name + " - " + code
        }
    }
    
    var customSubtitle: String? { return nil }
    
    init() {
    }
    
    required init?(map: Map){
    }
    
    func mapping(map: Map) {
        discountCauseId <- map["DiscountCauseId"]
        code <- map["Code"]
        name <- map["Name"]
        countryId <- map["CountryId"]
        maxDiscount <- (map["MaxDiscount"], Util.CustomDoubleTransform())
        maxValoricDiscount <- (map["MaxValoricDiscount"], Util.CustomDoubleTransform())
        isEnabled <- map["IsEnabled"]
        isFixedDiscount <- map["IsFixedDiscount"]
    }
}

class DiscountCausesResponse: Mappable {
    var odataMetadata: String?
    var value: [DiscountCauses]?
    
    required init?(map: Map){
        
    }
    
    func mapping(map: Map) {
        odataMetadata <- map["odata.metadata"]
        value <- map["value"]
    }
}
