Last Updated on : 2024-08-28 01:53:48download
This topic describes how to implement the features of member management using APIs. These APIs allow you to add, remove, modify, and invite a member. The table below lists the permissions by role.
Role type | Role description | Permissions |
---|---|---|
Home owner | The creator of a home, which has the highest level of privileges. There can be only one home owner per home. |
|
Admin | An admin can be added only by a home owner. Multiple admins can be added in a home. An admin can add a common member and leave a home, but cannot delete a home. |
|
Common member | A common member can be added by a home owner or admin. Multiple common members can be added in a home. A common member is only allowed to view information. |
|
FamilyManagerCoreKit.getMemberUseCase()
is used for member management.
Data model of MemberBean
Field | Type | Description |
---|---|---|
memberId | Long | The member ID. |
homeId | Long | The ID of the home that a member belongs to. |
headUrl | String | The avatar of the member. |
name | String | The name of the member. |
role | Integer | The role of the member.
|
account | String | The account associated with a member, which can be a phone number or email address. |
uid | String | The user ID of the member. |
memberStatus | Integer | The status of a home invitation:
|
validTime | Long | The validity period of an invitation code. After expiration, a new one can be created. |
invitationCode | String | The invitation code, which can only be used by one user. |
invitationId | Long | The invitation ID. |
API description
void addMember(MemberWrapperBean addMemberWrapperBean,IFamilyMemberDataCallback<MemberBean> callback);
Parameter description
Parameters | Description |
---|---|
addMemberWrapperBean | The information about the added member. |
callback | The callback. |
Data model of MemberWrapperBean
Field | Type | Description |
---|---|---|
homeId | Long | The home ID. |
nickName | String | The nickname set for the invitee. |
account | String | The account of the invitee. |
countryCode | String | The country code of the invitee’s account. |
role | Integer | The role of the member.
|
headPic | String | The avatar set for the invitee. |
Example
val builder = MemberWrapperBean.Builder()
val memberWrapperBean = builder
.setHomeId('homeId')
.setMemberId('memberId')
.setNickName( 'nickname')
.setHeadPic( 'headPic')
.setCountryCode('countryCode')
.setAccount('account')
.setRole(MemberRole.ROLE_MEMBER)
.build()
FamilyManagerCoreKit.getMemberUseCase()
.addMember(memberWrapperBean, object : IThingDataCallback<MemberBean?> {
override fun onSuccess(memberBean: MemberBean?) {
}
override fun onError(s: String, s1: String) {
}
})
Remove a member from a home.
API description
void removeMember(long homeId, long memberId,IFamilyMemberResultCallback callback)
Parameter description
Parameters | Description |
---|---|
homeId | The home ID. |
memberId | The ID of the member to remove. |
callback | The callback. |
Example
FamilyManagerCoreKit.getMemberUseCase().removeMember(homeId,memberid,object :IFamilyMemberResultCallback{
override fun onError(code: String?, error: String?) {
}
override fun onSuccess() {
}
})
API description
void updateMember(MemberWrapperBean memberWrapperBean,IFamilyMemberResultCallback callback);
Parameter description
Parameters | Description |
---|---|
memberWrapperBean | The information about the member, including memberId , nickname , headPic , and isAdmin . |
callback | The callback. |
Example
val builder = MemberWrapperBean.Builder()
val memberWrapperBean = builder
.setMemberId('memberId')
.setNickName( 'nickname')
.setHeadPic( 'headPic')
.setAdmin('isAdmin')
.build()
FamilyManagerCoreKit.getMemberUseCase()
.updateMember(memberWrapperBean, object : IFamilyMemberResultCallback {
override fun onSuccess() {
}
override fun onError(s: String, s1: String) {
}
})
If a home member is not linked with an email address or phone number, for example, when signing in with a third party, this method can link them with their email address or phone number.
API description
void addMemberAccount(MemberWrapperBean addMemberWrapperBean,IFamilyMemberDataCallback<String> callback);
Parameter description
Parameters | Description |
---|---|
addMemberWrapperBean | The information about the member, including memberId , countryCode , account , and role . |
callback | The callback. |
Example
val builder = MemberWrapperBean.Builder()
val memberWrapperBean = builder
.setMemberId('memberId')
.setCountryCode('countryCode')
.setAccount('account')
.setRole(MemberRole.ROLE_MEMBER)
.build()
FamilyManagerCoreKit.getMemberUseCase()
.addMember(memberWrapperBean, object : IThingDataCallback<MemberBean?> {
override fun onSuccess(memberBean: MemberBean?) {
}
override fun onError(s: String, s1: String) {
}
})
Get the list of members in a home.
API description
void getFamilyMemberList(long homeId,
IFamilyDataCallback<BizResponseData<List<MemberBean>>> callback);
Parameter description
Parameters | Description |
---|---|
homeId | The home ID. |
callback | The callback. |
Example
FamilyManagerCoreKit.getFamilyUseCase().getFamilyMemberList(homeId,object :IFamilyDataCallback<BizResponseData<List<MemberBean>>>{
override fun onSuccess(result: BizResponseData<List<MemberBean>>?) {
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Get the list of home invitations that have not been accepted, including the pending and expired ones.
API description
void getInvitationMemberList(long homeId,IFamilyDataCallback<BizResponseData<List<MemberBean>>> callback);
Parameter description
Parameters | Description |
---|---|
homeId | The home ID. |
callback | The callback. |
Example
FamilyManagerCoreKit.getFamilyUseCase().getInvitationMemberList(homeId,object :IFamilyDataCallback<BizResponseData<List<MemberBean>>>{
override fun onSuccess(result: BizResponseData<List<MemberBean>>?) {
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Get the information about members in a home.
API description
void getMemberInfo(long mHomeId, long memberId,IFamilyMemberDataCallback<MemberBean> callback)
Parameter description
Parameters | Description |
---|---|
homeId | The home ID. |
memberId | The member ID. |
callback | The callback. |
Example
FamilyManagerCoreKit.getMemberUseCase().getMemberInfo(homeId,memberId,object:IFamilyMemberDataCallback<MemberBean>{
override fun onSuccess(result: MemberBean?) {
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Get the list of devices that a member can use. For example, access to door locks or security devices is only granted to specific members.
API description
void getMemberDeviceList(long relationId,IFamilyMemberDataCallback<Map<String, List<MemberDeviceBean>>> callback);
Parameter description
Parameters | Description |
---|---|
relationId | The member ID. |
success | The success callback. |
failure | The failure callback. |
Example
FamilyManagerCoreKit.getMemberUseCase().getMemberDeviceList(memberId,object:IFamilyMemberDataCallback<Map<String, List<MemberDeviceBean>>>{
override fun onSuccess(result: Map<String, List<MemberDeviceBean>>?) {
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
A home owner can transfer their role to another home member.
API description
void transferOwner(long homeId, long memberId,
IFamilyDataCallback<Boolean> callback);
Parameter description
Parameters | Type | Description |
---|---|---|
homeId | Long | The home ID. |
memberId | Long | The member ID. |
callback | IFamilyDataCallback<Boolean> | Callback for the result of the query. |
Example
FamilyManagerCoreKit.getFamilyUseCase().transferOwner(homeId, memberId, object :
IFamilyDataCallback<Boolean>{
override fun onSuccess(result: Boolean) {
}
override fun onError(errcode: String?, errMsg: String?) {
}
});
Make a callback on success to return the invitation code and message.
API description
void getInvitationMessage(long homeId,IFamilyMemberDataCallback<InvitationMessageBean> callback);
Parameter description
Parameters | Description |
---|---|
homeId | The home ID. |
callback | The callback. |
Data model of InvitationMessageBean
Field | Type | Description |
---|---|---|
invitationMsgContent | String | The invitation message. |
invitationCode | String | The invitation code. |
Example
FamilyManagerCoreKit.getMemberUseCase().getInvitationMessage(
homeId,
object : IFamilyMemberDataCallback<InvitationMessageBean?> {
override fun onSuccess(result: InvitationMessageBean?) {
}
override fun onError(errorCode: String, errorMessage: String) {
}
})
After an invitation code expires, the method reInviteMember
can create a new one with the original invitation ID unchanged.
API description
void reInviteMember(long invitationId,IFamilyMemberDataCallback<InvitationMessageBean> callback);
Parameter description
Parameters | Description |
---|---|
invitationId | The invitation ID. |
callback | The success callback. |
Example
FamilyManagerCoreKit.getMemberUseCase().reInviteMember(
invitationId,
object : IFamilyMemberDataCallback<InvitationMessageBean?> {
override fun onSuccess(result: InvitationMessageBean?) {
}
override fun onError(errorCode: String, errorMessage: String) {
}
})
Revoke a home invitation code. The invitee cannot join the home with the code anymore.
API description
void cancelInviteMember(long invitationId,IFamilyMemberResultCallback callback);
Parameter description
Parameters | Description |
---|---|
invitationId | The invitation ID. |
callback | The success callback. |
Example
FamilyManagerCoreKit.getMemberUseCase().cancelInviteMember(
invitationId,
object : IFamilyMemberResultCallback {
override fun onSuccess() {
}
override fun onError(errorCode: String, errorMessage: String) {
}
})
Modify the information about the invitee and update the invitation code.
API description
void updateMemberByInvitation(long invitationId, MemberBean memberBean,IFamilyMemberDataCallback<Boolean> callback);
Parameter description
Parameters | Description |
---|---|
invitationId | The invitation ID. |
memberBean | The information about the invitee, including memberName and role . |
callback | The callback. |
Example
val member = MemberBean()
member.memberName = "xxx"
member.role = MemberRole.ROLE_MEMBER
FamilyManagerCoreKit.getMemberUseCase().updateMemberByInvitation(
invitationId,
member,
object : IFamilyMemberDataCallback<Boolean?> {
override fun onSuccess(result: Boolean?) {
}
override fun onError(errorCode: String, errorMessage: String) {
}
})
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback