#!/bin/sh
set -eu
# Set ODDSWIRE_API_KEY privately. Never put a key in a URL or enable shell tracing.
: "${ODDSWIRE_API_KEY:?Set ODDSWIRE_API_KEY}"
: "${ODDSWIRE_NAMESPACE:?Choose an entitled namespace}"
base="${ODDSWIRE_BASE_URL:-http://127.0.0.1:9113}"
# Local-only example: do not change the origin without reviewing credential handling.
case "$base" in
http://127.0.0.1:*) port="${base##*:}"; case "$port" in ""|*[!0-9]*) echo 'Invalid local port' >&2; exit 1;; esac ;;
*) echo 'This cURL example requires the local gateway.' >&2; exit 1;;
esac
# Header configuration goes over stdin, not the process argument list.
case "$ODDSWIRE_API_KEY" in *[!A-Za-z0-9_-]*) echo 'Invalid example key format' >&2; exit 1;; esac
printf 'header = "X-API-Key: %s"\n' "$ODDSWIRE_API_KEY" |
curl --config - --silent --show-error --fail-with-body --max-time 10 \
--get "$base/v1/fixtures" --data-urlencode "namespace=$ODDSWIRE_NAMESPACE" --data-urlencode 'limit=1'