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*/ -

User not found.

Request samples

Content type
application/json
{
  • "image": "string",
  • "predefined": "string"
}

Response samples

Content type
application/json
{
  • "id": 0,
  • "username": "string",
  • "status": 0,
  • "email": "string",
  • "image": "string",
  • "isAdmin": true,
  • "memberSince": {
    },
  • "postCount": 0
}

Get user posts

Request samples

Content type
application/json
{
  • "image": "string",
  • "predefined": "string"
}

Response samples

Content type
application/json
{
  • "id": 0,
  • "username": "string",
  • "status": 0,
  • "email": "string",
  • "image": "string",
  • "isAdmin": true,
  • "memberSince": {
    },
  • "postCount": 0
}

Update user permissions

Update user permissions with ID.

+
Authorizations:
BasicAuth
path Parameters
id
required
integer <int14>

User ID

+
Request Body schema: application/json
isAdmin
boolean

Responses

Request samples

Content type
application/json
{
  • "isAdmin": true
}

Response samples

Content type
application/json
{
  • "id": 0,
  • "username": "string",
  • "status": 0,
  • "email": "string",
  • "image": "string",
  • "isAdmin": true,
  • "memberSince": {
    },
  • "postCount": 0
}

Get user posts

Get a users posts ID.

Authorizations:
BasicAuth
path Parameters
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
{
  • "pages": 0,
  • "data": [
    ]
}
+

Response samples

Content type
application/json
{
  • "pages": 0,
  • "data": [
    ]
}