Skip to content

Commit

Permalink
Merge pull request #1152 from dbarzin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dbarzin authored Mar 3, 2025
2 parents 994cd92 + 540ef6e commit 7e1d24a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ command=/bin/sh -c '
else
php artisan migrate --force;
fi
php artisan passport:install --force --silent
php artisan key:generate
touch /tmp/migrated'
autorestart=false
startretries=0
Expand Down
41 changes: 37 additions & 4 deletions docs/api.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,46 @@ print(response.status_code)

Voici un exemple d'utilisation de l'API en ligne de commande avec [CURL](https://curl.se/docs/manpage.html) et [JQ](https://stedolan.github.io/jq/)
```
#!/usr/bin/bash
API_URL=http://127.0.0.1:8000/api
OBJECT=applications
OBJECT_ID=45
# valid login and password
data='{"email":"[email protected]","password":"password"}'
# get a token after correct login
token=$(curl -s -d ${data} -H "Content-Type: application/json" http://localhost:8000/api/login | jq -r .access_token)
# Get a token after correct login
TOKEN=$(curl -s -d ${data} -H "Content-Type: application/json" ${API_URL}/login | jq -r .access_token)
# Récupération de l'objet
RESPONSE=$(curl -s -X GET "${API_URL}/${OBJECT}/${OBJECT_ID}" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Accept: application/json")
echo "Objet récupéré: ${RESPONSE}"
# Mise à jour d'une valeur avec une requête PUT
RESPONSE=$(echo "$RESPONSE" | jq -c '.data')
RESPONSE=$(echo "$RESPONSE" | jq -r '.activities=[1]')
echo "Objet modifié: ${RESPONSE}"
curl -s -X PUT "${API_URL}/${OBJECT}/${OBJECT_ID}" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-H "cache-control: no-cache" \
-d "$RESPONSE"
# Vérification de la mise à jour
UPDATED_OBJECT=$(curl -s -X GET "${API_URL}/${OBJECT}/${OBJECT_ID}" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Accept: application/json")
# query users and decode JSON data with JQ.
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer ${token}" "http://127.0.0.1:8000/api/users" | jq .
echo "Objet mis à jour: ${UPDATED_OBJECT}"
```

0 comments on commit 7e1d24a

Please sign in to comment.