用户API
获取用户档案¶
GET https://uaa-openapi.hekr.me/user/profile HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"uid": "33995635438",
"birthday": 1496232255641,
"isSecurity": false,
"firstName": "twoyao",
"lastName": "bao",
"updateDate": 1496281207500,
"phoneNumber": "",
"gender": null,
"age": 22,
"avatarUrl": {
"big": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png",
"small": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png",
"middle": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png"
},
"foo": "bar",
"description": null,
"extraProperties": {
"foo": "bar"
},
"email": "t@hekr.me"
}
返回体¶
参数 | 含义 |
---|---|
uid | 用户ID |
birthday | 出生日期,UNIX毫秒时间戳 |
isSecurity | 是否设置了密保问题 |
firstName | 名 |
lastName | 姓 |
phoneNumber | 手机号码 可能为空 |
邮箱 可能为空 | |
gender | [MAN, WOMAN] 可能为空 |
age | 年龄[0,200],最小0,最大200,默认0 |
avatarUrl | 头像,分为大中小三种格式 |
description | 用户签名 |
extraProperties | 自定义属性 |
更新用户档案¶
若需修改头像,需先上传头像
PUT https://uaa-openapi.hekr.me/user/profile HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer {JWT_TOKEN}
{
"birthday": 1496232255641,
"firstName": "twoyao",
"lastName": "bao",
"gender": null,
"age":23,
"avatarUrl": {
"big": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png",
"small": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png",
"middle": "https://stage-allinone-ufile.hekr.me/userCloudStorageFile/ufile-3320585600100000000000-98b479772eb581ee808fc97af1ecba85.png"
},
"description": null,
"extraProperties": {
"foo": "bar"
}
}
HTTP/1.1 204 OK
Content-Type: application/json;charset=UTF-8
请求体¶
参数 | 是否必须 | 说明 | 例子 | 默认值 |
---|---|---|---|---|
birthday | false | 出生日期,UNIX毫秒时间戳 | 1496231441088 | 如果填写该参数,则age无效,否则age生效,不填则更新为null |
firstName | false | 名 | twoyao | |
lastName | false | 姓 | bao | |
gender | false | 性别[MAN, WOMAN] | MAN | |
age | false | 年龄,0-200,最小0,最大200 | 22 | birthday 优先,如果birthday为null,则age生效,请优先考虑birthday |
avatarUrl | false | 头像地址 | ||
description | false | 用户签名 | "我就是我,不一样的烟火" | |
extraProperties | false | 自定义用户属性 | {'foo': 'bar'} | {} |
绑定推送标签(逐个绑定)¶
POST https://user-openapi.hekr.me/user/pushTagBind HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
Content-Type: application/json
{
"clientId": "kwiZN...",
"locale" : "zh-CN",
"pushPlatform": "GETUI"
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
请求体¶
参数 | 是否可选 | 含义 |
---|---|---|
clientId | 必选 | 推送sdk分配给app的客户端id |
pushPlatform | 必选 | 推送平台, 可取值: [GETUI, XIAOMI, HUAWEI, FCM], GETUI 个推,XIAOMI 小米,HUAWEI 华为, FCM 谷歌推送 |
locale | 必选 | 用户所用语言, 可取值: [zh-CN, en-US, ...] Language Tag(IETF BCP 47 standard) |
绑定推送标签(全量绑定)¶
注意
每次绑定clientId时会清除之前绑定的记录,如需支持多平台处理,客户端需要先自行检测与各个推送平台的连接情况,然后统一上报。以优先使用FCM备选GETUI为例,客户端先检测和FCM及GETUI的连接,如果与FCM连接正常,clientIds 指定{ "FCM" : "fcm-token" }
,否则指定{ "GETUI" : "getui-clientid" }
。这样,即使用户之前上报过GETUI,后因"出国"可以使用FCM,仅上报FCM会清除GETUI的绑定,从而避免重复接收到GETUI的推送。
PUT https://user-openapi.hekr.me/user/pushTagBind HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
Content-Type: application/json
{
"locale": "zh_CN",
"clientIds": {
"FCM": "fcm-token"
}
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
请求体¶
参数 | 是否可选 | 含义 |
---|---|---|
clientIds | 必选 | 推送平台类型-clientId 键值对,推送平台可以是 [GETUI, XIAOMI, HUAWEI, FCM] |
locale | 必选 | 用户所用语言, 可取值: [zh, zh_CN, en, en_US...], 不支持language tag方式 |
解绑推送¶
POST https://user-openapi.hekr.me/user/unbindPushAlias HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
Content-Type: application/json
{
"clientId": "kwiZN...",
"pushPlatform": "GETUI"
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
请求体¶
参数 | 是否可选 | 默认 | 含义 |
---|---|---|---|
clientId | 必选 | 推送sdk分配给app的客户端id | |
pushPlatform | 必选 | 推送平台, 可取值: [GETUI, XIAOMI, HUAWEI, FCM], GETUI 个推,XIAOMI 小米,HUAWEI 华为, FCM 谷歌推送 |
删除所有推送配置¶
注意 该接口会删除当前用户下所有的推送配置,即所有的当前登录APP都将不会收到推送,直到再次调用绑定推送接口并绑定成功。
可以用在需要多个APP登录同一个账号,但是却不再需要推送给APP信息的场景下。
DELETE https://user-openapi.hekr.me/user/unbindAllPushAlias HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
请求体¶
无需参数
获取用户偏好¶
GET https://user-openapi.hekr.me/user/appPreferences HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"reservedKey": {
"_ReverseAuthAgree": false
},
"customKey": {
"key1": "red",
"key2": 5,
"key4": true,
"key3": 17.7
}
}
返回体¶
字段 | 含义 |
---|---|
reservedKey | 氦氪云内部实现业务逻辑所需要的参数 |
customKey | 自定义用户偏好 |
内置偏好¶
名称 | 取值范围 | 含义 |
---|---|---|
_ReverseAuthAgree | [true, false] | 反向授权流程中,用户分享的设备是否可以不经同意即可被请求者获取 |
修改用户偏好¶
POST https:/user-openapi.hekr.me/user/appPreferences HTTP/1.1
Authorization: Bearer {JWT_TOKEN}
{
"key1" : "value1"
}
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
{
"reservedKey": {
"_ReverseAuthAgree": false
},
"customKey": {
"key1": "red",
"key2": 5,
"key4": true,
"key3": 17.7
}
}
用户产品偏好设置¶
所谓产品偏好,即类似净化器默认工作模式等,跟某个产品相关的特性。 该类偏好设置跟具体品类相关。比如:
- 该品类预约任务最大数
- 该品类最大授权数
- 该品类的PM2.5值的默认报警阈值
- 该品类的AQI值在IFTTT规则中的默认触发区间
另外,需要注意的是: 用户不能通过调用云端 API来提交修改内置的品类偏好
curl -v -X POST \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "X-Hekr-ProdPubKey: {PPK}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://user-openapi.hekr.me/user/productPreferences" \
-d '{
"key1" : "value1",
...
}'
返回
< 201
< 创建的偏好设置
获取用户产品偏好设置¶
curl -v -X GET \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "X-Hekr-ProdPubKey: {PPK}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://user-openapi.hekr.me/user/productPreferences"
返回
< 200
< {
"key1" : "value1",
...
}
设置具体设备偏好设置¶
特定设备的偏好设置 我们可以认为:
- 品类偏好设置是具体设备偏好设置的默认设置
- 具体设备偏好设置是品类偏好设置的特例设置
curl -v -X POST \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "X-Hekr-ProdPubKey: {PPK}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://user-openapi.hekr.me/user/productDevicePreferences?devTid=xx&ctrlKey=xx&subDevTid=xx"
-d '{
"key1" : "value1",
...
}'
参数名 | 是否可选 | 参数类型 | 取值范围 | 说明 |
---|---|---|---|---|
devTid | 必选 | String | 设备ID | |
ctrlKey | 必选 | String | 控制码 | |
subDevTid | 可选 | String | 子设备ID |
返回
< 201
< 创建的偏好设置
获取具体设备偏好设置¶
获取特定设备的偏好设置,如果用户没有特殊设定则默认返回 品类偏好设置的默认值
curl -v -X GET \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "X-Hekr-ProdPubKey: {PPK}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://user-openapi.hekr.me/user/productDevicePreferences?devTid=xx&ctrlKey=xx&subDevTid=xx"
参数
参数名 | 是否可选 | 参数类型 | 取值范围 | 说明 |
---|---|---|---|---|
devTid | 必选 | String | 设备ID | |
ctrlKey | 必选 | String | 控制码 | |
subDevTid | 可选 | String | 子设备ID |
返回
< 200
< {
"key1" : "value1",
...
}
获取推送历史消息¶
拉取绑定或者授权过该产品厂家发给该用户的推送消息历史
curl -v -X GET \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://user-openapi.hekr.me/api/v1/app/push/history?page=0&size=10"
参数
参数名 | 是否可选 | 参数类型 | 取值范围 | 说明 |
---|---|---|---|---|
page | 可选 | int | [0, ?],默认为是0 | 页码 |
size | 可选 | int | [1, 100],默认是20 | 每页大小 |
返回
< 200
< {
"content": [
{
"title": "测试标题" // 推送标题
"content": "测试内容", // 推送内容
"pushTime": 1522749687059, // 推送时间
"pushAppOpenType": "APP", // 推送打开方式: APP 直接打开APP;URL 打开指定网页;CONTENT 打开自定义内容
"openContent": "" // 打开内容
}
],
"last": true,
"totalPages": 1,
"totalElements": 1,
"numberOfElements": 1,
"first": true,
"sort": [
{
"direction": "DESC",
"property": "pushTime",
"ignoreCase": false,
"nullHandling": "NATIVE",
"ascending": false
}
],
"size": 20,
"number": 0
}