#!/bin/bash
source .env

PREFIX=${PREFIX:-''}
SKIP_BINARY_DOWNLOAD=${SKIP_BINARY_DOWNLOAD:-''}

if [ "$SKIP_BINARY_DOWNLOAD" == true ]; then
  echo "Skipping binary download, set SKIP_BINARY_DOWNLOAD to false if you wish to download the binary"
  exit 0
fi


if [ -z "$OS" ]; then
 echo "Please populate the OS env variable with the mobile os"
 exit 1
elif [ "$OS" == "android" ]; then
  EXTENSION=.apk
  elif [ "$OS" == "ios" ]; then
  EXTENSION=.ipa
fi

if [ -z "$BRAND" ]; then
  echo "Please populate the BRAND env variable with a brand"
  exit 1
fi

if [ ! -z "$PREFIX" ]; then
  PREFIX="$PREFIX"_
fi


BUCKET_PATH='s3://orcd-mobile-binaries/'
FILE_PATH="$BUCKET_PATH""$PREFIX""$OS""_""$BRAND"_qa$EXTENSION
aws s3 cp "$FILE_PATH" apps/
