package cokr.xit.ens.biz.iup.signtalk.service.support.accept;

import cokr.xit.ens.biz.iup.domain.TbInputDataXit;
import cokr.xit.ens.core.utils.DateUtil;
import cokr.xit.ens.modules.kkomydoc.model.config.DocumentConfKkoMd;
import cokr.xit.ens.modules.kkomydoc.model.config.Property;
import lombok.RequiredArgsConstructor;

import java.time.format.DateTimeFormatter;
import java.util.Arrays;

@RequiredArgsConstructor
public class AcptDocKkoMd implements Accept<DocumentConfKkoMd> {

    private final TbInputDataXit tbInputDataXit;
    private final String redirectUrl;

    @Override
    public DocumentConfKkoMd createDocument() {
        return DocumentConfKkoMd.builder()
                .hash(null)
                .common_categories(Arrays.asList("NOTICE"))
                .read_expired_at(DateUtil.dateToAbsTimeSec(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))))
//                .read_expired_sec()
                .property(this.createProperty(tbInputDataXit))
                .bridge(null)
                .build();
    }


    private Property createProperty(TbInputDataXit data) {
        return Property.builder()
//                .link(data.getPayUrl())    
                .link(redirectUrl)    
                .payload(null)
                .message(null)
                .cs_name("문의처")
                .cs_number(data.getCallCenterNo())
//                .external_document_uuid(data.getDataId())
//                .external_document_uuid(data.getLinkedUuid())
                .build();
    }

}
