280 lines
5.1 KiB
TypeScript
280 lines
5.1 KiB
TypeScript
/**
|
|
* API of the server (auto-generated code)
|
|
*/
|
|
import {
|
|
HTTPMimeType,
|
|
HTTPRequestModel,
|
|
ModelResponseHttp,
|
|
RESTCallbacks,
|
|
RESTConfig,
|
|
RESTRequestJson,
|
|
RESTRequestJsonArray,
|
|
RESTRequestVoid
|
|
} from "./rest-tools"
|
|
import {
|
|
ChangePassword,
|
|
DataGetToken,
|
|
GetToken,
|
|
Long,
|
|
UserAuth,
|
|
UserAuthGet,
|
|
UserCreate,
|
|
UserOut,
|
|
isUserAuth,
|
|
isGetToken,
|
|
isUserOut,
|
|
isUserAuthGet,
|
|
} from "./model"
|
|
export namespace UserResource {
|
|
|
|
export function changePassword({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: ChangePassword,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/password",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
});
|
|
};
|
|
export function create({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: UserCreate,
|
|
}): Promise<UserAuthGet> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isUserAuthGet);
|
|
};
|
|
export function getApplicationRight({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
}): Promise<any> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, null);
|
|
};
|
|
export function getMe({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<UserOut> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/me",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isUserOut);
|
|
};
|
|
export function getToken({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: DataGetToken,
|
|
}): Promise<GetToken> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/get_token",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isGetToken);
|
|
};
|
|
export function getUser({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<UserAuthGet> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{id}",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isUserAuthGet);
|
|
};
|
|
export function getUsers({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<UserAuthGet[]> {
|
|
return RESTRequestJsonArray({
|
|
restModel: {
|
|
endPoint: "/users",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isUserAuthGet);
|
|
};
|
|
export function isEmailExist({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
email?: string,
|
|
},
|
|
}): Promise<boolean> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/is_email_exist",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
}, null);
|
|
};
|
|
export function isLoginExist({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
login?: string,
|
|
},
|
|
}): Promise<boolean> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/is_login_exist",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
}, null);
|
|
};
|
|
export function linkApplication({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<UserAuth> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/link",
|
|
requestType: HTTPRequestModel.POST,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isUserAuth);
|
|
};
|
|
export function patchApplicationRight({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
data: any,
|
|
}): Promise<any> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
|
requestType: HTTPRequestModel.PATCH,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, null);
|
|
};
|
|
export function setAdmin({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/{id}/set_admin",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
});
|
|
};
|
|
export function setBlocked({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/{id}/set_blocked",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
});
|
|
};
|
|
}
|