import 'dart:convert'; import 'dart:developer'; import 'dart:io'; import 'package:unit2/model/passo/property_appraisal.dart'; import 'package:http/http.dart' as http; class PropertyAppraisalServices { static final PropertyAppraisalServices _instance = PropertyAppraisalServices(); static PropertyAppraisalServices get instance => _instance; Future> getPropertyAppraisal(tempID) async { http.Response response = await http.get(Uri.parse( 'http://192.168.10.218:8000/api/rptass_app/property_appraisal/?bldgappr_details_id=$tempID')); print('Appraisal'); print(response.body); if (response.statusCode == 200) { final List result = jsonDecode(response.body)['data']; return result.map(((e) => PropertyAppraisal.fromJson(e))).toList(); } else { throw Exception(response.reasonPhrase); } } Future postPropertyAppraisal( PropertyAppraisal appraisal) async { http.Response? response; try { response = await http.post( Uri.parse( "http://192.168.10.218:8000/api/rptass_app/property_appraisal/"), headers: { HttpHeaders.contentTypeHeader: "application/json", }, body: jsonEncode(appraisal.toJson())); } catch (e) { log(e.toString()); } return response; } }