//
//  ElectronicInvoice.swift
//  iPOS
//
//  Created by Daniel Ciuciu on 12/13/19.
//  Copyright © 2019 BBC. All rights reserved.
//

import Foundation
import ObjectMapper

class ElectronicInvoiceRequest: Mappable {
    var storeId: Int!
    var cashRegister: Int!
    var companyId: Int!
    var dateFrom: Date = Date()
    var dateTo: Date = Date()
    var loadType: String = "N" // (n=new, t=total)
    var action: String = "L" // (l=load, e=export)
    
    init() {
        storeId = Int(settings.StoreId)!
        cashRegister = Int(settings.CashRegister)!
        companyId = settings.userSettings.companyId
    }
    
    required init?(map: Map){
        storeId = Int(settings.StoreId)!
        cashRegister = Int(settings.CashRegister)!
        companyId = settings.userSettings.companyId
    }
    
    func mapping(map: Map) {
        storeId <- map["StoreId"]
        cashRegister <- map["CashRegister"]
        companyId <- map["CompanyId"]
        
        dateFrom <- (map["DateFrom"], Util.CustomDateTransform())
        dateTo <- (map["DateTo"], Util.CustomDateTransform())
        loadType <- map["LoadType"]
        action <- map["Action"]
    }
}

class ElectronicInvoiceResponse: Mappable {
    var electronicInvoiceCount: Int = 0
    var name: String = ""
    var fiscalCode: String = ""
    var email: String = ""
    var telephone: String = ""
    var resultCode: Int = -1
    var errorMessage: String = ""
    var senderType: String = "" // (D=Direct, I=Intermediary)
    
    init() {
        
    }
    
    required init?(map: Map){
        
    }
    
    func mapping(map: Map) {
        electronicInvoiceCount <- map["ElectronicInvoiceCount"]
        name <- map["Name"]
        fiscalCode <- map["FiscalCode"]
        email <- map["Email"]
        telephone <- map["Telephone"]
        resultCode <- map["ResultCode"]
        errorMessage <- map["ErrorMessage"]
        senderType <- map["SenderType"]
    }
}
class EIAddSenderRequest: Mappable {
    var storeId: Int!
    var cashRegister: Int!
    var companyId: Int!
    var name: String = ""
    var fiscalCode: String = ""
    var email: String = ""
    var telephone: String = ""
    var senderType: String = "" // (D=Direct, I=Intermediary)
    
    init() {
        storeId = Int(settings.StoreId)!
        cashRegister = Int(settings.CashRegister)!
        companyId = settings.userSettings.companyId
    }
    
    required init?(map: Map){
        storeId = Int(settings.StoreId)!
        cashRegister = Int(settings.CashRegister)!
        companyId = settings.userSettings.companyId
    }
    
    func mapping(map: Map) {
        storeId <- map["StoreId"]
        cashRegister <- map["CashRegister"]
        companyId <- map["CompanyId"]
        name <- map["Name"]
        fiscalCode <- map["FiscalCode"]
        email <- map["Email"]
        telephone <- map["Telephone"]
        senderType <- map["SenderType"]
    }
}
