macOS
•
tmux-256color
•
zsh
28 views
# Create a user. Additional user data is fetched from an external service.
http POST 'localhost:8000/users/' passportNumber="5000 420000"
# Authenticate. For simplicity, username is used as password.
http --form POST 'http://localhost:8000/auth' grant_type=password "username=5000 420000" "password=5000 420000"
# Get authenticated user. For simplicity, user ID is used as token.
http -A bearer -a 11 GET 'http://localhost:8000/users/current'
# Update user...
http -A bearer -a 11 PATCH 'http://localhost:8000/users/11' passportNumber="1234 567890" "surname=Орлов"
# ...whoops, a passport number conflict. My bad, it was a typo of course. Let's input the *correct* new one.
http -A bearer -a 11 PATCH 'http://localhost:8000/users/11' passportNumber="5000 400000" "surname=Орлов"
# List users with filtering and pagination.
http -A bearer -a 11 GET 'http://localhost:8000/users/?filter=address=ул.&offset=0&limit=3'
# Create tasks.
http -A bearer -a 11 POST 'http://localhost:8000/tasks/' "description=Write code"
http -A bearer -a 11 POST 'http://localhost:8000/tasks/' "description=Refactor code"
http -A bearer -a 11 POST 'http://localhost:8000/tasks/' "description=Test code"
http -A bearer -a 11 POST 'http://localhost:8000/tasks/' "description=Fix code"
# Start and stop tasks. Comments to the right show currently active tasks.
started_at=$(date -u "+%Y-%m-%dT%H:%M:%SZ"); echo; echo "started at $started_at"
http -A bearer -a 11 POST 'http://localhost:8000/tasks/6/start' --headers --pretty colors | head -1 # writing code
echo "sleeping 1 second" && sleep 1 # writing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/7/start' --headers --pretty colors | head -1 # writing, refactoring code
echo "sleeping 1 second" && sleep 1 # writing, refactoring code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/7/stop' --headers --pretty colors | head -1 # writing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/8/start' --headers --pretty colors | head -1 # writing, testing code
echo "sleeping 2 seconds" && sleep 2 # writing, testing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/9/start' --headers --pretty colors | head -1 # writing, testing, fixing code
echo "sleeping 3 seconds" && sleep 3 # writing, testing, fixing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/9/stop' --headers --pretty colors | head -1 # writing, testing code
echo "sleeping 1 second" && sleep 1 # writing, testing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/8/stop' --headers --pretty colors | head -1 # writing code
http -A bearer -a 11 POST 'http://localhost:8000/tasks/6/stop' --headers --pretty colors | head -1 # done!
stopped_at=$(date -u "+%Y-%m-%dT%H:%M:%SZ"); echo "stopped at $stopped_at"
# Generate report.
http -A bearer -a 11 POST 'localhost:8000/users/11/report' "from=$started_at" "to=$stopped_at"