import 'dart:convert';

import '../../../requestCache.dart';
import 'getMessages.dart';
import 'getMessagesResponse.dart';

class GetMessagesCache extends RequestCache<GetMessagesResponse> {
  GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
    start("MarianumMobile", "message");
  }

  @override
  GetMessagesResponse onLocalData(String json) {
    return GetMessagesResponse.fromJson(jsonDecode(json));
  }

  @override
  Future<GetMessagesResponse> onLoad() {
    return GetMessages().run();
  }
}