Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check out books to a member #16

Closed
albendz opened this issue Dec 26, 2020 · 0 comments · Fixed by #18
Closed

Check out books to a member #16

albendz opened this issue Dec 26, 2020 · 0 comments · Fixed by #18

Comments

@albendz
Copy link
Owner

albendz commented Dec 26, 2020

Summary

Add capability to check out a copy of a book to a library member.

Details

  • Add a REST endpoint to checkout a book to a user: /book/{isbn}/checkout with a payload that has user ID and optionally a copy ID
  • Create a loan in DB linking member and copy of book
  • Book not found if book is not found
  • No copies available if no copies are available
  • Member not found if member is not found
  • Copy not available if specific copy is not available
  • Loan should have start date and expiry date
  • Duplicate checkout requests where a user already has a copy of a book does not checkout another copy, instead it will update the loan expiry date (i.e. renewal of loan)
  • Add configurable loan duration which is used in initial loan and when extending a loan
  • When a copy of a book is checked out, the number of available copies is updated in the book entity and shows when retrieved

Acceptance Criteria

  • API to checkout a book to a user exists: /book/{isbn}/checkout
    Request:
{
    "memberId" : "uuid",
    "copyId":"uuid",
}

Response:

{
    "loanId": "uuid",
    "memberId": "uuid",
    "copyId": "uuid",
    "book": { "title": "", "author": "", "isbn": ""},
    "loanStart":  "date",
    "loanEnd": "date",
}
  • Checkout request for a member that already has a copy of a book will update the loan end date
  • 404 if book is not found
  • 404 if member is not found
  • 404 if copy is not found
  • 400 if copy requested is unavailable
  • 400 if book requested has no available copies
  • Loan length is in configuration with a default of 15 days
  • Book checked out updates available copies and total copies to show loans

Related

#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant