{
    "vouchers": {
        "_id": "vouchers",
        "type": "channel",
        "common": {},
        "native": {
            "object_id": "vouchers"
        },
        "logic": {
            "has_key": "_self",
            "has": {
                "vouchers.voucher": {
                    "type": "channel",
                    "common": {},
                    "native": {
                        "object_id": "vouchers.voucher"
                    },
                    "logic": {
                        "_id": {
                            "cleanupForUseAsId": [
                                {
                                    "cat": [
                                        "voucher_",
                                        {
                                            "var": "code"
                                        }
                                    ]
                                }
                            ]
                        },
                        "common": {
                            "name": "code"
                        },
                        "has_key": "_self",
                        "has": {
                            "vouchers.voucher.code": {
                                "_id": "code",
                                "type": "state",
                                "common": {
                                    "name": "Code",
                                    "type": "string",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.code"
                                },
                                "logic": {
                                    "value": "code"
                                }
                            },
                            "vouchers.voucher.create_time": {
                                "_id": "create_time",
                                "type": "state",
                                "common": {
                                    "name": "Create time",
                                    "type": "string",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.create_time"
                                },
                                "logic": {
                                    "value": {
                                        "secondsToDateTime": [
                                            {
                                                "var": "create_time"
                                            }
                                        ]
                                    }
                                }
                            },
                            "vouchers.voucher.duration": {
                                "_id": "duration",
                                "type": "state",
                                "common": {
                                    "name": "Duration",
                                    "type": "string",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "unit": "m",
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.duration"
                                },
                                "logic": {
                                    "value": "duration"
                                }
                            },
                            "vouchers.voucher.note": {
                                "_id": "note",
                                "type": "state",
                                "common": {
                                    "name": "Note",
                                    "type": "string",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.note"
                                },
                                "logic": {
                                    "value": "note"
                                }
                            },
                            "vouchers.voucher.qos_overwrite": {
                                "_id": "qos_overwrite",
                                "type": "state",
                                "common": {
                                    "name": "QOS overwrite",
                                    "type": "boolean",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.qos_overwrite"
                                },
                                "logic": {
                                    "value": "qos_overwrite"
                                }
                            },
                            "vouchers.voucher.qos_rate_max_down": {
                                "type": "state",
                                "common": {
                                    "name": "QOS max download",
                                    "type": "number",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "unit": "Kbps",
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.qos_rate_max_down"
                                },
                                "logic": {
                                    "_id": {
                                        "ifNotNull": [
                                            {
                                                "var": "qos_rate_max_down"
                                            },
                                            "qos_rate_max_down",
                                            null
                                        ]
                                    },
                                    "value": "qos_rate_max_down"
                                }
                            },
                            "vouchers.voucher.qos_rate_max_up": {
                                "type": "state",
                                "common": {
                                    "name": "QOS max upload",
                                    "type": "number",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "unit": "Kbps",
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.qos_rate_max_up"
                                },
                                "logic": {
                                    "_id": {
                                        "ifNotNull": [
                                            {
                                                "var": "qos_rate_max_up"
                                            },
                                            "qos_rate_max_up",
                                            null
                                        ]
                                    },
                                    "value": "qos_rate_max_up"
                                }
                            },
                            "vouchers.voucher.qos_usage_quota": {
                                "type": "state",
                                "common": {
                                    "name": "QOS usage quota",
                                    "type": "number",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "unit": "MB",
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.qos_usage_quota"
                                },
                                "logic": {
                                    "_id": {
                                        "ifNotNull": [
                                            {
                                                "var": "qos_usage_quota"
                                            },
                                            "qos_usage_quota",
                                            null
                                        ]
                                    },
                                    "value": "qos_usage_quota"
                                }
                            },
                            "vouchers.voucher.quota": {
                                "_id": "quota",
                                "type": "state",
                                "common": {
                                    "name": "Quota",
                                    "type": "number",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.quota"
                                },
                                "logic": {
                                    "value": "quota"
                                }
                            },
                            "vouchers.voucher.status": {
                                "_id": "status",
                                "type": "state",
                                "common": {
                                    "name": "Status",
                                    "type": "string",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.status"
                                },
                                "logic": {
                                    "value": "status"
                                }
                            },
                            "vouchers.voucher.used": {
                                "_id": "used",
                                "type": "state",
                                "common": {
                                    "name": "Used",
                                    "type": "number",
                                    "role": "state",
                                    "read": true,
                                    "write": false,
                                    "desc": ""
                                },
                                "native": {
                                    "object_id": "vouchers.voucher.used"
                                },
                                "logic": {
                                    "value": "used"
                                }
                            }
                        }
                    }
                },
                "vouchers.create_vouchers": {
                    "_id": "create_vouchers",
                    "type": "state",
                    "common": {
                        "name": "Create new vouchers",
                        "type": "boolean",
                        "role": "button",
                        "read": false,
                        "write": true,
                        "desc": ""
                    },
                    "native": {
                        "object_id": "vouchers.create_vouchers"},
                    "logic": {}
                }
            }
        }
    }
}
