Home Member Management

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.
  • Query, modify, and delete a home.
  • Transfer the role of home owner.
  • Query, create, modify, and delete a room in the home.
  • Query, modify, and delete a home member.
  • Add an admin and common member.
  • Add, query, control, edit, share, and remove a device. View device status and update device firmware.
  • Create, edit, dismiss, and control a group, and control devices.
  • Query, modify, and add a scene.
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.
  • Query, modify, and leave a home.
  • Query, create, modify, and delete a room in the home.
  • Query home members. Add, modify, and delete a common member.
  • Add, query, control, edit, share, and remove a device. View device status and update device firmware.
  • Create, edit, dismiss, and control a group.
  • Query, modify, and add a scene.
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.
  • Query and leave a home.
  • Query a room.
  • Query a home member.
  • View device status and information.
  • View group information.
  • Query a scene.

Data model

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.
  • 0: Home owner MemberRole.ROLE_OWNER
  • 1: Admin MemberRole.ROLE_ADMIN
  • 2: Common member MemberRole.ROLE_MEMBER
The privileges are applied in descending order, with the home owner having the highest level of access.
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:
  • 1: Pending acceptance MemberStatus.WAITING
  • 2: Accepted MemberStatus.ACCEPT
  • 3: Declined MemberStatus.REJECT
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.

Add a home member

  • A home owner can add an admin and common member.
  • An admin can add a common member and role with low privileges.

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.
  • MemberRole.ROLE_OWNER: Home owner
  • MemberRole.ROLE_ADMIN: Admin
  • MemberRole.ROLE_MEMBER: Common 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 home member

Remove a member from a home.

  • A home owner can remove an admin and common member.
  • An admin can remove a common member and role with low privileges.

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() {

            }
        })

Update a home member

  • A home owner can edit an admin and role with low privileges.
  • An admin can edit a common member and role with low privileges.

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) {

                }
            })

Link an account

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.

  • A home owner can do this for an admin and role with low privileges.
  • An admin can do this for a common member and role with low privileges.

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

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 pending invitations

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 member information

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 devices a member can access

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?) {

            }
        })

Transfer a home

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?) {

            }
        });

Create a home invitation code

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) {

                }
            })

Renew a home invitation code

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

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) {

                }
        })

Update a home invitation code

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) {

                }
            })