Skip to content

Commit 02b9a2b

Browse files
committed
api: Set up stream topics API binding
1 parent 9eb149e commit 02b9a2b

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

lib/api/route/channels.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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(ApiConnection connection, {
8+
required int streamId,
9+
}) {
10+
return connection.get('getStreamTopics', GetStreamTopicsResult.fromJson, 'users/me/$streamId/topics', {});
11+
}
12+
13+
@JsonSerializable(fieldRename: FieldRename.snake)
14+
class GetStreamTopicsResult {
15+
final List<GetStreamTopicsEntry> topics;
16+
17+
GetStreamTopicsResult({
18+
required this.topics,
19+
});
20+
21+
factory GetStreamTopicsResult.fromJson(Map<String, dynamic> json) =>
22+
_$GetStreamTopicsResultFromJson(json);
23+
24+
Map<String, dynamic> toJson() => _$GetStreamTopicsResultToJson(this);
25+
}
26+
27+
@JsonSerializable(fieldRename: FieldRename.snake)
28+
class GetStreamTopicsEntry {
29+
final int maxId;
30+
final String name;
31+
32+
GetStreamTopicsEntry({
33+
required this.maxId,
34+
required this.name,
35+
});
36+
37+
factory GetStreamTopicsEntry.fromJson(Map<String, dynamic> json) => _$GetStreamTopicsEntryFromJson(json);
38+
39+
Map<String, dynamic> toJson() => _$GetStreamTopicsEntryToJson(this);
40+
}

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)