Usernames/Passwords
{
"email": "fake@email.com",
"password": "password"
}
- Register a new user
- email required (must be between 3 and 30 characters)
- password required (must be between 6 and 30 characters)
What you send:
{
"email": "SampleUser",
"password": "abc123"
}
What you receive:
{
"message": "Account successfully created. Welcome SampleUser!",
"newUser": {
"user_id": 5,
"first_name": "SampleUser",
"last_name": "FakeName",
"email": "sampleuser@fake.com"
}
}
- Login
- username and password required
- provides a newly created token
What you send:
{
"email": "sampleuser@fake.com",
"password": "abc123"
}
What you receive:
{
"message": "Welcome back SampleUser",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0Ijo1LCJ1c2VybmFtZSI6Ik5ld1VzZXIiLCJpYXQiOjE2MjcyNjY4MDYsImV4cCI6MTYyNzM1MzIwNn0.J1dFd3ghUPYVTodsaAU3Bg2RRcmYM_1oOe-96nvLLUg"
}
RESTRICTED ENDPOINT
- Get information on a specific user
- requires valid token in authorization header to access
- (example uses "1" for :user_id in URL)
What you receive:
{
"user_id": 1,
"first_name": "test",
"last_name": "account",
"email": "fake@email.com",
"plants": [
{
"plant_id": 1,
"nickname": "Bob",
"species": "Sunflower",
"days_between_watering": 1,
"notes": "Make sure to use clear water",
"img_url": null
},
{
"plant_id": 2,
"nickname": "Rufus",
"species": "Petunia",
"days_between_watering": 3,
"notes": null,
"img_url": null
}
]
}
RESTRICTED ENDPOINT
- Update an existing user
- requires valid token in authorization header to send
- can be used to update username or phone number
- (example uses "5" for :user_id in URL)
What you send:
{
"first_name": "updated",
"last_name": "user",
"email": "updated@email.com"
}
What you receive:
{
"user_id": 5,
"first_name": "updated",
"last_name": "user",
"email": "updated@email.com"
}
RESTRICTED ENDPOINT
- Delete an existing user
- requires valid token in authorization header to delete
- (example uses "6" for :user_id in URL)
What you receive:
{
"user_id": 6,
"first_name": "deleted",
"last_name": "user",
"email": "deleted@email.com"
}
RESTRICTED ENDPOINT
- Get an array of plants for a specific user
- requires valid token in authorization header to access
- (example uses "1" for :user_id in URL)
What you receive:
[
{
"plant_id": 1,
"nickname": "Bob",
"species": "Sunflower",
"days_between_watering": 1,
"notes": "Make sure to use clear water",
"img_url": null,
"user_id": 1
},
{
"plant_id": 2,
"nickname": "Rufus",
"species": "Petunia",
"days_between_watering": 3,
"notes": null,
"img_url": null,
"user_id": 1
}
]
RESTRICTED ENDPOINT
- Get information for a specific plant
- requires valid token in authorization header to access
- (example uses "1" for :user_id and "1" for :plant_id in URL)
What you receive:
{
"plant_id": 1,
"nickname": "Bob",
"species": "Sunflower",
"days_between_watering": 1,
"notes": "Make sure to use clear water",
"img_url": null,
"user_id": 1
}
RESTRICTED ENDPOINT
- Add a new plant for a user
- requires valid token in authorization header to send
- (example uses "1" for :user_id in URL)
- required information:
- nickname (string)
- species (string)
- days_between_watering (number)
- optional information:
- notes (string)
- img_url (string)
What you send:
{
"nickname": "Ted",
"species": "Daffodil",
"days_between_watering": 3,
"notes": "Optional notes",
"user_id": 1
}
What you receive:
{
"plant_id": 8,
"nickname": "Ted",
"species": "Daffodil",
"days_between_watering": 3,
"notes": "Optional notes",
"img_url": null,
"user_id": 1
}
RESTRICTED ENDPOINT
- Update an existing plant
- requires valid token in authorization header to send
- (example uses "1" for :user_id and "8" for :plant_id in URL)
- required information:
- nickname (string)
- species (string)
- days_between_watering (number)
- optional information:
- notes (string)
- img_url (string)
What you send:
{
"nickname": "Updated Plant Nickname!!!",
"species": "Updated species!!!",
"days_between_watering": 6
}
What you receive:
{
"plant_id": 8,
"nickname": "Updated Plant Nickname!!!",
"species": "Updated species!!!",
"days_between_watering": 6,
"notes": "Optional notes",
"img_url": null,
"user_id": 1
}
RESTRICTED ENDPOINT
- Delete a plant
- requires valid token in authorization header to delete
- (example uses "1" for :user_id in URL)
What you receive:
{
"plant_id": 1,
"nickname": "Bob",
"species": "Sunflower",
"user_id": 1
}