Women Who Code 2023 Hackathon for Social Good
FE Team:
BE Team:
PUT "/api/v1/puzzles"
Body of Request:
{
"zip_code": 12345
}
Response:
Status: 200
{
"data": [
{
"id": "1",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Flower Cycle",
"description": "A flower collage by Rosalind Wise",
"total_pieces": 1000,
"notes": "Very Difficult! Only for the brave of heart!",
"puzzle_image_url": "https://cloudinary.com/image/Flower_Cycle.jpg"
}
},
{
"id": "2",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Mountain Chalet",
"description": "Cabin near lake and mountains",
"total_pieces": 1000,
"notes": "Relaxing, feels like you're in Colorado!",
"puzzle_image_url": "https://cloudinary.com/image/Mountain_Chalet.jpg"
}
}, {...}
]
}
POST "/api/v1/users"
Body of Request:
{
"full_name": "Diana Puzzler",
"email": "d.puzzle@gmail.com",
"password": "PuzzleQueen1",
"password_confirmation": "PuzzleQueen1",
"zip_code": 12345,
"phone_number": 5051230000
}
Response:
Status: 201
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"full_name": "Diana Puzzler",
"email": "d.puzzle@gmail.com",
"zip_code": 12345,
"phone_number": "(505) 123-0000"
}
}
}
POST "/api/v1/login"
Body of Request:
{
"email": "d.puzzle@gmail.com",
"password": "PuzzleQueen1"
}
Response:
Status: 201
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"full_name": "Diana Puzzler",
"email": "d.puzzle@gmail.com",
"zip_code": 12345,
"phone_number": "(505) 123-0000"
}
}
}
DELETE "/api/v1/users/:id/logout"
Response:
Status: 204
GET "/api/v1/users/:id"
Response:
Status: 200
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"full_name": "Diana Puzzler",
"email": "d.puzzle@gmail.com",
"zip_code": 12345,
"phone_number": "(505) 123-0000"
}
}
}
GET "/api/v1/users/:id/dashboard"
Response:
Status: 200
{
"data": {
"id": "1",
"type": "dashboard",
"attributes": {
"user_info": {
"full_name": "Diana Puzzler",
"email": "d.puzzle@gmail.com",
"zip_code": 12345,
"phone_number": "(505) 123-0000"
},
"owner_loans": [
{
"loan_id": 1,
"owner_id": 1,
"borrower_id": 2,
"loan_status": "Pending",
"loan_created_at": "2023-10-21T02:52:18.777Z",
"puzzle_id": 1,
"puzzle_image_url": "https://cloudinary.com/image/Flower_Cycle.jpg",
"puzzle_title": "Flower Cycle",
"puzzle_status": "Pending"
}, {...}
],
"borrower_loans": [
{
"loan_id": 5,
"owner_id": 2,
"borrower_id": 1,
"loan_status": "Accepted",
"loan_created_at": "2023-10-21T17:01:40.848Z",
"puzzle_id": 55,
"puzzle_image_url": "https://cloudinary.com/image/Maroon_Lake.jpg",
"puzzle_title": "Maroon Lake",
"puzzle_status": "Not Available"
}, {...}
]
}
}
}
POST "/api/v1/users/:id/puzzles"
Body of Request:
{
"title": "Wild Beauty",
"description": "Horses running in the snow by Chris Cummings.",
"total_pieces": 1000,
"notes": "Lots of white snow...beware!",
"puzzle_image_url": "https://cloudinary.com/image/Wild_Beauty.jpg"
}
Response:
Status: 201
{
"data": {
"id": "3",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Wild Beauty",
"description": "Horses running in the snow by Chris Cummings.",
"total_pieces": 1000,
"notes": Lots of white snow...beware!",
"puzzle_image_url": "https://res.cloudinary.com/image/info/Wild_Beauty.jpg"
}
}
}
GET "/api/v1/users/:id/puzzles"
Response:
Status: 200
{
"data": [
{...},
{
"id": "4",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Humming Bird & Flowers",
"description": "Hummingbirds investigating some pretty flowers.",
"total_pieces": 1000,
"notes": "Not as hard as you might think!",
"puzzle_image_url": "https://res.cloudinary.com/image/info/Hummingbirds_Flowers.jpg"
}
},
{
"id": "5",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Durango Silverton",
"description": "Train coming around the bend!",
"total_pieces": 1000,
"notes": "Feels like a step back in time!",
"puzzle_image_url": "https://res.cloudinary.com/image/info/Durango_Silverton.jpg"
}
}, {...}
]
}
GET "/api/v1/users/:id/puzzles/:id"
Response:
Status: 200
{
"data": {
"id": "1",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Available",
"title": "Flower Cycle",
"description": "A flower collage by Rosalind Wise",
"total_pieces": 1000,
"notes": "Very Difficult! Only for the brave of heart!",
"puzzle_image_url": "https://cloudinary.com/image/Flower_Cycle.jpg"
}
}
}
PATCH "/api/v1/users/:id/puzzles/:id"
Body of Request:
{
"status": 2,
"title": "Rosalind Wise Flower Cycle",
"description": "A colorful flower collage",
"total_pieces": 2000,
"notes": "Challenging but not too much. The brave of heart can do it!"
}
Response:
Status: 200
{
"data": {
"id": "1",
"type": "puzzle",
"attributes": {
"user_id": 1,
"status": "Not Available",
"title": "Rosalind Wise Flower Cycle",
"description": "A colorful flower collage",
"total_pieces": 2000,
"notes": "Challenging but not too much. The brave of heart can do it!",
"puzzle_image_url": "https://res.cloudinary.com/image/info/Flower_Cycle.jpg"
}
}
}
POST "/api/v1/users/:id/loans"
Body of Request:
{
"borrower_id": 2,
"puzzle_id": 2
}
Response:
Status: 201
{
"data": {
"id": "7",
"type": "loan",
"attributes": {
"owner_id": 1,
"borrower_id": 2,
"puzzle_id": 2,
"status": "Pending"
}
}
}
owner clicks accept
OR borrower clicks withdraw
OR owner clicks deny
OR when loan is complete
PATCH "/api/v1/users/:id/loans/:id"
Body of Request:
{
"action_type": "accept"
}
Response:
Status: 200
{
"data": {
"id": "7",
"type": "loan",
"attributes": {
"owner_id": 1,
"borrower_id": 2,
"puzzle_id": 2,
"status": "Accepted"
}
}
}