diff --git a/exam/api/Users/Permissions/Permissions.php b/exam/api/Users/Permissions/Permissions.php new file mode 100644 index 0000000..3a52b58 --- /dev/null +++ b/exam/api/Users/Permissions/Permissions.php @@ -0,0 +1,49 @@ +updatePermissions($isAdmin)); + } catch (Exception $err) { + switch ($err->getMessage()) { + case "NotFound": + throw ApiError::notFound("user"); + default: + // Due to how the failed field is handled, it's ApiError is inside the models update + throw $err; + } + } + } +} diff --git a/exam/api/docs/api.yaml b/exam/api/docs/api.yaml index 6ada450..137609a 100644 --- a/exam/api/docs/api.yaml +++ b/exam/api/docs/api.yaml @@ -640,6 +640,57 @@ paths: } tags: - User + /users/{id}/permissions: + post: + summary: Update user permissions + description: Update user permissions with ID. + security: + - BasicAuth: [isAdmin] + parameters: + - name: id + in: path + description: User ID + required: true + schema: + type: integer + format: int14 + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UserPermissionsUpdateRequest" + responses: + 200: + description: Success. + content: + application/json: + schema: + $ref: "#/components/schemas/UserResponse" + 404: + description: User not found. + content: + application/json: + schema: + $ref: "#/components/schemas/NotFoundResponse" + examples: + User not found: + value: { "code": "NotFound", "entity": "user" } + 500: + description: Update failed. + content: + application/json: + schema: + $ref: "#/components/schemas/FailedUpdateResponse" + examples: + Failed username: + value: + { + "code": "FailedUpdate", + "fields": ["isAdmin"], + "reasons": ["string"], + } + tags: + - User /users/{id}/posts: get: summary: Get user posts @@ -816,6 +867,11 @@ components: type: string email: type: string + UserPermissionsUpdateRequest: + type: object + properties: + isAdmin: + type: boolean UserImageUpdateRequest: type: object properties: diff --git a/exam/api/docs/index.html b/exam/api/docs/index.html index b24e208..0978c4d 100644 --- a/exam/api/docs/index.html +++ b/exam/api/docs/index.html @@ -384,7 +384,7 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/
-{- "image": "string",
- "predefined": "string"
}{- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}{- "image": "string",
- "predefined": "string"
}{- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}Update user permissions with ID.
+| id required | integer <int14> User ID + |
| isAdmin | boolean |
{- "isAdmin": true
}{- "id": 0,
- "username": "string",
- "status": 0,
- "email": "string",
- "image": "string",
- "isAdmin": true,
- "memberSince": {
- "date": "2019-08-24T14:15:22Z",
- "timezone_type": 0,
- "timezone": "string"
}, - "postCount": 0
}Get a users posts ID.
| id required | integer <int14> User ID @@ -542,9 +552,9 @@ data-styled.g137[id="sc-kvXgyf"]{content:"fBvPoH,"}/*!sc*/ " class="sc-euGpHm sc-exayXG fwfkcU kqJXdD sc-dHrNzZ dRdjww">Success. Response samples
Content type application/json {Response samples
Content type application/json { |