How to run: Click the '<>Code' button above and download zip folder. Unzip the folder, change into the directory of the downloaded folder.
Run the following commands:
./mvnw clean install
java -jar target/Library-System-0.0.1-SNAPSHOT.jar
The server will start running and it can now receive HTTP requests.
Retrieves a list of all books.
curl -X GET http://localhost:8080/library/v1/books/all
Retrieves the book assigned with a given id.
curl -X GET http://localhost:8080/library/v1/books/id
Params:
id id of book to search for (required)
Retrieves books with titles that match a given string.
curl -X GET http://localhost:8080/library/v1/books/find/pattern
Params:
pattern pattern to match (required)
Adds a new book to the library.
curl -X POST -H "Content-Type: application/json" -d '{"title": "The Great Gatsby", "author": "F. Scott Fitzgerald"}' http://localhost:8080/library/v1/books/add
Params:
title title of the book to be added (required)
author author of the book to be added (required)
Replaces the book with a given id with another book.
The new book will have the same id as the old one.
curl -X PUT -H "Content-Type: application/json" -d '{"title": "My NEW title", "author": "My NEW author"}' http://localhost:8080/library/v1/books/update/id
Params:
id id of the book to be replaced (required)
title title of the new book (required)
author author of the new book (required)
Deletes the book assigned the given id.
curl -X DELETE -H "Content-Type: application/json" http://localhost:8080/library/v1/books/delete/id
Params:
id id of the book to be deleted (required)
Retrieves a list of all patron records.
curl -X GET http://localhost:8080/library/v1/patrons/all
Retrieves the patron assigned with a given id.
curl -X GET http://localhost:8080/library/v1/patrons/id
Params:
id id of patron to search for (required)
Retrieves patrons with names that match a given string.
curl -X GET http://localhost:8080/library/v1/patrons/find/pattern
Params:
pattern pattern to match (required)
Adds a new patron record to the library.
curl -X POST -H "Content-Type: application/json" -d '{"first_name": "My First Name", "last_name":
"My Last Name", "city": "My City", "state_code": "TX", "zip": "00000"}' http://localhost:8080/library/v1/patrons/add
Params:
first_name - first name of the patron to be added (required)
last_name - last name of the patron to be added (required)
street - street the patron lives on (optional)
apt_num - unit number if patron lives in an apartment (optional)
city - city the patron lives in (required)
state_code - state the patron lives in (required)
zip - zip code of the city the patron lives in (required)
Replaces the patron with a given id with another patron.
The new patron will have the same id as the old one.
curl -X PUT -H "Content-Type: application/json" -d '{"first_name": "My NEW First Name", "last_name": "My NEW Last Name",
"city": "My NEW City", "state_code": "NY", "zip": "My NEW Zip"}' http://localhost:8080/library/v1/patrons/update/bbcbf4c4-ae09-42c2-a926-1d00b5e0b375
Params:
id - id of the patron to be replaced (required)
first_name - first name of the new patron to be added (required)
last_name - last name of the new patron to be added (required)
street - street the new patron lives on (optional)
apt_num - unit number if patron lives in an apartment (optional)
city - city the new patron lives in (required)
state_code - state the new patron lives in (required)
zip - zip code of the city the new patron lives in (required)
Deletes the book assigned the given id.
curl -X DELETE -H "Content-Type: application/json" http://localhost:8080/library/v1/books/delete/id
Params:
id id of the patron to be deleted (required)