import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:easycook_mobile/models/home.dart';
import 'package:easycook_mobile/shared/shared_values.dart' as AppConst;

class HomeRepositories {
  Dio dio = new Dio();

  final String _baseUrl = AppConst.BASE_URL;

  Future<RecipeResponse> getRecipe() async {
    var response = await dio.get(
      "$_baseUrl/recipes",
      options: Options(headers: {
        HttpHeaders.contentTypeHeader: 'application/json',
      }, validateStatus: (status) => true),
    );

    Map<String, dynamic> data = {"data": response.data};
    return RecipeResponse.fromJson(jsonDecode(jsonEncode(data)));
  }
}
