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

import com.alibaba.fastjson.annotation.JSONField;
import org.tio.sitexxx.service.service.jpush.huawei.webpush.WebHmsOptions;
import org.tio.sitexxx.service.service.jpush.huawei.webpush.WebNotification;
import org.tio.sitexxx.service.service.jpush.huawei.webpush.WebpushHeaders;

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

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

    @JSONField(name = "notification")
    private WebNotification notification;

    @JSONField(name = "hms_options")
    private WebHmsOptions webHmsOptions;

    public WebpushHeaders getHeaders() {
        return headers;
    }

    public String getData() {
        return data;
    }

    public WebNotification getNotification() {
        return notification;
    }

    public WebHmsOptions getWebHmsOptions() {
        return webHmsOptions;
    }

    public WebPushConfig(Builder builder) {
        this.headers = builder.headers;
        this.data = builder.data;
        this.notification = builder.notification;
        this.webHmsOptions = builder.webHmsOptions;
    }

    public void check() {
        if (this.headers != null) {
            this.headers.check();
        }
        if (this.notification != null) {
            this.notification.check();
        }
        if (this.webHmsOptions != null) {
            this.webHmsOptions.check();
        }
    }

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

    public static class Builder {
        private WebpushHeaders headers;

        private String data;

        private WebNotification notification;

        private WebHmsOptions webHmsOptions;

        public Builder setHeaders(WebpushHeaders headers) {
            this.headers = headers;
            return this;
        }

        public Builder setData(String data) {
            this.data = data;
            return this;
        }

        public Builder setNotification(WebNotification notification) {
            this.notification = notification;
            return this;
        }

        public Builder setWebHmsOptions(WebHmsOptions webHmsOptions) {
            this.webHmsOptions = webHmsOptions;
            return this;
        }

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

}
