import { type FileParameter } from "./APIClient";
import { isNull, isUndefined } from "lodash";

export namespace Common {
  export function toFileParameter(object: File): FileParameter {
    if (isNull(object) || isUndefined(object))
      throw new Error("File is Null or Undefined");
    return {
      data: object,
      fileName: object.name
    }
  }

  export function toFileParameterOrNull(object?: File | null): FileParameter | null {
    if (isNull(object) || isUndefined(object)) return null;
    else return {
      data: object,
      fileName: object.name
    }
  }

}
