changed to new apis

merge-requests/18/head
nextwo 3 years ago
parent d2cf147acd
commit 6c792cbced

@ -91,23 +91,47 @@ class GasRefillApiClient {
required GasRefillModel? oldModel, required GasRefillModel? oldModel,
required GasRefillModel newModel, required GasRefillModel newModel,
}) async { }) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
"uid": UserApiClient().user?.id.toString(), "id": oldModel?.id,
"token": UserApiClient().user?.token, "gazRefillNo": await generateGazRefillNo(),
"title": newModel.title, "assignedEmployee": {
"status": newModel.status?.id.toString(), "id": UserApiClient().user?.id.toString(),
"name": UserApiClient().user?.username.toString()
},
"status": {
"id": 0,
"name": "",
"value": 0
},
}; };
body["gazRefillDetails"] = jsonEncode(newModel.details body["gazRefillDetails"] = newModel.details
?.map((model) => { ?.map((model) => {
"gasType": model.type?.id.toString(), "gasType": {
"cylinderSize": model.cylinderSize?.id.toString(), "id": model.type?.id,
"requestedQty": model.requestedQuantity.toString(), "name": model.type?.label.toString(),
"deliverdQty": model.deliveredQuantity.toString(), "value": model.type?.id
}) },
.toList()); "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();
final reponse = await ApiClient().postJsonForResponse("${URLs.host1}${URLs.updateGasRefill}/${newModel.id}", body); final reponse = await ApiClient().putJsonForResponse("${URLs.host1}${URLs.updateGasRefill}/${newModel.id}", body);
oldModel?.fromGasRefillModel(newModel); oldModel?.fromGasRefillModel(newModel);
} }

@ -27,7 +27,7 @@ class Device {
factory Device.fromJson(Map<String, dynamic> parsedJson) { factory Device.fromJson(Map<String, dynamic> parsedJson) {
return Device( return Device(
id: parsedJson["nid"] ?? parsedJson["id"], id: parsedJson["nid"] ?? parsedJson["id"].toString(),
serialNumber: parsedJson["sn"] ?? parsedJson["value"], serialNumber: parsedJson["sn"] ?? parsedJson["value"],
number: parsedJson["asset_no"], number: parsedJson["asset_no"],
brand: parsedJson["brand"] as String?, brand: parsedJson["brand"] as String?,

Loading…
Cancel
Save