Skip to content

Commit

Permalink
feat: MisTimetable
Browse files Browse the repository at this point in the history
  • Loading branch information
star0202 committed Apr 29, 2023
1 parent 9c77d2f commit fc87cd7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type {
ElsTimetableResponse,
MealServiceDietInfoParam,
MealServiceDietInfoResponse,
MisTimetableParam,
MisTimetableResponse,
NeisConfig,
SchoolInfoParam,
SchoolInfoResponse,
Expand Down Expand Up @@ -71,4 +73,16 @@ export class Neis extends NeisRequest {
): Promise<ElsTimetableResponse> {
return (await this.elsTimetableRaw(params))[0]
}

async getMisTimetable(
params: MisTimetableParam
): Promise<MisTimetableResponse[]> {
return await this.misTimetableRaw(params)
}

async getMisTimetableOne(
params: MisTimetableParam
): Promise<MisTimetableResponse> {
return (await this.misTimetableRaw(params))[0]
}
}
12 changes: 12 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type {
ElsTimetableResponse,
MealServiceDietInfoParam,
MealServiceDietInfoResponse,
MisTimetableParam,
MisTimetableResponse,
NeisConfig,
Params,
SchoolInfoParam,
Expand Down Expand Up @@ -113,6 +115,16 @@ export class NeisRequest {
)
}

protected async misTimetableRaw(
params: MisTimetableParam
): Promise<MisTimetableResponse[]> {
return await this.request<MisTimetableResponse>(
'GET',
'misTimetable',
params
)
}

private async request<T>(
method: string,
endpoint: string,
Expand Down
11 changes: 11 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,18 @@ export interface ElsTimetableParam extends DefaultParam, RequiresSchoolParam {
readonly TI_TO_YMD?: string
}

export interface MisTimetableParam extends ElsTimetableParam {
/** 주야과정명 */
readonly DGHT_CRSE_SC_NM?: string
}

export type Params =
| SchoolInfoParam
| MealServiceDietInfoParam
| SchoolScheduleParam
| AcaInsTiInfoParam
| ElsTimetableParam
| MisTimetableParam

interface BaseSchoolResponse {
/** 시도교육청코드 */
Expand Down Expand Up @@ -294,3 +300,8 @@ export interface ElsTimetableResponse extends BaseSchoolResponse {
/** 수정일 */
readonly LOAD_DTM: string
}

export interface MisTimetableResponse extends ElsTimetableResponse {
/** 주야과정명 */
readonly DGHT_CRSE_SC_NM: string
}
3 changes: 2 additions & 1 deletion tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const AE = 'B10'
export const AN = '3000037367'
export const SE = '7010057'
export const YMD = '20230302'
export const YMD = '20230428'

export const ELS = '7091414'
export const MIS = '7091455'
27 changes: 25 additions & 2 deletions tests/timetable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ElsTimetableResponse } from '../src'
import { AE, ELS, YMD } from './constants'
import type { ElsTimetableResponse, MisTimetableResponse } from '../src'
import { AE, ELS, MIS, YMD } from './constants'
import { neis } from './utils'

describe('Timetable', () => {
Expand All @@ -25,4 +25,27 @@ describe('Timetable', () => {

expect(data).toMatchObject<ElsTimetableResponse>(data)
})

it('should return MisTimetableResponse[]', async () => {
const data = await neis.getMisTimetable({
ATPT_OFCDC_SC_CODE: AE,
SD_SCHUL_CODE: MIS,
ALL_TI_YMD: YMD,
})

expect(data).toMatchObject<MisTimetableResponse[]>(data)
})

it('should return MisTimetableResponse', async () => {
const data = await neis.getMisTimetableOne({
ATPT_OFCDC_SC_CODE: AE,
SD_SCHUL_CODE: MIS,
ALL_TI_YMD: YMD,
GRADE: '1',
CLASS_NM: '1',
PERIO: '1',
})

expect(data).toMatchObject<MisTimetableResponse>(data)
})
})

0 comments on commit fc87cd7

Please sign in to comment.