package com.neptune.plugin.models;

import com.getcapacitor.JSObject;

import org.json.JSONObject;

public class SignalInfoModel {

    private Integer level;
    private Integer dbm;
    private Integer asu;
    private String networkType;
    private String operator;
    private String simState;
    private boolean airplane;
    private int sdk;
    private String source;

    public SignalInfoModel(Integer level, Integer dbm, Integer asu, String networkType, String operator, String simState, boolean airplane, int sdk, String source) {
        this.level = level;
        this.dbm = dbm;
        this.asu = asu;
        this.networkType = networkType;
        this.operator = operator;
        this.simState = simState;
        this.airplane = airplane;
        this.sdk = sdk;
        this.source = source;
    }

    public JSObject toJSON() {
        JSObject jo = new JSObject();
        jo.put("level", nullable(this.level));
        jo.put("dbm", nullable(this.dbm));
        jo.put("asu", nullable(this.asu));
        jo.put("networkType", nullable(this.networkType));
        jo.put("operator", nullable(this.operator));
        jo.put("simState", nullable(this.simState));
        jo.put("airplane", this.airplane);
        jo.put("sdk", this.sdk);
        jo.put("source", nullable(this.source));
        return jo;
    }

    private static Object nullable(Object value) {
        return (value != null) ? value : JSONObject.NULL;
    }
}
