Skip to content

Commit

Permalink
Add Response data type
Browse files Browse the repository at this point in the history
  • Loading branch information
vasya-polyansky committed Dec 14, 2020
1 parent 720a4c5 commit 29fc2ed
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 46 deletions.
11 changes: 7 additions & 4 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ targets:
options:
# Options configure how source code is generated for every
# `@JsonSerializable`-annotated class in the package.

any_map: false
checked: false
create_factory: true
create_to_json: true
disallow_unrecognized_keys: false
# If true, generated toJson methods will explicitly call toJson on nested objects.
explicit_to_json: true
field_rename: none
generic_argument_factories: false
ignore_unannotated: false
include_if_null: true
nullable: true
field_rename: none
generic_argument_factories: false

# If true, generated toJson methods will explicitly call toJson on nested objects.
explicit_to_json: true

28 changes: 28 additions & 0 deletions lib/src/response/response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tdproto_dart/tdproto_dart.dart';

part 'response.freezed.dart';
part 'response.g.dart';

/// Response
@freezed
abstract class Response with _$Response {
const factory Response({
/// Debug time
@JsonKey(name: '_time') String time,

/// Whether http status code is 200 or not
@JsonKey(name: 'ok') @required bool ok,

/// Requested data
@JsonKey(name: 'result') dynamic result,

/// Error code
@JsonKey(name: 'error') String error,

/// Details about the error
@JsonKey(name: 'details') Map<String, dynamic> details,
}) = _Response;

factory Response.fromJson(Map<String, dynamic> json) => _$ResponseFromJson(json);
}
257 changes: 257 additions & 0 deletions lib/src/response/response.freezed.dart

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

25 changes: 25 additions & 0 deletions lib/src/response/response.g.dart

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

Loading

0 comments on commit 29fc2ed

Please sign in to comment.