import 'dart:convert'; import 'package:fis_jsonrpc/rpc.dart'; import 'package:vitalapp/managers/interfaces/contract_template.dart'; import 'package:vitalapp/rpc.dart'; import 'package:vitalapp/store/store.dart'; import 'package:fis_common/logger/logger.dart'; class ContractTemplateManager implements IContractTemplateManager { @override Future getContractTemplateDetail(String code) async { try { final result = await rpc.vitalContractTemplate.getContractTemplateDetailAsync( GetContractTemplateRequest(code: code, token: Store.user.token), ); return result; } catch (e) { logger.e("ContractTemplate getContractTemplateDetail error.", e); return null; } } @override Future getContractTemplateDetailByKey( String key) async { try { final result = await rpc.vitalContractTemplate.getContractTemplateDetailByKeyAsync( GetContractTemplateByKeyRequest( key: key, token: Store.user.token, ), ); return result; } catch (e) { logger.e("ContractTemplate getContractTemplateDetailByKey error.", e); return null; } } @override Future?> getContractTemplatePageAsync() async { try { var request = ContractTemplatePageRequest( token: Store.user.token, pageIndex: 1, pageSize: 10, ); print(jsonEncode(request)); final result = await rpc.vitalContractTemplate.getContractTemplatePageAsync(request); return result.pageData; } catch (e) { logger.e("ContractTemplate getContractTemplatePageAsync error.", e); return null; } } }