handleApi method
Future<void>
handleApi({
- required String featureName,
- required String featurePath,
- required String pageName,
- required String pathPage,
- required String apiName,
- required dynamic body,
- required dynamic response,
- required String? method,
- required String pathUrl,
- required List<
String> paramPath, - required String? header,
- required bool isBodyList,
- required bool isResponseList,
- required String? cacheStrategy,
- required int? ttl,
- required bool? keepExpiredCache,
- required String? appsName,
Implementation
Future<void> handleApi({
required String featureName,
required String featurePath,
required String pageName,
required String pathPage,
required String apiName,
required dynamic body,
required dynamic response,
required String? method,
required String pathUrl,
required List<String> paramPath,
required String? header,
required bool isBodyList,
required bool isResponseList,
required String? cacheStrategy,
required int? ttl,
required bool? keepExpiredCache,
required String? appsName,
}) async {
if (body != null) {
createDataModelBody(
pathPage,
pageName,
apiName,
body,
(method ?? '').toLowerCase().contains('multipart'),
paramPath,
);
}
if (response != null) {
createDataModelResponse(pathPage, pageName, apiName, response);
createDomainEntity(pathPage, pageName, apiName, response);
appendMapper(pathPage, apiName, response);
}
final argBody = isBodyList ? '--body-list' : '--no-body-list';
final argResponse =
isResponseList ? '--response-list' : '--no-response-list';
final argCacheStrategy = cacheStrategy == null
? ''
: '--cache-strategy=$cacheStrategy${ttl == null ? '' : ' --ttl=$ttl'}${keepExpiredCache == null ? '' : ' --keep-expired-cache=$keepExpiredCache'}';
final argAppsName = appsName != null ? '-a "$appsName"' : '';
if (isApi) {
await 'morpheme api $apiName -f $featureName -p $pageName --json2dart --method=$method --path=$pathUrl ${header != null ? '--header=$header' : ''} $argBody $argResponse $argCacheStrategy $argAppsName'
.run;
}
}