using DoliMiddlewareApi.Dtos.Dolibarr.Setup;
using DoliMiddlewareApi.Dtos.query.Setup;

namespace DoliMiddlewareApi.Mappers;

public static class SetupMapper
{
    public static PaymentTypeDto MapToPaymentTypeDto(PaymentTypeResponse r)
    {
        return new PaymentTypeDto
        {
            Id = r.id,
            Code = r.code,
            Label = r.label,
            Type = r.type
        };
    }

    public static CountryDto MapToCountryDto(CountryResponse r)
    {
        return new CountryDto
        {
            Id = r.id,
            Code = r.code,
            Label = r.label,
            CodeIso = r.code_iso,
            NumericCode = r.numeric_code,
            Active = r.active == "1"
        };
    }

    public static CivilityDto MapToCivilityDto(CivilityResponse r)
    {
        return new CivilityDto
        {
            Id = r.id,
            Code = r.code,
            Label = r.label
        };
    }

    public static ContactTypeDto MapToContactTypeDto(ContactTypeResponse r)
    {
        return new ContactTypeDto
        {
            Id = r.id,
            Code = r.code,
            Label = r.label
        };
    }

    public static PaymentTermDto MapToPaymentTermDto(PaymentTermResponse r)
    {
        return new PaymentTermDto
        {
            Id = r.id,
            Code = r.code,
            Label = r.label,
            Description = r.descr,
            Nbjour = r.nbjour
        };
    }

    public static CompanyDto MapToCompanyDto(CompanyResponse r)
    {
        return new CompanyDto
        {
            Name = r.name,
            Address = r.address,
            Town = r.town,
            Zip = r.zip,
            Country = r.country,
            Phone = r.phone,
            Email = r.email,
            VatNumber = r.tva_intra,
            Siren = r.idprof1
        };
    }
}