UIKit/lib/api/account.ts

28 lines
864 B
TypeScript
Raw Normal View History

2023-08-28 14:29:26 +00:00
import { UserAccount, UserName } from "../model/account";
import { makeRequest } from "./makeRequest";
2023-08-28 14:18:03 +00:00
2025-05-10 20:31:17 +00:00
const apiUrl = import.meta.env.VITE__APP_DOMAIN + "/customer";
2023-08-28 14:18:03 +00:00
2024-07-24 17:16:03 +00:00
export function patchUserAccount(user: UserName, version:string | undefined) {
2023-08-28 14:18:03 +00:00
return makeRequest<UserName, UserAccount>({
2024-07-24 17:16:03 +00:00
url: `${apiUrl + (version ? `/${version}` : "")}/account`,
2023-08-28 14:18:03 +00:00
contentType: true,
method: "PATCH",
useToken: true,
withCredentials: false,
body: user,
});
}
2024-07-24 17:16:03 +00:00
export function createUserAccount(signal: AbortSignal, url: string | undefined, version: string) {
2023-08-28 14:18:03 +00:00
return makeRequest<never, UserAccount>({
2024-07-24 17:16:03 +00:00
url: url || `${apiUrl + (version.length > 0 ? `/${version}` : "")}/account`,
2023-08-28 14:18:03 +00:00
contentType: true,
method: "POST",
useToken: true,
withCredentials: false,
signal,
});
}