Member Management

Last Updated on : 2022-02-17 06:49:38download

TuyaCommunityHouseMemberService provides the API methods to manage house members. For example, add, transfer, query, or delete members.

Functional description

Add a member

Adds a member to a specified house.

API description

- (void)addMemberWithCommunityId:(NSString *)communityId
                       roomId:(NSString *)roomId
                      realName:(NSString *)realName
                           sex:(TuyaCommunityGenderType)sex
                   phoneNumber:(NSString *)phoneNumber
                      userType:(NSString *)userType
                          role:(TuyaCommunityMemberRole)role
                    expireTime:(NSString * _Nullable)expireTime
                       success:(void(^)(NSString *roomUserId))success
                       failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
communityId The community ID.
roomId The room ID.
realName The real name of the member.
sex The gender of the member. Valid values:
  • TuyaCommunityGenderTypeMale: male
  • TuyaCommunityGenderTypeFemale: 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 member. Valid values:
  • TuyaCommunityMemberRoleCustom: custom member.
  • TuyaCommunityMemberRoleMembe: house member.
  • TuyaCommunityMemberRoleAdmin: administrator.
  • TuyaCommunityMemberRoleOwner: owner.
  • TuyaCommunityMemberRoleUnknown: 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.
success The success callback.
failure The failure callback.

Example

[self.service addMemberWithCommunityId:@"xxx"
                                roomId:@"xxx"
                              realName:@"xxx"
                                   sex:TuyaCommunityGenderTypeMale
                           phoneNumber:@"xxx"
                              userType:@"xxx"
                                  role:TuyaCommunityMemberRoleMember
                            expireTime:nil
                               success:^(NSString * _Nonnull roomUserId) {
    // success handler
}
                               failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Query member details

Returns the details of a member in a house.

API description

- (void)getMemberDetailWithCommunityId:(NSString *)communityId
                            roomUserId:(NSString *)roomUserId
                               success:(void(^)(TuyaCommunityMemberModel *result))success
                               failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service getMemberDetailWithCommunityId:@"xxx"
                                  roomUserId:@"xxx"
                                     success:^(TuyaCommunityMemberModel * _Nonnull result) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Query member details transferred out of a house

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

API description

- (void)getMoveOutMemberDetailWithCommunityId:(NSString *)communityId
                                   roomUserId:(NSString *)roomUserId
                                      success:(void(^)(TuyaCommunityMemberModel *result))success
                                      failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service getMoveOutMemberDetailWithCommunityId:@"xxx"
                                         roomUserId:@"xxx"
                                            success:^(TuyaCommunityMemberModel * _Nonnull result) {
                                               // success handler
                                          } failure:^(NSError * _Nonnull error) {
                                              // failure handler
}];

Query a list of members

API description

- (void)getMemberListWithCommunityId:(NSString *)communityId
                             houseId:(long long)houseId
                             success:(void(^)(NSArray<TuyaCommunityMemberModel *>*list))success
                             failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service getMemberListWithCommunityId:@"xxx"
                                   houseId:@"xxx"
                                   success:^(NSArray<TuyaCommunityMemberModel *> * _Nonnull list) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Query a list of members transferred out of a house

API description

- (void)getMemberListWithCommunityId:(NSString *)communityId
                             houseId:(long long)houseId
                             success:(void(^)(NSArray<TuyaCommunityMemberModel *>*list))success
                             failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service getMoveOutMemberListWithCommunityId:@"xxx"
                                          houseId:@"xxx"
                                          success:^(NSArray<TuyaCommunityMemberModel *> * _Nonnull list) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Query a list of member types

API description

- (void)getMemberTypeListWithRoomId:(NSString *)roomId
                            success:(void(^)(NSArray<TuyaCommunityMemberTypeModel *>*list))success
                            failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
roomId The room ID.
success The success callback.
failure The failure callback.

Example

[self.service getMemberTypeListWithroomId:@"xxx"
                                  success:^(NSArray<TuyaCommunityMemberTypeModel *> * _Nonnull list) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Review a member

API description

- (void)auditMemberWithCommunityId:(NSString *)communityId
                        roomUserId:(NSString *)roomUserId
                             audit:(TuyaCommunityMemberAuditStatus)audit
                              role:(TuyaCommunityMemberRole)role
                           success:(void(^)(void))success
                           failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
communityId The community ID.
roomUserId The ID of the mapping between a house and a user.
audit The reviewing status. Valid values:
  • TuyaCommunityMemberAuditStatusPass: approved
  • TuyaCommunityMemberAuditStatusFailure: failed
role The role of the house member. Valid values:
  • TuyaCommunityMemberRoleMember: member
  • TuyaCommunityMemberRoleAdmin: administrator
  • TuyaCommunityMemberRoleOwner: owner
success The success callback.
failure The failure callback.

Example

[self.service getMemberTypeListWithroomId:@"xxx"
                                  success:^(NSArray<TuyaCommunityMemberTypeModel *> * _Nonnull list) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Query the verification status of a user

API description

- (void)getUserCertificationInfoWithSuccess:(void(^)(TuyaCommunityUserCertificationInfoModel *result))success
                                    failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
success The success callback.
failure The failure callback.

Example

[self.service getUserCertificationInfoWithSuccess:^(TuyaCommunityUserCertificationInfoModel * _Nonnull result) {
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Things to note

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.

Verify the identity of a user

API description

- (void)verifyUserInfoWithRealName:(NSString *)realName
                               sex:(TuyaCommunityGenderType)sex
                            idCard:(NSString * _Nullable)idCard
                           success:(void(^)(void))success
                           failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
realName The real name of the member.
sex The gender of the member.
idCard The ID card number. This parameter is optional.
success The success callback.
failure The failure callback.

Example

[self.service verifyUserInfoWithRealName:@"xxx"
                                     sex:TuyaCommunityGenderTypeMale
                                  idCard:nil
                                 success:^{
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];
  • 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.
  • The method addHouseWithName:communityId:roomId:userType:expireTime:success:failure: in the class TuyaCommunityHouseManager can be called to add a house.

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)updateMemberRoleWithMemberId:(long long)memberId
                                role:(TuyaCommunityMemberRole)role
                             success:(void(^)(void))success
                             failure:(void(^)(NSError *error))failure;

Parameters

Parameter Description
memberId The member ID.
role The role of the house member. Valid values:
  • TuyaCommunityMemberRoleMember: custom member
  • TuyaCommunityMemberRoleAdmin: administrator
  • TuyaCommunityMemberRoleOwner: owner
success The success callback.
failure The failure callback.

Example

[self.service updateMemberRoleWithMemberId:0
                                      role:TuyaCommunityMemberRoleMember
                                   success:^{
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];
  • 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.
  • TuyaCommunityMemberRoleOwner specifies a house owner that is granted the highest level of permissions. Only the owner can transfer other members out of the same house.

Transfer a member out of a house

Transfers a member other than an owner out of a house

API description

- (void)moveOutMemberWithCommunityId:(NSString *)communityId
                          roomUserId:(NSString *)roomUserId
                             success:(void(^)(void))success
                             failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service moveOutMemberWithCommunityId:@"xxx"
                                roomUserId:@"xxx"
                                   success:^{
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Delete a member

API description

- (void)deleteMemberWithCommunityId:(NSString *)communityId
                            houseId:(long long)houseId
                         roomUserId:(NSString *)roomUserId
                            success:(void(^)(void))success
                            failure:(void(^)(NSError *error))failure;

Parameters

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

Example

[self.service deleteMemberWithCommunityId:@"xxx"
                                  houseId:0
                               roomUserId:@"xxx"
                                  success:^{
    // success handler
} failure:^(NSError * _Nonnull error) {
    // failure handler
}];

Object description

TuyaCommunityMemberModel

Property Type Description
memberId long long The member ID.
headPic NSString The avatar of a member.
sex TuyaCommunityGenderType The gender of a member. Valid values:
  • TuyaCommunityGenderTypeMale: male
  • TuyaCommunityGenderTypeFemale: female
nickName NSString The nickname.
realName NSString The real name of a member.
account NSString The user.
roomUserId NSString The ID of the mapping between a house and a user.
houseId long long The house ID.
userTypeName NSString The type of member, such as an owner.
userTypeCode NSString 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
role TuyaCommunityMemberRole The role of the member. Valid values:
  • TuyaCommunityMemberRoleCustom: custom member
  • TuyaCommunityMemberRoleMember: house member
  • TuyaCommunityMemberRoleAdmin: administrator
  • TuyaCommunityMemberRoleOwner: house owner
audit TuyaCommunityMemberAuditStatus The reviewing status of a member. Valid values:
  • TuyaCommunityMemberAuditStatusPending: pending reviewing
  • TuyaCommunityMemberAuditStatusFailure: failed
  • TuyaCommunityMemberAuditStatusPass: approved
dealStatus TuyaCommunityMemberInviteStatus The invitation status of a member.
countryCode NSString The country code.
activeStatus BOOL The activation status.
uploaded BOOL Indicates whether a member has uploaded the biometric identity.
mobile NSString The mobile phone number.
uid NSString The user ID.
applySource TuyaCommunityMemberApplySourceType The type of channel through which a member sends a request.