$generateNotificationV3_Request method

  1. @experimental
Request $generateNotificationV3_Request({
  1. required String apiVersion3,
  2. required String userId,
  3. bool? oCSAPIRequest,
  4. ApiGenerateNotificationV3RequestApplicationJson? $body,
})

Generate a notification with rich object parameters for a user.

This endpoint requires admin access.

Returns a DynamiteRequest backing the generateNotificationV3 operation. Throws a DynamiteApiException if the API call does not return an expected status code.

Parameters:

  • apiVersion3
  • userId ID of the user.
  • oCSAPIRequest Required to be true for the API request to pass. Defaults to true.

Status codes:

  • 200: Notification generated successfully, returned id is the notification ID for future delete requests
  • 400: Provided data was invalid, check error field of the response of log file for details

See:

Implementation

@_i2.experimental
_i3.Request $generateNotificationV3_Request({
  required String apiVersion3,
  required String userId,
  bool? oCSAPIRequest,
  ApiGenerateNotificationV3RequestApplicationJson? $body,
}) {
  final _parameters = <String, Object?>{};
  final __apiVersion3 = _$jsonSerializers.serialize(apiVersion3, specifiedType: const FullType(String));
  _i6.checkString(
    __apiVersion3,
    'apiVersion3',
    pattern: RegExp(r'^(v3)$'),
  );
  _parameters['apiVersion3'] = __apiVersion3;

  final __userId = _$jsonSerializers.serialize(userId, specifiedType: const FullType(String));
  _parameters['userId'] = __userId;

  final _path = _i4.UriTemplate('/ocs/v2.php/apps/notifications/api/{apiVersion3}/admin_notifications/{userId}')
      .expand(_parameters);
  final _uri = Uri.parse('${_rootClient.baseURL}$_path');
  final _request = _i3.Request('post', _uri);
  _request.headers['Accept'] = 'application/json';
// coverage:ignore-start
  final authentication = _i5.IterableExtension(_rootClient.authentications)?.firstWhereOrNull(
    (auth) => switch (auth) {
      _i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
      _ => false,
    },
  );

  if (authentication != null) {
    _request.headers.addAll(
      authentication.headers,
    );
  } else {
    throw Exception('Missing authentication for bearer_auth or basic_auth');
  }

// coverage:ignore-end
  var __oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
  __oCSAPIRequest ??= true;
  _request.headers['OCS-APIRequest'] = const _i6.HeaderEncoder().convert(__oCSAPIRequest);

  _request.headers['Content-Type'] = 'application/json';
  _request.body = $body != null
      ? json.encode(
          _$jsonSerializers.serialize(
            $body,
            specifiedType: const FullType(ApiGenerateNotificationV3RequestApplicationJson),
          ),
        )
      : json.encode(
          _$jsonSerializers.serialize(
            ApiGenerateNotificationV3RequestApplicationJson(),
            specifiedType: const FullType(ApiGenerateNotificationV3RequestApplicationJson),
          ),
        );
  return _request;
}