Allow Users having phone numbers to save flavor keywords for which they would like to receive notifications when those flavors are updated. Ultimately it's Ingredients that are matched with Users to produce notifications.
The API
Find Ingredients...
GET /api/v1/ingredient?searchTerms=chocolate,coconut
Response:
{
meta: {},
items: [
{
ingredient_id: 24,
keyword: "chocolate", // If the user makes an association, I want to record the keyword they searched for
},
]
}
Find Stores...
GET /api/v1/store
This already exists and is documented.
Save Ingredient associations...
POST /api/v1/user/{userUUID}/ingredient
Request Body:
{
user_uuid: "e6fc6b5a-882c-40ba-b860-b11a413ec2df",
ingredient_id: 17,
store_id: 2,
keyword: "chocolate", // The keyword the user used to find the ingredient for the association
}
Delete Ingredient association...
DELETE /api/v1/users/{UserUUID}/ingredient/{IngredientID}
The Database
The schema will change to reflect this by creating a table: ingredient_user with the following fields:
- id
- ingredient_id
- user_id
- keyword (log the exact keyword submitted by the user that matched the ingredient, this could be useful for auditing purposes or future functionality)
- created
Type(s)
The following Type will be added to models
UserIngredient struct{
ID
User
Ingredient
}
The following Type will be added to handlers.go
UserIngredientResponse struct {
ID int
UserUUID uuid.UUID
IngredientID int
StoreID int
Keyword string
Created time.Time
}
Model(s)
The User model will get the following methods:
AddIngredient(userID int, ingredient models.Ingredient) (models.UserIngredient, error)
GetUserIngredients(userID int) ([]models.UserIngredient, error)
RemoveIngredient(models.UserIngredient) error
Allow Users having phone numbers to save flavor keywords for which they would like to receive notifications when those flavors are updated. Ultimately it's Ingredients that are matched with Users to produce notifications.
The API
Find Ingredients...
GET /api/v1/ingredient?searchTerms=chocolate,coconut
Response:
Find Stores...
GET /api/v1/store
This already exists and is documented.
Save Ingredient associations...
POST /api/v1/user/{userUUID}/ingredient
Request Body:
Delete Ingredient association...
DELETE /api/v1/users/{UserUUID}/ingredient/{IngredientID}
The Database
The schema will change to reflect this by creating a table:
ingredient_userwith the following fields:Type(s)
The following Type will be added to
modelsThe following Type will be added to
handlers.goModel(s)
The User model will get the following methods:
AddIngredient(userID int, ingredient models.Ingredient) (models.UserIngredient, error)GetUserIngredients(userID int) ([]models.UserIngredient, error)RemoveIngredient(models.UserIngredient) error