Skip to content

Commit e2fa1eb

Browse files
committed
autocomplete: Setup stream topics API binding
1 parent 540df4e commit e2fa1eb

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

lib/api/route/channels.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
3+
import '../core.dart';
4+
part 'channels.g.dart';
5+
6+
/// https://zulip.com/api/get-stream-topics
7+
Future<GetStreamTopicsResult> getStreamTopics(
8+
ApiConnection connection, {
9+
required int streamId,
10+
}) {
11+
return connection.get('getStreamTopics', GetStreamTopicsResult.fromJson,
12+
'users/me/$streamId/topics', {});
13+
}
14+
15+
@JsonSerializable(fieldRename: FieldRename.snake)
16+
class GetStreamTopicsResult {
17+
final List<GetStreamTopicsEntry> topics;
18+
19+
GetStreamTopicsResult({
20+
required this.topics,
21+
});
22+
23+
factory GetStreamTopicsResult.fromJson(Map<String, dynamic> json) =>
24+
_$GetStreamTopicsResultFromJson(json);
25+
26+
Map<String, dynamic> toJson() => _$GetStreamTopicsResultToJson(this);
27+
}
28+
29+
@JsonSerializable(fieldRename: FieldRename.snake)
30+
class GetStreamTopicsEntry {
31+
final int maxId;
32+
final String name;
33+
34+
GetStreamTopicsEntry({
35+
required this.maxId,
36+
required this.name,
37+
});
38+
39+
factory GetStreamTopicsEntry.fromJson(Map<String, dynamic> json) => _$GetStreamTopicsEntryFromJson(json);
40+
41+
Map<String, dynamic> toJson() => _$GetStreamTopicsEntryToJson(this);
42+
}

lib/api/route/channels.g.dart

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)