2023-04-04 16:06:14 +00:00
|
|
|
import 'package:graphql/client.dart';
|
2021-01-14 21:48:05 +00:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
final DateFormat formatter = DateFormat('hh:mm');
|
2021-01-14 21:48:05 +00:00
|
|
|
|
|
|
|
class Message {
|
2023-04-04 16:06:14 +00:00
|
|
|
Message({this.text, this.severity = MessageSeverity.normal})
|
|
|
|
: time = DateTime.now();
|
2022-06-05 22:40:34 +00:00
|
|
|
Message.warn({this.text})
|
2023-04-04 16:06:14 +00:00
|
|
|
: severity = MessageSeverity.warning,
|
2022-06-05 22:40:34 +00:00
|
|
|
time = DateTime.now();
|
2021-01-14 21:48:05 +00:00
|
|
|
|
2021-03-15 15:39:44 +00:00
|
|
|
final String? text;
|
2021-01-14 21:48:05 +00:00
|
|
|
final DateTime time;
|
2023-04-04 16:06:14 +00:00
|
|
|
final MessageSeverity severity;
|
2022-02-16 07:28:29 +00:00
|
|
|
String get timeString => formatter.format(time);
|
2021-01-18 10:21:55 +00:00
|
|
|
}
|
|
|
|
|
2023-04-04 16:06:14 +00:00
|
|
|
enum MessageSeverity {
|
2021-01-18 10:21:55 +00:00
|
|
|
normal,
|
|
|
|
warning,
|
2021-01-14 21:48:05 +00:00
|
|
|
}
|
2023-04-04 16:06:14 +00:00
|
|
|
|
|
|
|
class RestApiRequestMessage extends Message {
|
|
|
|
RestApiRequestMessage({
|
|
|
|
this.method,
|
|
|
|
this.uri,
|
|
|
|
this.data,
|
|
|
|
this.headers,
|
|
|
|
}) : super(text: 'request-uri: $uri\nheaders: $headers\ndata: $data');
|
|
|
|
|
|
|
|
final String? method;
|
|
|
|
final Uri? uri;
|
|
|
|
final String? data;
|
|
|
|
final Map<String, dynamic>? headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RestApiResponseMessage extends Message {
|
|
|
|
RestApiResponseMessage({
|
|
|
|
this.method,
|
|
|
|
this.uri,
|
|
|
|
this.statusCode,
|
|
|
|
this.data,
|
|
|
|
}) : super(text: 'response-uri: $uri\ncode: $statusCode\ndata: $data');
|
|
|
|
|
|
|
|
final String? method;
|
|
|
|
final Uri? uri;
|
|
|
|
final int? statusCode;
|
|
|
|
final String? data;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GraphQlResponseMessage extends Message {
|
|
|
|
GraphQlResponseMessage({
|
|
|
|
this.data,
|
|
|
|
this.errors,
|
|
|
|
this.context,
|
|
|
|
}) : super(text: 'GraphQL Response\ndata: $data');
|
|
|
|
|
|
|
|
final Map<String, dynamic>? data;
|
|
|
|
final List<GraphQLError>? errors;
|
|
|
|
final Context? context;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GraphQlRequestMessage extends Message {
|
|
|
|
GraphQlRequestMessage({
|
|
|
|
this.operation,
|
|
|
|
this.variables,
|
|
|
|
this.context,
|
|
|
|
}) : super(text: 'GraphQL Request\noperation: $operation');
|
|
|
|
|
|
|
|
final Operation? operation;
|
|
|
|
final Map<String, dynamic>? variables;
|
|
|
|
final Context? context;
|
|
|
|
}
|