Skip to content

gabrielcnunez/lunch_and_learn

Repository files navigation

Lunch and Learn

This repo is a back end application utilizing four external APIs to expose five endpoints for use by a fictional front end application.

The purpose of this project is to simulate the real-world challenge of developing an application based on the requirements of a front end team.

Table of Contents


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 by using mocking tools, such as Webmock and VCR

Tech and Tools

Built With

  • Ruby 2.7.4
  • Rails 5.2.8.1
  • RSpec 3.12.0
  • RSpec
  • PostgreSQL

Gems Used:


Developer Setup

  1. Fork and clone this repository
  2. cd into the root directory
  3. Run bundle install
  4. Run bundle exec figaro install
  5. Run rails db:{create,migrate}
  6. To run this server, run rails s in your terminal
  7. To stop the local server, use command Control + c
  8. Sign up for the following APIs (all available for free):

    REST Countries API | Edamam API | Youtube API | Unsplash API

    In config > application.yml

       recipe_app_id: <edamam_app_id>
       recipe_api_key: <edamam_api_key>
       video_api_key: <youtube_api_key>
       images_api_key: <unsplash_api_key>
    

How to Run Test Suite

After set up:

  1. Run bundle exec rspec spec

Available Endpoints

Get Recipes for a Particular Country
  • GET "/api/v1/recipes?country=thailand"
  • Sample response body:
      {
        "data": [
          {
            "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.com/web-img/f4e571219.jpg"
            }
          },
          {
            "id": "null",
            "type": "recipe",
            "attributes": {
              "title": "Sriracha",
              "url": "http://www.jamieoliver.com/recipes/vegetables-recipes/sriracha/",
              "country": "thailand",
              "image": "https://edamam-product-images.com/web-img/h4w832793.jpg"
          }
        ]
      }
    
Get Recipes for a Random Country
  • GET "/api/v1/recipes
  • Sample response body:
      {
        "data": [
          {
            "id": "null",
            "type": "recipe",
            "attributes": {
              "title": "Tropical Pops(Antigua and Barbuda)",
              "url": "http://www.food.com/recipe/tropical-pops-antigua-and-barbuda-507250",
              "country": "Antigua and Barbuda",
              "image": "https://edamam-product-images.com/web-img/m9h234343.jpg"
            }
          },
          {
            "id": "null",
            "type": "recipe",
            "attributes": {
              "title": "Papaya Pie (Antigua and Barbuda)",
              "url": "http://www.food.com/recipe/papaya-pie-antigua-and-barbuda-468338",
              "country": "Antigua and Barbuda",
              "image": "https://edamam-product-images.com/web-img/j6y293874.jpg"
          }
        ]
      }
    
Get Learning Resources for a Particular Country
  • GET "/api/v1/learning_resources?country=laos"
  • 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.jpg'
              },
              {
                "alt_tag": "aerial view of city at daytime",
                "url": "https://images.unsplash.com/photo-1570366583862.jpg"
              }
            ]
          }
        }
      }
    
Register a New User
  • POST "/api/v1/users/"
  • Sample request body:
    {
        "name": "Jon X Sample",
        "email": "jon@sample.com"
    }
    
  • Sample response body:
      {
        "data": {
          "id": "2",
          "type": "user",
          "attributes": {
            "name": "Jon X Sample",
            "email": "jon@sample.com",
            "api_key": "Xge8Ls27WdlS"
          }
        }
      }
    
Add Favorited Recipe to User
  • POST "/api/v1/favorites"
  • Sample request body:
    {
        "api_key": "d1gdyTIHlmEK",
        "country": "vietnam",
        "recipe_link": "https://www.seriouseats.com/kenji_rulez.html",
        "recipe_title": "Garlic Noodles (a San Francisco Treat, not THE San Francisco Treat)"
    }
    
  • Sample response body:
      {
        "success": "Favorite added successfully"
      }
    
Get All Favorites for a User
  • GET "api/v1/favorites?api_key=d1gdyTIHlmEK"
  • Sample response body:
      {
        "data": [
          {
            "id": "1",
            "type": "favorite",
            "attributes": {
                "recipe_title": "Garlic Noodles (a San Francisco Treat, not THE San Francisco Treat)",
                "recipe_link": "https://www.seriouseats.com/kenji_rulez.html",
                "country": "vietnam",
                "created_at": "2023-01-17T21:12:19.336Z"
            }
          },
          {
            "id": "2",
            "type": "favorite",
            "attributes": {
                "recipe_title": "Thai Coconut Cremes",
                "recipe_link": "https://food52.com/recipes/37220-thai-coconut-cremes",
                "country": "thailand",
                "created_at": "2023-01-18T08:37:50.770Z"
            }
          }
        ]
      }
    

Project Team:

Contributors

Gabe Nuñez

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published