inspection static method

dynamic inspection({
  1. dynamic token,
  2. dynamic customerId,
  3. dynamic policyId,
  4. dynamic providerId,
  5. dynamic distributorId,
  6. dynamic timeStamp,
  7. required File interior,
  8. required File dashboard,
  9. required File frontSide,
  10. required File backSide,
  11. required File leftSide,
  12. required File rightSide,
  13. required File chassisNumber,
  14. dynamic address,
  15. dynamic lon,
  16. dynamic lat,
  17. dynamic inspectionType,
  18. dynamic videoUrl,
})

Implementation

static inspection(
    {token,
    customerId,
    policyId,
    providerId,
    distributorId,
    timeStamp,
    required File interior,
    required File dashboard,
    required File frontSide,
    required File backSide,
    required File leftSide,
    required File rightSide,
    required File chassisNumber,
    address,
    lon,
    lat,
    inspectionType,
    videoUrl}) async {
  Map<String, String> headers = {
    "Accept": "application/json",
    "Authorization": "Bearer " + token
  };

  var uri = Uri.parse(ApiScheme.submitInspectionUrl);

  var request = http.MultipartRequest("POST", uri);

  request.files
      .add(await http.MultipartFile.fromPath('interior', interior.path));
  request.files
      .add(await http.MultipartFile.fromPath('front_side', frontSide.path));
  request.files
      .add(await http.MultipartFile.fromPath('back_side', backSide.path));
  request.files
      .add(await http.MultipartFile.fromPath('left_side', leftSide.path));
  request.files
      .add(await http.MultipartFile.fromPath('right_side', rightSide.path));
  request.files
      .add(await http.MultipartFile.fromPath('dashboard', dashboard.path));
  request.files.add(
      await http.MultipartFile.fromPath('chasis_number', chassisNumber.path));

  request.headers.addAll(headers);

  request.fields['customer_id'] = customerId;
  request.fields['policy_id'] = policyId;
  request.fields['provider_id'] = providerId;
  request.fields['distributor_id'] = distributorId;
  request.fields['inspection_type'] = inspectionType;
  request.fields['timestamp'] = timeStamp;
  request.fields['address'] = address ?? 'hehhe';
  request.fields['video_url'] = videoUrl;
  request.fields['longitude'] = lon.toString();
  request.fields['latitude'] = lat.toString();

  var response = await request.send();
  print(response.statusCode);
  print(response.reasonPhrase);

  return response;
}