Site Member Management

Last Updated on : 2022-03-03 06:42:24download

Functional description

The class TuyaResidenceSiteInvitation of TuyaSmartResidence is used to invite and update members on a site. The following types of sites are supported:

  • Business-authorized site: a site authorized by a business. The highest-level user role is admin. The site cannot be modified or deleted, and its ownership cannot be transferred.
  • Self-managed site: a site created by you with the role owner. This role is granted the highest-level permissions.

Create an invitation code

API description

Creates an invitation code and only applies to a self-managed site. The instance method of TuyaResidenceSiteInvitation is used.

- (void)invitationMemberWithCreateRequestModel:(TuyaResidenceInvitationCreateRequestModel *)createRequestModel
                                       success:(void(^)(TuyaResidenceInvitationResultModel *invitationResultModel))success
                                       failure:(TYFailureError)failure;

Parameters

Parameter Description
createRequestModel The request model to generate an invitation code.
success The success callback.
failure The failure callback.

Data model of TuyaResidenceInvitationCreateRequestModel

Field Type Description
siteID long long The ID of the site that the target member joins.
needMsgContent BOOL Specifies whether invitation text is required.

Data model of TuyaResidenceInvitationResultModel

Field Type Description
invitationMsgContent NSString The invitation text.
invitationCode NSString The invitation code.
invitationId NSNumber The invitation ID.

Example

[self.siteInvitation invitationMemberWithCreateRequestModel:model success:^(TuyaResidenceInvitationResultModel * _Nonnull invitationResultModel) {

} failure:^(NSError *error) {

}];

Join a site with an invitation code

API description

- (void)joinSiteWithInvitationCode:(NSString *)invitationCode
                           success:(TYSuccessBOOL)success
                           failure:(TYFailureError)failure;

Parameters

Parameter Description
invitationCode The invitation code.
success The success callback.
failure The failure callback.

Example

[self.siteInvitation joinSiteWithInvitationCode:invitationCode success:^(BOOL result) {

} failure:^(NSError *error) {

}];

Send invitation code to invite again

API description

- (void)reinviteInvitationWithReinviteRquestModel:(TuyaResidenceInvitationCreateRequestModel *)createRequestModel
                                          success:(void(^)(TuyaResidenceInvitationResultModel *invitationResultModel))success
                                          failure:(TYFailureError)failure;

Parameters

Parameter Description
createRequestModel The request model to generate an invitation code.
success The success callback.
failure The failure callback.

Example

[self.siteInvitation reinviteInvitationWithReinviteRquestModel:model success:^(TuyaResidenceInvitationResultModel * _Nonnull invitationResultModel) {

} failure:^(NSError *error) {

}];

Inviate by email address or mobile phone number

API description

- (void)addMemberWithSiteId:(long long)siteId
                   nickName:(NSString *)nickName
                   userName:(NSString *)userName
                    isAdmin:(BOOL)isAdmin
               isAutoAccept:(BOOL)isAutoAccept
                    success:(TYSuccessHandler)success
                    failure:(TYFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
nickName The nickname of the member.
userName The username that can be a mobile phone number or email address. A mobile phone number must be prefixed with a country code
in the format of country code-mobile phone number. Example: 00-1234567.
isAdmin Specifies whether the target member is an administrator.
  • 1: yes
  • 0: no
This parameter only applies to a self-managed site.
isAutoAccept Specifies whether the target member automatically accepts the invitation.
  • 1: yes
  • 0: no
This parameter only applies to a self-managed site.
success The success callback.
failure The failure callback.

Example

[self.siteInvitation addMemberWithSiteId:[Helper getCurrentSiteModel].siteId nickName:_nicknameTextField.text userName:_accountTextField.text isAdmin:NO isAutoAccept:YES success:^{

} failure:^(NSError *error) {

}];

Revoke an invitation by invitation code

API description

- (void)cancelInvitationWithInvitationID:(NSNumber *)invitationID
                                 success:(TYSuccessBOOL)success
                                 failure:(TYFailureError)failure;

Parameters

Parameter Description
invitationID The invitation ID.
success The success callback.
failure The failure callback.

Example

[self.siteInvitation cancelInvitationWithInvitationID:invitationID success:^(BOOL result) {

} failure:^(NSError *error) {

}];

Query invitation records

Returns the invitation records for a self-managed site.

API description

- (void)fetchInvitationRecordListWithSiteID:(long long)siteID
                                    success:(void(^)(NSArray<TuyaResidenceInvitationRecordModel *> *invitationRecordList))success
                                    failure:(TYFailureError)failure;

Parameters

Parameter Description
siteID The site ID.
success The success callback.
failure The failure callback.

Example

[self.siteInvitation fetchInvitationRecordListWithSiteID:siteID success:^(NSArray<TuyaResidenceInvitationRecordModel *> * _Nonnull invitationRecordList) {

} failure:^(NSError *error) {

}];