Skip to content

RESTful Services API

xinruili07 edited this page Mar 2, 2020 · 14 revisions

Introduction

Our project is deployed on Heroku: Link here

All the use cases of the employer viewpoint are available as RESTful services using Java Spring. Next section will briefly summarize all the RESTful service endpoints we have implemented.

RESTful Services

User Profile/Person/App User

Pet Post

Adopt Request

Question

Donation


Create an account

Title AppUser: Create an account
URL /appuser
Method POST
URL Params username=[String]
Data Params Required password=[String], appUserRole=[PersonRole]
Success Response Code: 200 Ok Request
Body Example: {
"username": "michael",
"password": "mcgill123",
"appUserRole": "ADOPTER"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Username cannot be empty!"
2) "Password cannot be empty!"
3) "AppUserRole cannot be empty!"
Description Allows a person to signup for an appUser account
Title AppAdmin: Create an account
URL /appadmin
Method POST
URL Params username=[String]
Data Params Required password=[String]
Success Response Code: 200 Ok Request
Body Example: {
"username": "michael",
"password": "mcgill123"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Username cannot be empty!"
2) "Password cannot be empty!"
Code:500 Internal Server Error:
1) "Can only have one admin!"
Description Allows the petshelter to signup for an appAdmin account

Account Login

Title AppUser: Account Login
URL /loginuser
Method POST
URL Params username=[String]
Data Params Required: password=[string]
Success Response Code: 200 Ok
Response Body: blank
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Username cannot be empty!"
2) "Password cannot be empty!"
3)"This account cannot be found!"
Description Allows an existing user to login
Title AppAdmin: Account Login
URL /loginadmin
Method POST
URL Params username=[String]
Data Params Required: password=[string]
Success Response Code: 200 Ok
Response Body: blank
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Username cannot be empty!"
2) "Password cannot be empty!"
3)"This account cannot be found!"
Description Allows an existing admin to login

Update Profile Information

Title UserProfile/Person: Update Profile Information
URL /update_profile/
Method POST
URL Params None
Data Params UserProfileDto object
Success Response Code: 200 Ok
Response Body: {
"address": "new address",
"hasExperienceWithPets": "false",
"numbersOfPetsCurrentlyOwned": "0",
"typeOfLivingAccomodation": "house"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "hasExperienceWithPets is set to false but numberOfPetsCurrentlyOwned != 0"
Description User must provide relevant information about themselves and their homes.

Get UserProfile by Person

Title UserProfile/Person: Get UserProfile by person
URL /user_profile/{username}
Method GET
URL Params username=[string]
Data Params None
Success Response Code: 200 Ok
Response Body: {
"address": "new address",
"hasExperienceWithPets": "false",
"numbersOfPetsCurrentlyOwned": "0",
"typeOfLivingAccomodation": "house"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such username"
Description Users can access their own as well as other's user profiles

Create PetPost

Title PetPost: Create PetPost
URL /petPosts/newPetPost
Method POST
URL Params None
Data Params PetPostDTO object
Success Response Code: 200 Ok
Response Body: {
"availability": "true",
"name": "doggo",
"typeOfPet": "Dog",
"description": "very calm",
"relatesTo": "question"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "No availability"
2) Empty name field
3) Empty type of pet
Description Users can create a new pet post.

Delete PetPost

Title PetPost: Delete a petPost by petPostId
URL /deletePetPost/{petPostId}
Method DELETE
URL Params petPostId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: { "petPostId": "1" }"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such petPost"
Description Users can delete their pet posts.

Update PetPost

Title PetPost: Update a petPost
URL /update/{petPostId}
Method PATCH
URL Params petPostId=[Integer]
Data Params PetPostDto Object
Success Response Code: 200 Ok
Response Body: {
"availability": "true",
"name": "doggo",
"typeOfPet": "Dog",
"description": "very calm",
"relatesTo": "question"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such pet post"
Description Users can edit the content of their pet post.

Get PetPost by petPostID

Title PetPost: Get PetPost by petPostId
URL /petPost/{petPostId}
Method GET
URL Params petPostId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: Response Body: {
"availability": "true",
"name": "doggo",
"typeOfPet": "Dog",
"description": "very calm",
"relatesTo": "question"}"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such pet Post"
Description View a specific pet post by pet post ID.

Get list of all PetPosts

Title PetPost: Get list of all PetPosts
URL /petPost/
Method GET
URL Params None
Data Params None
Success Response Code: 200 Ok
Response Body: A list of all pet PostsDto Objects
Error Response Code: 400 Bad Request
Description View all pet posts.

Create adoptRequest

Title adoptRequest: create adopt request
URL /adoptRequest/{petPostId}
Method POST
URL Params petPostId=[Integer]
Data Params adoptRequestDto Object
Success Response Code: 200 Ok
Response Body: {
"status": "PENDING",
"requestBy": "username",
"requesting": "petPost",
"adoptRequestId": "1"}
Error Response Code: 400 Bad Request
Error Message Examples:
1) "No such pet post"
Description Users can submit a request to a pet post.

Delete adoptRequest

Title adoptRequest: Delete an adopt request
URL /deleteAdoptRequest/{adoptRequestId}
Method DELETE
URL Params adoptRequestId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: { "adoptRequestId": "1" }"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such adoptRequest"
Description Users can delete one of their adopt request.


Get adoptRequest by adoptRequestId

Title adoptRequest: Get a specific adopt request
URL /adoptRequest/{adoptRequestId}
Method GET
URL Params adoptRequestId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: An adoptRequestDto object
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such adoptRequest"
Description View a specific adoptRequest

Get all adoptRequests

Title PetPost: Get all adoptRequest
URL /adoptRequest/
Method GET
URL Params None
Data Params None
Success Response Code: 200 Ok
Response Body: List of all adoptRequestDto Objects
Error Response Code: 400 Bad Request
Description View all adopt requests

Create Question

Title Question: create question
URL /question/{petPostId}
Method POST
URL Params petPostId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: {
"question": "What does the pet like to eat",
"answer": "",
"isRelatedTo": "petPost",
"person": "username",
"questionId": "1"}
Error Response Code: 400 Bad Request
Error Message Examples:
1) "No such pet post"
Description Users can submit a question to a pet post.

Delete question

Title Question: Delete a question
URL /deleteQuestion/{questionId}
Method DELETE
URL Params questionId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: { "questionId": "1" }"
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such question"
Description Users can delete one of their question.


Get Question by questionId

Title Question: Get a specific question by questionId
URL /question/{questionId}
Method GET
URL Params questionId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: An questionDto object
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such question"
Description View a specific question

Add answer to a question

Title Question: add an answer to a question
URL /question/{questionId}
Method PATCH
URL Params questionId=[Integer]
Data Params questionDto Object
Success Response Code: 200 Ok
Response Body: new questionDto object with updated answer field
Error Response Code: 400 Bad Request
Error Message Examples:
1) "There is no such user"
Description View all adopt requests by a specific person

Get all questions for a petPost

Title PetPost: Get list of all questions related to a specific pet post
URL /questions/{petPostId}
Method GET
URL Params petPostId=[Integer]
Data Params None
Success Response Code: 200 Ok
Response Body: List of questionDto Objects
Error Response Code: 400 Bad Request Error Message Examples:
1) "There is no such pet Post"
Description View all questions related to a specific pet post.

Create donation

Title Donation: create donation
URL /donation
Method POST
URL Params None
Data Params DonationDto Object
Success Response Code: 200 Ok
Response Body: {
"amount": "5$",
"comment": "Thanks for the post",
"setNameAnonymous": "true",
"person": "Person",
"donationId": "1"}
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Invalid field"
Description Users can give a donation.

Get list of all donations

Title Donation: Get a list of all donations
URL /donation
Method GET
URL Params None
Data Params None
Success Response Code: 200 Ok
Response Body: List of DonationsDto Objects
Error Response Code: 400 Bad Request
Error Message Examples:
1) "Invalid field"
Description View a list of all donations.

Wiki Contents

RESTful Service

Requirements Model

Domain Model

Quality Assurance

Sprint 1

Meeting Minutes

Efforts

Report

Sprint 2

Meeting Minutes

Efforts

Report

Sprint 3

Meeting Minutes

Efforts

Report

Sprint 4

Meeting Minutes

Efforts

Report

Clone this wiki locally