Member Management

Last Updated on : 2022-02-17 06:55:55download

The member management API methods can be called to implement a bunch of features to manage house members. For example, add, transfer, query, or delete members.

Feature overview

  • ITuyaCommunityHouseMember provides the capabilities to add a member, get a list of house members, and delete members. The class TuyaCommunitySDK.getHouseMemberInstance() is called to implement these features.

  • Data types of TuyaCommunityMemberBean

    Property Type Description
    memberId String The member ID.
    headPic String The avatar of the member.
    sex Integer The gender of the member.
    • 0: unknown
    • 1: male
    • 2: female
    houseId Long The house ID.
    nickName String The nickname of the member.
    roomUserId String The ID of the mapping between a house and a user.
    houseId Long The house ID.
    userTypeName String The type of the current user.
    userTypeCode String The user type code of the current user. Valid values:
    • HOUSEHOLDER: owner
    • FAMILY: house member
    • TENANT: tenant
    • FRIEND: friend
    • RELATIVES: relative
    • COLLEAGUE: colleague
    • DECORATOR: decorator
    • BABYSITTER: housekeeper
    • OTHER: others
    audit Integer The reviewing status of a member. Valid values:
    • 0: pending approval
    • 20: approved
    • 10: rejected
    dealStatus Integer The status of a member’s request to join a house. Valid values:
    • 1: pending acceptance
    • 2: accepted
    • 3: rejected
    role Integer The role of the member. Valid values:
    • -1: custom member.
    • 0: house member.
    • 1: administrator.
    • 2: house owner.
    • -999: invalid member. A member will become invalid in specific conditions.
    activeStatus Boolean Indicates whether the member is activated. The member’s mobile phone number is registered for activation.
    uploaded Boolean Indicates whether a member has uploaded the biometric identity.
    mobile String The mobile phone number of the member.
    applySource Integer The channel through which the member is added. Valid values:
    • 1: enter the member information in the background
    • 2: send a request on the app
    • 3: add the member by using DingTalk
    • 4: send a request through the official account on WeChat
    • 5: send an in-app invitation

Add a member

Adds a member to a specified house.

API description

void addMember(String communityId, String roomId, String realName, @TuyaCommunityGenderType int sex,
				String phoneNumber, String userType, @TuyaCommunityMemberRole int role,
				@Nullable String expireTime, ITuyaCommunityResultCallback<String> callback);

Request parameter

Parameter Description
communityId The community ID.
houseId The house ID.
realName The real name of the member.
sex The gender of a member. Valid values:
  • TuyaCommunityGenderType.Male: male
  • TuyaCommunityGenderType.Female: female
phoneNumber The mobile phone number.
userType The type of member. You can get the value from the returned list of user types.
role The role of the house member. Valid values:
  • TuyaCommunityMemberRole.ROLE_CUSTOM: custom member.
  • TuyaCommunityMemberRole.ROLE_MEMBER: house member.
  • TuyaCommunityMemberRole.ROLE_ADMIN: administrator.
  • TuyaCommunityMemberRole.ROLE_OWNER: owner.
  • TuyaCommunityMemberRole.INVALID_ROLE: invalid member. A member will become invalid in specific conditions.
expireTime The expiration time. This parameter is optional and specifies the time when a lease expires for a tenant user.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().addMember(communityId, roomId,
					etName.getText().toString(), TuyaCommunityGenderType.Female, etPhone.getText().toString(),
						mUserType, TuyaCommunityMemberRole.ROLE_MEMBER,"", new ITuyaCommunityResultCallback<String>() {
						@Override
						public void onSuccess(String roomUserId) {
							// do something
						}

						@Override
						public void onFailure(String s, String s1) {
							// do something
						}
					});

Get member details

Returns the details of a member in a house.

API description

    void getMemberDetail(String communityId, String roomUserId, ITuyaCommunityResultCallback<TuyaCommunityMemberBean> callback);

Request parameter

Parameter Description
communityId The community ID.
roomUserId The ID of the mapping between a house and a user.
callback The callback.

Example

    TuyaCommunitySDK.getHouseMemberInstance().getMemberDetail(communityId, item.getRoomUserId(), new ITuyaCommunityResultCallback<TuyaCommunityMemberBean>() {
                    @Override
                    public void onSuccess(TuyaCommunityMemberBean tuyaCommunityMemberBean) {
                        // do something
                    }

                    @Override
                    public void onFailure(String s, String s1) {
                        // do something
                    }
                });

Query member details transferred out of a house

Returns the details of a member that is transferred out of a house.

API description

void getMoveOutMemberDetail(String communityId, String roomUserId, ITuyaCommunityResultCallback<TuyaCommunityMemberBean> callback);

Request parameter

Parameter Description
communityId The community ID.
roomUserId The ID of the mapping between a house and a user.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance(). getMoveOutMemberDetail(communityId, item.getRoomUserId(), new ITuyaCommunityResultCallback<TuyaCommunityMemberBean>() {
				@Override
				public void onSuccess(TuyaCommunityMemberBean tuyaCommunityMemberBean) {
					// do something
				}

				@Override
				public void onFailure(String s, String s1) {
					// do something
				}
			});

Get a list of members

Returns a list of members that are not transferred out of a house.

API description

    void getMemberList(String communityId, long houseId, ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberBean>> callback);

Request parameter

Parameter Description
communityId The community ID.
houseId The house ID.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().getMemberList(communityId, houseId, new ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberBean>>() {
		@Override
		public void onSuccess(ArrayList<TuyaCommunityMemberBean> tuyaCommunityMemberBeans) {
			if (tuyaCommunityMemberBeans != null) {
				mCommunityListAdapter.setCommunityList(tuyaCommunityMemberBeans);
			}
		}

		@Override
		public void onFailure(String s, String s1) {

		}
	});

Query a list of members transferred out of a house

Returns a list of members that are transferred out of a house.

API description

void getMoveOutMemberList(String communityId, long houseId, ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberBean>> callback);

Request parameter

Parameter Description
communityId The community ID.
houseId The house ID.
callback The callback.

Example

    TuyaCommunitySDK.getHouseMemberInstance().getMemberList(communityId, houseId, new ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberBean>>() {
            @Override
            public void onSuccess(ArrayList<TuyaCommunityMemberBean> tuyaCommunityMemberBeans) {
                if (tuyaCommunityMemberBeans != null) {
                    mCommunityListAdapter.setCommunityList(tuyaCommunityMemberBeans);
                }
            }

            @Override
            public void onFailure(String s, String s1) {

            }
        });

Query a list of member types

Returns the type of members, such as the owner, house member, or tenant.

API description

void getMemberTypeList(String roomId, ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberTypeBean>> callback);

Request parameter

Parameter Description
roomId The house ID.
callback The callback.

Data types of TuyaCommunityMemberTypeBean

Property Type Description
memberTypeCode String The type of member. Valid values:
  • HOUSEHOLDER: owner
  • FAMILY: house member
  • TENANT: tenant
  • FRIEND: friend
  • RELATIVES: relative
  • COLLEAGUE: colleague
  • DECORATOR: decorator
  • BABYSITTER: housekeeper
  • OTHER: others
memberTypeId String The ID of the member type. Valid values are the same as that of memberTypeCode.
memberTypeName String The name of the member type.
ifHasOwner Boolean Indicates whether the house has an owner.
select Boolean Indicates whether a member type is available.

Example

TuyaCommunitySDK.getHouseMemberInstance().getMemberTypeList(roomId, new ITuyaCommunityResultCallback<ArrayList<TuyaCommunityMemberTypeBean>>() {
		@Override
		public void onSuccess(ArrayList<TuyaCommunityMemberTypeBean> data) {

		}

		@Override
		public void onFailure(String s, String s1) {
		}
	});

Review a member

API description

void auditMember(String communityId, String roomUserId, @TuyaCommunityMemberAuditStatus int audit, @TuyaCommunityMemberRole int role, ISuccessFailureCallback callback);

Request parameter

Parameter Description
communityId The community ID.
roomUserId The ID of the mapping between a house and a user.
audit The reviewing status. Valid values:
  • TuyaCommunityMemberAuditStatus.Pass: approved
  • TuyaCommunityMemberAuditStatus.Failure: rejected
role The role of the house member. Valid values:
  • TuyaCommunityMemberRole.ROLE_MEMBER: house member.
  • TuyaCommunityMemberRole.ROLE_ADMIN: administrator.
  • TuyaCommunityMemberRole.ROLE_OWNER: owner.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().auditMember(communityId, roomUserId, audit, role, new ISuccessFailureCallback() {
							@Override
							public void onSuccess() {
							// do something
							}

							@Override
							public void onFailure(String s, String s1) {
							// do something
							}
						}););

Query the verification status of a user

This API method is used to verify a user’s identity and mobile phone number in a community. It is required when the user requests to add a house to the community. The house can be added only after the user identity is verified.

API description

void getUserCertificationInfo(ITuyaCommunityResultCallback<TuyaCommunityUserCertificationInfoBean> callback);

Request parameter

Parameter Description
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().getUserCertificationInfo(new ITuyaCommunityResultCallback<TuyaCommunityUserCertificationInfoBean>() {
				@Override
				public void onSuccess(TuyaCommunityUserCertificationInfoBean houseCerificationBean) {
					if (!houseCerificationBean.isUserIdentificationStatus()) {
						startActivity(new Intent(HouseListActivity.this, VerifyInfoActivity.class));
					} else {
						startActivity(new Intent(HouseListActivity.this, ChooseCommunityActivity.class));
					}
				}

				@Override
				public void onFailure(String s, String s1) {
					ToastUtil.shortToast(HouseListActivity.this, s1);
				}
			});

Verify the identity of a user

If the current user gets the verification status as unverified, this API method can be called to implement user identity verification. After the user identity is verified, the user is allowed to add a house.

API description

void verifyUserInfo(String realName, @TuyaCommunityGenderType int sex, @Nullable String idCard, ISuccessFailureCallback callback);

Request parameter

Parameter Description
realName The real name of the member.
sex The gender of a member. Valid values:
  • TuyaCommunityGenderType.Male: male
  • TuyaCommunityGenderType.Female: female
idCard The ID card number. This parameter is optional.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().verifyUserInfo(etName.getText().toString(),
						1, etIdCard.getText().toString(), new ISuccessFailureCallback() {
							@Override
							public void onSuccess() {
								startActivity(new Intent(VerifyInfoActivity.this, ChooseCommunityActivity.class));
							}

							@Override
							public void onFailure(String s, String s1) {
								ToastUtil.shortToast(VerifyInfoActivity.this, s1);
							}
						});

Update member information

Updates the role of a member in a house. In most cases, this API method is called when the member is transferred out of the house.

API description

void updateMemberRole(long memberId, @TuyaCommunityMemberRole int role, ISuccessFailureCallback callback);

Request parameter

Parameter Description
memberId The member ID.
name The name of the member. This parameter is optional.
headPic The avatar of the member. This parameter is optional.
role The role of the house member. Valid values:
  • TuyaCommunityMemberRole.ROLE_MEMBER: house member.
  • TuyaCommunityMemberRole.ROLE_ADMIN: administrator.
  • TuyaCommunityMemberRole.ROLE_OWNER: owner.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().updateMemberRole(memberId, TuyaCommunityMemberRole.ROLE_ADMIN, new ISuccessFailureCallback() {
			@Override
			public void onSuccess() {
				if (communityId !=null){

				}
			}

			@Override
			public void onFailure(String s, String s1) {
				if (communityId !=null){
				}
			}
		});
  • The roles specified by TuyaCommunityMemberRole can be sorted in ascending order of permission levels: Custom < Member < Admin < Owner. Members can manage those with the same or lower levels of permissions.
  • TuyaCommunityMemberRole.ROLE_OWNER specifies a house owner that is granted the highest level of permission. Only the owner can transfer other members out of the same house.

Transfer a member out of a house

Transfers a member out of a house by using the role of an owner.

API description

void moveOutMember(String communityId, String roomUserId, ISuccessFailureCallback callback);

Request parameter

Parameter Description
communityId The community ID.
roomUserId The ID of the mapping between a house and a user.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance(). moveOutMember(communityId, roomUserId, item.getRoomUserId(), new ISuccessFailureCallback() {
							@Override
							public void onSuccess() {
							// do something
							}

							@Override
							public void onFailure(String s, String s1) {
							// do something
							}
						});

Delete a member

API description

void deleteMember(String communityId, long houseId, String roomUserId, ISuccessFailureCallback callback);

Request parameter

Parameter Description
communityId The community ID.
houseId The house ID.
roomUserId The ID of the mapping between a house and a user.
callback The callback.

Example

TuyaCommunitySDK.getHouseMemberInstance().deleteMember(communityId, houseId, item.getRoomUserId(), new ISuccessFailureCallback() {
							@Override
							public void onSuccess() {
							// do something
							}

							@Override
							public void onFailure(String s, String s1) {
							// do something
							}
						});