Role
Definition
- JSON
- Typescript
role.json
{
"id": 0,
"roleName": "",
"roleDescription": "",
"status": 0,
"createdAt": "",
"updatedAt": "",
}
role.ts
export interface IRole {
id: number;
roleName: string;
roleDescription: string | null;
status: number;
createdAt: Date | null;
updatedAt: Date | null;
}
Get Roles
- Curl
- Typescript
curl -X GET "${baseUrl}/role/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get Role
- Curl
- Typescript
curl -X GET "${baseUrl}/role/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/${id}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Apply Role.ID
- Curl
- Typescript
curl -X POST "${baseUrl}/apply/role/id/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/apply/role/id/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Create Role
- Curl
- Typescript
curl -X POST "${baseUrl}/role/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @role.json
info
role.json
{
"roleName": "",
"roleDescription": "",
"status": 0,
}
tip
success status: 201
const response = await fetch("${baseUrl}/role/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Update Role
- Curl
- Typescript
#!/bin/bash
curl -X PUT "${baseUrl}/role/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @role.json
info
role.json
{
"roleName": "",
"roleDescription": "",
"status": 0,
}
const response = await fetch("${baseUrl}/role/${id}", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Patch Role
- Curl
- Typescript
curl -X PATCH "${baseUrl}/role/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Attrs: roleName,roleDescription,status" \
-d @role.json
info
role.json
{
"roleName": "",
"roleDescription": "",
"status": 0,
}
const response = await fetch("${baseUrl}/role/${id}", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
"Attrs": "${attrs}",
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Update Role Status
- Curl
- Typescript
curl -X PATCH "${baseUrl}/role/${id}/status/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @role.json
info
role.json
{
"status": 0
}
const response = await fetch("${baseUrl}/role/${id}/status/", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Destroy Role
- Curl
- Typescript
curl -X DELETE "${baseUrl}/role/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/${id}", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get Applications
- Curl
- Typescript
curl -X GET "${baseUrl}/role/${id}/application/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/${id}/application/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Link Applications
- Curl
- Typescript
curl -X POST "${baseUrl}/role/${id}/application/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/role/${id}/application/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
UnLink Applications
- Curl
- Typescript
curl -X DELETE "${baseUrl}/role/${id}/application/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/role/${id}/application/", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get ApplicationRole
- Curl
- Typescript
curl -X GET "${baseUrl}/role/${id}/application/${applicationID}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/${id}/application/${applicationID}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Update ApplicationRole
- Curl
- Typescript
curl -X PUT "${baseUrl}/role/${id}/application/${applicationID}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @applicationRole.json
info
applicationRole.json
{
"right": 0,
}
const response = await fetch("${baseUrl}/role/${id}/application/${applicationID}", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get Users
- Curl
- Typescript
curl -X GET "${baseUrl}/role/${id}/user/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/role/${id}/user/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Link Users
- Curl
- Typescript
curl -X POST "${baseUrl}/role/${id}/user/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/role/${id}/user/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
UnLink Users
- Curl
- Typescript
curl -X DELETE "${baseUrl}/role/${id}/user/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/role/${id}/user/", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}