Sports#

GET /api/sports#

Obtenir tous les sports

Scope : workouts:read

Exemple de requête :

GET /api/sports HTTP/1.1
Content-Type: application/json

Exemple de réponse :

  • pour un utilisateur non admin :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": [
      {
        "color": null,
        "id": 1,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Sport)",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "id": 2,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Transport)",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "id": 3,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Hiking",
        "stopped_speed_threshold": 0.1
      },
      {
        "color": null,
        "id": 4,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Mountain Biking",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "id": 5,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Running",
        "stopped_speed_threshold": 0.1
      },
      {
        "color": null,
        "id": 6,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Walking",
        "stopped_speed_threshold": 0.1
      }
    ]
  },
  "status": "success"
}
  • pour un administrateur :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": [
      {
        "color": null,
        "has_workouts": true,
        "id": 1,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Sport)",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "has_workouts": false,
        "id": 2,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Transport)",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "has_workouts": false,
        "id": 3,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Hiking",
        "stopped_speed_threshold": 0.1
      },
      {
        "color": null,
        "has_workouts": false,
        "id": 4,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Mountain Biking",
        "stopped_speed_threshold": 1
      },
      {
        "color": null,
        "has_workouts": false,
        "id": 5,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Running",
        "stopped_speed_threshold": 0.1
      },
      {
        "color": null,
        "has_workouts": false,
        "id": 6,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Walking",
        "stopped_speed_threshold": 0.1
      }
    ]
  },
  "status": "success"
}
En-têtes de requête:
Codes d’état:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

GET /api/sports/(int: sport_id)#

Obtenir un sport

Scope : workouts:read

Exemple de requête :

GET /api/sports/1 HTTP/1.1
Content-Type: application/json

Exemple de réponse :

  • succès pour un utilisateur non admin :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": [
      {
        "color": null,
        "id": 1,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Sport)",
        "stopped_speed_threshold": 1
      }
    ]
  },
  "status": "success"
}
  • succès pour un administrateur :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": [
      {
        "color": null,
        "has_workouts": false,
        "id": 1,
        "is_active": true,
        "is_active_for_user": true,
        "label": "Cycling (Sport)",
        "stopped_speed_threshold": 1
      }
    ]
  },
  "status": "success"
}
  • sport non trouvé :

HTTP/1.1 404 NOT FOUND
Content-Type: application/json

{
  "data": {
    "sports": []
  },
  "status": "not found"
}
Paramètres:
  • sport_id (integer) – identifiant du sport

En-têtes de requête:
Codes d’état:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 404 Not Foundsport not found

PATCH /api/sports/(int: sport_id)#

Modifier un sport.

L’utilisateur authentifié doit avoir des droits d’administration.

Scope : workouts:write

Exemple de requête :

PATCH /api/sports/1 HTTP/1.1
Content-Type: application/json

Exemple de réponses :

  • success:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": [
      {
        "color": null,
        "has_workouts": false,
        "id": 1,
        "is_active": false,
        "is_active_for_user": false,
        "label": "Cycling (Sport)",
        "stopped_speed_threshold": 1
      }
    ]
  },
  "status": "success"
}
  • sport non trouvé :

HTTP/1.1 404 NOT FOUND
Content-Type: application/json

{
  "data": {
    "sports": []
  },
  "status": "not found"
}
Paramètres:
  • sport_id (integer) – identifiant du sport

Objet JSON de requête:
  • is_active (string) – état d’activation du sport

En-têtes de requête:
Codes d’état: