import 'dart:core';

import 'package:fis_jsonrpc/client_base.dart';
import 'package:fis_common/json_convert.dart';

import 'masterInteractionCenter.m.dart';


class MasterInteractionCenterService extends JsonRpcClientBase {
	MasterInteractionCenterService(
		String host, {
		String serviceName = "IMasterInteractionCenterService",
		Map<String, String>? headers,
		int? timeout,
	}) : super(
						host,
						serviceName,
						headers: headers,
						timeout: timeout,
				) {
		/// 注册响应实体反序列化处理器
		FJsonConvert.setDecoder((map) => OperationLogDTO.fromJson(map));
	}

	Future<List<OperationLogDTO>> getOpLogsFromMasterAsync(GetOpLogsFormMasterRequest request) async {
		var rpcRst = await call("GetOpLogsFromMasterAsync", request);
		var result = (rpcRst as List).map((e)=>OperationLogDTO.fromJson(e as Map<String, dynamic>)).toList();
		return result;
	}

	Future<List<OperationLogDTO>> getOpLogsByCodesFromMasterAsync(GetOpLogsByCodesFormMasterRequest request) async {
		var rpcRst = await call("GetOpLogsByCodesFromMasterAsync", request);
		var result = (rpcRst as List).map((e)=>OperationLogDTO.fromJson(e as Map<String, dynamic>)).toList();
		return result;
	}

	Future<bool> syncOpLogToMasterAsync(SyncOpLogToMasterRequest request) async {
		var rpcRst = await call("SyncOpLogToMasterAsync", request);
		return rpcRst;
	}

	Future<bool> syncReceiveSlaveServiceDataAsync(SyncReceiveServiceDataRequest request) async {
		var rpcRst = await call("SyncReceiveSlaveServiceDataAsync", request);
		return rpcRst;
	}

}