|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
import 'package:test_sa/api/user_api_client.dart';
|
|
|
|
|
|
|
|
|
|
import '../controllers/api_routes/urls.dart';
|
|
|
|
|
@ -37,20 +38,45 @@ class GasRefillApiClient {
|
|
|
|
|
Future<GasRefillModel> createModel({
|
|
|
|
|
required GasRefillModel model,
|
|
|
|
|
}) async {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
"uid": UserApiClient().user?.id.toString(),
|
|
|
|
|
"token": UserApiClient().user?.token ?? "",
|
|
|
|
|
"title": model.title ?? "",
|
|
|
|
|
"status": "0", //model.status.value.toString(),
|
|
|
|
|
"gazRefillNo": await generateGazRefillNo(),
|
|
|
|
|
"assignedEmployee": {
|
|
|
|
|
"id": UserApiClient().user?.id.toString(),
|
|
|
|
|
"name": UserApiClient().user?.username.toString()
|
|
|
|
|
},
|
|
|
|
|
"status": {
|
|
|
|
|
"id": 0,
|
|
|
|
|
"name": "",
|
|
|
|
|
"value": 0
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
body["gazRefillDetails"] = jsonEncode(model.details
|
|
|
|
|
body["gazRefillDetails"] = model.details
|
|
|
|
|
?.map((model) => {
|
|
|
|
|
"gasType": model.type?.id.toString(),
|
|
|
|
|
"cylinderSize": model.cylinderSize?.id.toString(),
|
|
|
|
|
"requestedQty": model.requestedQuantity.toString(),
|
|
|
|
|
"gasType": {
|
|
|
|
|
"id": model.type?.id,
|
|
|
|
|
"name": model.type?.label.toString(),
|
|
|
|
|
"value": model.type?.id
|
|
|
|
|
},
|
|
|
|
|
"cylinderType": {
|
|
|
|
|
"id": 0,
|
|
|
|
|
"name": "",
|
|
|
|
|
"value": 0
|
|
|
|
|
},
|
|
|
|
|
"cylinderSize": {
|
|
|
|
|
"id": model.cylinderSize?.id,
|
|
|
|
|
"name": model.cylinderSize?.label.toString(),
|
|
|
|
|
"value": model.cylinderSize?.id,
|
|
|
|
|
},
|
|
|
|
|
"requestedQty": model.requestedQuantity,
|
|
|
|
|
"deliverdQty": 0
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.toList());
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
print(body);
|
|
|
|
|
|
|
|
|
|
final response = await ApiClient().postJsonForResponse(
|
|
|
|
|
"${URLs.host1}${URLs.requestGasRefill}",
|
|
|
|
|
@ -85,4 +111,13 @@ class GasRefillApiClient {
|
|
|
|
|
|
|
|
|
|
oldModel?.fromGasRefillModel(newModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<String> generateGazRefillNo() async {
|
|
|
|
|
|
|
|
|
|
final reponse = await ApiClient().getJsonForResponse("${URLs.host1}${URLs.generateGazRefillNo}");
|
|
|
|
|
var data = json.decode(reponse.body);
|
|
|
|
|
return data['data'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|