28 lines
932 B
Dart
28 lines
932 B
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'package:easycook_mobile/models/supplier.dart';
|
|
import 'package:easycook_mobile/shared/shared_values.dart' as AppConst;
|
|
import 'package:dio/dio.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class SupplierRepositories {
|
|
Dio dio = new Dio();
|
|
|
|
final String _baseUrl = AppConst.BASE_URL;
|
|
|
|
Future<SupplierResponse> getSupplier(id) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
var token = prefs.getString('token');
|
|
var response = await dio.get(
|
|
"$_baseUrl/pantry/$id/rekomendasi/",
|
|
options: Options(headers: {
|
|
HttpHeaders.contentTypeHeader: 'application/json',
|
|
HttpHeaders.authorizationHeader: 'Token $token',
|
|
}, validateStatus: (status) => true),
|
|
);
|
|
|
|
Map<String, dynamic> data = {"data": response.data};
|
|
return SupplierResponse.fromJson(jsonDecode(jsonEncode(data)));
|
|
}
|
|
}
|