Browse Source

specs, nextcloud: Fix finding user status

pull/49/head
jld3103 2 years ago
parent
commit
097b7374aa
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 36
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  2. 2
      packages/nextcloud/lib/src/nextcloud.openapi.g.dart
  3. 10
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 10
      packages/nextcloud/test/user_status_test.dart
  5. 10
      specs/user_status.json

36
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -3113,6 +3113,40 @@ class UserStatusFindAllStatuses {
Map<String, dynamic> toJson() => _$UserStatusFindAllStatusesToJson(this);
}
class UserStatusFindStatusOcsData {
UserStatusFindStatusOcsData(
this._data, {
this.userStatusPublicUserStatus,
this.list,
});
factory UserStatusFindStatusOcsData.fromJson(dynamic data) {
UserStatusPublicUserStatus? userStatusPublicUserStatus;
try {
userStatusPublicUserStatus = UserStatusPublicUserStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {}
List? list;
try {
list = data as List;
} catch (_) {}
assert([userStatusPublicUserStatus, list].where((final x) => x != null).length == 1, 'Need oneOf');
return UserStatusFindStatusOcsData(
data,
userStatusPublicUserStatus: userStatusPublicUserStatus,
list: list,
);
}
final dynamic _data;
final UserStatusPublicUserStatus? userStatusPublicUserStatus;
/// Only happens when the user has never set a status
final List? list;
dynamic toJson() => _data;
}
@JsonSerializable()
class UserStatusFindStatusOcs {
UserStatusFindStatusOcs({
@ -3124,7 +3158,7 @@ class UserStatusFindStatusOcs {
final OCSMeta? meta;
final UserStatusPublicUserStatus? data;
final UserStatusFindStatusOcsData? data;
Map<String, dynamic> toJson() => _$UserStatusFindStatusOcsToJson(this);
}

2
packages/nextcloud/lib/src/nextcloud.openapi.g.dart

@ -1558,7 +1558,7 @@ Map<String, dynamic> _$UserStatusFindAllStatusesToJson(UserStatusFindAllStatuses
UserStatusFindStatusOcs _$UserStatusFindStatusOcsFromJson(Map<String, dynamic> json) => UserStatusFindStatusOcs(
meta: json['meta'] == null ? null : OCSMeta.fromJson(json['meta'] as Map<String, dynamic>),
data: json['data'] == null ? null : UserStatusPublicUserStatus.fromJson(json['data'] as Map<String, dynamic>),
data: json['data'] == null ? null : UserStatusFindStatusOcsData.fromJson(json['data']),
);
Map<String, dynamic> _$UserStatusFindStatusOcsToJson(UserStatusFindStatusOcs instance) => <String, dynamic>{

10
packages/nextcloud/lib/src/nextcloud.openapi.json

@ -1521,7 +1521,15 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"$ref": "#/components/schemas/UserStatusPublicUserStatus"
"oneOf": [
{
"$ref": "#/components/schemas/UserStatusPublicUserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
}
]
}
}
}

10
packages/nextcloud/test/user_status_test.dart

@ -93,11 +93,11 @@ Future main() async {
await client.userStatus.setStatus(statusType: UserStatusType.online);
final response = await client.userStatus.findStatus(userId: 'test');
expect(response.ocs!.data!.userId, 'test');
expect(response.ocs!.data!.message, null);
expect(response.ocs!.data!.icon, null);
expect(response.ocs!.data!.clearAt, null);
expect(response.ocs!.data!.status, UserStatusType.online);
expect(response.ocs!.data!.userStatusPublicUserStatus!.userId, 'test');
expect(response.ocs!.data!.userStatusPublicUserStatus!.message, null);
expect(response.ocs!.data!.userStatusPublicUserStatus!.icon, null);
expect(response.ocs!.data!.userStatusPublicUserStatus!.clearAt, null);
expect(response.ocs!.data!.userStatusPublicUserStatus!.status, UserStatusType.online);
});
test('Set predefined message', () async {

10
specs/user_status.json

@ -191,7 +191,15 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"$ref": "#/components/schemas/UserStatusPublicUserStatus"
"oneOf": [
{
"$ref": "#/components/schemas/UserStatusPublicUserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
}
]
}
}
}

Loading…
Cancel
Save