Skip to content

Commit 22f7040

Browse files
authored
Merge pull request #54 from hotsoycandy/feature/update-5.2.1
Feature/update 5.2.1
2 parents 6570d4f + 7339519 commit 22f7040

8 files changed

Lines changed: 133 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
You can send text messages(SMS, LMS, MMS), Kakao friendtalk(include notification friendtalk) in Korea using this
6-
package.
6+
package.
77
This package is 100% compatible with SOLAPI family services (Purple Book, Nurigo, etc.).
88

99
## Installing
@@ -40,4 +40,4 @@ environment and OS you’re using. Please include a stack trace and reduced repr
4040
Licensed under the MIT License.
4141

4242

43-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs?ref=badge_large)
43+
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs?ref=badge_large)

changelog/ko/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 5.2.1 (2023년 1월 25일)
2+
3+
- 080 수신 거부 목록을 조회할 수 있는 기능을 추가했습니다.
4+
- 예제가 추가되었습니다.
5+
- 코드 안정화가 진행되었습니다.
6+
- 그룹 조회 시 검색 조건이 제대로 작동하지 않는 부분을 안정화 했습니다.
7+
18
# 5.2.0 (2022년 12월 13일)
29

310
- 5.1.1에서 추가된 카카오 알림톡 채널/템플릿 관리 기능을 안정화 했습니다.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* 080 수신 거부 목록 조회
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.getBlacks({
11+
// 차단 당한 발신번호를 검색하는 경우
12+
// senderNumber: '029302266',
13+
14+
// 날짜로 검색하는 경우
15+
// startDate: '2022-12-01 00:00:00', // Date 객체로도 요청 가능
16+
// endDate: '2022-12-31 23:59:59' // Date 객체로도 요청 가능
17+
}).then(res => {
18+
// 목록
19+
console.log('#page1', res.blackList);
20+
21+
// 응답에 nextKeyr가 있을 경우 다음 페이지도 조회 가능
22+
messageService.getBlacks({
23+
startKey: res.nextKey
24+
}).then(res => {
25+
console.log('#page2', res.blackList);
26+
});
27+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solapi",
3-
"version": "5.2.0",
3+
"version": "5.2.1",
44
"description": "SOLAPI SDK for Node.js(Server Side Only)",
55
"repository": {
66
"type": "git",

src/requests/getBlacksRequest.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {formatWithTransfer} from '../lib/stringDateTrasnfer';
2+
import { DatePayloadType } from './messageRequest';
3+
4+
export interface GetBlacksRequest {
5+
senderNumber?: string;
6+
startKey?: string;
7+
limit?: number;
8+
/**
9+
* @description 조회할 시작 날짜
10+
*/
11+
startDate?: string | Date;
12+
13+
/**
14+
* @description 조회할 종료 날짜
15+
*/
16+
endDate?: string | Date;
17+
}
18+
19+
export class GetBlacksFinalizeRequest implements GetBlacksRequest {
20+
type = 'DENIAL' as const;
21+
senderNumber?: string;
22+
startKey?: string;
23+
limit?: number;
24+
dateCreated?: DatePayloadType;
25+
26+
constructor(parameter: GetBlacksRequest) {
27+
this.type = 'DENIAL';
28+
this.senderNumber = parameter.senderNumber;
29+
this.startKey = parameter.startKey;
30+
this.limit = parameter.limit;
31+
32+
if (parameter.startDate != undefined) {
33+
this.dateCreated = Object.assign(this.dateCreated ?? {}, {
34+
gte: formatWithTransfer(parameter.startDate),
35+
});
36+
}
37+
if (parameter.endDate != undefined) {
38+
this.dateCreated = Object.assign(this.dateCreated ?? {}, {
39+
lte: formatWithTransfer(parameter.endDate),
40+
});
41+
}
42+
}
43+
}

src/responses/getBlacksResponse.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
HandleKey,
3+
Black,
4+
} from '../types/commonTypes';
5+
6+
export type GetBlacksResponse = {
7+
startKey: string | null | undefined;
8+
limit: number;
9+
nextKey: string | null | undefined;
10+
blackList: Record<HandleKey, Black>;
11+
};

src/solapi.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
RequestKakaoChannelTokenResponse,
3030
SingleMessageSentResponse,
3131
} from './responses/messageResponses';
32+
import { GetBlacksResponse } from './responses/getBlacksResponse';
3233
import {GroupId} from './types/commonTypes';
3334
import {formatISO} from 'date-fns';
3435
import ImageToBase64 from 'image-to-base64';
@@ -70,6 +71,10 @@ import {
7071
GetGroupsFinalizeRequest,
7172
GetGroupsRequest,
7273
} from './requests/messages/groups/getGroupsRequest';
74+
import {
75+
GetBlacksFinalizeRequest,
76+
GetBlacksRequest,
77+
} from './requests/getBlacksRequest';
7378
import {
7479
GetMessagesRequest,
7580
GetMessagesFinalizeRequest,
@@ -343,7 +348,7 @@ export class SolapiMessageService {
343348
async getGroups(data?: GetGroupsRequest) {
344349
let payload: GetGroupsFinalizeRequest = {};
345350
if (data) {
346-
payload = new GetGroupsFinalizeRequest(payload);
351+
payload = new GetGroupsFinalizeRequest(data);
347352
}
348353
const parameter = qs.stringify(payload, {
349354
indices: false,
@@ -849,4 +854,29 @@ export class SolapiMessageService {
849854

850855
return new KakaoAlimtalkTemplate(response);
851856
}
857+
858+
/**
859+
* 080 수신 거부 조회
860+
* @param data 080 수신 거부 상세 조회용 request 데이터
861+
* @returns GetBlacksResponse
862+
*/
863+
async getBlacks(data?: GetBlacksRequest): Promise<GetBlacksResponse> {
864+
let payload: GetBlacksFinalizeRequest = { type: 'DENIAL' };
865+
if (data) {
866+
payload = new GetBlacksFinalizeRequest(data);
867+
}
868+
const parameter = qs.stringify(payload, {
869+
indices: false,
870+
addQueryPrefix: true,
871+
});
872+
const endpoint = `${this.baseUrl}/iam/v1/black${parameter}`;
873+
const requestConfig: RequestConfig = {
874+
method: 'GET',
875+
url: endpoint,
876+
};
877+
return defaultFetcher<never, GetBlacksResponse>(
878+
this.authInfo,
879+
requestConfig,
880+
);
881+
}
852882
}

src/types/commonTypes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ export type Group = {
8686
dateUpdated: string;
8787
};
8888

89+
export type HandleKey = string;
90+
91+
export type Black = {
92+
handleKey: HandleKey;
93+
type: 'DENIAL';
94+
senderNumber: string;
95+
recipientNumber: string
96+
dateCreated: string;
97+
dateUpdated: string
98+
}
99+
89100
/**
90101
* @description 검색 조건 파라미터
91102
* @see https://docs.solapi.com/api-reference/overview#operator

0 commit comments

Comments
 (0)