package com.xiaoyudesign.rnupdate;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;

public enum UpdateResultParams {
    SUCCESS(200, "OK"),
    PPK_VERSION_INSTALL(201, "版本已安装"),
    PPK_VERSION_UNINSTALL(202, "版本已下载，未安装"),
    PPK_VERSION_UNDOWNLOAD(203, "版本未下载"),
    ERROR_PARAMS(501, "参数错误"),
    ERROR_RUNTIME(500, "运行时错误");

    private int code;
    private String desc;

    UpdateResultParams(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public UpdateResultParams setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public ReadableMap toReadableMap() {
        WritableMap map = Arguments.createMap();
        map.putInt("code", this.code);
        map.putString("msg", this.desc);
        return map;
    }
}
