🎉 feat: initialization
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/* eslint-disable */
|
||||
import request from "@workspace/ui/lib/request";
|
||||
|
||||
/** Apple Login Callback POST /v1/auth/oauth/callback/apple */
|
||||
export async function appleLoginCallback(
|
||||
body: {
|
||||
id_token: string;
|
||||
state: string;
|
||||
},
|
||||
options?: { [key: string]: any }
|
||||
) {
|
||||
const formData = new FormData();
|
||||
|
||||
Object.keys(body).forEach((ele) => {
|
||||
const item = (body as any)[ele];
|
||||
|
||||
if (item !== undefined && item !== null) {
|
||||
if (typeof item === "object" && !(item instanceof File)) {
|
||||
if (Array.isArray(item)) {
|
||||
for (const f of item) {
|
||||
formData.append(ele, f || "");
|
||||
}
|
||||
} else {
|
||||
formData.append(
|
||||
ele,
|
||||
new Blob([JSON.stringify(item)], { type: "application/json" })
|
||||
);
|
||||
}
|
||||
} else {
|
||||
formData.append(ele, item);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return request<API.Response & { data?: any }>(
|
||||
"/v1/auth/oauth/callback/apple",
|
||||
{
|
||||
method: "POST",
|
||||
data: formData,
|
||||
...(options || {}),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** OAuth login POST /v1/auth/oauth/login */
|
||||
export async function oAuthLogin(
|
||||
body: API.OAthLoginRequest,
|
||||
options?: { [key: string]: any }
|
||||
) {
|
||||
return request<API.Response & { data?: API.OAuthLoginResponse }>(
|
||||
"/v1/auth/oauth/login",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** OAuth login get token POST /v1/auth/oauth/login/token */
|
||||
export async function oAuthLoginGetToken(
|
||||
body: API.OAuthLoginGetTokenRequest,
|
||||
options?: { [key: string]: any }
|
||||
) {
|
||||
return request<API.Response & { data?: API.LoginResponse }>(
|
||||
"/v1/auth/oauth/login/token",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user