Skip to content

Commit 38f3f5d

Browse files
Merge pull request #51 from Palbahngmiyine/master
Release SOLAPI Node.js SDK 5.2.0
2 parents 16ee35d + f073b58 commit 38f3f5d

61 files changed

Lines changed: 4649 additions & 3075 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"parser": "@typescript-eslint/parser",
33
"plugins": [
44
"@typescript-eslint/eslint-plugin",
5-
"eslint-plugin-tsdoc"
5+
"eslint-plugin-tsdoc",
6+
"unused-imports"
67
],
78
"extends": [
89
"plugin:@typescript-eslint/recommended"
@@ -28,7 +29,8 @@
2829
"ignoreParameters": true
2930
}
3031
],
31-
"@typescript-eslint/no-unused-vars": "warn"
32+
"@typescript-eslint/no-unused-vars": "warn",
33+
"unused-imports/no-unused-imports": "warn"
3234
},
3335
"ignorePatterns": [
3436
"dist/**/*",

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSameLine": true,
4+
"bracketSpacing": false,
5+
"singleQuote": true,
6+
"trailingComma": "all"
7+
}

changelog/ko/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 5.2.0 (2022년 12월 13일)
2+
3+
- 5.1.1에서 추가된 카카오 알림톡 채널/템플릿 관리 기능을 안정화 했습니다.
4+
- 템플릿 내 아이템리스트 유형 및 바로연결 버튼 유형이 추가되었습니다.
5+
- `getKakaoChannels`, `getKakaoAlimtalkTemplates`, `getKakaoChannel`, `getKakaoAlimtalkTemplate`
6+
, `createKakaoAlimtalkTemplate`, `updateKakaoAlimtalkTemplate`, `cancelInspectionKakaoAlimtalkTemplate`, `deleteKakaoAlimtalkTemplate`, `requestInspectionKakaoAlimtalkTemplate`
7+
호출 시 실제 각 모델 별 클래스 인스턴스를
8+
반환하도록 수정되었습니다.
9+
- KakaoButton 타입이 조금 더 정확하게 타입을 추론하도록 수정되었습니다.
10+
- 알림톡 템플릿의 이름을 수정할 수 있는 메소드가 추가되었습니다.
11+
- updateKakaoAlimtalkTemplateName 메소드는 검수 상태와 무관하게 이름을 수정할 수 있습니다.
12+
- send 메소드에 messages 파라미터 이후의 파라미터들을 하나의 오브젝트(requestConfigParameter)로 변경되었습니다.
13+
- breaking change가 발생하여 예약 발송, 중복 수신번호 허용, appId를 사용하시던 사용자는 업데이트 후 코드를 변경하셔야 합니다.
14+
- send 메소드에서 messages 파라미터의 타입을 `Message | Array<Message>` 타입이 아닌 `MessageParameter | Array<MessageParameter>`
15+
변경했습니다.
16+
- 따라서 이후 send 메소드 호출 시 단순 오브젝트로만 넣어도 type 경고/에러가 뜨지 않도록 조치되었습니다.
17+
- SDK에서 반환되는 에러들도 가져올 수 있도록 변경되었습니다.
18+
- Message 모델에서 수신번호(to)를 string[] 타입(문자 배열)이 추가되었습니다.
19+
- 동일한 내용을 여러 건 발송 시 수신번호(to)를 배열로 넣어 여러 건을 발송할 수 있습니다.

examples/javascript/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
},
1010
"license": "ISC",
1111
"dependencies": {
12-
"solapi": "^5.1.3"
12+
"solapi": "^5.2.0"
1313
}
1414
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
/**
22
* 잔액 조회 예제
33
*/
4-
const { SolapiMessageService } = require("solapi");
5-
const messageService = new SolapiMessageService("ENTER_YOUR_API_KEY", "ENTER_YOUR_API_SECRET");
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
69

7-
messageService.getBalance().then(res => console.log(res));
10+
messageService.getBalance().then(res => {
11+
// 잔액 조회
12+
console.log(res.balance);
13+
14+
// 포인트 조회
15+
console.log(res.point);
16+
});
Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,49 @@
11
/**
22
* 메시지 조회 예제(문자, 알림톡 등)
33
*/
4-
const { SolapiMessageService } = require("solapi");
5-
const messageService = new SolapiMessageService("ENTER_YOUR_API_KEY", "ENTER_YOUR_API_SECRET");
6-
7-
messageService.getMessages({
8-
// 불러올 메시지 갯수 제한
9-
// limit: 5, // 5를 입력하면 5건이 조회됩니다, 미 입력시 20개로 지정
10-
11-
// 메시지 ID로 검색
12-
// messageId: '메시지 ID 입력', // 메시지 ID는 대개 M4V로 시작합니다
13-
14-
// 여러 메시지 ID로 검색
15-
/*messageIds: [
16-
'메시지 ID 입력' // 메시지 ID는 대개 M4V로 시작합니다
17-
],*/
18-
19-
// 그룹 ID로 검색
20-
// groupId: '그룹 ID 입력', // 그룹 ID는 대개 G4V로 시작합니다
21-
22-
// 발신번호로 검색
23-
// from: '01012345678',
24-
25-
// 수신번호로 검색
26-
// to: '01012345678',
27-
28-
/**
29-
* 메시지 타입으로 검색
30-
* SMS: 단문 문자, LMS: 장문 문자, MMS: 사진 문자, ATA: 알림톡, CTA: 친구톡, CTI: 이미지(1장) 친구톡
31-
*/
32-
// type: "SMS",
33-
34-
// 날짜로 검색하는 경우
35-
/*duration: {
36-
dateType: 'CREATED', 메시지 생성 일 기준, UPDATED로 변경하면 메시지 상태 갱신일자 기준으로 조회 함
37-
startDate: '2022-03-01 00:00:00', // Date 객체로도 요청 가능
38-
endDate: '2022-03-31 23:59:59' // Date 객체로도 요청 가능
39-
}*/
40-
}).then(res => console.log(res));
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
9+
10+
messageService
11+
.getMessages({
12+
// 불러올 메시지 갯수 제한
13+
// limit: 5, // 5를 입력하면 5건이 조회됩니다, 미 입력시 20개로 지정
14+
// 메시지 ID로 검색
15+
// messageId: '메시지 ID 입력', // 메시지 ID는 대개 M4V로 시작합니다
16+
// 여러 메시지 ID로 검색
17+
/*messageIds: [
18+
'메시지 ID 입력', // 메시지 ID는 대개 M4V로 시작합니다
19+
],*/
20+
// 그룹 ID로 검색
21+
// groupId: '그룹 ID 입력', // 그룹 ID는 대개 G4V로 시작합니다
22+
// 발신번호로 검색
23+
// from: '01012345678',
24+
// 수신번호로 검색
25+
// to: '01012345678',
26+
/**
27+
* 메시지 타입으로 검색
28+
* SMS: 단문 문자, LMS: 장문 문자, MMS: 사진 문자, ATA: 알림톡, CTA: 친구톡, CTI: 이미지(1장) 친구톡
29+
*/
30+
// type: "SMS",
31+
// 날짜로 검색하는 경우
32+
// startDate: '2022-12-01 00:00:00', // Date 객체로도 요청 가능
33+
// endDate: '2022-12-31 23:59:59', // Date 객체로도 요청 가능
34+
})
35+
.then(res => console.log(res));
4136

4237
/**
4338
* 페이징 예제
4439
* */
4540
messageService.getMessages().then(res => {
46-
47-
messageService.getMessages({
48-
// startKey 부분에 nextKey를 입력할 경우 초기 20건 다음의 데이터를 표시하게 됩니다.
49-
startKey: res.nextKey
50-
}).then(res2 => {
51-
console.log(res2);
52-
});
53-
41+
messageService
42+
.getMessages({
43+
// startKey 부분에 nextKey를 입력할 경우 초기 20건 다음의 데이터를 표시하게 됩니다.
44+
startKey: res.nextKey,
45+
})
46+
.then(res2 => {
47+
console.log(res2);
48+
});
5449
});
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/**
22
* 통계 조회 예제
33
*/
4-
const { SolapiMessageService } = require("solapi");
5-
const messageService = new SolapiMessageService("ENTER_YOUR_API_KEY", "ENTER_YOUR_API_SECRET");
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
69

7-
messageService.getStatistics({
8-
// 날짜로 검색하는 경우
9-
/*duration: {
10-
startDate: '2022-03-01 00:00:00', // Date 객체로도 요청 가능
11-
endDate: '2022-03-31 23:59:59' // Date 객체로도 요청 가능
12-
}*/
13-
}).then(res => console.log(res));
10+
messageService
11+
.getStatistics({
12+
// 날짜로 검색하는 경우
13+
// startDate: '2022-12-01 00:00:00', // Date 객체로도 요청 가능
14+
// endDate: '2022-12-31 23:59:59' // Date 객체로도 요청 가능
15+
})
16+
.then(res => console.log(res));
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/**
2+
* 카카오 알림톡 템플릿 생성 예제
3+
*/
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
9+
10+
// 사전에 템플릿 카테고리를 조회해야 합니다.
11+
// 반드시 실제 템플릿 생성시엔 템플릿에 맞는 카테고리를 조회하여 넣어주세요!
12+
messageService.getKakaoAlimtalkTemplateCategories().then(res => {
13+
const categoryCode = res[res.length - 1].code;
14+
messageService
15+
.createKakaoAlimtalkTemplate({
16+
name: '등록할 템플릿 제목(등록된 템플릿과 중복불가)',
17+
content: '등록할 템플릿 내용',
18+
channelId: '등록할 템플릿의 채널 ID(pfId)',
19+
// 채널 그룹으로 등록하는 경우 아래 주석 해제
20+
// channelGroupId: '등록할 템플릿의 채널 그룹 ID(pfId)',
21+
categoryCode,
22+
// 아래 데이터부터는 선택사항
23+
24+
/**
25+
* 알림톡 버튼, 최대 5개까지 입력할 수 있으며, 바로연결이 추가되면 최대 두개까지만 추가될 수 있습니다.
26+
*/
27+
/*buttons: [
28+
{
29+
buttonName: '버튼이름',
30+
/!**
31+
* 카카오 버튼 타입에 대한 설명은 아래 페이지를 참고해주세요!
32+
* @see https://developers.solapi.com/references/kakao/button-link-type
33+
*!/
34+
buttonType: 'WL',
35+
linkMo: 'https://m.example.com',
36+
linkPc: 'https://example.com',
37+
},
38+
],*/
39+
40+
/**
41+
* 바로연결, 10개까지만 등록할 수 있으며, 바로연결이 추가되면 버튼은 최대 두개까지 추가될 수 있습니다.
42+
*/
43+
/*quickReplies: [
44+
{
45+
name: '바로연결 버튼이름',
46+
/!**
47+
* 카카오 버튼 타입에 대한 설명은 아래 페이지를 참고해주세요!
48+
* @see https://developers.solapi.com/references/kakao/button-link-type
49+
* 바로연결에서 허용되는 버튼 타입은 아래와 같습니다.
50+
* WL: 웹링크, AL: 앱링크, BK: 봇키워드, BT: 봇전환, BC: 상담톡전환
51+
*!/
52+
linkType: 'WL',
53+
linkMo: 'https://m.example.com',
54+
linkPc: 'https://example.com',
55+
},
56+
],*/
57+
58+
/**
59+
* 카카오 알림톡 템플릿 메시지 유형
60+
* BA:기본형, EX:부가정보형, AD:광고추가형, MI: 복합형
61+
* 미지정시 기본값은 기본형(BA)입니다.
62+
*/
63+
//messageType: 'BA',
64+
65+
/**
66+
* 카카오 알림톡 템플릿 강조 유형
67+
* NONE: 선택안함, TEXT: 강조표기형, IMAGE: 이미지형, ITEM_LIST: 아이템리스트형
68+
* 미지정시 기본값은 선택안함(NONE) 입니다.
69+
* 강조 유형에 대한 자세한 설명은 아래 페이지를 참고해주세요!
70+
* @see https://developers.solapi.com/references/kakao/templates/createTemplate#%EA%B0%95%EC%A1%B0-%EC%9C%A0%ED%98%95
71+
*/
72+
//emphasizeType: 'NONE',
73+
74+
// 강조표기형(TEXT) 유형일 때 추가할 수 있는 강조표기형 제목
75+
//emphasizeTitle: '',
76+
77+
// 강조표기형(TEXT) 유형일 때 추가할 수 있는 강조표기형 부제목
78+
//emphasizeSubTitle: '',
79+
80+
/**
81+
* 아이템 리스트(ITEM_LIST) 유형에서만 사용 가능한 알림톡 헤더.
82+
* 변수(치환문구) 포함 가능. 최대 16자
83+
*/
84+
//header: '헤더 입력',
85+
86+
//알림톡 하이라이트, 강조 유형이 아이템 리스트일 때만 사용 가능합니다.
87+
/*highlight: {
88+
title: '하이라이트 제목', // 알림톡 하이라이트 제목, 변수 포함가능 및 최대 30자까지 입력 가능
89+
description: '', // 알림톡 하이라이트 내용. 변수 포함 불가능. 최대 16자까지 입력 가능
90+
/!**
91+
* 알림톡에 사용되는 이미지 고유 아이디. 이미지 타입이 ATA일 경우에만 사용 가능합니다.
92+
* 이미지 ID에 관한 설명은 아래 페이지를 확인해보세요!
93+
* @see https://developers.solapi.com/references/storage
94+
*!/
95+
// imageId: ''
96+
},*/
97+
98+
// 알림톡 아이템, 목록과 요약이 있습니다. 강조 유형이 아이템 리스트일 때만 사용 가능합니다.
99+
/*item: {
100+
// 알림톡 아이템 리스트, 최소 2개, 최대 10개까지 등록할 수 있습니다.
101+
list: [
102+
{
103+
title: '아이템리스트', // 아이템 리스트 제목, 변수 포함 불가, 최대 6자까지 입력 가능합니다.
104+
description: '아이템 리스트 내용', // 아이템 리스트 내용, 변수 포함가능, 최대 23까지 입력 가능합니다.
105+
},
106+
],
107+
summary: {
108+
title: '', // 알림톡 아이템 리스트 요약 제목, 변수 포함 불가, 최대 6자까지 입력 가능합니다.
109+
description: '', // 알림톡 아이템 리스트 요약 내용. 변수 포함 가능. 화폐 단위, 숫자, 쉼표, 마침표만 사용 가능합니다. 최대 14자까지 입력 가능합니다.
110+
},
111+
},*/
112+
113+
// 부가정보. 변수 포함 불가능. 최대 500자
114+
//extra: '',
115+
116+
/**
117+
* 보안 템플릿 여부. true일 경우 해당 템플릿을 PC에서는 확인할 수 없습니다. 기본값: false
118+
* 미지정시 기본값은 false 입니다.
119+
*/
120+
//securityFlag: false,
121+
122+
//알림톡에 사용되는 이미지 고유 아이디. 이미지 타입이 ATA일 경우에만 사용 가능합니다.
123+
//imageId: '',
124+
})
125+
.then(res => {
126+
console.log(res);
127+
128+
// 생성한 카카오 알림톡 템플릿을 즉시 검수할 수 있습니다.
129+
/*messageService
130+
.requestInspectionKakaoAlimtalkTemplate(res.templateId)
131+
.then(res2 => console.log(res2));*/
132+
});
133+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* 카카오 알림톡 템플릿 조회 예제
3+
*/
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
9+
10+
messageService
11+
.getKakaoAlimtalkTemplate('조회할 알림톡 template ID')
12+
.then(res => console.log(res));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* 카카오 알림톡 템플릿 카테고리 목록 조회 예제
3+
*/
4+
const {SolapiMessageService} = require('solapi');
5+
const messageService = new SolapiMessageService(
6+
'ENTER_YOUR_API_KEY',
7+
'ENTER_YOUR_API_SECRET',
8+
);
9+
10+
messageService.getKakaoAlimtalkTemplateCategories().then(res => {
11+
for (const category of res) {
12+
console.log(category);
13+
}
14+
});

0 commit comments

Comments
 (0)