Lunch and Learn is a backend rails API, that allows a front-end app to find recipes from a country, as well as provide visual learning resources for that country. Registered users with a valid api key may favorite recipes. Created in a five day sprint.
Created with Rails 5.2.8
- Expose an API that aggregates data from multiple external APIs
- Expose an API that requires an authentication token
- Expose an API for CRUD functionality
- Determine completion criteria based on the needs of other developers
- Test both API consumption and exposure, making use of at least one mocking tool (VCR, Webmock, etc).
Fork and clone the project, then install the required gems with bundle.
bundle installSetup the database:
rails db:{drop,create,migrate}You will need to create API keys to run this back-end server. You will need the following keys:
Once you have your keys, set up your environment with
bundle exec figaro installThen add your keys to config/application.yml:
edamam_app_id: <insert your id>
edamam_app_key: <insert your key>
youtube_key: <insert your key>
geoapify_key: <insert your key>
unsplash_client_id: <insert your key>Start a rails server, and you're ready to query
rails sGets recipes from a single country.
| Parameter | Description | Parameter type | Data type |
|---|---|---|---|
| country | Optional - specify a country | query | String |
If no country parameter is included, recipes for a random country will be returned
Sample response (status 200)
{
"data": [
{
"id": null,
"type": "recipe",
"attributes": {
"title": "Andy Ricker's Naam Cheuam Naam Taan Piip (Palm Sugar Simple Syrup)",
"url": "https://www.seriouseats.com/recipes/2013/11/andy-rickers-naam-cheuam-naam-taan-piip-palm-sugar-simple-syrup.html",
"country": "thailand",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/611/611..."
}
},
{
"id": null,
"type": "recipe",
"attributes": {
"title": "THAI COCONUT CREMES",
"url": "https://food52.com/recipes/37220-thai-coconut-cremes",
"country": "thailand",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/8cd/8c..."
}
},
{
"id": null,
"type": "recipe",
"attributes": {
"title": "Sriracha",
"url": "http://www.jamieoliver.com/recipes/vegetables-recipes/sriracha/",
"country": "thailand",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/cb5..."
}
}
]
}Gets learning resources from a single country.
| Parameter | Description | Parameter type | Data type |
|---|---|---|---|
| country | Optional - specify a country | query | String |
Sample response (status 200)
{
"data": {
"id": null,
"type": "learning_resource",
"attributes": {
"country": "laos",
"video": {
"title": "A Super Quick History of Laos",
"youtube_video_id": "uw8hjVqxMXw"
},
"images": [
{
"alt_tag": "time lapse photography of flying hot air balloon",
"url": "https://images.unsplash.com/photo-154..."
},
{
"alt_tag": "aerial view of city at daytime",
"url": "https://images.unsplash.com/photo-157..."
}
]
}
}
}Register a new user. For this endpoint, all parameters are required.
| Parameter | Description | Parameter type | Data type |
|---|---|---|---|
| name | User name | body | String |
| User email must be unique | body | String | |
| password | Secure password required | body | String |
| password_confirmation | Must match password | body | String |
Sample response (status 201)
{
"data": {
"id": "3",
"type": "user",
"attributes": {
"name": "Athena Dao",
"email": "athenadao@bestgirlever.com",
"api_key": "58ec6581e4ce87b5b154332c7bbd6b1c"
}
}
}Register a new user. For this endpoint, all parameters are required.
| Parameter | Description | Parameter type | Data type |
|---|---|---|---|
| country | Country of origin | body | String |
| recipe_link | Link to recipe | body | String |
| recipe_title | Secure password required | body | String |
| api_key | Must match a user's API key | body | String |
Sample response (status 201)
{
"success": "Favorite added successfully"
}
Get a user's favorites
| Parameter | Description | Parameter type | Data type |
|---|---|---|---|
| api_key | Must match a user's API key | query | String |
Sample response (status 201)
{
"data": [
{
"id": "1",
"type": "favorite",
"attributes": {
"recipe_title": "recipe title",
"recipe_link": "recipe url",
"country": "Benin",
"created_at": "2022-11-15T17:44:49.306Z"
}
},
{
"id": "2",
"type": "favorite",
"attributes": {
"recipe_title": "another_url",
"recipe_link": "some_url",
"country": "France",
"created_at": "2022-11-15T21:54:59.105Z"
}
}
]
}