Git Product home page Git Product logo

api-test's Introduction

Appointment Scheduler Api

This is a simple service allowing users to schedule appointments.

Api Usage

GET /appts/{userid}

  • userid : (string) e.g. "antwil"
Response

List of all appointments in JSON format

  • e.g. [{"userid":"antwil","date":"2021-10-17","time":"12:00", "duration":30}, ..., {...}]

POST /appts

Schedule a 30 minute appointment for the user at the given date and time. A user cannot have more than 1 appointment scheduled per day. A user cannot schedule appointments in the past.

Request body
  • userid: (string) e.g. "antwil"
  • date: (string)
    • Format: "YYYY-MM-DD" e.g. "2021-10-17"
      • Date and time must be at least now or in the future, cannot schedule past appointments
  • time: (string)
    • Format: "HH:MM eg: "09:00"
      • Appointment must be scheduled on the hour or half-hour
      • I repeat, date and time must be at least now or in the future, cannot schedule past appointments
Response

The appointment made if successful

  • e.g. {“userid”:“antwil”,“date”:“2021-12-25”,“time”:“12:00”, "duration":30}

Project Setup

Dependencies

Build

  • cd into project root
  • mvn clean install
  • cd docker
  • docker build -t appt-api .
  • docker run -d -p 8080:8080 --name <container-name> appt-api

Use

The api should be up and running now on http://localhost:8080, here are some sample curl commands to get you started

  • curl -v -H "Content-Type: application/json" -d {"userid":"antwil","date":"2021-12-25","time":"06:00"}" http://localhost:8080/appts
  • curl -v -H "Content-Type: application/json" http://localhost:8080/appts/antwil

Project Considerations

Decided not to allow scheduling appointments in the past. Sure we allow weekends and holidays and 2am appointments, but this seemed like a simple and practical thing to add.

Decided to allow any kind of string to be passed in as userid. The account creation service can restrict the username format allowed :) Given more time on the project, I might have been more restrictive on the username format.

Used a simple Java Map to store the appointment details. Given more time, might have integrated with a proper data store.

api-test's People

Contributors

antwil 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.