isAssemblyFinished method

bool isAssemblyFinished(
  1. TransloaditResponse response
)

Returns whether the assembly has finished, whether successful or not

Implementation

bool isAssemblyFinished(TransloaditResponse response) {
  final status = response.data["ok"];
  bool isAborted = status == "REQUEST_ABORTED";
  bool isCancelled = status == "ASSEMBLY_CANCELED";
  bool isCompleted = status == "ASSEMBLY_COMPLETED";
  bool isFailed = response.data["error"] != null;

  if (isFailed) {
    throw Exception(response.data["error"]);
  }

  return isAborted || isCancelled || isCompleted || isFailed;
}