import 'package:flutter/material.dart';

import '../../app.dart';

class CMSApi {
  static String className = 'CMSApi';

  static Future<List<CMSModel>> get() async {
    final String fnName = 'get';

    List<CMSModel> list = [];

    try {
      debugPrint('class: $className, method: $fnName');

      String path = Constants.BASE_URL + 'cms';

      final response = await HttpUtil().get(
        path: path,
        queryParameters: {
          'locale': await getLocale(),
        },
      );

      for (final json in response['data']) {
        list.add(CMSModel.fromJson(json));
      }

      return list;
    } catch (e) {
      debugPrint('ERROR: class: $className, method: $fnName, error: $e ');
      return list;
    }
  }
}
