updated project style guidelines
This commit is contained in:
@ -14,13 +14,9 @@ class GetChat extends TalkApi<GetChatResponse> {
|
||||
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetChatResponse> onLoad() {
|
||||
return GetChat(
|
||||
Future<GetChatResponse> onLoad() => GetChat(
|
||||
chatToken,
|
||||
GetChatParams(
|
||||
lookIntoFuture: GetChatParamsSwitch.off,
|
||||
@ -22,11 +21,8 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
limit: 200,
|
||||
)
|
||||
).run();
|
||||
}
|
||||
|
||||
@override
|
||||
GetChatResponse onLocalData(String json) {
|
||||
return GetChatResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetChatResponse onLocalData(String json) => GetChatResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,4 +31,4 @@ class GetChatParams extends ApiParams {
|
||||
enum GetChatParamsSwitch {
|
||||
@JsonValue(1) on,
|
||||
@JsonValue(0) off,
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class GetChatResponse extends ApiResponse {
|
||||
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
|
||||
|
||||
List<GetChatResponseObject> sortByTimestamp() {
|
||||
List<GetChatResponseObject> sorted = data.toList();
|
||||
var sorted = data.toList();
|
||||
sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp));
|
||||
return sorted;
|
||||
}
|
||||
@ -60,12 +60,11 @@ class GetChatResponseObject {
|
||||
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
|
||||
|
||||
static GetChatResponseObject getDateDummy(int timestamp) {
|
||||
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
var elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
|
||||
}
|
||||
|
||||
static GetChatResponseObject getTextDummy(String text) {
|
||||
return GetChatResponseObject(
|
||||
static GetChatResponseObject getTextDummy(String text) => GetChatResponseObject(
|
||||
0,
|
||||
'',
|
||||
GetRoomResponseObjectMessageActorType.user,
|
||||
@ -81,13 +80,12 @@ class GetChatResponseObject {
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Map<String, RichObjectString>? _fromJson(json) {
|
||||
if(json is Map<String, dynamic>) {
|
||||
Map<String, RichObjectString> data = {};
|
||||
var data = <String, RichObjectString>{};
|
||||
for (var element in json.keys) {
|
||||
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element]));
|
||||
}
|
||||
@ -119,4 +117,4 @@ enum RichObjectStringObjectType {
|
||||
@JsonValue('guest') guest,
|
||||
@JsonValue('highlight') highlight,
|
||||
@JsonValue('talk-poll') talkPoll,
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ class RichObjectStringProcessor {
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ class CreateRoom extends TalkApi {
|
||||
CreateRoom(this.params) : super('v4/room', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -22,4 +20,4 @@ class CreateRoom extends TalkApi {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,4 @@ class CreateRoomParams extends ApiParams {
|
||||
|
||||
factory CreateRoomParams.fromJson(Map<String, dynamic> json) => _$CreateRoomParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CreateRoomParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class DeleteMessage extends TalkApi {
|
||||
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class DeleteReactMessage extends TalkApi {
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -23,4 +21,4 @@ class DeleteReactMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ class DeleteReactMessageParams extends ApiParams {
|
||||
|
||||
factory DeleteReactMessageParams.fromJson(Map<String, dynamic> json) => _$DeleteReactMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$DeleteReactMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,9 @@ class GetParticipants extends TalkApi<GetParticipantsResponse> {
|
||||
GetParticipants(this.token) : super('v4/room/$token/participants', null);
|
||||
|
||||
@override
|
||||
GetParticipantsResponse assemble(String raw) {
|
||||
return GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
GetParticipantsResponse assemble(String raw) => GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,11 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetParticipantsResponse> onLoad() {
|
||||
return GetParticipants(
|
||||
Future<GetParticipantsResponse> onLoad() => GetParticipants(
|
||||
chatToken,
|
||||
).run();
|
||||
}
|
||||
|
||||
@override
|
||||
GetParticipantsResponse onLocalData(String json) {
|
||||
return GetParticipantsResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetParticipantsResponse onLocalData(String json) => GetParticipantsResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -69,4 +69,4 @@ enum GetParticipantsResponseObjectParticipantsInCallFlags {
|
||||
@JsonValue(2) providesAudio,
|
||||
@JsonValue(3) providesVideo,
|
||||
@JsonValue(4) usesSipDialIn
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,9 @@ class GetReactions extends TalkApi<GetReactionsResponse> {
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
assemble(String raw) => GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,4 +30,4 @@ class GetReactionsResponseObject {
|
||||
enum GetReactionsResponseObjectActorType {
|
||||
@JsonValue('guests') guests,
|
||||
@JsonValue('users') users,
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,8 @@ class LeaveRoom extends TalkApi {
|
||||
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.delete(uri, headers: headers);
|
||||
}
|
||||
}
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.delete(uri, headers: headers);
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class ReactMessage extends TalkApi {
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -23,4 +21,4 @@ class ReactMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ class ReactMessageParams extends ApiParams {
|
||||
|
||||
factory ReactMessageParams.fromJson(Map<String, dynamic> json) => _$ReactMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ReactMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,9 @@ class GetRoom extends TalkApi<GetRoomResponse> {
|
||||
|
||||
|
||||
@override
|
||||
GetRoomResponse assemble(String raw) {
|
||||
return GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
}
|
||||
GetRoomResponse assemble(String raw) => GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
|
||||
|
||||
@override
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
return http.get(uri, headers: headers);
|
||||
}
|
||||
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,12 @@ class GetRoomCache extends RequestCache<GetRoomResponse> {
|
||||
}
|
||||
|
||||
@override
|
||||
GetRoomResponse onLocalData(String json) {
|
||||
return GetRoomResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
GetRoomResponse onLocalData(String json) => GetRoomResponse.fromJson(jsonDecode(json));
|
||||
|
||||
@override
|
||||
Future<GetRoomResponse> onLoad() {
|
||||
return GetRoom(
|
||||
Future<GetRoomResponse> onLoad() => GetRoom(
|
||||
GetRoomParams(
|
||||
includeStatus: true,
|
||||
)
|
||||
).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ class GetRoomParams extends ApiParams {
|
||||
enum GetRoomParamsStatusUpdate {
|
||||
@JsonValue(0) defaults,
|
||||
@JsonValue(1) keepAlive,
|
||||
}
|
||||
}
|
||||
|
@ -164,4 +164,4 @@ enum GetRoomResponseObjectMessageType {
|
||||
@JsonValue('comment_deleted') deletedComment,
|
||||
@JsonValue('system') system,
|
||||
@JsonValue('command') command,
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ class SendMessage extends TalkApi {
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
|
||||
@ -22,4 +20,4 @@ class SendMessage extends TalkApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ class SendMessageParams extends ApiParams {
|
||||
|
||||
factory SendMessageParams.fromJson(Map<String, dynamic> json) => _$SendMessageParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SendMessageParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ import '../../../apiResponse.dart';
|
||||
|
||||
class SendMessageResponse extends ApiResponse {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class SetFavorite extends TalkApi {
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -24,4 +22,4 @@ class SetFavorite extends TalkApi {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,7 @@ class SetReadMarker extends TalkApi {
|
||||
}
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
return null;
|
||||
}
|
||||
assemble(String raw) => null;
|
||||
|
||||
@override
|
||||
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||
@ -29,4 +27,4 @@ class SetReadMarker extends TalkApi {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@ class SetReadMarkerParams extends ApiParams {
|
||||
|
||||
factory SetReadMarkerParams.fromJson(Map<String, dynamic> json) => _$SetReadMarkerParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SetReadMarkerParamsToJson(this);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
getParameters?.update(key, (value) => value.toString());
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
var endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
|
||||
headers ??= {};
|
||||
headers?.putIfAbsent('Accept', () => 'application/json');
|
||||
@ -65,4 +65,4 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
throw Exception('Error assembling Talk API response');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,5 @@ class TalkError {
|
||||
TalkError(this.status, this.code, this.message);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Talk - $status - ($code): $message';
|
||||
}
|
||||
}
|
||||
String toString() => 'Talk - $status - ($code): $message';
|
||||
}
|
||||
|
Reference in New Issue
Block a user