All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.yawenok.fcm.client.request.FcmMessage Maven / Gradle / Ivy

The newest version!
package io.github.yawenok.fcm.client.request;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import io.github.yawenok.fcm.client.enums.Priority;
import io.github.yawenok.fcm.client.options.FcmMessageOptions;

public class FcmMessage {
    private final FcmMessageOptions options;
    private final Object data;
    private final Object notification;

    public FcmMessage(FcmMessageOptions options, Object data, Object notification) {
        if (options == null) {
            throw new IllegalArgumentException("options");
        }
        this.options = options;
        this.data = data;
        this.notification = notification;
    }

    @JSONField(name = "collapse_key")
    public String getCollapseKey() {
        return options.getCollapseKey();
    }

    @JSONField(name = "priority")
    public Priority getPriority() {
        return options.getPriority();
    }

    @JSONField(name = "content_available")
    public Boolean getContentAvailable() {
        return options.getContentAvailable();
    }

    @JSONField(name = "mutable_content")
    public Boolean getMutableContent() {
        return options.getMutableContent();
    }

    @JSONField(name = "time_to_live")
    public int getTimeToLive() {
        return options.getTimeToLive();
    }

    @JSONField(name = "restricted_package_name")
    public String getRestrictedPackageName() {
        return options.getRestrictedPackageName();
    }

    @JSONField(name = "dry_run")
    public Boolean getDryRun() {
        return options.getDryRun();
    }

    @JSONField(name = "data")
    public Object getPayload() {
        return data;
    }

    @JSONField(name = "notification")
    public Object getNotification() {
        return this.notification;
    }

    public String build() {
        return JSON.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy