Skip to content

Commit 646e1e5

Browse files
committed
feat(api): add user avatarGreet
1 parent f393d78 commit 646e1e5

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [x] 短信登录
2626
- [x] 手机号与密码登录
2727
- [ ] 保存设备 Token
28+
- [x] 弹一弹头像
2829
- 用户关系
2930
- [x] 获取关注列表
3031
- [x] 获取被关注列表

src/api/users.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,16 @@ export const loginWithPhoneAndPassword = <T = Users.LoginResponse>(
9797
},
9898
})
9999
)
100+
101+
/**
102+
* 弹一弹
103+
* @param username 用户名
104+
*/
105+
export const avatarGreet = <T = Users.AvatarGreetResponse>(username: string) =>
106+
toResponse<T>(
107+
request.post('1.0/users/avatarGreet/create', {
108+
json: {
109+
username,
110+
},
111+
})
112+
)

src/types/api-responses.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export namespace Users {
102102
export type Profile<M extends boolean = boolean> = M extends true
103103
? MyProfile
104104
: UserProfile
105+
106+
export interface AvatarGreetResponse {
107+
success: boolean
108+
}
105109
}
106110

107111
export namespace PersonalUpdate {

tests/api/users.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,13 @@ describe('users should work', () => {
6161
expect(result.data.success).toBe(true)
6262
if (result.data.success) expect(result.data.user).toBeTruthy()
6363
})
64+
65+
it('avatarGreet should work', async () => {
66+
const result = await api.users.avatarGreet(
67+
'5C505995-681E-4C1E-AD4A-1CC683627B6E'
68+
)
69+
expect(result.status).toBe(200)
70+
expect(result.data.success).is.a('boolean')
71+
expect(result.data.success).toBe(true)
72+
})
6473
})

0 commit comments

Comments
 (0)