summaryrefslogtreecommitdiff
path: root/lib/knox-api/employee/employee.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/knox-api/employee/employee.ts')
-rw-r--r--lib/knox-api/employee/employee.ts34
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/knox-api/employee/employee.ts b/lib/knox-api/employee/employee.ts
index 885b5a3f..d9e66555 100644
--- a/lib/knox-api/employee/employee.ts
+++ b/lib/knox-api/employee/employee.ts
@@ -1,12 +1,8 @@
"use server"
-// Knox API 임직원 관련 서버 액션들
+import { getKnoxConfig, createJsonHeaders } from '../common';
-// 기본 설정 타입
-interface KnoxConfig {
- baseUrl: string;
- systemId: string;
-}
+// Knox API 임직원 관련 서버 액션들
// 공통 응답 타입
interface BaseResponse {
@@ -184,28 +180,14 @@ interface TitleResponse extends BaseResponse {
titles: Title[];
}
-// 설정 가져오기 (환경변수 또는 설정에서)
-const getKnoxConfig = (): KnoxConfig => {
- return {
- baseUrl: process.env.KNOX_API_BASE_URL || "https://api.knox.samsung.com",
- systemId: process.env.KNOX_SYSTEM_ID || "C60REST0001"
- };
-};
-// 공통 헤더 생성
-const createHeaders = (systemId: string): Record<string, string> => {
- return {
- "Content-Type": "application/json",
- "System-ID": systemId
- };
-};
/**
* 임직원 조회 API
* POST /employee/api/v2.0/employees
*/
export async function searchEmployees(params: EmployeeSearchParams): Promise<EmployeeResponse> {
- const config = getKnoxConfig();
+ const config = await getKnoxConfig();
try {
// URL 파라미터 구성
@@ -232,7 +214,7 @@ export async function searchEmployees(params: EmployeeSearchParams): Promise<Emp
`${config.baseUrl}/employee/api/v2.0/employees?${searchParams.toString()}`,
{
method: "POST",
- headers: createHeaders(config.systemId),
+ headers: await createJsonHeaders(),
body: JSON.stringify(body)
}
);
@@ -254,7 +236,7 @@ export async function searchEmployees(params: EmployeeSearchParams): Promise<Emp
* GET /employee/api/v2.0/organizations
*/
export async function searchOrganizations(params: OrganizationSearchParams): Promise<OrganizationResponse> {
- const config = getKnoxConfig();
+ const config = await getKnoxConfig();
try {
// URL 파라미터 구성
@@ -270,7 +252,7 @@ export async function searchOrganizations(params: OrganizationSearchParams): Pro
`${config.baseUrl}/employee/api/v2.0/organizations?${searchParams.toString()}`,
{
method: "GET",
- headers: createHeaders(config.systemId)
+ headers: await createJsonHeaders()
}
);
@@ -291,7 +273,7 @@ export async function searchOrganizations(params: OrganizationSearchParams): Pro
* GET /employee/api/v2.0/titles
*/
export async function searchTitles(params: TitleSearchParams): Promise<TitleResponse> {
- const config = getKnoxConfig();
+ const config = await getKnoxConfig();
try {
// URL 파라미터 구성
@@ -302,7 +284,7 @@ export async function searchTitles(params: TitleSearchParams): Promise<TitleResp
`${config.baseUrl}/employee/api/v2.0/titles?${searchParams.toString()}`,
{
method: "GET",
- headers: createHeaders(config.systemId)
+ headers: await createJsonHeaders()
}
);