#!/bin/bash

# Gets info from a cloud voucher

ACTION=$1
VOUCHER=$2
CLOUD_TOKEN=$3

if [ "$VOUCHER" = "" ] || [ "$CLOUD_TOKEN" = "" ]; then
  echo "Usage: $0 <action> <voucher> <cloud_token>"
  exit
fi

if [ "$ACTION" = "info" ]; then
  STATEMENT=`curl --connect-timeout 2 --max-time 2 -F "voucher=$VOUCHER" -F "token=$CLOUD_TOKEN" http://apisv1.net-bo.com/shared_vouchers/info 2> /dev/null`

  if [ $? != 0 ]; then
    echo -n "ERROR"
  else
    echo -n "$STATEMENT"
  fi

else
  echo "Invalid action - $action"
fi

