createChannelMembership method
- required String channelArn,
- required String memberArn,
- required ChannelMembershipType type,
Adds a user to a channel. The InvitedBy
response field is
derived from the request header. A channel member can:
- List messages
- Send messages
- Receive messages
- Edit their own messages
- Leave the channel
- Public Channels: You do not need to be a member to list messages, but you must be a member to send messages.
- Private Channels: You must be a member to list or send messages.
May throw BadRequestException. May throw ForbiddenException. May throw UnauthorizedClientException. May throw ConflictException. May throw ResourceLimitExceededException. May throw ThrottledClientException. May throw ServiceUnavailableException. May throw ServiceFailureException.
Parameter channelArn
:
The ARN of the channel to which you're adding users.
Parameter memberArn
:
The ARN of the member you want to add to the channel.
Parameter type
:
The membership type of a user, DEFAULT
or
HIDDEN
. Default members are always returned as part of
ListChannelMemberships
. Hidden members are only returned if
the type filter in ListChannelMemberships
equals
HIDDEN
. Otherwise hidden members are not returned. This is
only supported by moderators.
Implementation
Future<CreateChannelMembershipResponse> createChannelMembership({
required String channelArn,
required String memberArn,
required ChannelMembershipType type,
}) async {
ArgumentError.checkNotNull(channelArn, 'channelArn');
_s.validateStringLength(
'channelArn',
channelArn,
5,
1600,
isRequired: true,
);
ArgumentError.checkNotNull(memberArn, 'memberArn');
_s.validateStringLength(
'memberArn',
memberArn,
5,
1600,
isRequired: true,
);
ArgumentError.checkNotNull(type, 'type');
final $payload = <String, dynamic>{
'MemberArn': memberArn,
'Type': type.toValue(),
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/channels/${Uri.encodeComponent(channelArn)}/memberships',
exceptionFnMap: _exceptionFns,
);
return CreateChannelMembershipResponse.fromJson(response);
}