#!/usr/bin/env bash

SEP="########################################################################"

# Use wget to download a file
echo "Fetching orchard logo"
wget -q https://cdn.theorchard.io/images/OrchardLogo.png
echo "OrchardLogo.png info:"
stat OrchardLogo.png
rm OrchardLogo.png

printf "\n%s\n" "$SEP"

# Use curl to check an http response code
RESPONSE_CODE=$(curl -sL -w '%{http_code}' -o /dev/null "https://www.theorchard.com")
echo "Response code from theorchard.com was $RESPONSE_CODE"

printf "\n%s\n" "$SEP"

# Use curl to get the website body and headers
RESPONSE_LINES=$(curl -isL https://www.theorchard.com | wc -l | tr -d " ")
echo "theorchard.com responded with $RESPONSE_LINES lines"

printf "\n%s\n" "$SEP"

# Use curl to post a JSON body
curl -sL -w '%{http_code}' \
    https://qa-ows-abacus-event.theorchard.io/abacus-event \
    -H "content-type: application/json" \
    -d "{\"event_name\":\"foo\",\"target_type\":\"foo\",\"target_id\":\"1\"}" \
    -o /dev/null

printf "\n%s\n" "$SEP"
