import '../../../services/service_config.dart';
import '../index.dart';
import 'magento_service.dart';

mixin MagentoMixin on ConfigMixin {
  @override
  void configMagento(appConfig) {
    var url = appConfig['url']?.toString().trim() ?? '';
    if (url.endsWith('/')) {
      url = url.substring(0, url.length - 1);
    }

    final magentoApi = MagentoService(
      domain: url,
      blogDomain: appConfig['blog'],
      accessToken: appConfig['accessToken'],
    );
    api = magentoApi;
    widget = MagentoWidget(magentoApi);
  }
}
