
import 'package:http/http.dart' as http;
import 'package:http/http.dart';

import '../talkApi.dart';
import 'setReadMarkerParams.dart';

class SetReadMarker extends TalkApi {
  String chatToken;
  bool readState;
  SetReadMarkerParams? setReadMarkerParams;

  SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super('v1/chat/$chatToken/read', null, getParameters: setReadMarkerParams?.toJson()) {
    if(readState) assert(setReadMarkerParams?.lastReadMessage != null);
  }

  @override
  assemble(String raw) => null;

  @override
  Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
    if(readState) {

      return http.post(uri, headers: headers);
    } else {
      return http.delete(uri, headers: headers);
    }
  }

}
