updateRoomExternalOAuthRegistration method

Future<void> updateRoomExternalOAuthRegistration({
  1. required String projectId,
  2. required String roomName,
  3. required String registrationId,
  4. required OAuthClientConfig oauth,
  5. required String clientId,
  6. String? clientSecret,
  7. String? delegatedTo,
  8. ConnectorRef? connector,
})

Implementation

Future<void> updateRoomExternalOAuthRegistration({
  required String projectId,
  required String roomName,
  required String registrationId,
  required OAuthClientConfig oauth,
  required String clientId,
  String? clientSecret,
  String? delegatedTo,
  ConnectorRef? connector,
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedRoomName = Uri.encodeComponent(roomName);
  final encodedRegistrationId = Uri.encodeComponent(registrationId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/rooms/$encodedRoomName/external-oauth/$encodedRegistrationId');
  final body = <String, dynamic>{
    'oauth': oauth.toJson(),
    'client_id': clientId,
    if (clientSecret != null) 'client_secret': clientSecret,
    if (delegatedTo != null) 'delegated_to': delegatedTo,
    if (connector != null) 'connector': connector.toJson(),
  };
  final response = await httpClient.put(uri, body: jsonEncode(body));

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to update room external oauth registration. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
}