44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
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<List<PropertyAppraisal>> 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<http.Response?> 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;
|
|
}
|
|
}
|