2019-12-08 00:32:00 +05:30
|
|
|
import request from 'app/services/request';
|
2016-05-01 15:58:54 +05:30
|
|
|
|
2019-12-07 16:58:52 +05:30
|
|
|
export interface UserResponse {
|
2020-05-24 04:38:24 +05:30
|
|
|
elyProfileLink: string;
|
|
|
|
email: string;
|
|
|
|
hasMojangUsernameCollision: boolean;
|
|
|
|
id: number;
|
|
|
|
isActive: boolean;
|
|
|
|
isOtpEnabled: boolean;
|
2020-07-29 01:30:51 +05:30
|
|
|
isDeleted: boolean;
|
2020-05-24 04:38:24 +05:30
|
|
|
lang: string;
|
|
|
|
passwordChangedAt: number; // timestamp
|
|
|
|
registeredAt: number; // timestamp
|
|
|
|
shouldAcceptRules: boolean;
|
|
|
|
username: string;
|
|
|
|
uuid: string;
|
2019-12-07 16:58:52 +05:30
|
|
|
}
|
2017-12-26 01:33:21 +05:30
|
|
|
|
2019-01-28 00:42:58 +05:30
|
|
|
export function getInfo(id: number, token?: string): Promise<UserResponse> {
|
2020-07-29 01:30:51 +05:30
|
|
|
return request.get(`/api/v1/accounts/${id}`, {}, { token });
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
export function changePassword(
|
2020-05-24 04:38:24 +05:30
|
|
|
id: number,
|
|
|
|
{
|
|
|
|
password = '',
|
|
|
|
newPassword = '',
|
|
|
|
newRePassword = '',
|
|
|
|
logoutAll = true,
|
|
|
|
}: {
|
|
|
|
password?: string;
|
|
|
|
newPassword?: string;
|
|
|
|
newRePassword?: string;
|
|
|
|
logoutAll?: boolean;
|
|
|
|
},
|
2019-11-27 14:33:32 +05:30
|
|
|
): Promise<{ success: boolean }> {
|
2020-05-24 04:38:24 +05:30
|
|
|
return request.post(`/api/v1/accounts/${id}/password`, {
|
|
|
|
password,
|
|
|
|
newPassword,
|
|
|
|
newRePassword,
|
|
|
|
logoutAll,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
export function acceptRules(id: number): Promise<{ success: boolean }> {
|
2020-05-24 04:38:24 +05:30
|
|
|
return request.post(`/api/v1/accounts/${id}/rules`);
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
export function changeUsername(
|
2020-05-24 04:38:24 +05:30
|
|
|
id: number,
|
|
|
|
username: string | void,
|
|
|
|
password: string | void,
|
2019-11-27 14:33:32 +05:30
|
|
|
): Promise<{ success: boolean }> {
|
2020-05-24 04:38:24 +05:30
|
|
|
return request.post(`/api/v1/accounts/${id}/username`, {
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
export function changeLang(id: number, lang: string): Promise<{ success: boolean }> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/language`, {
|
|
|
|
lang,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
export function requestEmailChange(id: number, password: string): Promise<{ success: boolean }> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/email-verification`, {
|
|
|
|
password,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
export function setNewEmail(id: number, email: string, key: string): Promise<{ success: boolean }> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/new-email-verification`, {
|
|
|
|
email,
|
|
|
|
key,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
export function confirmNewEmail(id: number, key: string): Promise<{ success: boolean }> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/email`, {
|
|
|
|
key,
|
|
|
|
});
|
2019-01-25 22:59:32 +05:30
|
|
|
}
|
2020-07-27 12:58:37 +05:30
|
|
|
|
|
|
|
export function deleteAccount(id: number, { password }: { password?: string }): Promise<{ success: boolean }> {
|
|
|
|
return request.delete(`/api/v1/accounts/${id}`, {
|
|
|
|
password,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function restoreAccount(id: number): Promise<{ success: boolean }> {
|
|
|
|
return request.post(`/api/v1/accounts/${id}/restore`);
|
|
|
|
}
|