Browse Source

specs,nextcloud: Use news v1.3 API

pull/49/head
jld3103 2 years ago
parent
commit
f76b6928f8
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 6
      packages/neon/lib/src/apps/news/blocs/articles.dart
  2. 62
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  3. 60
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 2
      packages/nextcloud/lib/src/version_supported.dart
  5. 9
      packages/nextcloud/test/news_test.dart
  6. 60
      specs/news.json

6
packages/neon/lib/src/apps/news/blocs/articles.dart

@ -87,8 +87,7 @@ class NewsArticlesBloc extends $NewsArticlesBloc {
_$starArticleEvent.listen((final article) {
_wrapArticleAction((final client) async {
await client.news.starArticle(
feedId: article.feedId!,
guidHash: article.guidHash!,
itemId: article.id!,
);
// TODO
//_articleUpdateController.add(article..starred = true);
@ -98,8 +97,7 @@ class NewsArticlesBloc extends $NewsArticlesBloc {
_$unstarArticleEvent.listen((final article) {
_wrapArticleAction((final client) async {
await client.news.unstarArticle(
feedId: article.feedId!,
guidHash: article.guidHash!,
itemId: article.id!,
);
// TODO
//_articleUpdateController.add(article..starred = false);

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

@ -1702,7 +1702,7 @@ class NewsClient {
}
Future<NewsListFolders> listFolders() async {
var path = '/apps/news/api/v1-2/folders';
var path = '/apps/news/api/v1-3/folders';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1719,7 +1719,7 @@ class NewsClient {
}
Future<NewsListFolders> createFolder({required String name}) async {
var path = '/apps/news/api/v1-2/folders';
var path = '/apps/news/api/v1-3/folders';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1740,7 +1740,7 @@ class NewsClient {
required int folderId,
required String name,
}) async {
var path = '/apps/news/api/v1-2/folders/{folderId}';
var path = '/apps/news/api/v1-3/folders/{folderId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1759,7 +1759,7 @@ class NewsClient {
}
Future deleteFolder({required int folderId}) async {
var path = '/apps/news/api/v1-2/folders/{folderId}';
var path = '/apps/news/api/v1-3/folders/{folderId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1780,14 +1780,14 @@ class NewsClient {
required int folderId,
required int newestItemId,
}) async {
var path = '/apps/news/api/v1-2/folders/{folderId}/read';
var path = '/apps/news/api/v1-3/folders/{folderId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString()));
queryParameters['newestItemId'] = newestItemId.toString();
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
@ -1799,7 +1799,7 @@ class NewsClient {
}
Future<NewsListFeeds> listFeeds() async {
var path = '/apps/news/api/v1-2/feeds';
var path = '/apps/news/api/v1-3/feeds';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1819,7 +1819,7 @@ class NewsClient {
required String url,
int? folderId,
}) async {
var path = '/apps/news/api/v1-2/feeds';
var path = '/apps/news/api/v1-3/feeds';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1840,7 +1840,7 @@ class NewsClient {
}
Future deleteFeed({required int feedId}) async {
var path = '/apps/news/api/v1-2/feeds/{feedId}';
var path = '/apps/news/api/v1-3/feeds/{feedId}';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1861,7 +1861,7 @@ class NewsClient {
required int feedId,
int? folderId,
}) async {
var path = '/apps/news/api/v1-2/feeds/{feedId}/move';
var path = '/apps/news/api/v1-3/feeds/{feedId}/move';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1885,7 +1885,7 @@ class NewsClient {
required int feedId,
required String feedTitle,
}) async {
var path = '/apps/news/api/v1-2/feeds/{feedId}/rename';
var path = '/apps/news/api/v1-3/feeds/{feedId}/rename';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1907,14 +1907,14 @@ class NewsClient {
required int feedId,
required int newestItemId,
}) async {
var path = '/apps/news/api/v1-2/feeds/{feedId}/read';
var path = '/apps/news/api/v1-3/feeds/{feedId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
queryParameters['newestItemId'] = newestItemId.toString();
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
@ -1933,7 +1933,7 @@ class NewsClient {
int offset = 0,
int oldestFirst = 0,
}) async {
var path = '/apps/news/api/v1-2/items';
var path = '/apps/news/api/v1-3/items';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1960,7 +1960,7 @@ class NewsClient {
int id = 0,
int lastModified = 0,
}) async {
var path = '/apps/news/api/v1-2/items/updated';
var path = '/apps/news/api/v1-3/items/updated';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
@ -1980,13 +1980,13 @@ class NewsClient {
}
Future markArticleAsRead({required int itemId}) async {
var path = '/apps/news/api/v1-2/items/{itemId}/read';
var path = '/apps/news/api/v1-3/items/{itemId}/read';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
@ -1998,13 +1998,13 @@ class NewsClient {
}
Future markArticleAsUnread({required int itemId}) async {
var path = '/apps/news/api/v1-2/items/{itemId}/unread';
var path = '/apps/news/api/v1-3/items/{itemId}/unread';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
@ -2015,18 +2015,14 @@ class NewsClient {
throw ApiException.fromResponse(response);
}
Future starArticle({
required int feedId,
required String guidHash,
}) async {
var path = '/apps/news/api/v1-2/items/{feedId}/{guidHash}/star';
Future starArticle({required int itemId}) async {
var path = '/apps/news/api/v1-3/items/{itemId}/star';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
path = path.replaceAll('{guidHash}', Uri.encodeQueryComponent(guidHash.toString()));
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
@ -2037,18 +2033,14 @@ class NewsClient {
throw ApiException.fromResponse(response);
}
Future unstarArticle({
required int feedId,
required String guidHash,
}) async {
var path = '/apps/news/api/v1-2/items/{feedId}/{guidHash}/unstar';
Future unstarArticle({required int itemId}) async {
var path = '/apps/news/api/v1-3/items/{itemId}/unstar';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
path = path.replaceAll('{guidHash}', Uri.encodeQueryComponent(guidHash.toString()));
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest(
'put',
'post',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,

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

@ -1847,7 +1847,7 @@
}
}
},
"/apps/news/api/v1-2/folders": {
"/apps/news/api/v1-3/folders": {
"get": {
"operationId": "list-folders",
"tags": [
@ -1895,7 +1895,7 @@
}
}
},
"/apps/news/api/v1-2/folders/{folderId}": {
"/apps/news/api/v1-3/folders/{folderId}": {
"parameters": [
{
"name": "folderId",
@ -1939,7 +1939,7 @@
}
}
},
"/apps/news/api/v1-2/folders/{folderId}/read": {
"/apps/news/api/v1-3/folders/{folderId}/read": {
"parameters": [
{
"name": "folderId",
@ -1951,7 +1951,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-folder-as-read",
"tags": [
"news"
@ -1974,7 +1974,7 @@
}
}
},
"/apps/news/api/v1-2/feeds": {
"/apps/news/api/v1-3/feeds": {
"get": {
"operationId": "list-feeds",
"tags": [
@ -2030,7 +2030,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}": {
"/apps/news/api/v1-3/feeds/{feedId}": {
"parameters": [
{
"name": "feedId",
@ -2053,7 +2053,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/move": {
"/apps/news/api/v1-3/feeds/{feedId}/move": {
"parameters": [
{
"name": "feedId",
@ -2086,7 +2086,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/rename": {
"/apps/news/api/v1-3/feeds/{feedId}/rename": {
"parameters": [
{
"name": "feedId",
@ -2119,7 +2119,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/read": {
"/apps/news/api/v1-3/feeds/{feedId}/read": {
"parameters": [
{
"name": "feedId",
@ -2130,7 +2130,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-feed-as-read",
"tags": [
"news"
@ -2152,7 +2152,7 @@
}
}
},
"/apps/news/api/v1-2/items": {
"/apps/news/api/v1-3/items": {
"get": {
"operationId": "list-articles",
"tags": [
@ -2228,7 +2228,7 @@
}
}
},
"/apps/news/api/v1-2/items/updated": {
"/apps/news/api/v1-3/items/updated": {
"get": {
"operationId": "list-updated-articles",
"tags": [
@ -2277,7 +2277,7 @@
}
}
},
"/apps/news/api/v1-2/items/{itemId}/read": {
"/apps/news/api/v1-3/items/{itemId}/read": {
"parameters": [
{
"name": "itemId",
@ -2288,7 +2288,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-article-as-read",
"tags": [
"news"
@ -2300,7 +2300,7 @@
}
}
},
"/apps/news/api/v1-2/items/{itemId}/unread": {
"/apps/news/api/v1-3/items/{itemId}/unread": {
"parameters": [
{
"name": "itemId",
@ -2311,7 +2311,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-article-as-unread",
"tags": [
"news"
@ -2323,26 +2323,18 @@
}
}
},
"/apps/news/api/v1-2/items/{feedId}/{guidHash}/star": {
"/apps/news/api/v1-3/items/{itemId}/star": {
"parameters": [
{
"name": "feedId",
"name": "itemId",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "guidHash",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"put": {
"post": {
"operationId": "star-article",
"tags": [
"news"
@ -2354,26 +2346,18 @@
}
}
},
"/apps/news/api/v1-2/items/{feedId}/{guidHash}/unstar": {
"/apps/news/api/v1-3/items/{itemId}/unstar": {
"parameters": [
{
"name": "feedId",
"name": "itemId",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "guidHash",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"put": {
"post": {
"operationId": "unstar-article",
"tags": [
"news"

2
packages/nextcloud/lib/src/version_supported.dart

@ -12,7 +12,7 @@ extension NewsVersionSupported on NewsClient {
/// Checks if the app on the server is supported by the client
Future<bool> isSupported() async {
final versions = await getSupportedApiVersions();
return versions.apiLevels!.contains('v1-2');
return versions.apiLevels!.contains('v1-3');
}
}

9
packages/nextcloud/test/news_test.dart

@ -140,8 +140,7 @@ Future main() async {
response = await client.news.listArticles();
await client.news.starArticle(
feedId: response.items![0].feedId!,
guidHash: response.items![0].guidHash!,
itemId: response.items![0].id!,
);
response = await client.news.listArticles(type: 2);
expect(response.items, hasLength(1));
@ -154,15 +153,13 @@ Future main() async {
final item = response.items![0];
await client.news.starArticle(
feedId: item.feedId!,
guidHash: item.guidHash!,
itemId: item.id!,
);
response = await client.news.listArticles(type: 2);
expect(response.items, hasLength(1));
await client.news.unstarArticle(
feedId: item.feedId!,
guidHash: item.guidHash!,
itemId: item.id!,
);
response = await client.news.listArticles(type: 2);
expect(response.items, hasLength(0));

60
specs/news.json

@ -264,7 +264,7 @@
}
}
},
"/apps/news/api/v1-2/folders": {
"/apps/news/api/v1-3/folders": {
"get": {
"operationId": "list-folders",
"tags": [
@ -312,7 +312,7 @@
}
}
},
"/apps/news/api/v1-2/folders/{folderId}": {
"/apps/news/api/v1-3/folders/{folderId}": {
"parameters": [
{
"name": "folderId",
@ -356,7 +356,7 @@
}
}
},
"/apps/news/api/v1-2/folders/{folderId}/read": {
"/apps/news/api/v1-3/folders/{folderId}/read": {
"parameters": [
{
"name": "folderId",
@ -368,7 +368,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-folder-as-read",
"tags": [
"news"
@ -391,7 +391,7 @@
}
}
},
"/apps/news/api/v1-2/feeds": {
"/apps/news/api/v1-3/feeds": {
"get": {
"operationId": "list-feeds",
"tags": [
@ -447,7 +447,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}": {
"/apps/news/api/v1-3/feeds/{feedId}": {
"parameters": [
{
"name": "feedId",
@ -470,7 +470,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/move": {
"/apps/news/api/v1-3/feeds/{feedId}/move": {
"parameters": [
{
"name": "feedId",
@ -503,7 +503,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/rename": {
"/apps/news/api/v1-3/feeds/{feedId}/rename": {
"parameters": [
{
"name": "feedId",
@ -536,7 +536,7 @@
}
}
},
"/apps/news/api/v1-2/feeds/{feedId}/read": {
"/apps/news/api/v1-3/feeds/{feedId}/read": {
"parameters": [
{
"name": "feedId",
@ -547,7 +547,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-feed-as-read",
"tags": [
"news"
@ -569,7 +569,7 @@
}
}
},
"/apps/news/api/v1-2/items": {
"/apps/news/api/v1-3/items": {
"get": {
"operationId": "list-articles",
"tags": [
@ -645,7 +645,7 @@
}
}
},
"/apps/news/api/v1-2/items/updated": {
"/apps/news/api/v1-3/items/updated": {
"get": {
"operationId": "list-updated-articles",
"tags": [
@ -694,7 +694,7 @@
}
}
},
"/apps/news/api/v1-2/items/{itemId}/read": {
"/apps/news/api/v1-3/items/{itemId}/read": {
"parameters": [
{
"name": "itemId",
@ -705,7 +705,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-article-as-read",
"tags": [
"news"
@ -717,7 +717,7 @@
}
}
},
"/apps/news/api/v1-2/items/{itemId}/unread": {
"/apps/news/api/v1-3/items/{itemId}/unread": {
"parameters": [
{
"name": "itemId",
@ -728,7 +728,7 @@
}
}
],
"put": {
"post": {
"operationId": "mark-article-as-unread",
"tags": [
"news"
@ -740,26 +740,18 @@
}
}
},
"/apps/news/api/v1-2/items/{feedId}/{guidHash}/star": {
"/apps/news/api/v1-3/items/{itemId}/star": {
"parameters": [
{
"name": "feedId",
"name": "itemId",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "guidHash",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"put": {
"post": {
"operationId": "star-article",
"tags": [
"news"
@ -771,26 +763,18 @@
}
}
},
"/apps/news/api/v1-2/items/{feedId}/{guidHash}/unstar": {
"/apps/news/api/v1-3/items/{itemId}/unstar": {
"parameters": [
{
"name": "feedId",
"name": "itemId",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "guidHash",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"put": {
"post": {
"operationId": "unstar-article",
"tags": [
"news"

Loading…
Cancel
Save