module WolfCore::Barton::Onboarding::FileOperations

def build_file_payload(

def build_file_payload(
  salesforce_max_file_size:, encoded_file:, url:,
  parent_id:, file_id:, filename:
)
  limit = salesforce_max_file_size.to_i
  file_payload = {
    parentId: parent_id,
    appFileId: file_id,
    fileTitle: filename,
    versionData: encoded_file,
    extension: filename.split('.').second
  }
  size = file_payload.to_json.size
  exceed_limit = size >= limit
  if exceed_limit
    file_payload[:limit] = limit
    file_payload[:payloadSize] = size
    file_payload[:url] = url
    file_payload.delete(:versionData)
  end
  file_payload
end