GithubHelp home page GithubHelp logo

shiftheroes's Introduction

ShiftHeroes by Harry JMG

python

Challenge Web Site


Summary

  1. API
  2. Plannings
  3. Shift
  4. Reservations
  5. Converter

API

Toutes les requêtes de l'API doivent être authentifiées à l'aide du token d'API généré via l'interface utilisateur. L'authentification doit être effectuée en incluant le header Authorization: Bearer YOUR_API_TOKEN dans chaque requête.

YOUR_API_TOKEN est une clé unique qui te permettra d'accéder à l'API ( Générer un token )


Plannings

Les plannings sont la ressource centrale de l'API. Tu peux lister tous les plannings disponibles et filtrer par type.

  • Lister les plannings GET /api/v1/plannings

Endpoint : GET /api/v1/plannings Requête (sans filtre) :

curl -X GET "https://shiftheroes.fr/api/v1/plannings" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings" -Headers $headers

Requête (avec filtre de type) :

curl -X GET "https://shiftheroes.fr/api/v1/plannings?type=TYPE" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings?type=TYPE" -Headers $headers

Réponse :

[ { "id": "X05fNV", "planning_type": "daily", "state": "available", "published_at": "2023-07-07T08:46:45.215Z" }, { "id": "e6bdK2", "planning_type": "permanent", "state": "available", "published_at": "2023-07-07T08:37:54.353Z" }, { "id": "j9KDf4", "planning_type": "weekly", "state": "available", "published_at": "2023-07-07T08:47:58.611Z" } ]

Astuce :
Utilisez le paramètre ?type=TYPE pour filtrer les plannings selon leur type (permanent, daily, weekly).


Shifts

  • Lister les créneaux d'un planning GET /api/v1/plannings/:planning_id/shifts

Endpoint : GET /api/v1/plannings/:planning_id/shifts Requête :

curl -X GET "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts" -Headers $headers

Réponse :

[ { "id": "lqQFnY", "day": "mardi", "start_hour": "2000-01-01T08:00:00.000Z", "end_hour": "2000-01-01T14:00:00.000Z", "seats": 10, "seats_taken": 1 }, { "id": "x2OFW1", "day": "lundi", "start_hour": "2000-01-01T08:00:00.000Z", "end_hour": "2000-01-01T14:00:00.000Z", "seats": 12, "seats_taken": 0 } ]

Astuce :
Dans l'exemple j'utilise dans l'url :planning_id , ce qu'il faut faire c'est modifier cette valeur par la valeur de l'identifiant du planning souhaité.


Reservations

  • Lister ses réservations sur un planning GET /api/v1/plannings/:planning_id/reservations

Endpoint : GET /api/v1/plannings/:planning_id/reservation Requête :

curl -X GET "https://shiftheroes.fr/api/v1/plannings/:planning_id/reservations" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/reservations" -Headers $headers

Réponse :

[ { "id": 103, "user_id": 5, "shift_id": "lqQFnY" }, { "id": 104, "user_id": 5, "shift_id": "x2OFW1" } ]
  • Créer une réservation sur un shift POST /api/v1/plannings/:planning_id/shifts/:shift_id/reservations

Endpoint : POST /api/v1/plannings/:planning_id/shifts/:shift_id/reservations Requête :

curl -X POST "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations" -Method Post -Headers $headers

Réponse :

La réservation est crée avec succès.
  • Supprimer une réservation DELETE /api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id

Endpoint : DELETE /api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id Requête :

curl -X DELETE "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id" -H "Authorization: Bearer YOUR_API_TOKEN"

OR

$headers = @{
    "Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id" -Method Delete -Headers $headers

Réponse :

La réservation est supprimée avec succès.

Converter

I've used this to convert Curl requests to Python
Curl Converter


shiftheroes's People

Contributors

lybe-source avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.