// 假设有一个基础的请求函数,用于发送API请求
const baseRequest = (method, path, params) => {
// 这里应该包含发送请求的逻辑,例如使用axios或者其他HTTP库
// 返回一个Promise对象
};
// 获取用户信息
const getUserInfo = async (accessToken) => {
const path = '/user/get_info';
const params = {
access_token: accessToken,
};
return await baseRequest('GET', path, params);
};
// 获取用户的开放权限
const getUserAuth = async (accessToken) => {
const path = '/user/get_auth';
const params = {
access_token: accessToken,
};
return await baseRequest('GET', path, params);
};
// 用户绑定门锁
const userBindLock = async (accessToken, lockToken) => {
const path = '/user/bind_lock';
const params = {
access_token: accessToken,
lock_token: lockToken,
};
return await baseRequest('POST', path, params);
};
// 用户解绑门锁
const userUnbindLock = async (accessToken, lockToken) => {
const path = '/user/unbind_lock';
const params = {
access_token: accessToken,
lock_token: lockToken,
};
return await baseRequest('POST', path, params);
};
// 用户更新门锁固件
const userUpdateLockFirmware = async (accessToken, lockToken, firmwareUrl) => {
const path = '/user/update_lock_firmware';
const params = {
access_token: accessToken,
lock_token: lockToken,
firmware_url: firmwareUrl,
};
return await baseRequest('POST', path, params);
};
// 用户获取绑定的门锁列表
const getUserLockList = async (accessToken) => {
const path = '/user/get_lock_list';
const params = {
access_token: accessToken,
};
return await baseRequest('GET', path, params);
};
// 用户获取门锁运营数据
const getLockOperationData = async (accessToken, lockToken, startTime, endTime) => {
const path = '/user/get_lock_operation_data';
const params = {
access_token: accessToken,
lock_token: lockToken,
start_time: startTime,
end_time: endTime,
};
return await baseRequest('GET', path, params);
};
// 用户获取门锁系统信息
const getLockSystemInfo = async (accessToken, lockToken) => {
const path = '/user/get_lock_system_info';
const params = {
access_token: accessToken,
lock_token: lockToken,
};
return await baseRequest('GET