HTTP API to bring out shared positions from argumented statements
Retruco is a software fostering argumentative discussion around statements and allowing to bring out shared positions.
Retruco means immediate, precise and firm response in spanish.
For the first time only:
npm install
su - postgres
createuser -D -P -R -S retruco
Enter password for new role: retruco
Enter it again: retruco
createdb -E utf-8 -O retruco retruco
psql retruco
CREATE EXTENSION IF NOT EXISTS pg_trgm;
\q
npm run configure
npm run start
In another terminal:
npm run process-votes
To explore Retruco API, open sample Swagger UI and explore http://localhost:3000/swagger.json.
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --data-binary @- "http://localhost:3000/users"
{
"name": "Alice",
"urlName": "alice",
"email": "[email protected]",
"password": "secret"
}
EOF
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --data-binary @- "http://localhost:3000/login"
{
"userName": "alice",
"password": "secret"
}
EOF
Returns:
{
"apiVersion": "1",
"data": {
"apiKey": "HoIw4IqGwymIeP+xRK2MUg",
"createdAt": "2016-05-03T21:28:34.447Z",
"name": "Alice",
"urlName": "alice"
}
}
Retrieve the API key in field data.apiKey
of the response.
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements"
{
"type": "PlainStatement",
"language": "fr",
"name": "Il faut ouvrir le code source des logiciels du secteur public"
}
EOF
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements"
{
"type": "PlainStatement",
"language": "fr",
"name": "Ouvrir le code source est préférable à ouvrir les algorithmes"
}
EOF
curl --header "Accept: application/json" "http://localhost:3000/statements"
Returns:
{
"apiVersion": "1",
"data": [
{
"createdAt": "2016-05-05T17:32:23.143Z",
"id": "1630eafd-e387-44bf-abbb-70c5bf9fdfc8",
"language": "fr",
"name": "Il est plus pratique de diffuser le code source que de le communiquer au cas par cas aux citoyens qui en font la demande",
"type": "PlainStatement"
},
{
{
"createdAt": "2016-05-03T21:42:48.226Z",
"id": "c671c17e-a272-4a6a-9bc1-2b82db7c7499",
"language": "fr",
"name": "Ouvrir le code source est préférable à ouvrir les algorithmes",
"type": "PlainStatement"
},
{
"createdAt": "2016-05-03T21:31:18.124Z",
"id": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"language": "fr",
"name": "Il faut ouvrir le code source des logiciels du secteur public",
"type": "PlainStatement"
}
]
}
curl --header "Accept: application/json" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979"
Returns:
{
"apiVersion": "1",
"data": {
"createdAt": "2016-05-03T21:31:18.124Z",
"id": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"language": "fr",
"name": "Il faut ouvrir le code source des logiciels du secteur public",
"authorName": "alice"
}
}
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/rating"
{
"rating": 1
}
EOF
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"updatedAt": "2016-05-03T21:33:34.282Z",
"voterName": "alice"
}
}
curl --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/rating"
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"updatedAt": "2016-05-03T21:33:34.282Z",
"voterName": "alice"
}
}
curl -X DELETE --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/rating"
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"updatedAt": "2016-05-03T21:33:34.282Z",
"voterName": "alice"
}
}
curl --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/rating"
Returns:
{
"apiVersion": "1",
"data": {
"statementId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"voterName": "alice"
}
}
curl -X DELETE --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/rating"
Returns:
{
"apiVersion": "1",
"data": {
"statementId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"voterName": "alice"
}
}
curl --header "Accept: application/json" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/arguments/c671c17e-a272-4a6a-9bc1-2b82db7c7499"
Returns:
{
"apiVersion": "1",
"data": {
"claimId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"createdAt": "2016-05-05T17:41:10.863Z",
"groundId": "c671c17e-a272-4a6a-9bc1-2b82db7c7499",
"id": "0d872e6d-6760-442f-aefa-82a0c06f104d",
"type": "Argument"
}
}
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/arguments/c671c17e-a272-4a6a-9bc1-2b82db7c7499/rating"
{
"rating": 1
}
EOF
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "0d872e6d-6760-442f-aefa-82a0c06f104d",
"updatedAt": "2016-05-05T17:43:05.322Z",
"voterName": "alice"
}
}
curl --header "Accept: application/json" "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/arguments/c671c17e-a272-4a6a-9bc1-2b82db7c7499"
Returns:
{
"apiVersion": "1",
"data": {
"claimId": "82d4e0ac-c234-45eb-8ba2-02d4d6a41979",
"createdAt": "2016-05-05T17:41:10.863Z",
"groundId": "c671c17e-a272-4a6a-9bc1-2b82db7c7499",
"id": "0d872e6d-6760-442f-aefa-82a0c06f104d",
"rating": 1,
"ratingCount": 1,
"ratingSum": 1,
"type": "Argument"
}
}
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/82d4e0ac-c234-45eb-8ba2-02d4d6a41979/arguments/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/rating"
{
"rating": 1
}
EOF
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/rating"
{
"rating": 1
}
EOF
curl --header "Accept: application/json" "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/abuse"
Returns:
{
"apiVersion": "1",
"data": {
"createdAt": "2016-05-05T18:51:58.488Z",
"id": "d342c445-d12e-40b2-81d9-c2b7939fc732",
"statementId": "1630eafd-e387-44bf-abbb-70c5bf9fdfc8",
"type": "Abuse"
}
}
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/abuse/rating"
{
"rating": 1
}
EOF
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "d342c445-d12e-40b2-81d9-c2b7939fc732",
"updatedAt": "2016-05-05T18:55:49.961Z",
"voterName": "alice"
}
}
curl -X DELETE --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/abuse/rating"
curl --header "Accept: application/json" "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/tags/logiciel_libre"
Returns:
{
"apiVersion": "1",
"data": {
"createdAt": "2016-05-05T22:46:54.069Z",
"id": "dd3fd0ad-206e-495f-be47-3d4952f44a8d",
"name": "logiciel_libre",
"statementId": "1630eafd-e387-44bf-abbb-70c5bf9fdfc8",
"type": "Tag"
}
}
cat <<'EOF' | curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Retruco-API-Key: HoIw4IqGwymIeP+xRK2MUg" --data-binary @- "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/tags/logiciel_libre/rating"
{
"rating": 1
}
EOF
Returns:
{
"apiVersion": "1",
"data": {
"rating": 1,
"statementId": "dd3fd0ad-206e-495f-be47-3d4952f44a8d",
"updatedAt": "2016-05-05T22:48:58.320Z",
"voterName": "alice"
}
}
curl --header "Accept: application/json" "http://localhost:3000/statements/1630eafd-e387-44bf-abbb-70c5bf9fdfc8/tags"
Returns:
{
"apiVersion": "1",
"data": [
{
"createdAt": "2016-05-05T22:46:54.069Z",
"id": "dd3fd0ad-206e-495f-be47-3d4952f44a8d",
"name": "logiciel_libre",
"rating": 1,
"ratingCount": 1,
"ratingSum": 1,
"statementId": "1630eafd-e387-44bf-abbb-70c5bf9fdfc8",
"type": "Tag"
}
]
}