Member Information Management

Last Updated on : 2023-05-25 06:23:50

Add a home member

A home owner can add an administrator and other members with lower permissions to the home. But the administrator can only add common members and other members with lower permissions to the home.

API description

The autoAccept field of the MemberWrapperBean object specifies whether an invitation is automatically accepted to add an invitee to the home. If the value is set to false, you must call the processInvitation() method, so the invitee needs to accept the invitation before joining the home.

void addMember(MemberWrapperBean memberWrapperBean, IThingDataCallback<MemberBean> callback)

Parameters

Parameter Description
memberWrapperBean The member information.

Data model of MemberWrapperBean

Field Type Description
homeId long The ID of the home that the invitee joins.
nickName String The nickname of the invitee.
admin boolean Specifies whether the invitee is an administrator.
memberId long The member ID.
headPic String The avatar of the invitee. If the value is set to nil, the invitee’s personal avatar is used.
account String The account of the invitee.
countryCode String The country code of the invitee’s account.
invitationCode String The invitation code.
role int The member role of the invitee. For more information, see the definition of MemberRole. Valid values:
  • -1: custom role
  • 0: common member
  • 1: administrator
  • 2: owner
  • -999: invalid role
autoAccept boolean Specifies whether the invitation is automatically accepted. Valid values:
  • true: The invitation is automatically accepted.
  • false: The invitee needs to accept the invitation before joining the home.

Data model of MemberBean

Field Type Description
homeId long The ID of the home that the invitee joins.
nickName String The nickname of the invitee.
admin boolean Specifies whether the invitee is an administrator.
memberId long The member ID.
headPic String The avatar of the invitee. If the value is set to null, the invitee’s personal avatar is used.
account String The account of the invitee.
role int The member role of the invitee. For more information, see the definition of MemberRole.
role int The member role of the invitee. For more information, see the definition of MemberRole. Valid values:
  • -1: custom role
  • 0: common member
  • 1: administrator
  • 2: owner
  • -999: invalid role
memberStatus int The status of the invitation. For more information, see the definition of MemberStatus. Valid values:
  • 1: to be accepted
  • 2: accepted
  • 3: rejected
  • 4: invalid

Example

ThingHomeSdk.getMemberInstance().addMember(memberWrapperBean, new IThingDataCallback<MemberBean>() {
		@Override
		public void onSuccess(MemberBean result) {
			// do something
		}
		@Override
		public void onError(String errorCode, String errorMessage) {
			// do something
		}
	});

Remove a member

A home owner can remove an administrator and other members with lower permissions. The administrator can only remove common members and other members with lower permissions.

API description

The home will be processed in varied ways, depending on different values of memberId:

  • If memberId is set to an administrator, common member, or custom role, the member to be removed will leave the home. In this case, the home will not be deleted and its devices will not be reset.
  • If memberId is set to the home owner, the home is deleted and all devices of the home will be reset. The result is the same as that of dismissHome.
void removeMember(long memberId, IResultCallback callback)

Parameters

Parameter Description
memberId The member ID.

Example

ThingHomeSdk.getMemberInstance().removeMember(memberId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Query a list of home members

API description

void queryMemberList(long mHomeId, IThingGetMemberListCallback callback)

Parameters

Parameter Description
mHomeId The home ID.

Example

ThingHomeSdk.getMemberInstance().queryMemberList(mHomeId, new IThingGetMemberListCallback() {
		@Override
		public void onSuccess(List<MemberBean> memberBeans) {
			// do something
		}
		@Override
		public void onError(String errorCode, String error) {
			// do something
		}
	});

Update member information

API description (recommended)

void updateMember(MemberWrapperBean memberWrapperBean, IResultCallback callback)

Parameters

Parameter Type Description
memberWrapperBean MemberWrapperBean The member information.

Example

ThingHomeSdk.getMemberInstance().updateMember(memberWrapperBean, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

API description (not recommended)

void updateMember(long memberId, String name, boolean admin, IResultCallback callback)

Parameters

Parameter Type Description
memberId long The member ID.
name name The name of the member.
admin boolean Specifies whether the member is an administrator.

Example

ThingHomeSdk.getMemberInstance().updateMember(memberId, name, admin, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	 });

Query the invitation code to add a member

API description

void getInvitationMessage(long homeId, IThingDataCallback callback)

Parameters

Parameter Description
homeId The home ID.

Example

ThingHomeSdk.getMemberInstance().getInvitationMessage(homeId, new IThingDataCallback<InviteMessageBean>() {
			@Override
			public void onSuccess(InviteMessageBean result) {
				// onSuc
			}

			@Override
			public void onError(String errorCode, String errorMessage) {
				// onErr
			}
		});

Join a home with an invitation code

API description

void joinHomeByInviteCode(String code, IResultCallback callback);

Parameters

Parameter Description
code The invitation code.

Example

ThingHomeSdk.getHomeManagerInstance().joinHomeByInviteCode("code" , new IResultCallback() {
			@Override
			public void onError(String code, String error) {

			}

			@Override
			public void onSuccess() {

			}
		});

Revoke an invitation to join a home

API description

void cancelMemberInvitationCode(long invitationId, IResultCallback callBack)

Parameters

Parameter Description
invitationId The invitation ID.

Example

ThingHomeSdk.getMemberInstance().cancelMemberInvitationCode(invitationId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Accept or decline an invitation to join a home

API description

void processInvitation(long homeId, boolean action, IResultCallback callBack)

Parameters

Parameter Description
homeId The home ID.
action Accepts or declines the invitation.

Example

ThingHomeSdk.getMemberInstance().processInvitation(homeId, action, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Query invitation records

API description

void getInvitationList(long homeId, IThingDataCallback callback)

Parameters

Parameter Description
homeId The home ID.

Data model of InviteListResponseBean

Parameter Type Description
validTime long The validity period of the invitation.
invitationId long The invitation ID.
invitationCode String The invitation code.
gid long The ID of the home that the invitee joins.
name String The nickname of the invitee.
admin boolean Specifies whether the member is an administrator.
dealStatus int
  • 1: to be accepted
  • 2: accepted
  • 3: rejected
  • 4: invalid
role int The member role of the invitee. For more information, see the definition of MemberRole.
role int The member role of the invitee. For more information, see the definition of MemberRole. Valid values:
  • -1: custom role
  • 0: common member
  • 1: administrator
  • 2: owner
  • -999: invalid role

Example

ThingHomeSdk.getMemberInstance().getInvitationList(homeId, new IThingDataCallback() {
		@Override
		public void onSuccess(List<InvitedMemberBean> memberBeans) {
			// do something
		}
		@Override
		public void onError(String errorCode, String error) {
			// do something
		}
	});

Modify invitee information

API description

void updateInvitedMember(long invitationId, String memberName, int memberRole, IResultCallback callBack)

Parameters

Parameter Description
invitationId The invitation ID.
memberName The nickname of the invitee.
memberRole The role of the invitee to join the home.

Example

ThingHomeSdk.getMemberInstance().updateInvitedMember(invitationId, memberName, membeRole, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});