Toggle Block
The toggleBlock() function is used to block or unblock a user based on the parameters provided in the BlockUserRequest. It returns an LMResponse.
Steps to Block or Unblock a User
- Build a
BlockUserRequestobject using theBlockUserRequestBuilderclass. - Call the
toggleBlock()function using an instance of theLMFeedClientclass. - Use the response
LMResponseas per your requirement.
- Block User
- Unblock User
// Build the request object
final BlockUserRequest blockUserRequest = (BlockUserRequestBuilder()
..uuid("USER_UUID_HERE") // Replace with the actual user UUID
..shouldBlock(true)) // pass true to block a user
.build();
// Get the response from calling the function
final LMResponse<void> blockUserResponse = await lmFeedClient.toggleBlock(blockUserRequest);
// Process the response, as per requirement
if (blockUserResponse.success) {
// Your function to handle successful block action
handleBlockSuccess();
} else {
// Your function to handle error message
handleBlockError(blockUserResponse.errorMessage);
}
// Build the request object to unblock a user
final BlockUserRequest unBlockUserRequest = (BlockUserRequestBuilder()
..uuid("USER_UUID_HERE") // Replace with the actual user UUID
..shouldBlock(false)) // pass false to unblock a user
.build();
// Get the response from calling the function
final LMResponse<void> unBlockUserResponse = await lmFeedClient.toggleBlock(unBlockUserRequest);
// Process the response, as per requirement
if (unBlockUserResponse.success) {
// Your function to handle successful unblock action
handleUnblockSuccess();
} else {
// Your function to handle error message
handleUnblockError(unBlockUserResponse.errorMessage);
}
info
To check if a user is blocked or not, refer to this Get Blocked User
Models
BlockUserRequest
The BlockUserRequest class represents the parameters required to block or unblock a user. Below are the details of the BlockUserRequest model:
| Variable | Type | Description | Optional |
|---|---|---|---|
| uuid | String | The unique identifier (UUID) of the user. | No |
| shouldBlock | bool | true to block the user, false to unblock. | No |