Skip to content

Commit cbc8d30

Browse files
committed
feat(nextcloud)!: Support notifications 31
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 50ebd55 commit cbc8d30

File tree

5 files changed

+955
-63
lines changed

5 files changed

+955
-63
lines changed

external/nextcloud-notifications

packages/nextcloud/lib/src/api/notifications/notifications.openapi.dart

Lines changed: 309 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,109 @@ class $ApiClient {
319319
return _i1.ResponseConverter<ApiGenerateNotificationV3ResponseApplicationJson, void>(_serializer)
320320
.convert(_response);
321321
}
322+
323+
/// Builds a serializer to parse the response of [$selfTestPush_Request].
324+
@_i2.experimental
325+
_i1.DynamiteSerializer<ApiSelfTestPushResponseApplicationJson, void> $selfTestPush_Serializer() =>
326+
_i1.DynamiteSerializer(
327+
bodyType: const FullType(ApiSelfTestPushResponseApplicationJson),
328+
headersType: null,
329+
serializers: _$jsonSerializers,
330+
validStatuses: const {200, 400},
331+
);
332+
333+
/// Send a test notification to push registered mobile apps.
334+
///
335+
/// Required capability: `ocs-endpoints > test-push`.
336+
///
337+
/// Returns a `DynamiteRequest` backing the [selfTestPush] operation.
338+
/// Throws a `DynamiteApiException` if the API call does not return an expected status code.
339+
///
340+
/// Parameters:
341+
/// * [apiVersion3]
342+
/// * [oCSAPIRequest] Required to be true for the API request to pass. Defaults to `true`.
343+
///
344+
/// Status codes:
345+
/// * 200: Test notification generated successfully, but the device should still show the message to the user
346+
/// * 400: Test notification could not be generated, show the message to the user
347+
///
348+
/// See:
349+
/// * [selfTestPush] for a method executing this request and parsing the response.
350+
/// * [$selfTestPush_Serializer] for a converter to parse the `Response` from an executed this request.
351+
@_i2.experimental
352+
_i3.Request $selfTestPush_Request({
353+
required String apiVersion3,
354+
bool? oCSAPIRequest,
355+
}) {
356+
final _parameters = <String, Object?>{};
357+
final __apiVersion3 = _$jsonSerializers.serialize(apiVersion3, specifiedType: const FullType(String));
358+
_i6.checkString(
359+
__apiVersion3,
360+
'apiVersion3',
361+
pattern: RegExp(r'^(v3)$'),
362+
);
363+
_parameters['apiVersion3'] = __apiVersion3;
364+
365+
final _path = _i4.UriTemplate('/ocs/v2.php/apps/notifications/api/{apiVersion3}/test/self').expand(_parameters);
366+
final _uri = Uri.parse('${_rootClient.baseURL}$_path');
367+
final _request = _i3.Request('post', _uri);
368+
_request.headers['Accept'] = 'application/json';
369+
// coverage:ignore-start
370+
final authentication = _i5.IterableExtension(_rootClient.authentications)?.firstWhereOrNull(
371+
(auth) => switch (auth) {
372+
_i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
373+
_ => false,
374+
},
375+
);
376+
377+
if (authentication != null) {
378+
_request.headers.addAll(
379+
authentication.headers,
380+
);
381+
} else {
382+
throw Exception('Missing authentication for bearer_auth or basic_auth');
383+
}
384+
385+
// coverage:ignore-end
386+
var __oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
387+
__oCSAPIRequest ??= true;
388+
_request.headers['OCS-APIRequest'] = const _i6.HeaderEncoder().convert(__oCSAPIRequest);
389+
390+
return _request;
391+
}
392+
393+
/// Send a test notification to push registered mobile apps.
394+
///
395+
/// Required capability: `ocs-endpoints > test-push`.
396+
///
397+
/// Returns a [Future] containing a `DynamiteResponse` with the status code, deserialized body and headers.
398+
/// Throws a `DynamiteApiException` if the API call does not return an expected status code.
399+
///
400+
/// Parameters:
401+
/// * [apiVersion3]
402+
/// * [oCSAPIRequest] Required to be true for the API request to pass. Defaults to `true`.
403+
///
404+
/// Status codes:
405+
/// * 200: Test notification generated successfully, but the device should still show the message to the user
406+
/// * 400: Test notification could not be generated, show the message to the user
407+
///
408+
/// See:
409+
/// * [$selfTestPush_Request] for the request send by this method.
410+
/// * [$selfTestPush_Serializer] for a converter to parse the `Response` from an executed request.
411+
Future<_i1.DynamiteResponse<ApiSelfTestPushResponseApplicationJson, void>> selfTestPush({
412+
required String apiVersion3,
413+
bool? oCSAPIRequest,
414+
}) async {
415+
final _request = $selfTestPush_Request(
416+
apiVersion3: apiVersion3,
417+
oCSAPIRequest: oCSAPIRequest,
418+
);
419+
final _streamedResponse = await _rootClient.httpClient.send(_request);
420+
final _response = await _i3.Response.fromStream(_streamedResponse);
421+
422+
final _serializer = $selfTestPush_Serializer();
423+
return _i1.ResponseConverter<ApiSelfTestPushResponseApplicationJson, void>(_serializer).convert(_response);
424+
}
322425
}
323426

324427
class $EndpointClient {
@@ -1608,33 +1711,13 @@ sealed class $ApiGenerateNotificationV3RequestApplicationJsonInterface {
16081711
specifiedType: const FullType(String),
16091712
)! as String;
16101713

1611-
static final _$subjectParameters = _$jsonSerializers.deserialize(
1612-
const {},
1613-
specifiedType: const FullType(BuiltMap, [
1614-
FullType(String),
1615-
FullType(BuiltMap, [FullType(String), FullType(JsonObject)]),
1616-
]),
1617-
)! as BuiltMap<String, BuiltMap<String, JsonObject>>;
1618-
1619-
static final _$messageParameters = _$jsonSerializers.deserialize(
1620-
const {},
1621-
specifiedType: const FullType(BuiltMap, [
1622-
FullType(String),
1623-
FullType(BuiltMap, [FullType(String), FullType(JsonObject)]),
1624-
]),
1625-
)! as BuiltMap<String, BuiltMap<String, JsonObject>>;
1626-
16271714
/// Subject of the notification.
16281715
String get subject;
16291716

16301717
/// Message of the notification.
16311718
String get message;
1632-
1633-
/// Rich objects to fill the subject placeholders, {@see \OCP\RichObjectStrings\Definitions}.
1634-
BuiltMap<String, BuiltMap<String, JsonObject>> get subjectParameters;
1635-
1636-
/// Rich objects to fill the message placeholders, {@see \OCP\RichObjectStrings\Definitions}.
1637-
BuiltMap<String, BuiltMap<String, JsonObject>> get messageParameters;
1719+
BuiltMap<String, BuiltMap<String, JsonObject>>? get subjectParameters;
1720+
BuiltMap<String, BuiltMap<String, JsonObject>>? get messageParameters;
16381721

16391722
/// Rebuilds the instance.
16401723
///
@@ -1650,8 +1733,6 @@ sealed class $ApiGenerateNotificationV3RequestApplicationJsonInterface {
16501733
static void _defaults($ApiGenerateNotificationV3RequestApplicationJsonInterfaceBuilder b) {
16511734
b.subject = _$subject;
16521735
b.message = _$message;
1653-
b.subjectParameters.replace(_$subjectParameters);
1654-
b.messageParameters.replace(_$messageParameters);
16551736
}
16561737

16571738
@BuiltValueHook(finalizeBuilder: true)
@@ -1894,6 +1975,195 @@ abstract class ApiGenerateNotificationV3ResponseApplicationJson
18941975
}
18951976
}
18961977

1978+
@BuiltValue(instantiable: false)
1979+
sealed class $ApiSelfTestPushResponseApplicationJson_Ocs_DataInterface {
1980+
String get message;
1981+
1982+
/// Rebuilds the instance.
1983+
///
1984+
/// The result is the same as this instance but with [updates] applied.
1985+
/// [updates] is a function that takes a builder [$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder].
1986+
$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterface rebuild(
1987+
void Function($ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder) updates,
1988+
);
1989+
1990+
/// Converts the instance to a builder [$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder].
1991+
$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder toBuilder();
1992+
@BuiltValueHook(initializeBuilder: true)
1993+
static void _defaults($ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder b) {}
1994+
@BuiltValueHook(finalizeBuilder: true)
1995+
static void _validate($ApiSelfTestPushResponseApplicationJson_Ocs_DataInterfaceBuilder b) {}
1996+
}
1997+
1998+
abstract class ApiSelfTestPushResponseApplicationJson_Ocs_Data
1999+
implements
2000+
$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterface,
2001+
Built<ApiSelfTestPushResponseApplicationJson_Ocs_Data, ApiSelfTestPushResponseApplicationJson_Ocs_DataBuilder> {
2002+
/// Creates a new ApiSelfTestPushResponseApplicationJson_Ocs_Data object using the builder pattern.
2003+
factory ApiSelfTestPushResponseApplicationJson_Ocs_Data([
2004+
void Function(ApiSelfTestPushResponseApplicationJson_Ocs_DataBuilder)? b,
2005+
]) = _$ApiSelfTestPushResponseApplicationJson_Ocs_Data;
2006+
2007+
// coverage:ignore-start
2008+
const ApiSelfTestPushResponseApplicationJson_Ocs_Data._();
2009+
// coverage:ignore-end
2010+
2011+
/// Creates a new object from the given [json] data.
2012+
///
2013+
/// Use [toJson] to serialize it back into json.
2014+
// coverage:ignore-start
2015+
factory ApiSelfTestPushResponseApplicationJson_Ocs_Data.fromJson(Map<String, dynamic> json) =>
2016+
_$jsonSerializers.deserializeWith(serializer, json)!;
2017+
// coverage:ignore-end
2018+
2019+
/// Parses this object into a json like map.
2020+
///
2021+
/// Use the fromJson factory to revive it again.
2022+
// coverage:ignore-start
2023+
Map<String, dynamic> toJson() => _$jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
2024+
// coverage:ignore-end
2025+
2026+
/// Serializer for ApiSelfTestPushResponseApplicationJson_Ocs_Data.
2027+
static Serializer<ApiSelfTestPushResponseApplicationJson_Ocs_Data> get serializer =>
2028+
_$apiSelfTestPushResponseApplicationJsonOcsDataSerializer;
2029+
2030+
@BuiltValueHook(initializeBuilder: true)
2031+
static void _defaults(ApiSelfTestPushResponseApplicationJson_Ocs_DataBuilder b) {
2032+
$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterface._defaults(b);
2033+
}
2034+
2035+
@BuiltValueHook(finalizeBuilder: true)
2036+
static void _validate(ApiSelfTestPushResponseApplicationJson_Ocs_DataBuilder b) {
2037+
$ApiSelfTestPushResponseApplicationJson_Ocs_DataInterface._validate(b);
2038+
}
2039+
}
2040+
2041+
@BuiltValue(instantiable: false)
2042+
sealed class $ApiSelfTestPushResponseApplicationJson_OcsInterface {
2043+
OCSMeta get meta;
2044+
ApiSelfTestPushResponseApplicationJson_Ocs_Data get data;
2045+
2046+
/// Rebuilds the instance.
2047+
///
2048+
/// The result is the same as this instance but with [updates] applied.
2049+
/// [updates] is a function that takes a builder [$ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder].
2050+
$ApiSelfTestPushResponseApplicationJson_OcsInterface rebuild(
2051+
void Function($ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder) updates,
2052+
);
2053+
2054+
/// Converts the instance to a builder [$ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder].
2055+
$ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder toBuilder();
2056+
@BuiltValueHook(initializeBuilder: true)
2057+
static void _defaults($ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder b) {}
2058+
@BuiltValueHook(finalizeBuilder: true)
2059+
static void _validate($ApiSelfTestPushResponseApplicationJson_OcsInterfaceBuilder b) {}
2060+
}
2061+
2062+
abstract class ApiSelfTestPushResponseApplicationJson_Ocs
2063+
implements
2064+
$ApiSelfTestPushResponseApplicationJson_OcsInterface,
2065+
Built<ApiSelfTestPushResponseApplicationJson_Ocs, ApiSelfTestPushResponseApplicationJson_OcsBuilder> {
2066+
/// Creates a new ApiSelfTestPushResponseApplicationJson_Ocs object using the builder pattern.
2067+
factory ApiSelfTestPushResponseApplicationJson_Ocs([
2068+
void Function(ApiSelfTestPushResponseApplicationJson_OcsBuilder)? b,
2069+
]) = _$ApiSelfTestPushResponseApplicationJson_Ocs;
2070+
2071+
// coverage:ignore-start
2072+
const ApiSelfTestPushResponseApplicationJson_Ocs._();
2073+
// coverage:ignore-end
2074+
2075+
/// Creates a new object from the given [json] data.
2076+
///
2077+
/// Use [toJson] to serialize it back into json.
2078+
// coverage:ignore-start
2079+
factory ApiSelfTestPushResponseApplicationJson_Ocs.fromJson(Map<String, dynamic> json) =>
2080+
_$jsonSerializers.deserializeWith(serializer, json)!;
2081+
// coverage:ignore-end
2082+
2083+
/// Parses this object into a json like map.
2084+
///
2085+
/// Use the fromJson factory to revive it again.
2086+
// coverage:ignore-start
2087+
Map<String, dynamic> toJson() => _$jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
2088+
// coverage:ignore-end
2089+
2090+
/// Serializer for ApiSelfTestPushResponseApplicationJson_Ocs.
2091+
static Serializer<ApiSelfTestPushResponseApplicationJson_Ocs> get serializer =>
2092+
_$apiSelfTestPushResponseApplicationJsonOcsSerializer;
2093+
2094+
@BuiltValueHook(initializeBuilder: true)
2095+
static void _defaults(ApiSelfTestPushResponseApplicationJson_OcsBuilder b) {
2096+
$ApiSelfTestPushResponseApplicationJson_OcsInterface._defaults(b);
2097+
}
2098+
2099+
@BuiltValueHook(finalizeBuilder: true)
2100+
static void _validate(ApiSelfTestPushResponseApplicationJson_OcsBuilder b) {
2101+
$ApiSelfTestPushResponseApplicationJson_OcsInterface._validate(b);
2102+
}
2103+
}
2104+
2105+
@BuiltValue(instantiable: false)
2106+
sealed class $ApiSelfTestPushResponseApplicationJsonInterface {
2107+
ApiSelfTestPushResponseApplicationJson_Ocs get ocs;
2108+
2109+
/// Rebuilds the instance.
2110+
///
2111+
/// The result is the same as this instance but with [updates] applied.
2112+
/// [updates] is a function that takes a builder [$ApiSelfTestPushResponseApplicationJsonInterfaceBuilder].
2113+
$ApiSelfTestPushResponseApplicationJsonInterface rebuild(
2114+
void Function($ApiSelfTestPushResponseApplicationJsonInterfaceBuilder) updates,
2115+
);
2116+
2117+
/// Converts the instance to a builder [$ApiSelfTestPushResponseApplicationJsonInterfaceBuilder].
2118+
$ApiSelfTestPushResponseApplicationJsonInterfaceBuilder toBuilder();
2119+
@BuiltValueHook(initializeBuilder: true)
2120+
static void _defaults($ApiSelfTestPushResponseApplicationJsonInterfaceBuilder b) {}
2121+
@BuiltValueHook(finalizeBuilder: true)
2122+
static void _validate($ApiSelfTestPushResponseApplicationJsonInterfaceBuilder b) {}
2123+
}
2124+
2125+
abstract class ApiSelfTestPushResponseApplicationJson
2126+
implements
2127+
$ApiSelfTestPushResponseApplicationJsonInterface,
2128+
Built<ApiSelfTestPushResponseApplicationJson, ApiSelfTestPushResponseApplicationJsonBuilder> {
2129+
/// Creates a new ApiSelfTestPushResponseApplicationJson object using the builder pattern.
2130+
factory ApiSelfTestPushResponseApplicationJson([void Function(ApiSelfTestPushResponseApplicationJsonBuilder)? b]) =
2131+
_$ApiSelfTestPushResponseApplicationJson;
2132+
2133+
// coverage:ignore-start
2134+
const ApiSelfTestPushResponseApplicationJson._();
2135+
// coverage:ignore-end
2136+
2137+
/// Creates a new object from the given [json] data.
2138+
///
2139+
/// Use [toJson] to serialize it back into json.
2140+
// coverage:ignore-start
2141+
factory ApiSelfTestPushResponseApplicationJson.fromJson(Map<String, dynamic> json) =>
2142+
_$jsonSerializers.deserializeWith(serializer, json)!;
2143+
// coverage:ignore-end
2144+
2145+
/// Parses this object into a json like map.
2146+
///
2147+
/// Use the fromJson factory to revive it again.
2148+
// coverage:ignore-start
2149+
Map<String, dynamic> toJson() => _$jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
2150+
// coverage:ignore-end
2151+
2152+
/// Serializer for ApiSelfTestPushResponseApplicationJson.
2153+
static Serializer<ApiSelfTestPushResponseApplicationJson> get serializer =>
2154+
_$apiSelfTestPushResponseApplicationJsonSerializer;
2155+
2156+
@BuiltValueHook(initializeBuilder: true)
2157+
static void _defaults(ApiSelfTestPushResponseApplicationJsonBuilder b) {
2158+
$ApiSelfTestPushResponseApplicationJsonInterface._defaults(b);
2159+
}
2160+
2161+
@BuiltValueHook(finalizeBuilder: true)
2162+
static void _validate(ApiSelfTestPushResponseApplicationJsonBuilder b) {
2163+
$ApiSelfTestPushResponseApplicationJsonInterface._validate(b);
2164+
}
2165+
}
2166+
18972167
class EndpointListNotificationsApiVersion extends EnumClass {
18982168
const EndpointListNotificationsApiVersion._(super.name);
18992169

@@ -4287,6 +4557,21 @@ final Serializers _$serializers = (Serializers().toBuilder()
42874557
ApiGenerateNotificationV3ResponseApplicationJson_Ocs_DataBuilder.new,
42884558
)
42894559
..add(ApiGenerateNotificationV3ResponseApplicationJson_Ocs_Data.serializer)
4560+
..addBuilderFactory(
4561+
const FullType(ApiSelfTestPushResponseApplicationJson),
4562+
ApiSelfTestPushResponseApplicationJsonBuilder.new,
4563+
)
4564+
..add(ApiSelfTestPushResponseApplicationJson.serializer)
4565+
..addBuilderFactory(
4566+
const FullType(ApiSelfTestPushResponseApplicationJson_Ocs),
4567+
ApiSelfTestPushResponseApplicationJson_OcsBuilder.new,
4568+
)
4569+
..add(ApiSelfTestPushResponseApplicationJson_Ocs.serializer)
4570+
..addBuilderFactory(
4571+
const FullType(ApiSelfTestPushResponseApplicationJson_Ocs_Data),
4572+
ApiSelfTestPushResponseApplicationJson_Ocs_DataBuilder.new,
4573+
)
4574+
..add(ApiSelfTestPushResponseApplicationJson_Ocs_Data.serializer)
42904575
..add(EndpointListNotificationsApiVersion.serializer)
42914576
..addBuilderFactory(
42924577
const FullType(EndpointListNotificationsResponseApplicationJson),

0 commit comments

Comments
 (0)