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