fromChain static method

Danger<GenerateRequest, CitrusRequestExceptionA> fromChain(
  1. Chain chain
)
override

Implementation

static Danger<GenerateRequest, CitrusRequestExceptionA> fromChain(Chain chain) {

    final log = Log(classLocation: GenerateRequest, functionLocation: 'fromChain');

    final generateLocationResult = chain.getOptionAsSingleString(JSON_KEY_GENERATE_LOCATION);
    log.add(generateLocationResult);
    if (generateLocationResult is! Success<String, ChainExceptionIJK>) return Failure(CitrusRequestExceptionA(), log);

    final generateModeResult = chain.getOptionAsSingleString(JSON_KEY_GENERATE_MODE);
    log.add(generateModeResult);
    if (generateModeResult is! Success<String, ChainExceptionIJK>) return Failure(CitrusRequestExceptionA(), log);

    final templateFileLocationResult = chain.getOptionAsSingleString(JSON_KEY_TEMPLATE_FILE_LOCATION);
    log.add(templateFileLocationResult);
    if (templateFileLocationResult is! Success<String, ChainExceptionIJK>) return Failure(CitrusRequestExceptionA(), log);

    final templateFileNameResult = chain.getOptionAsSingleString(JSON_KEY_TEMPLATE_FILE_NAME);
    log.add(templateFileNameResult);
    if (templateFileNameResult is! Success<String, ChainExceptionIJK>) return Failure(CitrusRequestExceptionA(), log);

    final logResult = chain.isFlag(JSON_KEY_LOG);
    log.add(logResult);

    final result = GenerateRequest(
        generateLocationResult.wrapped,
        generateModeResult.wrapped,
        templateFileLocationResult.wrapped,
        templateFileNameResult.wrapped,
        chain,

        logResult.wrapped,
    );

    return Success(result, log);

}