import 'dart:convert';

import 'package:hl_lieferservice/services/erpframe.dart';
import 'package:hl_lieferservice/persistence.dart';
import 'package:hl_lieferservice/repository.dart';

/// This repository manages the configuration file stored on the phone
/// locally.
class ConfigurationRepository extends BaseRepository{
  const ConfigurationRepository({required super.path});

  Future<LocalDocuFrameConfiguration> getDocuFrameConfiguration() async {
    String content = await FileStorage().read(path);
    return LocalDocuFrameConfiguration.fromJson(json.decode(content));
  }

  Future<void> setDocuFrameConfiguration(LocalDocuFrameConfiguration configuration) async {
    String content = json.encode(configuration.toJson());
    await FileStorage().write(path, content);
  }
}