1. 创建楼栋
创建用楼栋
POST:http://api.xdua.com/tower
只有角色root,权限addtower才有权利创建tower.
字段名 | 位置 | 字段 | 字段说明 | 举例 | 必选 |
---|---|---|---|---|---|
apiv | head | string | API版本,默认是1.0.0 | 1.0.0 | 可选 |
Authorization | head | string | 客户端保存的鉴权token | Authorization字符串 | 必选 |
name | body | string | 楼栋的名字 | utf8-bin64个字符以内 | 必选 |
ntier | body | string | 楼栋的层数 | short int | 必选 |
note | body | string | 楼栋的备注 | 64个字符以内,必须是英文或者数字 | 必选 |
enabled | body | string | 楼栋的状态 | 1:启用楼栋 0:楼栋不启动 | 必选 |
avatar | body | string | 楼栋的图像 | 必选 |
BrowserSDK调用代码
const lovearth = require('../lib')
async function test_addroom() {
//--------------------------------------------------
const dua = await lovearth({
APP_KEY: "您的appkey",
APP_SECRET: "您的appsecret",
})
api_name = "创建楼栋";
got_room_id = "";
await dua.login({
by : "tel",
ustr: '+86-15810419011',
pwd : 'a906449d5769fa7361d7ecc6aa3f6d28',
room: "XdUaXduA",
role: "none"
})
const res = await dua.addroom({
name:"测试楼栋",
brief:"这是一个测试用的楼栋",
avatar:"",
pid:"户群的id",
god_id:"管理员的id"
})
console.log(res);
if(res.error == 0){
got_room_id = res.result.id;
console.log(api_name+"成功 "+got_room_id);
}else{
got_room_id = res.result.id;
console.log(api_name+"失败 "+res.reason);
}
}
test_addroom();
1.1. 成功的返回
返回的id便是新创建的room的id.
{
"error": 0,
"reason": "Success",
"result": ["id"=>"3bc8d2bf"]
}
1.2. 失败的返回
{
"error": 1,
"reason": "失败原因",
"result": {"失败返回的参考数据"}
}