Skip to content

amikaross/lunch_and_learn

Repository files navigation

Lunch and Learn API

This project was created for mod 3 of Turing School of Software and Design

Table of Contents

About the Project

Learning Goals:
  • 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).
Built With:
  • Ruby 2.7.4
  • Rails 5.2.8.1

Database Schema

db schema

Developer Setup

If you would like to demo this API on your local machine:

  1. Ensure you have Ruby 2.7.4 and Rails 5.2.8 installed
  2. Fork and clone down this repo and navigate to the root folder
  3. Run bundle install
  4. Run bundle exec figaro install
  5. Register for an edamam app id and key
  6. Register for an unsplash key
  7. Register for a google api key and enable the youtube api
  8. Add the following variables to config/application.yml:
    • edamam_app_id
    • edamam_app_key
    • unsplash_key
    • google_api_key
  9. Run rails db:{drop,create,migrate,seed}
  10. To run the test suite, run bundle exec rspec
  11. To demo endpoints in postman or other tool, run rails s and use base url http://localhost:3000 to explore the available endpoints

Endpoints

Get Recipes By Country
  • GET "/api/v1/recipes?country=country_name"
  • Sample response body:
      {
        "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..."
                }
            },
            {
                "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..."
                }
            },
            {...},
            {...},
          ...
        ]
      }
    
Get Recipes for Random Country
  • GET "/api/v1/recipes"
  • Sample response body:
      {
        "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..."
                }
            },
            {
                "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..."
                }
            },
            {...},
            {...},
          ...
        ]
      }
    
Get Learning Resources By Country
  • GET "/api/v1/learning_resources?country=country_name"
  • Sample response body:
      {
        "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-1540611025311-01df3cef54b5..."
                    },
                    {
                        "alt_tag": "aerial view of city at daytime",
                        "url": "https://images.unsplash.com/photo-1570366583862-f91883984fde..."
                    },
                    {...},
                    {...},
                  ...
              ]
          }
      }
    
Create A New User
  • POST "/api/v1/users"
  • Sample request body:
      {
        "name": "Athena Dao",
        "email": "athenadao@bestgirlever.com"
      }
    
  • Sample response body:
      {
        "data": {
          "type": "user",
          "id": "1",
          "attributes": {
            "name": "Athena Dao",
            "email": "athenadao@bestgirlever.com",
            "api_key": "jgn983hy48thw9begh98h4539h4"
          }
        }
      }
    
Create a New Favorite
  • POST "/api/v1/favorites"
  • Sample request body:
      {
          "api_key": "jgn983hy48thw9begh98h4539h4",
          "country": "thailand",
          "recipe_link": "https://www.tastingtable.com/.....",
          "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)"
      }
    
  • Sample response body:
      {
        "success": "Favorite added successfully"
      }
    
Get User's Favorites
  • GET "/api/v1/favorites/?api_key=user_api_key"
  • Sample response body:
      {
        "data": [
            {
                "id": "1",
                "type": "favorite",
                "attributes": {
                    "recipe_title": "Recipe: Egyptian Tomato Soup",
                    "recipe_link": "http://www.thekitchn.com/recipe-egyptian-tomato-soup-weeknight....",
                    "country": "egypt",
                    "created_at": "2022-11-02T02:17:54.111Z"
                }
            },
            {
                "id": "2",
                "type": "favorite",
                "attributes": {
                    "recipe_title": "Crab Fried Rice (Khaao Pad Bpu)",
                    "recipe_link": "https://www.tastingtable.com/.....",
                    "country": "thailand",
                    "created_at": "2022-11-07T03:44:08.917Z"
                }
            }
          ]
       }    
    

Contact

Built by Amanda Ross - find me on: linkedin | github

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published