open-project-flutter-api/doc/NewsApi.md
2023-11-05 19:54:17 +01:00

4.1 KiB

openapi.api.NewsApi

Load the API package

import 'package:openapi/api.dart';

All URIs are relative to https://community.openproject.org

Method HTTP request Description
listNews GET /api/v3/news List News
viewNews GET /api/v3/news/{id} View news

listNews

Object listNews(offset, pageSize, sortBy, filters)

List News

Lists news. The news returned depend on the provided parameters and also on the requesting user's permissions.

Example

import 'package:openapi/api.dart';
// TODO Configure HTTP basic authorization: BasicAuth
//defaultApiClient.getAuthentication<HttpBasicAuth>('BasicAuth').username = 'YOUR_USERNAME'
//defaultApiClient.getAuthentication<HttpBasicAuth>('BasicAuth').password = 'YOUR_PASSWORD';

final api_instance = NewsApi();
final offset = 25; // int | Page number inside the requested collection.
final pageSize = 25; // int | Number of elements to display per page.
final sortBy = [["created_at", "asc"]]; // String | JSON specifying sort criteria. Accepts the same format as returned by the [queries](https://www.openproject.org/docs/api/endpoints/queries/) endpoint. Currently supported sorts are:  + id: Sort by primary key  + created_at: Sort by news creation datetime
final filters = [{ "project_id": { "operator": "=", "values": ["1", "2"] } }]; // String | JSON specifying filter conditions. Accepts the same format as returned by the [queries](https://www.openproject.org/docs/api/endpoints/queries/) endpoint. Currently supported filters are:  + project_id: Filter news by project

try {
    final result = api_instance.listNews(offset, pageSize, sortBy, filters);
    print(result);
} catch (e) {
    print('Exception when calling NewsApi->listNews: $e\n');
}

Parameters

Name Type Description Notes
offset int Page number inside the requested collection. [optional] [default to 1]
pageSize int Number of elements to display per page. [optional]
sortBy String JSON specifying sort criteria. Accepts the same format as returned by the queries endpoint. Currently supported sorts are: + id: Sort by primary key + created_at: Sort by news creation datetime [optional]
filters String JSON specifying filter conditions. Accepts the same format as returned by the queries endpoint. Currently supported filters are: + project_id: Filter news by project [optional]

Return type

Object

Authorization

BasicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/hal+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

viewNews

NewsModel viewNews(id)

View news

Example

import 'package:openapi/api.dart';
// TODO Configure HTTP basic authorization: BasicAuth
//defaultApiClient.getAuthentication<HttpBasicAuth>('BasicAuth').username = 'YOUR_USERNAME'
//defaultApiClient.getAuthentication<HttpBasicAuth>('BasicAuth').password = 'YOUR_PASSWORD';

final api_instance = NewsApi();
final id = 1; // int | news id

try {
    final result = api_instance.viewNews(id);
    print(result);
} catch (e) {
    print('Exception when calling NewsApi->viewNews: $e\n');
}

Parameters

Name Type Description Notes
id int news id

Return type

NewsModel

Authorization

BasicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/hal+json

[Back to top] [Back to API list] [Back to Model list] [Back to README]