54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type {
|
|
AuthorizationsService,
|
|
AuthorizationsParams,
|
|
AuthorizationsList,
|
|
AuthorizationFormData,
|
|
WithRoleAuthorizations,
|
|
} from "../model/authorization-interface";
|
|
|
|
export class AuthorizationsApiService implements AuthorizationsService {
|
|
public async getAuthorizationsList(
|
|
params?: AuthorizationsParams,
|
|
): Promise<AuthorizationsList> {
|
|
const response = await client.get<AuthorizationsList>(
|
|
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async getAuthorizationInfo(
|
|
authorizationNo: string,
|
|
): Promise<WithRoleAuthorizations> {
|
|
const response = await client.get<WithRoleAuthorizations>(
|
|
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}/${authorizationNo}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async createAuthorization(
|
|
data: AuthorizationFormData,
|
|
): Promise<WithRoleAuthorizations> {
|
|
const response = await client.post<WithRoleAuthorizations>(
|
|
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async updateAuthorization(
|
|
authorizationNo: string,
|
|
data: AuthorizationFormData,
|
|
): Promise<WithRoleAuthorizations> {
|
|
const response = await client.put<WithRoleAuthorizations>(
|
|
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}/${authorizationNo}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const AuthorizationsApi = new AuthorizationsApiService();
|