Skip to content

Moon-Garden/moon_garden_be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Checkout Moon Garden Here! »

Explore the Moon Garden Frontend Application »

CircleCI

If this is green then the API is in good shape.


API Usage


USER

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\":\"jennnnnn@gmail.com\",\"unverified_email\":\"jennsssrlhalloran@gmail.com\",\"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": "jennnnnn@gmail.com",
			"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": "jennnnnn@gmail.com",
			"image": 
 "https://lh3.googleusercontent.com/a-/AFdZucr_zffBdhJaydFkdXeeHkhe2BzmVNKGIE-Ozwh=s96-c"
		}
	}
}

Garden

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"
		}
	}
}

Plant

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
		}
	}
}

Feel like contributing??

Note: "plant_id" in the plant table is referencing the id from an outside api.

Installation

  1. Clone this directory to your local repository using the SSH key:

$ git clone git@github.com:Moon-Garden/moon_garden_be.git

  1. Install gems for development using Bundler:

$ bundle install

  1. Set up your database with:

$ rails db:{drop,create,migrate,seed}

  1. Run the test suite with:

$ bundle exec rspec

  1. Run your development server with:

$ rails s

  1. In your browser, visit 'localhost:3000/` to see the app in action.

  2. Contribute away!

ScreenShot

Contributors


Jim R. (he/him)


Andrew K. (he/him)


Casey F. (they/she)


Jennifer H. (she/her)


Bryce W. (he/him)


Stephen W. (he/him)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published