- Installer https://getbitbar.com
- Copier le fichier
OystAPI.10s.sh
dans lePlugin folder
(/Users/oyst/Documents/bitbar-plugins) - Améliorer ;)
Last active
November 29, 2022 21:36
-
-
Save mehdichaouch/1a42b00187ed54d2fe07aaa02aeccca7 to your computer and use it in GitHub Desktop.
BitBar / xbar - Plugin Oyst API status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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