package cokr.xit.ens.biz.traffic.cheonan.signtalk.service.support.accept;

import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.TcaElctrnNticSndngDetail;
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.util.Arrays;

@RequiredArgsConstructor
public class AcptDocKkoMd implements Accept<DocumentConfKkoMd> {

    private final TcaElctrnNticSndngDetail tcaElctrnNticSndngDetail;
    private final String redirectUrl;

    @Override
    public DocumentConfKkoMd createDocument() {
        return DocumentConfKkoMd.builder()
                .hash(null)
                .common_categories(Arrays.asList("NOTICE"))
                .read_expired_at(DateUtil.dateToAbsTimeSec(tcaElctrnNticSndngDetail.getElctrnNticSndng().getClosDt()))
//                .read_expired_sec()
                .property(this.createProperty())
                .bridge(null)
                .build();
    }


    private Property createProperty() {
        return Property.builder()
                .link(this.redirectUrl)    
                .payload(null)
                .message(null)
                .cs_name(null)
                .cs_number(null)
                .build();
    }

}
