#!/usr/bin/env bash
# Lab step 7: two requests that differ only in who the email goes to. What does the queue show?
source /lab/env.sh
A=$(authz '{"actor":"lab-agent","action":"send_customer_email","resource":{"customer":"42"},"args":{"to":"pat@example.com","subject":"Your invoice"},"confidence":0.99}' | jq -r .review_id)
B=$(authz '{"actor":"lab-agent","action":"send_customer_email","resource":{"customer":"42"},"args":{"to":"entire-customer-list@example.com","subject":"Your invoice"},"confidence":0.99}' | jq -r .review_id)
for r in $A $B; do
  curl -sS -H "Authorization: Bearer $KEY" "$BASE/v1/queue/$r" | jq -c 'del(.enqueued_at,.id,.confidence_score)'
done
