import 'package:http/http.dart' as http;

import '../../nextcloud_ocs.dart';
import '../talk_api.dart';
import 'get_shared_items_overview_response.dart';

/// Fetches the latest shared items of every type at once (Talk's
/// `GET /chat/{token}/share/overview`). Used to decide which category tabs to
/// show and to seed their first page. [limit] caps the items returned per type.
class GetSharedItemsOverview extends TalkApi<GetSharedItemsOverviewResponse> {
  GetSharedItemsOverview(String token, {int limit = 20})
    : super(
        'v1/chat/$token/share/overview',
        null,
        getParameters: {'limit': limit},
      );

  @override
  GetSharedItemsOverviewResponse assemble(String raw) =>
      GetSharedItemsOverviewResponse.fromOcs(NextcloudOcs.decode(raw));

  @override
  Future<http.Response> request(
    Uri uri,
    Object? body,
    Map<String, String>? headers,
  ) => http.get(uri, headers: headers);
}
