build method

Future<OsmosSDK> build()

Implementation

Future<OsmosSDK> build() async {
  if (_clientId == null) {
    throw OsmosException(
      errorCode: OsmosErrorCodes.missingParameter,
      details: 'Client ID is required',
    );
  }

  // Use global instance config as fallback if available
  final globalConfig = OsmosSDK._sdkInstance?._config;

  final config = OsmosConfig(
    clientId: _clientId!,
    debug: _debugSet ? _debug : (globalConfig?.debug ?? false),
    displayAdsHost:
        _displayAdsHost ?? globalConfig?.displayAdsHost ?? "osx-ba.o-s.io",
    productAdsHost:
        _productAdsHost ?? globalConfig?.productAdsHost ?? "osx-pla.o-s.io",
    eventTrackingHost:
        _eventTrackingHost ?? globalConfig?.eventTrackingHost ?? "osx.o-s.io",
  );

  await MethodHandler.invokeNativeMethod('build', arguments: config.toMap());
  return OsmosSDK._(config);
}