package cn.axzo.msg.center.service.template.response;

import cn.axzo.msg.center.service.enums.CardBizState;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author xudawei@axzo.cn
 * @date 2024/12/10
 * @desc 配置状态戳
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MessageTemplateV3ConfigStateResponse implements Serializable {

    private static final long serialVersionUID = 6772912658753264863L;

    /**
     * code
     */
    private String stateCode;

    /**
     * 描述
     */
    private String description;
    /**
     * 是否启用
     */
    private Boolean enabled;
    /**
     * url
     */
    private String imageUrl;

    /**
     * 对象转换
     */
    public static List<MessageTemplateV3ConfigStateResponse> cardStateToResp() {
        List<CardBizState> cardStates = CardBizState.imageConfigurableStates();
        return cardStates.stream().map(item ->
            MessageTemplateV3ConfigStateResponse.builder()
                    .stateCode(item.name())
                    .description(item.getDescription())
                    .imageUrl(item.getDefaultImageUrl())
                    .build()
        ).collect(Collectors.toList());
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
