Code Monkey home page Code Monkey logo

phone-testing-inventory's Introduction

Phone Booking API

REST API for a phone rental system providing inventory management, booking capabilities, and phone status tracking.

Java 18
H2 database
Gradle
Spring Boot
Spring Data JPA
Flyway

It's initially created with 2 users with emails:
[email protected]
[email protected]

The API utilizes standard HTTP status codes (400 range for client errors, 500 range for server-side)
Endpoints

  1. GET /api/phones

Purpose: Lists all phones within the system .

Success Response

  • Status Code: 200 OK

  • Content-Type: application/json An array of phone objects. Object structure

{
  "id": 1,
  "spec": {
    "manufacturer": "Samsung",
    "model": "Galaxy S9"
  },
  "os": {
    "os": "ANDROID",
    "version": "5.0"
  },
  "available": true
}
  1. GET /api/phones/available

(Similar Structure, emphasize difference in response filtering available items)

  1. GET /api/phones/{phoneId}
    Purpose: Retrieves details of a specific phone by its unique identifier. Includes booking information if the phone is currently booked.

Success Response

  • Status Code: 200 OK

  • Content-Type: application/json

Example Response

{
  "phone": {
    "id": 1,
    "spec": {
      "manufacturer": "Samsung",
      "model": "Galaxy S9"
    },
    "os": {
      "os": "ANDROID",
      "version": "5.0"
    },
    "available": false
  },
  "activeBooking": {
    "id": 2,
    "user": {
      "name": "Bob Smith",
      "email": "[email protected]"
    },
    "bookedAt": "2024-02-13T19:38:24.922Z"
  }
}
  1. POST /api/phones/book

Initiates the booking process for a phone specified by its ID.
Requires a JSON request body containing the user's email.

Request Body

  • Content-Type: application/json

Example Request

{
  "phoneId": 1,
  "userEmail": "[email protected]"
}

Success Response

  • Status Code: 200 OK

  • Content-Type: application/json

Example Response

{
  "id": 2,
  "spec": {
    "manufacturer": "Samsung",
    "model": "Galaxy S9"
  },
  "user": {
    "name": "Bob Smith",
    "email": "[email protected]"
  },
  "bookedAt": "2024-02-13T19:38:24.922Z",
  "returnedAt": null
}
  1. POST /api/phones/book/spec

Initiates the booking process for a phone specified by phone specification. It tries to book first available phone that matches specification.
The response format is equal to POST /api/phones/book endpoint.

Request Body

  • Content-Type: application/json

Example Request

{
  "manufacturer": "Samsung",
  "model": "Galaxy S9",
  "userEmail": "[email protected]"
}
  1. PUT /return/{bookingId} Marks a booked phone as returned, using the provided 'bookingId'. Success Response
  • Status Code: 200 OK

phone-testing-inventory's People

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.