package org.tio.sitexxx.service.service.jpush.huawei.apns;

import com.alibaba.fastjson.annotation.JSONField;
import org.tio.sitexxx.service.service.jpush.huawei.util.ValidatorUtils;

/**
 * <pre>
 *    @author : vagrancy
 *    e-mail : 18050829067@163.com
 *    time   : 2025-02-21 11:03
 *    desc   :
 * </pre>
 */
public class Aps {
    @JSONField(name = "alert")
    private Object alert;

    @JSONField(name = "badge")
    private Integer badge;

    @JSONField(name = "sound")
    private String sound;

    @JSONField(name = "content-available")
    private Integer contentAvailable;

    @JSONField(name = "category")
    private String category;

    @JSONField(name = "thread-id")
    private String threadId;

    public Object getAlert() {
        return alert;
    }

    public Integer getBadge() {
        return badge;
    }

    public String getSound() {
        return sound;
    }

    public Integer getContentAvailable() {
        return contentAvailable;
    }

    public String getCategory() {
        return category;
    }

    public String getThreadId() {
        return threadId;
    }

    public void check() {
        if (this.alert != null) {
            if(this.alert instanceof Alert){
                ((Alert) this.alert).check();
            }else{
                ValidatorUtils.checkArgument((this.alert instanceof String), "Alter should be Dictionary or String");
            }
        }
    }

    private Aps(Builder builder) {
        this.alert = builder.alert;
        this.badge = builder.badge;
        this.sound = builder.sound;
        this.contentAvailable = builder.contentAvailable;
        this.category = builder.category;
        this.threadId = builder.threadId;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private Object alert;
        private Integer badge;
        private String sound;
        private Integer contentAvailable;
        private String category;
        private String threadId;

        public Builder setAlert(Object alert) {
            this.alert = alert;
            return this;
        }

        public Builder setBadge(Integer badge) {
            this.badge = badge;
            return this;
        }

        public Builder setSound(String sound) {
            this.sound = sound;
            return this;
        }

        public Builder setContentAvailable(Integer contentAvailable) {
            this.contentAvailable = contentAvailable;
            return this;
        }

        public Builder setCategory(String category) {
            this.category = category;
            return this;
        }

        public Builder setThreadId(String threadId) {
            this.threadId = threadId;
            return this;
        }

        public Aps build() {
            return new Aps(this);
        }
    }

}
