#!/bin/bash

SECRET=YOURSECRET
WRITE_TO_DIR=src/messages
URL="https://translationhut.com/export/flat_json?languages=EN-US,NL-NL&include_empty=false"

# Download file to messages.zip
curl "$URL" -H "Authorization: Api-Key $SECRET" --output messages.zip

# unzip messages.zip to relative path folder, declared in "WRITE_TO_DIR"
# -o flag will make unzip overwrite destination files
unzip -o messages -d $WRITE_TO_DIR;
if [[ $? != 0 ]];
then
  # If something went wrong, log the downloaded files,
  # since it will most likely contain errors
  printf '\n\nSomething went wrong.\n'
  cat messages.zip;
fi;

rm messages.zip