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

import Foundation
import ObjectMapper

class Features: Mappable, INameable {
    var featureId: Int!
    var productFamilyId: Int?
    var productSubfamilyId: Int?
    var name:  String!
    var code: String!
    var editorType:  String?
    var isVisible:  Bool!
    var isRequired:  Bool!
    var defaultValueId: Int?
    var featureValues: [FeatureValues] = [FeatureValues]()
    
    init() {
    }
    
    var customName: String { get { return name }}
    var customSubtitle: String? { return nil }
    
    required init?(map: Map){
        
    }
    
    func mapping(map: Map) {
        featureId <- map["FeatureId"]
        productFamilyId <- map["ProductFamilyId"]
        productSubfamilyId <- map["ProductSubfamilyId"]
        name <- map["Name"]
        code <- map["Code"]
        editorType <- map["EditorType"]
        isVisible <- map["IsVisible"]
        isRequired <- map["IsRequired"]
        defaultValueId <- map["DefaultValueId"]
        featureValues <- map["FeatureValues"]
    }
}

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


class FeatureValues: Mappable, INameable {
    var featureValueId: Int!
    var featureId: Int!
    var value:  String!
    var sortIndex: Int?
    var isVisible: Bool?
    
    init() {
    }
    
    var customName: String { get { return value }}
    var customSubtitle: String? { return nil }
    
    required init?(map: Map){
        
    }
    
    func mapping(map: Map) {
        featureValueId <- map["FeatureValueId"]
        featureId <- map["FeatureId"]
        value <- map["Value"]
        sortIndex <- map["SortIndex"]
        isVisible <- map["IsVisible"]
    }
}

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

class ProductFeatures: Mappable {
    var productFeatureId: Int!
    var productId:  String!
    var featureValueId: Int!
    var featureId: Int!
    
    init() {
    }
    
    required init?(map: Map){
    }
    
    func mapping(map: Map) {
        productFeatureId <- map["ProductFeatureId"]
        productId <- map["ProductId"]
        featureValueId <- map["FeatureValueId"]
        featureId <- map["FeatureId"]
    }
}

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

class FeaturesForProduct: Mappable {
    var productFeatureId: Int!
    var featureId: Int!
    var featureName:  String!
    var featureValueId: Int!
    var featureValue: String!
    
    var productId: String!
    
    init() {
    }
    
    required init?(map: Map){
    }
    
    func mapping(map: Map) {
        productFeatureId <- map["ProductFeatureId"]
        featureId <- map["FeatureId"]
        featureName <- map["FeatureName"]
        featureValueId <- map["FeatureValueId"]
        featureValue <- map["FeatureValue"]
    }
}

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