Skip to content

api [nfc]: Use Dart-standard camel case throughout our source code #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ to use, and [download a `.zuliprc` file][download-zuliprc]. Then
create a file `lib/credential_fixture.dart` in this worktree with the
following form:
```dart
// ignore_for_file: constant_identifier_names
const String realm_url = '…';
const String realmUrl = '…';
const String email = '…';
const String api_key = '…';
const String apiKey = '…';
```

Now build and run the app (see "Flutter help" above), and things
Expand Down
16 changes: 7 additions & 9 deletions lib/api/model/events.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: non_constant_identifier_names

import 'package:json_annotation/json_annotation.dart';

import 'model.dart';
Expand Down Expand Up @@ -46,15 +44,15 @@ class UnexpectedEvent extends Event {
}

/// A Zulip event of type `alert_words`.
@JsonSerializable()
@JsonSerializable(fieldRename: FieldRename.snake)
class AlertWordsEvent extends Event {
@override
@JsonKey(includeToJson: true)
String get type => 'alert_words';

final List<String> alert_words;
final List<String> alertWords;

AlertWordsEvent({required super.id, required this.alert_words});
AlertWordsEvent({required super.id, required this.alertWords});

factory AlertWordsEvent.fromJson(Map<String, dynamic> json) =>
_$AlertWordsEventFromJson(json);
Expand All @@ -75,9 +73,9 @@ class MessageEvent extends Event {
// normalize that away in deserialization.
//
// The other difference in the server API between message objects in these
// events and in the get-messages results is that `match_content` and
// `match_subject` are absent here. Already [Message.match_content] and
// [Message.match_subject] are optional, so no action is needed on that.
// events and in the get-messages results is that `matchContent` and
// `matchSubject` are absent here. Already [Message.matchContent] and
// [Message.matchSubject] are optional, so no action is needed on that.
final Message message;

MessageEvent({required super.id, required this.message});
Expand All @@ -100,7 +98,7 @@ class MessageEvent extends Event {
}
}

@JsonSerializable()
@JsonSerializable(fieldRename: FieldRename.snake)
class HeartbeatEvent extends Event {
@override
@JsonKey(includeToJson: true)
Expand Down
4 changes: 2 additions & 2 deletions lib/api/model/events.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 15 additions & 17 deletions lib/api/model/initial_snapshot.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// ignore_for_file: non_constant_identifier_names

import 'package:json_annotation/json_annotation.dart';

import 'model.dart';

part 'initial_snapshot.g.dart';

// https://zulip.com/api/register-queue#response
@JsonSerializable()
@JsonSerializable(fieldRename: FieldRename.snake)
class InitialSnapshot {
final String? queue_id;
final int last_event_id;
final int zulip_feature_level;
final String zulip_version;
final String? zulip_merge_base; // TODO(server-5)
final String? queueId;
final int lastEventId;
final int zulipFeatureLevel;
final String zulipVersion;
final String? zulipMergeBase; // TODO(server-5)

final List<String> alert_words;
final List<String> alertWords;

final List<CustomProfileField> custom_profile_fields;
final List<CustomProfileField> customProfileFields;

// TODO etc., etc.

Expand All @@ -26,13 +24,13 @@ class InitialSnapshot {
// TODO etc., etc.

InitialSnapshot({
this.queue_id,
required this.last_event_id,
required this.zulip_feature_level,
required this.zulip_version,
this.zulip_merge_base,
required this.alert_words,
required this.custom_profile_fields,
this.queueId,
required this.lastEventId,
required this.zulipFeatureLevel,
required this.zulipVersion,
this.zulipMergeBase,
required this.alertWords,
required this.customProfileFields,
required this.subscriptions,
});

Expand Down
28 changes: 14 additions & 14 deletions lib/api/model/initial_snapshot.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading