# Streetlity User A server for managin the streetlity user ## User ### Login Login need username, password and token of the device for notification. **Path**: `/user/login` **Method**: `POST` **Param**: <pre> - username - password - deviceToken: token of the device </pre> ### Logout **Path**: `/user/logout` **Method**: `POST` **Param**: <pre> - username - rtoken: refresh token - deviceToken: token of the device </pre> ### Refresh Token **Path**: `/user/refresh` **Method**: `POST` **Param**: <pre> - rtoken </pre> ### Notify Using to send notify to users **Path**: `/user/notify` **Method**: `POST` **Param**: <pre> - id (array): id of the user - notify-title: title - notify-body: message content of the notification - notify-image: path to the image that will be showed on the notification - data (array): the following data need to be sent. data must following the format: "key:value" </pre> ### User Validation Validate the user before the registration. User validation could validate in 3 cases: only username, only email, both username and email perspective with 1, 2, 3 **Path**: `/user/validate/` **Method**: `GET` **Param**: <pre> - case: determining the validation case, have value 1, 2 or 3 - username (optional by case) - email (optional by case) </pre> ### Register Create new common user **Path**: `/user/common/register` **Method**: `POST` **Param**: <pre> - username - passwd - email - phone - address </pre> ### Get user information Get information of a specified user **Path**: `/user/info/` **Method**: `GET` **Param**: <pre> - id: id of the user </pre> **Return**: <pre> - Info: information of the user </pre> ### Update user information Update information of a specified user **Path**: `user/info/` **Method**: `POST` **Param**: <pre> - id: id of the updating user - name: new name of the user - address: new address of the user - phone: new phone of the user - avatar: new avatar of the user </pre> ## Maintenance User ### Register Create new maintenance user. If them maintenance service is not available, [another register](#register-when-service-is-not-availble) will be used. **Path**: `/user/maintenance/register` **Method**: `POST` **Param**: <pre> - username - passwd - email - phone - address - serviceId: service id of the maintenance user </pre> ### Register when service is not available Not all of services are available when create a new maintenance user, in this case maintenance user can define their own service and it will be added when approved. **Path**: `/user/maintenance/register` **Method**: `POST` **Param**: <pre> Same as Register but have more param to define the service - service_name - location (array): contains lat and lon in location[0] and location[1] perspective. - service_address - note (optional) </pre> ### Approve Approve a specified maintenance user **Path**: `/user/maintenance/approve` **Method**: `POST` **Param**: <pre> - username: username that needed to approve </pre> ## Achievement Achievement provide methods to record the actions, get and update the achievement ### Get achievement Return the achievement of the specified user **Path**: `/user/achievement` **Method**: `GET` **Param**: <pre> - id: username of the user </pre> **Return**: <pre> - Achievement: information about the achievement </pre> ### Get achievement progress Return achievement progress of a specified user in json format. **Path**: `/user/achievement/progress` **Method**: `GET` **Param**: <pre> - id: username of the user </pre> **Return**: <pre> - Progress: progress of the user in json format </pre> ### Get user reputation Return the reputation of a specified user **Path**: `/user/achievement/reputation` **Method**: `GET` **Param**: <pre> - id: username of the user </pre> **Return**: <pre> - Reputation </pre> ### Add action Record an action for a specified user by a pair of information. the information contains `action_type`, `time`, `affect`, `service`. `$action_type` could be: - `contribute` - `review` - `upvote` **Path**: `/user/action/$action_type/` **Method**: `POST` **Param**: <pre> - id: id of the user - time (array): - affect (array): id of the affection things that affected by the action. eg: if review affect is the id of the review, if upvote we use the id of the upvoted service, if contribute... - service (array): "Atm", "Fuel", "Maintenance" or "Toilet" to determine the service that the action affect. </pre> ### Remove action Same as add action `$action_type` could be: - `contribute` - `review` - `upvote` **Path**: `/user/action/$action_type/` **Method**: `DELETE` **Param**: <pre> - affect (array): affect of the action - service (array): "Atm", "Fuel", "Maintenance" or "Toilet" to determine the service that the action affect. </pre> ## Emergency Contains methods for working with emergency maintenance ### Get emergency maintenance **Path**: `users/maintenance/emergency`