Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Happy Path: Endpoint #5 Get User Favorites - GET /api/v1/favorites #7

Open
ajpulzone opened this issue Jan 17, 2023 · 2 comments
Open
Assignees

Comments

@ajpulzone
Copy link
Owner

Get a User's Favorites

Should have a JSON body of "{ "api_key": "jgn983hy48thw9begh98h4539h4" }

Your api should expose this endpoint:

Request:

GET /api/v1/favorites?api_key=jgn983hy48thw9begh98h4539h4

Content-Type: application/json
Accept: application/json

Response:

The response data should contain exactly these elements and nothing more:

  • a data attribute, under which all other attributes are present:
    • id, from the database
    • type, always set to “favorite”
    • attributes, an object containing favorited book information:
      • recipe title
      • recipe link
      • country
      • created at date/time
{
    "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"
            }
        }
    ]
 }  

Requirements:

  • For this get request, api_key can be sent as a query parameter.
  • If the api_key is invalid, an appropriate 400-level status code should be returned, as well as a message explaining what went wrong.
  • If the api_key is valid, this response will return all recipes that the user has favorited.
  • If the user has not favorited any recipes, the data object should point to an empty array.

Wireframes:

Image

@ajpulzone ajpulzone converted this from a draft issue Jan 17, 2023
@ajpulzone ajpulzone self-assigned this Jan 17, 2023
@ajpulzone ajpulzone moved this from Todo to In Progress in Lunch and Learn Project Board Jan 17, 2023
@ajpulzone
Copy link
Owner Author

1/16/23 9:00pm:

Pretty sure the original documentation for this project had a note to send the user_api_key in the body and the params

Should have a JSON body of "{ "api_key": "jgn983hy48thw9begh98h4539h4" }

But it appears it was corrected (or I copied it wrong)

Will send user_api_key in query params.

Image

@ajpulzone
Copy link
Owner Author

1/16/23 9:00pm:

Working in postman, but testing is HIGHLY inadequate.

However, response in postman is what we expect. AJP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant