import 'package:aitrainer_app/model/cache.dart';
import 'dart:convert';
import 'package:aitrainer_app/model/exercise_device.dart';

import 'api.dart';

class ExerciseDeviceApi {
  final APIClient _client = new APIClient();

  Future<List<ExerciseDevice>> getDevices() async {
    final body = await _client.get("exercise_device/", "");
    final Iterable json = jsonDecode(body);
    final List<ExerciseDevice> devices = json.map((device) => ExerciseDevice.fromJson(device)).toList();
    Cache().setDevices(devices);
    return devices;
  }
}
