Explore the Moon Garden Frontend Application »
If this is green then the API is in good shape.
-
Base URL:
https://moon-garden-be.herokuapp.com
-
Available Endpoints:
Login User/ Create and login
- This endpoint consumes data returned from Google OAuth, looks for a user, and if no user exists creates one.
[POST] /api/v1/find_or_create_user
Required PARAMS:
- _json: google_OAuth_data.to_json
Example:
[POST] /api/v1/find_or_create_user
- Params:
- _json : "{\"name\":\"Jennifer \",\"email\":\"[email protected]\",\"unverified_email\":\"[email protected]\",\"email_verified\":true,\"first_name\":\"Jennifer\",\"last_name\":\"Halloan\",\"image\":\"https://lh3.googleusercontent.com/a-/AFdZucr_zffBdhJaydFkdXeeHkhe2BzmVNKGIE-Ozwh=s96-c\"}"
RESPONSE:
{
"data": {
"id": "3",
"type": "user",
"attributes": {
"name": "Jennifer ",
"email": "[email protected]",
"image":
"https://lh3.googleusercontent.com/a-/AFdZucr_zffBdhJaydFkdXeeHkhe2BzmVNKGIE-Ozwh=s96-c"
}
}
}
Find User
- This endpoint finds an existing user, based on user id
[GET] /api/v1/users/:id
RESPONSE:
{
"data": {
"id": "3",
"type": "user",
"attributes": {
"name": "Jennifer ",
"email": "[email protected]",
"image":
"https://lh3.googleusercontent.com/a-/AFdZucr_zffBdhJaydFkdXeeHkhe2BzmVNKGIE-Ozwh=s96-c"
}
}
}
Create Garden
- This endpoint creates a garden for a user
[POST] /api/v1/users/:id/gardens
Required PARAMS:
- _json: user_data.to_json
Example:
[POST] /api/v1/users/:id/gardens
- Params:
- _json : "{\"user_id\":1,\"name\":\"Summer Garden\",\"notes\":\"it's too damn hot\",\"cardinal_direction\":1}"
RESPONSE:
{
"data": {
"id": "2",
"type": "garden",
"attributes": {
"name": "Summer Garden",
"cardinal_direction": "South",
"notes": "it's too damn hot"
}
}
}
User Gardens
- This endpoint returns all the gardens for a user
[GET] /api/v1/users/:user_id/gardens
RESPONSE:
{
"data": [
{
"id": "1",
"type": "garden",
"attributes": {
"name": "Summer Garden",
"cardinal_direction": "South",
"notes": "it's too damn hot"
}
},
{
"id": "2",
"type": "garden",
"attributes": {
"name": "Summer Garden",
"cardinal_direction": "South",
"notes": "it's too damn hot"
}
}
]
}
Garden Show
- This endpoint returns a particular garden
[GET] /api/v1/users/:user_id/gardens
RESPONSE:
{
"data": {
"id": "2",
"type": "garden",
"attributes": {
"name": "Summer Garden",
"cardinal_direction": "South",
"notes": "it's too damn hot"
}
}
}
Garden Destroy
- This endpoint destroys a particular garden
[DELETE] /api/v1/users/:user_id/gardens/:id
RESPONSE:
No Response
Garden Update
- This endpoint updates a particular garden
[PATCH] /api/v1/users/:user_id/gardens/:id
Example:
[PATCH] /api/v1/users/:user_id/gardens/:id
- Params:
- _json : "{\"name\":\"Summer Garden\",\"notes\":\"it's too damn hot\",\"cardinal_direction\":1}"
RESPONSE:
{
"data": {
"id": "2",
"type": "garden",
"attributes": {
"name": "Summer Garden",
"cardinal_direction": "South",
"notes": "it's too damn hot"
}
}
}
Create Plant
- This endpoint creates a garden for a user
[POST] /api/v1/users/:user_id/gardens/:garden_id/plants
Required PARAMS:
- _json: plant_data.to_json
Example:
[POST] /api/v1/users/:user_id/gardens/:garden_id/plants
- Params:
- _json: "{\"user_id\":\"1\",\"garden_id\":\"1\",\"name\":\"Carrot\",\"plant_id\":\"sae2340987dage\"}"
RESPONSE:
{
"data": {
"id": "2",
"type": "plant",
"attributes": {
"name": "Carrot",
"plant_id": "sae2340987dage",
"date_planted": null,
"moon_phase": null,
"date_matured": null,
"bounty_amount": null,
"pruning_behaviors": null,
"notes": null,
"garden_id": 1
}
}
}
Garden Plants
- This endpoint returns all the plants for a garden
[GET] /api/v1/users/:user_id/gardens/:garden_id/plants
RESPONSE:
{
"data": [
{
"id": "1",
"type": "plant",
"attributes": {
"name": "Carrot",
"plant_id": "sae2340987dage",
"date_planted": null,
"moon_phase": null,
"date_matured": null,
"bounty_amount": null,
"pruning_behaviors": null,
"notes": null,
"garden_id": 1
}
},
{
"id": "2",
"type": "plant",
"attributes": {
"name": "Carrot",
"plant_id": "sae2340987dage",
"date_planted": null,
"moon_phase": null,
"date_matured": null,
"bounty_amount": null,
"pruning_behaviors": null,
"notes": null,
"garden_id": 1
}
}
]
}
Plant Show
- This endpoint returns a particular plant
[GET] /api/v1/users/:user_id/gardens/:garden_id/plants/:id
RESPONSE:
{
"data": {
"id": "2",
"type": "plant",
"attributes": {
"name": "Carrot",
"plant_id": "sae2340987dage",
"date_planted": null,
"moon_phase": null,
"date_matured": null,
"bounty_amount": null,
"pruning_behaviors": null,
"notes": null,
"garden_id": 1
}
}
}
Plant Destroy
- This endpoint destroys a particular plant
[DELETE] /api/v1/users/:user_id/gardens/:garden_id/plants/:id
RESPONSE:
No Response
Plant Update
- This endpoint updates a particular plant
[PATCH] /api/v1/users/:user_id/gardens/:garden_id/plants/:id
Example:
[PATCH] /api/v1/users/:user_id/gardens/:garden_id/plants/:id
- Params:
- _json : "{\"moon_phase\":\"Full\"}"
RESPONSE:
{
"data": {
"id": "2",
"type": "plant",
"attributes": {
"name": "Carrot",
"plant_id": "sae2340987dage",
"date_planted": null,
"moon_phase": "Full",
"date_matured": null,
"bounty_amount": null,
"pruning_behaviors": null,
"notes": null,
"garden_id": 1
}
}
}
Note: "plant_id" in the plant table is referencing the id from an outside api.
- Clone this directory to your local repository using the SSH key:
$ git clone [email protected]:Moon-Garden/moon_garden_be.git
- Install gems for development using Bundler:
$ bundle install
- Set up your database with:
$ rails db:{drop,create,migrate,seed}
- Run the test suite with:
$ bundle exec rspec
- Run your development server with:
$ rails s
-
In your browser, visit 'localhost:3000/` to see the app in action.
-
Contribute away!
Jim R. (he/him) |
Andrew K. (he/him) |
Casey F. (they/she) |
Jennifer H. (she/her) |
Bryce W. (he/him) |
Stephen W. (he/him) |