Skip to content

Commit 98c35df

Browse files
authored
Merge pull request #55 from hotsoycandy/feature/update-5.2.2
feature/update-5.2.2
2 parents fd70a2b + 57acf1d commit 98c35df

6 files changed

Lines changed: 95 additions & 1 deletion

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.getBlockGroups({
11+
// 해당 그룹이 켜져있는지 아닌지 확인하고 싶을 경우
12+
// status: 'ACTIVE' // 'ACTIVE' 혹은 'INACTIVE'
13+
}).then(res => {
14+
// 목록
15+
console.log('#page1', res.blockGroups);
16+
17+
// 응답에 nextKey가 있을 경우 다음 페이지도 조회 가능
18+
messageService.getBlockGroups({
19+
startKey: res.nextKey
20+
}).then(res => {
21+
console.log('#page2', res.blockGroups);
22+
});
23+
});

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.1",
3+
"version": "5.2.2",
44
"description": "SOLAPI SDK for Node.js(Server Side Only)",
55
"repository": {
66
"type": "git",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface GetBlockGroupsRequest {
2+
status?: 'ACTIVE' | 'INACTIVE';
3+
startKey?: string;
4+
limit?: number;
5+
}
6+
7+
export class GetBlockGroupsFinalizeRequest implements GetBlockGroupsRequest {
8+
status?: 'ACTIVE' | 'INACTIVE';
9+
startKey?: string;
10+
limit?: number;
11+
12+
constructor(parameter: GetBlockGroupsRequest) {
13+
this.status = parameter.status;
14+
this.startKey = parameter.startKey;
15+
this.limit = parameter.limit;
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
BlockGroupId,
3+
BlockGroup
4+
} from '../types/commonTypes';
5+
6+
export type GetBlockGroupsResponse = {
7+
startKey: string | null | undefined;
8+
limit: number;
9+
nextKey: string | null | undefined;
10+
blockGroups: Record<BlockGroupId, BlockGroup>;
11+
};

src/solapi.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
SingleMessageSentResponse,
3131
} from './responses/messageResponses';
3232
import { GetBlacksResponse } from './responses/getBlacksResponse';
33+
import { GetBlockGroupsResponse } from './responses/getBlockGroupsResponse';
3334
import {GroupId} from './types/commonTypes';
3435
import {formatISO} from 'date-fns';
3536
import ImageToBase64 from 'image-to-base64';
@@ -75,6 +76,10 @@ import {
7576
GetBlacksFinalizeRequest,
7677
GetBlacksRequest,
7778
} from './requests/getBlacksRequest';
79+
import {
80+
GetBlockGroupsFinalizeRequest,
81+
GetBlockGroupsRequest
82+
} from './requests/getBlockGroupsRequest';
7883
import {
7984
GetMessagesRequest,
8085
GetMessagesFinalizeRequest,
@@ -879,4 +884,29 @@ export class SolapiMessageService {
879884
requestConfig,
880885
);
881886
}
887+
888+
/**
889+
* 수신 거부 그룹 조회
890+
* @param data 수신 거부 그룹 조회용 request 데이터
891+
* @returns GetBlockGroupsResponse
892+
*/
893+
async getBlockGroups(data?: GetBlockGroupsRequest): Promise<GetBlockGroupsResponse> {
894+
let payload: GetBlockGroupsFinalizeRequest = { };
895+
if (data) {
896+
payload = new GetBlockGroupsFinalizeRequest(data);
897+
}
898+
const parameter = qs.stringify(payload, {
899+
indices: false,
900+
addQueryPrefix: true,
901+
});
902+
const endpoint = `${this.baseUrl}/iam/v1/block/groups${parameter}`;
903+
const requestConfig: RequestConfig = {
904+
method: 'GET',
905+
url: endpoint,
906+
};
907+
return defaultFetcher<never, GetBlockGroupsResponse>(
908+
this.authInfo,
909+
requestConfig,
910+
);
911+
}
882912
}

src/types/commonTypes.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ export type Black = {
9797
dateUpdated: string
9898
}
9999

100+
export type BlockGroupId = string;
101+
102+
export type BlockGroup = {
103+
blockGroupId: BlockGroupId;
104+
accountId: string;
105+
status: 'INACTIVE' | 'ACTIVE';
106+
name: string;
107+
useAll: boolean;
108+
senderNumbers: string[]
109+
dateCreated: string;
110+
dateUpdated: string;
111+
}
112+
100113
/**
101114
* @description 검색 조건 파라미터
102115
* @see https://docs.solapi.com/api-reference/overview#operator

0 commit comments

Comments
 (0)