import 'package:satu/core/base/base_service.dart';
import 'package:satu/core/models/inventarization/inventarization_response.dart';
import 'package:satu/core/utils/locator.dart';

import '../models/response/response_entity.dart';
import 'api_service.dart';

class InventarizationService  extends BaseService {
  final ApiService _api = locator<ApiService>();

  Future<List<InventarizationResponse>> getList(
      {required int page, required int perpage, dynamic filter}) async {
    List<InventarizationResponse> list = [];
    try {
      final Map<String, dynamic> requestBody = <String, dynamic>{
        'page': page,
        'perpage': perpage
      };

      ResponseEntity categories = await _api
          .postRequest('/goods_inventory_get', requestBody: requestBody);
      if (categories.original.data != null &&
          categories.original.data!.isNotEmpty) {
        for (final dynamic map in categories.original.data!) {
          final InventarizationResponse item = InventarizationResponse.fromJson(map);
          list.add(item);
        }
      }
    } catch (e, stack) {
      log.e('getList', e, stack);
    }
    return list;
  }

}