-
Notifications
You must be signed in to change notification settings - Fork 0
[N3] firebase auth and update apis #5
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
base: dev
Are you sure you want to change the base?
Conversation
| """Generate ISO 8601 timestamp with Z suffix and milliseconds for frontend compatibility""" | ||
| return datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z' | ||
|
|
||
| class FridgePreferencesModel(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these fields should map 1to1 with Fridge Status Update Fields
Client can improve the language, for example: "runningLow" in frontend can be mapped to foodLevel1 or "updatedWithFood" can be mapped to foodLevel: 2-4
just a thought, but might be error prone
| foodLevel2: bool | ||
| foodLevel3: bool | ||
|
|
||
| class ContactTypePreferencesModel(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think notifications could be laid out something like this in the future on web and mobile
on web:
if user clicks on phone -> redirects them to download mobile app
if user clicks on email -> updates user preference
note: The only notification that I can think of that would be email specific: Weekly/Monthly Digest which emails the user monthly stats about the fridge (not included yet)
| @@ -0,0 +1,73 @@ | |||
| import json | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can ignore - was testing to see how streams worked
| Authorizers: | ||
| FirebaseAuthorizer: | ||
| JwtConfiguration: | ||
| issuer: !Sub "https://securetoken.google.com/${FirebaseProjectId}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firebase auth
| ## DynamoDB Tables ## | ||
| ########################## | ||
|
|
||
| UserFridgeNotificationsTable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash/PrimaryKey: userId
Range: fridgeId
Description
API Docs: https://fridgefinder.github.io/CFM_Notification/
API
Base URLs:
https://notifications-api-dev.communityfridgefinder.comhttps://notifications-api-staging.communityfridgefinder.comhttps://notifications-api-prod.communityfridgefinder.comAuthentication: All endpoints (except health check) require Firebase JWT token in
Authorization: Bearer <token>header.Endpoints
Get Notification for Specific Fridge
GET /v1/users/{user_id}/fridge-notifications/{fridge_id}Retrieve notification preferences for a specific fridge.
Path Parameters:
user_id(string, required) - Firebase User ID (must match authenticated user)fridge_id(string, required) - Unique fridge identifierSuccess Response (200):
{ "userId": "abc123xyz456def789", "fridgeId": "fridge_123abc", "contactTypePreferences": { "email": { "good": true, ... } }, "createdAt": "2025-12-13T10:30:45.123Z", "updatedAt": "2025-12-13T15:20:30.456Z" }Create Notification Preferences
POST /v1/users/{user_id}/fridge-notifications/{fridge_id}Create new notification preferences for a fridge.
Path Parameters:
user_id(string, required) - Firebase User ID (must match authenticated user)fridge_id(string, required) - Unique fridge identifierRequest Body:
{ "contactTypePreferences": { "email": { "good": true, ... }, "device": { "good": false, ... } } }Success Response (201):
{ "userId": "abc123xyz456def789", "fridgeId": "fridge_123abc", "contactTypePreferences": { "email": { "good": true, ... }, "device": { "good": false, ... } }, "createdAt": "2025-12-13T10:30:45.123Z", "updatedAt": "2025-12-13T10:30:45.123Z" }Update Notification Preferences
PATCH /v1/users/{user_id}/fridge-notifications/{fridge_id}Update existing notification preferences for a fridge.
Path Parameters:
user_id(string, required) - Firebase User ID (must match authenticated user)fridge_id(string, required) - Unique fridge identifierRequest Body:
{ "contactTypePreferences": { "email": { "good": false, ... }, "device": { "good": true, ... } } }Success Response (200):
{ "userId": "abc123xyz456def789", "fridgeId": "fridge_123abc", "contactTypePreferences": { "email": { "good": false, ... }, "device": { "good": true, ... } }, "createdAt": "2025-12-13T10:30:45.123Z", "updatedAt": "2025-12-13T16:45:22.789Z" }Get All User Notifications
GET /v1/users/{user_id}/fridge-notificationsRetrieve all notification preferences for a user.
Path Parameters:
user_id(string, required) - Firebase User ID (must match authenticated user)Success Response (200):
{ "data": [ { "userId": "abc123xyz456def789", "fridgeId": "fridge_123abc", "contactTypePreferences": { "email": { "good": true, "dirty": true, "outOfOrder": true, "notAtLocation": false, "ghost": false, "foodLevel0": true, "foodLevel1": false, "foodLevel2": false, "foodLevel3": false }, "device": { "good": false, ... } }, "createdAt": "2025-12-13T10:30:45.123Z", "updatedAt": "2025-12-13T15:20:30.456Z" } ], "count": 1 }Delete Notification Preferences
DELETE /v1/users/{user_id}/fridge-notifications/{fridge_id}Remove notification preferences for a specific fridge.
Path Parameters:
user_id(string, required) - Firebase User ID (must match authenticated user)fridge_id(string, required) - Unique fridge identifierSuccess Response (204):
Error Responses
All errors follow a standardized format with an
errorobject containing acodeandmessage.Error Response Structure
{ "error": { "code": "ERROR_CODE", "message": "Human-readable error message" } }Error Examples
400 Bad Request - Validation Error
{ "error": { "code": "VALIDATION_ERROR", "message": "Input validation failed" } }404 Not Found
{ "error": { "code": "NOT_FOUND", "message": "Notification preference not found" } }409 Conflict
{ "error": { "code": "ALREADY_EXISTS", "message": "Notification preference already exists for this user and fridge" } }500 Internal Server Error
{ "error": { "code": "INTERNAL_SERVER_ERROR", "message": "An unexpected error occurred" } }401 Unauthorized
{ "message": "Unauthorized" }401 errors are returned from API Gateway if JWT token is not valid