getEndpoint method

String? getEndpoint(
  1. String endpointConstant
)

Gets a specific API endpoint from CDN config using constant identifiers

Implementation

String? getEndpoint(String endpointConstant) {
  _ensureInitialized();
  try {
    final cachedConfig = getCDNConfig();

    // Use the constant to get the property name, then look up the value
    if (cachedConfig?.apiEndpoints?[endpointConstant] != null) {
      final value = cachedConfig!.apiEndpoints![endpointConstant];
      return value;
    }

    // Fallback to default config using the same property name
    final defaultValue = (_bundledConfig['api']?['endpoints'] as Map<String, dynamic>?)?[endpointConstant] as String?;
    return defaultValue;
  } catch (e) {
    return (_bundledConfig['api']?['endpoints'] as Map<String, dynamic>?)?[endpointConstant] as String?;
  }
}