-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './the-camp.client'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TheCampClient } from './the-camp.client'; | ||
|
||
describe.skip('TheCampClient e2e', () => { | ||
it('성공', async () => { | ||
const theCampClient = new TheCampClient(); | ||
|
||
await theCampClient.login({ | ||
id: '', | ||
password: '', | ||
}); | ||
|
||
await theCampClient.sendLetter( | ||
{ | ||
성분: '예비군인/훈련병', | ||
군종: '육군', | ||
이름: '홍길동', | ||
입영부대: '육군훈련소-논산', | ||
관계: '팬', | ||
생년월일: '2001-01-01', | ||
입영일: '2022-02-14', | ||
전화번호: '01012341234', | ||
|
||
생년월일Code: '08IyuIy6/tXS/vveGiNc+Q==', | ||
입영부대TypeCode: '0000140001', | ||
입영부대EduId: '', | ||
훈련병Id: '', | ||
}, | ||
{ | ||
작성자: '장지훈', | ||
제목: `내용은 곧 제목`, | ||
내용: `제목은 | ||
곧 | ||
내용`, | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { TheCampSession } from '@common/types'; | ||
import { Credential, 관계, 군종, 성분, 입영부대 } from '@core/types'; | ||
|
||
import { TheCampService } from '../services/the-camp'; | ||
|
||
export class TheCampClient { | ||
private readonly theCampService: TheCampService = new TheCampService(); | ||
private session!: TheCampSession; | ||
|
||
async login(credential: Credential): Promise<void> { | ||
this.session = await this.theCampService.login(credential); | ||
} | ||
|
||
async sendLetter( | ||
soldierInfo: SoldierInfo, | ||
letterInfo: LetterInfo, | ||
): Promise<void> { | ||
if (!this.isLoggedIn()) { | ||
throw new Error('로그인 후에 위문편지 전송이 가능합니다.'); | ||
} | ||
|
||
// TODO: soldierInfo를 1회만 만들어서 재사용 할 수 있는 방법 생각하여 registerSoldier, registerCafe를 sendLetter에서 분리하기 | ||
await this.theCampService.registerSoldier(soldierInfo, this.session); | ||
await this.theCampService.registerCafe(soldierInfo, this.session); | ||
|
||
await this.theCampService.sendLetter( | ||
{ ...soldierInfo, ...letterInfo }, | ||
this.session, | ||
); | ||
} | ||
|
||
isLoggedIn(): boolean { | ||
return Boolean(this.session); | ||
} | ||
} | ||
|
||
export interface SoldierInfo { | ||
성분: 성분; | ||
군종: 군종; | ||
관계: 관계; | ||
입영부대: 입영부대; | ||
|
||
이름: string; | ||
생년월일: string; // yyyy-MM-dd | ||
입영일: string; // yyyy-MM-dd | ||
전화번호?: string; | ||
|
||
// TODO: 아래 필드들 사이트에서 fetch 하도록 작업 | ||
생년월일Code: string; | ||
입영부대TypeCode: string; | ||
|
||
입영부대EduId: string; | ||
훈련병Id: string; | ||
} | ||
|
||
export interface LetterInfo { | ||
제목: string; | ||
내용: string; | ||
작성자: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
async function main() { | ||
console.log('test'); | ||
} | ||
main(); | ||
export * from './client'; | ||
export * from './core/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters