Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Last active November 29, 2022 21:36
Show Gist options
  • Save mehdichaouch/1a42b00187ed54d2fe07aaa02aeccca7 to your computer and use it in GitHub Desktop.
Save mehdichaouch/1a42b00187ed54d2fe07aaa02aeccca7 to your computer and use it in GitHub Desktop.
BitBar / xbar - Plugin Oyst API status

Oyst

image

  1. Installer https://getbitbar.com
  2. Copier le fichier OystAPI.10s.sh dans le Plugin folder (/Users/oyst/Documents/bitbar-plugins)
  3. Améliorer ;)
#!/bin/bash
#set -e
#set -x
# Oyst API status
API_KEY_SANDBOX=
API_KEY_STAGING=
ENVIRONMENTS=('sandbox' 'staging') # Add more env here if needed ; Add also variable above
if [ -z "$API_KEY_SANDBOX" ] && [ -z "$API_KEY_STAGING" ]; then
echo "🔴 Configure your Oyst API key"
else
echo "Oyst API Status"
for ENVIRONMENT in "${ENVIRONMENTS[@]}"; do
API_KEY=API_KEY_$(echo "$ENVIRONMENT" | tr '[:lower:]' '[:upper:]')
if [ -z "${!API_KEY}" ]; then
echo "🔴 $ENVIRONMENT API key is missing"
continue
fi
HOSTNAME="api.$ENVIRONMENT.oyst.eu"
URL_SHIPMENT_TYPES="https://$HOSTNAME/catalog/v1/shipments/types"
result=$(curl -sS -o /dev/null -w "%{http_code}" --request GET --url $URL_SHIPMENT_TYPES --header "authorization: Bearer ${!API_KEY}" --header 'content-type: application/json')
if [ '200' -eq $result ]; then
status="✅"
else
status="🔴"
fi
echo "$ENVIRONMENT: $status"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment