generateEndpoints method

Future<void> generateEndpoints(
  1. EndpointConfig config
)

Generates endpoint methods and writes them to the output file.

Parameters:

  • config: The endpoint configuration

Implementation

Future<void> generateEndpoints(EndpointConfig config) async {
  final StringBuffer file = StringBuffer();

  file.write('abstract class ${config.projectName.pascalCase}Endpoints {\n');

  // Generate URI creation methods
  await _generateUriCreationMethods(file, config.json2DartPaths);

  file.writeln();

  // Generate endpoint methods
  await _generateEndpointMethods(file, config.json2DartPaths);

  file.write('}');

  // Write to output file
  config.outputPath.write(file.toString());
  StatusHelper.generated(config.outputPath);

  // Format the generated code
  final pathDir = join(
    current,
    'core',
    'lib',
    'src',
    'data',
    'remote',
  );
  await ModularHelper.format([pathDir]);
}