Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
3
Indexable
Never
package br.com.senior.erpxcomven.pedido.converter.impl;

import java.util.Objects;

import org.springframework.stereotype.Component;

import br.com.senior.erpxcomven.foundation.E001endEntity;
import br.com.senior.erpxcomven.foundation.E001pesEntity;
import br.com.senior.erpxcomven.pedido.ShippingAddress;

@Component
public class ShippingAddressConverter {

    public ShippingAddress convert(E001endEntity shippingAddress) {
        if (Objects.isNull(shippingAddress)) {
            return null;
        }
        E001pesEntity e001pes = shippingAddress.getE001pes();
        var dto = new ShippingAddress();
        dto.address = shippingAddress.getEndPes();
        dto.addressNumber = shippingAddress.getNenEnd();
        dto.addressComplement = shippingAddress.getCplEnd();
        dto.neighborhood = shippingAddress.getBaiEnd();
        dto.postCode = shippingAddress.getPostalCode();
        if (Objects.nonNull(e001pes)) {
            dto.document = e001pes.getCnpCpf();
            dto.name = e001pes.getNomPes();
        }
        return dto;
    }

}