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

import java.time.format.*;

import cokr.xit.ens.biz.iup.domain.*;
import cokr.xit.ens.core.utils.*;
import cokr.xit.ens.modules.kkotalk.model.*;
import lombok.*;

@RequiredArgsConstructor
public class AcptDocKkoTalk implements Accept<KkotalkApiDTO.Envelope> {

    private final TbInputDataXit tbInputDataXit;
    private final String redirectUrl;

    @Override
    public KkotalkApiDTO.Envelope createDocument() {
        final String readExpiresAt = DateUtil.getTimeTOfTime(tbInputDataXit.getTbInputXit().getPayExpiresDt().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
        return KkotalkApiDTO.Envelope.builder()
            .hash(null)
            .content(
                KkotalkApiDTO.Content.builder()
                    .link(redirectUrl)
                    .build())
            .readExpiresAt(readExpiresAt)
            .reviewExpiresAt(DateUtil.getAddDayT(readExpiresAt, 1))
            .build();
    }
}
