REST API

REST API

Difficile

Istruzioni

Implementa un'API RESTful per tenere traccia degli IOU.

Quattro coinquilini hanno l'abitudine di darsi denaro in prestito a vicenda e fanno fatica a ricordare chi deve dei soldi a chi, e quanto.

Il tuo compito è implementare una semplice RESTful API che riceve gli IOU come richieste POST e può fornire determinate informazioni di riepilogo tramite richieste GET.

Specifiche dell'API

Oggetto utente

{
  "name": "Adam",
  "owes": {
    "Bob": 12.0,
    "Chuck": 4.0,
    "Dan": 9.5
  },
  "owed_by": {
    "Bob": 6.5,
    "Dan": 2.75
  },
  "balance": "<(total owed by other users) - (total owed to other users)>"
}

Metodi

Descrizione Metodo HTTP URL Formato del payload Risposta senza payload Risposta con payload
Elenco delle informazioni degli utenti GET /users {"users":["Adam","Bob"]} {"users":<List of all User objects>} {"users":<List of User objects for <users> (sorted by name)}
Creazione di un utente POST /add {"user":<name of new user (unique)>} N/D <User object for new user>
Creazione di un IOU POST /iou {"lender":<name of lender>,"borrower":<name of borrower>,"amount":5.25} N/D {"users":<updated User objects for <lender> and <borrower> (sorted by name)>}

Altre risorse

Modifica tramite GitHub Il link si apre in una nuova finestra o scheda
SQLite Exercism

Vuoi iniziare REST API?

Iscriviti a Exercism per imparare e padroneggiare SQLite con 81 esercizi e il mentoring di persone reali, tutto gratis.