/the-camp-lib

๐Ÿ“ฎ Unofficial library for THE CAMP, an army communication service

Primary LanguageTypeScriptMIT LicenseMIT

THE CAMP Unofficial Library

npm downloads npm version health check npm license

๐Ÿ›‘ ์œก๊ตฐํ›ˆ๋ จ์†Œ๊ฐ€ ํœด๋Œ€์ „ํ™” ์‚ฌ์šฉ์„ ํ—ˆ๊ฐ€ํ•˜๋ฉด์„œ ์ธํ„ฐ๋„ท ํŽธ์ง€ ์„œ๋น„์Šค๋ฅผ ์ค‘๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค. (์œก๊ตฐํ›ˆ๋ จ์†Œ ๊ณต์ง€) ์‚ฌ๋‹จ ์‹ ๋ณ‘๊ต์œก๋Œ€์—์„œ๋„ ํ›ˆ๋ จ๋ณ‘์˜ ํœด๋Œ€์ „ํ™” ์‚ฌ์šฉ์„ ํ—ˆ๊ฐ€ํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ, ์•ž์œผ๋กœ๋Š” ๋” ์บ ํ”„๋ฅผ ํ†ตํ•ด ์ž‘์„ฑํ•œ ํŽธ์ง€๊ฐ€ ์ถœ๋ ฅ๋ฌผ๋กœ ์ „๋‹ฌ๋˜์ง€ ์•Š์„ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์Šต๋‹ˆ๋‹ค. (๋” ์บ ํ”„ ๊ณต์ง€) ์ด์— ๋”ฐ๋ผ the-camp-lib์˜ ์œ ์ง€๋ณด์ˆ˜๋ฅผ ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. (2023๋…„ 11์›” 6์ผ)

โš ๏ธ ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ๋” ์บ ํ”„ ์„œ๋น„์Šค์˜ ๊ณต์‹ API ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์˜ˆ๊ณ ์—†์ด API ์ œ๊ณต์ด ์ •์ง€๋˜๊ฑฐ๋‚˜, ๋™์ž‘์ด ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ™… ์‚ฌ์šฉ์ž๋Š” ๋” ์บ ํ”„ ์„œ๋น„์Šค์˜ ์šด์˜์„ ๊ณ ์˜๋กœ ๋ฐฉํ•ดํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค. ์„œ๋น„์Šค์— ๊ณผ๋„ํ•œ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ฑฐ๋‚˜ ๊ฒฐํ•จ์„ ์œ ๋ฐœํ•˜๋Š” ๋“ฑ ์„œ๋น„์Šค ์šด์˜์„ ๋ฐฉํ•ดํ•˜๋Š” ํ–‰์œ„๋ฅผ ํ•˜์ง€ ์•Š๋„๋ก ์ฃผ์˜ํ•ด์ฃผ์„ธ์š”. ์‚ฌ์šฉ์ž๊ฐ€ ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐœ์ƒํ•œ ๊ฒฐ๊ณผ์— ๋Œ€ํ•ด ํ”„๋กœ์ ํŠธ ์˜ค๋„ˆ์™€ ๋ฉ”์ธํ…Œ์ด๋„ˆ๋Š” ์–ด๋– ํ•œ ์ฑ…์ž„๋„ ๋ถ€๋‹ดํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

โœ‰๏ธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋Œ€ํ•œ ๋ฌธ์˜๋Š” ์ด์Šˆ๋กœ ๋“ฑ๋กํ•ด์ฃผ์„ธ์š”.

๋Œ€๊ตญ๋ฏผ ๊ตญ๊ตฐ ์†Œํ†ต ์„œ๋น„์Šค ๋” ์บ ํ”„๋ฅผ ์‚ฌ์ดํŠธ ์™ธ๋ถ€์—์„œ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“  ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. ํ˜„์žฌ ์ธํ„ฐ๋„ท ํŽธ์ง€ ๋ฐœ์†ก์„ ์ค‘์‹ฌ์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋งค์ฃผ ์›”์š”์ผ 0์‹œ API์˜ ์œ ํšจ์„ฑ์„ ์ฒดํฌํ•ฉ๋‹ˆ๋‹ค. passing ์ƒํƒœ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด API๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ˆ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

Installation

$ npm install the-camp-lib --save

Usage

const thecamp = require('the-camp-lib');
// or
import * as thecamp from 'the-camp-lib';

async function main() {
  const soldier = new thecamp.Soldier(
    '๋ฐ•๋ซ„๋ซ„',
    '20011129',
    '20200829',
    '์˜ˆ๋น„๊ตฐ์ธ/ํ›ˆ๋ จ๋ณ‘',
    '์œก๊ตฐ',
    '์œก๊ตฐํ›ˆ๋ จ์†Œ(00์—ฐ๋Œ€)',
    thecamp.SoldierRelationship.FRIEND,
  );

  const client = new thecamp.Client();

  await client.login('user@email.com', 'password');
  await client.addSoldier(soldier);

  const [trainee] = await client.fetchSoldiers(soldier);
  const message = new thecamp.Message('Test title', 'Test content', trainee);

  await client.sendMessage(soldier, message);
}

Development

์ €์žฅ์†Œ๋ฅผ ํด๋ก ํ•˜๊ณ  ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

$ git clone https://github.com/ParkSB/the-camp-lib.git
$ cd the-camp-lib
$ npm install

๋ชจ๋“  ์ฝ”๋“œ๋Š” src ๋””๋ ‰ํ† ๋ฆฌ ์•„๋ž˜์— ์žˆ์Šต๋‹ˆ๋‹ค. npm test ๋ช…๋ น์œผ๋กœ API ์œ ํšจ์„ฑ์„ ์ฒดํฌํ•˜๊ณ  ์œ ๋‹› ํ…Œ์ŠคํŠธ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. npm run test:unit ๋ช…๋ น๊ณผ npm run test:health-check ๋ช…๋ น์œผ๋กœ ์œ ๋‹› ํ…Œ์ŠคํŠธ์™€ API ์ฒดํฌ๋ฅผ ๋”ฐ๋กœ ์‹คํ–‰ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ test/feature ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„์— ํ…Œ์ŠคํŠธํ•  ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•œ ๋’ค ts-node filename.ts๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์‹ค์ œ ๋™์ž‘์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‰˜์—์„œ npm run build๋ฅผ ์‹คํ–‰ํ•˜๋ฉด dist ๋””๋ ‰ํ† ๋ฆฌ์— ๋นŒ๋“œ๋œ ํŒŒ์ผ์ด ๋งŒ๋“ค์–ด์ง‘๋‹ˆ๋‹ค. test ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„์— ์˜ˆ์‹œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“  ๋’ค npm init, npm install ../../ --save๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์— ํŒจํ‚ค์ง€๊ฐ€ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋กœ์ปฌ์—์„œ ๋ฐฐํฌ ๋ฒ„์ „์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Specifications

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ๋” ์บ ํ”„์— ๊ฐ€์ž…๋œ ๊ณ„์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

Models

interface Cookie

์„ธ์…˜ ์‹๋ณ„์„ ์œ„ํ•œ ์ฟ ํ‚ค.

  • iuid: string

class Soldier

๊ตฐ์ธ ์ •๋ณด.

  • missSoldierClassCdNm: SoldierClassName - ์„ฑ๋ถ„
  • missSoldierClassCd: SoldierClass - ์„ฑ๋ถ„ ์ฝ”๋“œ
  • grpCdNm: SoldierGroupName - ๊ตฐ์ข…
  • grpCd: SoldierGroup - ๊ตฐ์ข… ์ฝ”๋“œ
  • name: string - ์ด๋ฆ„
  • birth: string - ์ƒ๋…„์›”์ผ
  • enterDate: string - ์ž…์—ด ๋‚ ์งœ
  • trainUnitCd: SoldierUnit - ์ž…์˜๋ถ€๋Œ€ ์ฝ”๋“œ
  • trainUnitNm: SoldierUnitNm - ์ž…์˜๋ถ€๋Œ€
  • missSoldierRelationshipCd: SoldierRelationship - ๊ด€๊ณ„ ์ฝ”๋“œ
  • traineeMgrSeq?: string - ํ›ˆ๋ จ๋ณ‘ ์‹๋ณ„ ์ฝ”๋“œ

Constructor

  • name: string - ์ด๋ฆ„ (e.g., '๋ฐ•๋ซ„๋ซ„')
  • birth: string - ์ƒ๋…„์›”์ผ (e.g., '20011129')
  • enterDate: string - ์ž…์˜๋‚ ์งœ (e.g., '20200829')
  • className: SoldierClassName - ์„ฑ๋ถ„ (e.g., '์˜ˆ๋น„๊ตฐ์ธ/ํ›ˆ๋ จ๋ณ‘')
  • groupName: SoldierGroupName - ๊ตฐ์ข… (e.g., '์œก๊ตฐ')
  • unitName: SoldierUnitName - ์ž…์˜๋ถ€๋Œ€ (e.g., '28์‚ฌ๋‹จ', '์œก๊ตฐํ›ˆ๋ จ์†Œ(25์—ฐ๋Œ€)')
  • relationship: SoldierRelationship - ๊ด€๊ณ„ (e.g., SoldierRelationship.FRIEND)

enum SoldierClass

์„ฑ๋ถ„ ์ฝ”๋“œ.

  • '์˜ˆ๋น„๊ตฐ์ธ/ํ›ˆ๋ จ๋ณ‘' = '0000490001'
  • '๋ณ‘์‚ฌ' = '0000490002'
  • '์žฅ๊ต' = '0000490003'
  • '๋ถ€์‚ฌ๊ด€' = '0000490004'
  • '๊ตฐ๋ฌด์›' = '0000490005'

์ธํ„ฐ๋„ท ํŽธ์ง€๋Š” ์˜ˆ๋น„๊ตฐ์ธ/ํ›ˆ๋ จ๋ณ‘์—๊ฒŒ๋งŒ ๋ฐœ์†กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

enum SoldierGroup

๊ตฐ์ข… ์ฝ”๋“œ.

  • '์œก๊ตฐ' = '0000010001'
  • 'ํ•ด๊ตฐ' = '0000010002'
  • '๊ณต๊ตฐ' = '0000010003'
  • 'ํ•ด๋ณ‘๋Œ€' = '0000010004'

์ธํ„ฐ๋„ท ํŽธ์ง€๋Š” ์œก๊ตฐ์—๊ฒŒ๋งŒ ๋ฐœ์†กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

enum SoldierRelationship

๊ด€๊ณ„ ์ฝ”๋“œ.

  • PARENT = '0000420001' - ๋ถ€๋ชจ
  • SPOUSE = '0000420003' - ๋ฐฐ์šฐ์ž
  • SIBLING = '0000420002' - ํ˜•์ œ/์ž๋งค
  • FRIEND = '0000420006' - ์นœ๊ตฌ/์ง€์ธ
  • LOVER = '0000420005' - ์• ์ธ
  • RELATIVE = '0000420004' - ์นœ์ฒ™
  • FAN = '0000420007' - ํŒฌ

class Message

์ธํ„ฐ๋„ท ํŽธ์ง€ ์ •๋ณด.

  • sympathyLetterSubject: string - ํŽธ์ง€ ์ œ๋ชฉ
  • sympathyLetterContent: string - ํŽธ์ง€ ๋‚ด์šฉ (1500์ž ์ดํ•˜)
  • traineeMgrSeq: string - ํ›ˆ๋ จ๋ณ‘ ์‹๋ณ„ ์ฝ”๋“œ

Constructor

  • sympathyLetterSubject: string - ํŽธ์ง€ ์ œ๋ชฉ (e.g., 'Title')
  • sympathyLetterContent: string - ํŽธ์ง€ ๋‚ด์šฉ (e.g., 'Content', '<i>Content</i>')
  • traineeMgrSeq: string - ํ›ˆ๋ จ๋ณ‘ ์‹๋ณ„ ์ฝ”๋“œ (e.g., soldier.getTraineeMgrSeq()!)

Services

login(id: string, password: string)

๋” ์บ ํ”„์— ๋กœ๊ทธ์ธํ•ด ์„ธ์…˜ ์ฟ ํ‚ค๋ฅผ ์–ป๋Š”๋‹ค.

  • Parameters
    • id: string - ๋” ์บ ํ”„ ๊ณ„์ • ์ด๋ฉ”์ผ
    • password: string - ๋” ์บ ํ”„ ๊ณ„์ • ๋น„๋ฐ€๋ฒˆํ˜ธ
  • Return value
    • Promise<Cookie> - ์„ธ์…˜ ์‹๋ณ„์„ ์œ„ํ•œ ์ฟ ํ‚ค

addSoldier(cookies: Cookie, soldier: Soldier)

๊ณ„์ •์— ๊ตฐ์ธ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

  • Parameters
    • cookies: Cookie - ์„ธ์…˜ ์‹๋ณ„์„ ์œ„ํ•œ ์ฟ ํ‚ค
    • soldier: Soldier - ๊ตฐ์ธ ์ •๋ณด
  • Return value
    • Promise<boolean> - ์ถ”๊ฐ€์— ์„ฑ๊ณตํ•˜๊ฑฐ๋‚˜, ์ด๋ฏธ ํ•ด๋‹น ๊ตฐ์ธ์ด ์กด์žฌํ•˜๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

fetchSoldier(cookies: Cookie, soldier: Soldier)

๊ตฐ์ธ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜จ๋‹ค.

  • Parameters
    • cookies: Cookie - ์„ธ์…˜ ์‹๋ณ„์„ ์œ„ํ•œ ์ฟ ํ‚ค
    • soldier: Soldier - ๊ตฐ์ธ ์ •๋ณด
  • Return value
    • Promise<Soldier[]> - ๊ณ„์ •์— ์ถ”๊ฐ€ํ•œ ๊ตฐ์ธ ๋ชฉ๋ก ์ค‘ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌํ•œ ๊ตฐ์ธ๊ณผ ์ด๋ฆ„, ์ƒ์ผ, ์ž…์˜ ๋‚ ์งœ, ์ž…์˜ ๋ถ€๋Œ€ ์ฝ”๋“œ๊ฐ€ ์ผ์น˜ํ•˜๋Š” Soldier ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

sendMessage(cookies: Cookie, trainee: Soldier, message: Message)

์ธํ„ฐ๋„ท ํŽธ์ง€๋ฅผ ์ „์†กํ•œ๋‹ค.

  • Parameters
    • cookies: Cookie - ์„ธ์…˜ ์‹๋ณ„์„ ์œ„ํ•œ ์ฟ ํ‚ค
    • trainee: Trainee - ํ›ˆ๋ จ๋ณ‘ ์ •๋ณด
    • message: Message - ์ธํ„ฐ๋„ท ํŽธ์ง€ ์ •๋ณด
  • Return value
    • Promise<boolean> - ์ „์†ก์— ์„ฑ๊ณตํ•˜๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

Examples

  • ์ธํ„ฐ๋„ท ํŽธ์ง€ ์ „์†ก ์˜ˆ์‹œ: send-message
  • ๋‰ด์Šค ๋ฐœ์†ก ํ”„๋กœ์ ํŠธ: daily-news-for-trainee

Other implementations

License

This project is licensed under the MIT License - see the LICENSE file for details.