45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:unit2/model/passo/land_ref.dart';
|
||
|
import 'package:http/http.dart' as http;
|
||
|
import 'package:unit2/utils/request.dart';
|
||
|
import 'package:unit2/utils/urls.dart';
|
||
|
|
||
|
class LandRefServices {
|
||
|
static final LandRefServices _instance = LandRefServices();
|
||
|
static LandRefServices get instance => _instance;
|
||
|
|
||
|
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
||
|
String xClientKeySecret = "unitcYqAN7GGalyz";
|
||
|
|
||
|
Future<LandRef> fetch(tempID) async {
|
||
|
String path = Url.instance.landRef();
|
||
|
Map<String, String> headers = {
|
||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||
|
'X-Client-Key': xClientKey,
|
||
|
'X-Client-Secret': xClientKeySecret
|
||
|
};
|
||
|
Map<String, String> params = {
|
||
|
"bldgappr_details_id": tempID.toString(),
|
||
|
};
|
||
|
try {
|
||
|
http.Response response = await Request.instance
|
||
|
.getRequest(param: params, path: path, headers: headers);
|
||
|
print('land ref');
|
||
|
print(response.statusCode);
|
||
|
if (response.statusCode == 200) {
|
||
|
final jsonData = jsonDecode(response.body);
|
||
|
final dataList = jsonData['data'] as List<dynamic>;
|
||
|
final result = LandRef.fromJson(dataList[0] as Map<String, dynamic>);
|
||
|
|
||
|
return result;
|
||
|
} else {
|
||
|
print(response.reasonPhrase);
|
||
|
throw Exception(response.reasonPhrase);
|
||
|
}
|
||
|
} catch (e) {
|
||
|
throw e.toString();
|
||
|
}
|
||
|
}
|
||
|
}
|