Tracardi / tracardi

TRACARDI is a new HOME for your customer data. TRACARDI is an Composable API-first solution for any company that need inexpensive CDP to intergrate with.
https://www.tracardi.com
Other
519 stars 95 forks source link

User preferences endpoints #704

Closed atompie closed 2 years ago

atompie commented 2 years ago

Is your feature request related to a problem? Please describe. With the new version will need user preferences to be saved in the database. Therefore we need user preference endpoints.

Describe the solution you'd like We need the following endpoint:

@router.get("/user/preference/{key}", tags=["user"], include_in_schema=server.expose_gui_api,
            response_model=Optional[dict])
async def get_user_preference(key: str, user=Depends(Permissions(["admin", "developer", "marketer", "maintainer"]))):
    """
    Returns user preference
    """
    return user.preference.get(key, None)

@router.post("/user/preference/{key}", tags=["user"], include_in_schema=server.expose_gui_api, response_model=dict)
async def set_user_preference(key: str, preference: Union[dict, str, int, float],
                              user=Depends(Permissions(["admin", "developer", "marketer", "maintainer"]))):
    """
    Sets user preference.Uses key to set the preference
    """
    pass

@router.delete("/user/preference/{key}", tags=["user"], include_in_schema=server.expose_gui_api, response_model=dict)
async def delete_user_preference(key: str, user=Depends(Permissions(["admin", "developer", "marketer", "maintainer"]))):
    """
    Deletes user preference
    """
    pass

@router.get("/user/preferences", tags=["user"], include_in_schema=server.expose_gui_api, response_model=dict)
async def gets_all_user_preferences(user=Depends(Permissions(["admin", "developer", "marketer", "maintainer"]))):
    """
    Returns all user preferences
    """
    pass

Endpoint GET /user/properties is already done. All the endpoints are defined in user_endpoint.py. We need to fill them with the code.

atompie commented 2 years ago

Done in 0.7.2