Phone
Definition
- JSON
- Typescript
phone.json
{
"id": 0,
"userID": 0,
"phoneNumber": "",
"phoneVerifiedAt": "",
"status": 0,
"createdAt": "",
"updatedAt": "",
}
phone.ts
export interface IPhone {
id: number;
userID: number;
phoneNumber: string;
phoneVerifiedAt: Date | null;
status: number;
createdAt: Date | null;
updatedAt: Date | null;
}
Get Phones
- Curl
- Typescript
curl -X GET "${baseUrl}/phone/?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}/phone/?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 Phone
- Curl
- Typescript
curl -X GET "${baseUrl}/phone/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/phone/${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 Phone.ID
- Curl
- Typescript
curl -X POST "${baseUrl}/apply/phone/id/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/apply/phone/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 Phone
- Curl
- Typescript
curl -X POST "${baseUrl}/phone/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @phone.json
信息
phone.json
{
"userID": 0,
"phoneNumber": "",
"phoneVerifiedAt": "",
"status": 0,
}
提示
success status: 201
const response = await fetch("${baseUrl}/phone/", {
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 Phone
- Curl
- Typescript
#!/bin/bash
curl -X PUT "${baseUrl}/phone/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @phone.json
信息
phone.json
{
"userID": 0,
"phoneNumber": "",
"phoneVerifiedAt": "",
"status": 0,
}
const response = await fetch("${baseUrl}/phone/${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 Phone
- Curl
- Typescript
curl -X PATCH "${baseUrl}/phone/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Attrs: userID,phoneNumber,phoneVerifiedAt,status" \
-d @phone.json
信息
phone.json
{
"userID": 0,
"phoneNumber": "",
"phoneVerifiedAt": "",
"status": 0,
}
const response = await fetch("${baseUrl}/phone/${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 Phone Status
- Curl
- Typescript
curl -X PATCH "${baseUrl}/phone/${id}/status/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @phone.json
信息
phone.json
{
"status": 0
}
const response = await fetch("${baseUrl}/phone/${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 Phone
- Curl
- Typescript
curl -X DELETE "${baseUrl}/phone/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/phone/${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);
}