diff --git a/addItemToBox.bash b/scripts/addItemToBox.bash similarity index 100% rename from addItemToBox.bash rename to scripts/addItemToBox.bash diff --git a/deleteItemsInBox.bash b/scripts/deleteItemsInBox.bash similarity index 100% rename from deleteItemsInBox.bash rename to scripts/deleteItemsInBox.bash diff --git a/scripts/getboxes.bash b/scripts/getboxes.bash new file mode 100644 index 0000000..c466333 --- /dev/null +++ b/scripts/getboxes.bash @@ -0,0 +1,37 @@ +#!/bin/bash + +# API base URL +API_BASE_URL="http://10.0.0.66:8080" + +# Login credentials +USERNAME="boxuser" +PASSWORD="boxuser" + +# Function to make an authenticated request +function authenticated_request() { + local method=$1 + local endpoint=$2 + local data=$3 + + # Get a new JWT token + TOKEN=$(curl -s -X POST -H "Content-Type: application/json" \ + -d "{\"username\":\"$USERNAME\", \"password\":\"$PASSWORD\"}" \ + "$API_BASE_URL/login" | jq -r '.token') + + # Make the authenticated request + curl -s -X $method -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -d "$data" \ + "$API_BASE_URL$endpoint" +} + +# Get all boxes +response=$(authenticated_request "GET" "/boxes" "") + +# Check if the request was successful +if [[ $? -eq 0 ]]; then + # Pretty print the boxes using jq + echo "$response" | jq . +else + echo "Error: Failed to get boxes." +fi diff --git a/getitems.bash b/scripts/getitems.bash similarity index 100% rename from getitems.bash rename to scripts/getitems.bash diff --git a/getitemsinbox.bash b/scripts/getitemsinbox.bash similarity index 100% rename from getitemsinbox.bash rename to scripts/getitemsinbox.bash diff --git a/test2.bash b/scripts/test2.bash similarity index 100% rename from test2.bash rename to scripts/test2.bash diff --git a/tests.bash b/scripts/tests.bash similarity index 100% rename from tests.bash rename to scripts/tests.bash