User
Definition
- JSON
- Typescript
user.json
{
"id": 0,
"ref": 0,
"outKey": "",
"firstName": "",
"lastName": "",
"avatarUrl": "",
"photoUrl": "",
"password": "",
"rememberToken": "",
"status": 0,
"createdAt": "",
"updatedAt": "",
}
user.ts
export interface IUser {
id: number;
ref: number;
outKey: string | null;
firstName: string;
lastName: string;
avatarUrl: string | null;
photoUrl: string | null;
password: string;
rememberToken: string | null;
status: number;
createdAt: Date | null;
updatedAt: Date | null;
}
Get Users
- Curl
- Typescript
curl -X GET "${baseUrl}/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}/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);
}
Get User
- Curl
- Typescript
curl -X GET "${baseUrl}/user/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/user/${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 User.ID
- Curl
- Typescript
curl -X POST "${baseUrl}/apply/user/id/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/apply/user/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 User
- Curl
- Typescript
curl -X POST "${baseUrl}/user/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @user.json
info
user.json
{
"ref": 0,
"outKey": "",
"firstName": "",
"lastName": "",
"avatarUrl": "",
"photoUrl": "",
"status": 0,
}
tip
success status: 201
const response = await fetch("${baseUrl}/user/", {
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 User
- Curl
- Typescript
#!/bin/bash
curl -X PUT "${baseUrl}/user/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @user.json
info
user.json
{
"ref": 0,
"outKey": "",
"firstName": "",
"lastName": "",
"avatarUrl": "",
"photoUrl": "",
"status": 0,
}
const response = await fetch("${baseUrl}/user/${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 User
- Curl
- Typescript
curl -X PATCH "${baseUrl}/user/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Attrs: ref,outKey,firstName,lastName,avatarUrl,photoUrl,status" \
-d @user.json
info
user.json
{
"ref": 0,
"outKey": "",
"firstName": "",
"lastName": "",
"avatarUrl": "",
"photoUrl": "",
"status": 0,
}
const response = await fetch("${baseUrl}/user/${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 User Status
- Curl
- Typescript
curl -X PATCH "${baseUrl}/user/${id}/status/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @user.json
info
user.json
{
"status": 0
}
const response = await fetch("${baseUrl}/user/${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 User
- Curl
- Typescript
curl -X DELETE "${baseUrl}/user/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/user/${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}/user/${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}/user/${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}/user/${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}/user/${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}/user/${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}/user/${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 ApplicationUser
- Curl
- Typescript
curl -X GET "${baseUrl}/user/${id}/application/${applicationID}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/user/${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 ApplicationUser
- Curl
- Typescript
curl -X PUT "${baseUrl}/user/${id}/application/${applicationID}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @applicationUser.json
info
applicationUser.json
{
"right": 0,
}
const response = await fetch("${baseUrl}/user/${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 Roles
- Curl
- Typescript
curl -X GET "${baseUrl}/user/${id}/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}/user/${id}/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);
}
Link Roles
- Curl
- Typescript
curl -X POST "${baseUrl}/user/${id}/role/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/user/${id}/role/", {
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 Roles
- Curl
- Typescript
curl -X DELETE "${baseUrl}/user/${id}/role/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/user/${id}/role/", {
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);
}