UNPKG

coolsms-node-sdk

Version:

CoolSMS SDK for Node.js(Server Side Only)

506 lines (504 loc) 14.7 kB
/** * @name "카카오 버튼타입" */ type KakaoButtonType = 'WL' | 'AL' | 'BK' | 'MD' | 'DS' | 'BC' | 'BT' | 'AC'; type KakaoButton = { buttonName: string; buttonType: KakaoButtonType; linkMo?: string; linkPc?: string; linkAnd?: string; linkIos?: string; }; declare class KakaoOption { pfId: string; templateId?: string; variables?: Record<string, string>; disableSms: boolean; adFlag: boolean; buttons?: Array<KakaoButton>; imageId?: string; constructor(pfId: string, templateId: string, variables: Record<string, string>, disableSms: boolean, adFlag: boolean, buttons: Array<KakaoButton>, imageId: string); } /** * @name "RCS 버튼타입" */ type RcsButtonType = 'WL' | 'ML' | 'MQ' | 'MR' | 'CA' | 'CL' | 'DL' | 'MS'; type RcsWebButton = { buttonName: string; buttonType: Extract<RcsButtonType, 'WL'>; link: string; }; type RcsMapButton = { buttonName: string; buttonType: Extract<RcsButtonType, 'ML'>; latitude: string; longitude: string; }; type RcsDefaultButton = { buttonName: string; buttonType: Exclude<RcsButtonType, 'WL'>; link: string; }; type RcsButton = RcsWebButton | RcsMapButton | RcsDefaultButton; type AdditionalBody = { title: string; description: string; imaggeId?: string; buttons?: Array<RcsButton>; }; type RcsOptionRequest = { brandId: string; templateId?: string; copyAllowed?: boolean; mmsType?: 'M3' | 'S3' | 'M4' | 'S4' | 'M5' | 'S5' | 'M6' | 'S6'; commercialType?: boolean; variables?: Record<string, string>; disableSms?: boolean; additionalBody?: AdditionalBody; buttons: Array<RcsButton>; }; declare class RcsOption { brandId: string; templateId?: string; copyAllowed?: boolean; mmsType?: 'M3' | 'S3' | 'M4' | 'S4' | 'M5' | 'S5' | 'M6' | 'S6'; commercialType?: boolean; variables?: Record<string, string>; disableSms?: boolean; additionalBody?: AdditionalBody; buttons: Array<RcsButton>; constructor(parameter: RcsOptionRequest); } /** * @name MessageType 메시지 유형(단문 문자, 장문 문자, 알림톡 등) * SMS: 단문 문자 * LMS: 장문 문자 * MMS: 사진 문자 * ATA: 알림톡 * CTA: 친구톡 * CTI: 사진 한장이 포함된 친구톡 * RCS_SMS: RCS 단문 문자 * RCS_LMS: RCS 장문 문자 * RCS_MMS: RCS 사진 문자 * RCS_TPL: RCS 템플릿 * NSA: 네이버 스마트알림(톡톡) */ type MessageType = 'SMS' | 'LMS' | 'MMS' | 'ATA' | 'CTA' | 'CTI' | 'RCS_SMS' | 'RCS_LMS' | 'RCS_MMS' | 'RCS_TPL' | 'NSA'; /** * 메시지 모델 */ declare class Message { /** * 수신번호 */ to: string; /** * 발신번호 */ from: string; /** * 메시지 내용 */ text?: string; /** * 메시지 생성일자 */ dateCreated?: string; /** * 메시지 수정일자 */ dateUpdated?: string; /** * 메시지의 그룹 ID */ groupId?: string; /** * 해당 메시지의 ID */ messageId?: string; /** * MMS 전용 스토리지(이미지) ID */ imageId?: string; /** * @name MessageType 메시지 유형 */ type?: MessageType; /** * 문자 제목(LMS, MMS 전용) */ subject?: string; /** * 메시지 타입 감지 여부(비활성화 반드시 타입이 명시 되어야 함) */ autoTypeDetect: boolean; /** * 카카오 알림톡/친구톡을 위한 프로퍼티 */ kakaoOptions?: KakaoOption; /** * RCS 메시지를 위한 프로퍼티 */ rcsOptions?: RcsOption; /** * 해외 문자 발송을 위한 국가번호(예) "82", "1" 등) */ country?: string | undefined; /** * 메시지 로그 */ log?: Array<object>; constructor(to: string, from: string, text: string, dateCreated: string, dateUpdated: string, groupId: string, messageId: string, imageId: string, type: MessageType, subject: string, autoTypeDetect: boolean, kakaoOptions: KakaoOption, rcsOptions: RcsOption, country: string); } type Count = { total: number; sentTotal: number; sentFailed: number; sentSuccess: number; sentPending: number; sentReplacement: number; refund: number; registeredFailed: number; registeredSuccess: number; }; type CountryChargeStatus = Record<string, number>; type CountForCharge = { sms: CountryChargeStatus; lms: CountryChargeStatus; mms: CountryChargeStatus; ata: CountryChargeStatus; cta: CountryChargeStatus; cti: CountryChargeStatus; nsa: CountryChargeStatus; rcs_sms: CountryChargeStatus; rcs_lms: CountryChargeStatus; rcs_mms: CountryChargeStatus; rcs_tpl: CountryChargeStatus; }; type CommonCashResponse = { requested: number; replacement: number; refund: number; sum: number; }; type MessageTypeRecord = { sms: number; lms: number; mms: number; ata: number; cta: number; cti: number; nsa: number; rcs_sms: number; rcs_lms: number; rcs_mms: number; rcs_tpl: number; }; type App = { profit: MessageTypeRecord; appId: string | null | undefined; }; type Log = Array<object>; type GroupId = string; type Group = { count: { total: number; sentTotal: number; sentFailed: number; sentSuccess: number; sentPending: number; sentReplacement: number; refund: number; registeredFailed: number; registeredSuccess: number; }; balance: CommonCashResponse; point: CommonCashResponse; app: App; sdkVersion: string; osPlatform: string; log: Log; status: string; scheduledDate?: string; dateSent?: string; dateCompleted?: string; isRefunded: boolean; groupId: GroupId; accountId: string; countForCharge: CountForCharge; dateCreated: string; dateUpdated: string; }; type GetGroupMessagesRequest = { startKey?: string; limit?: number; }; type GetGroupsRequest = { startKey?: string; limit?: number; startDate?: string; endDate?: string; }; type DateType = 'CREATED' | 'UPDATED'; type GetMessagesRequestType = { startKey?: string; limit?: number; messageId?: string; messageIds?: Array<string>; groupId?: GroupId; to?: string; from?: string; type?: MessageType; statusCode?: string; duration?: { dateType?: DateType; startDate: string; endDate: string; }; }; type GetStatisticsRequestType = { duration?: { startDate: string | Date; endDate: string | Date; }; masterAccountId: string; }; type FileType = 'KAKAO' | 'MMS' | 'DOCUMENT' | 'RCS'; type SingleMessageSentResponse = { groupId: string; to: string; from: string; type: MessageType; statusMessage: string; country: string; messageId: string; statusCode: string; accountId: string; }; type GroupMessageResponse = { count: Count; countForCharge: CountForCharge; balance: CommonCashResponse; point: CommonCashResponse; app: App; log: Log; status: string; allowDuplicates: boolean; isRefunded: boolean; accountId: string; masterAccountId: string | null; apiVersion: string; groupId: string; price: object; dateCreated: string; dateUpdated: string; }; type AddMessageResult = { to: string; from: string; type: string; country: string; messageId: string; statusCode: string; statusMessage: string; accountId: string; }; type AddMessageResponse = { errorCount: string; resultList: Array<AddMessageResult>; }; type GetMessagesResponse = { startKey: string | null; nextKey: string | null; limit: number; messageList: Record<string, Message>; }; type RemoveGroupMessagesResponse = { groupId: GroupId; errorCount: number; resultList: Array<{ messageId: string; resultCode: string; }>; }; type GetGroupsResponse = { startKey: string | null | undefined; limit: number; nextKey: string | null | undefined; groupList: Record<GroupId, Group>; }; type StatisticsPeriodResult = { total: number; sms: number; lms: number; mms: number; ata: number; cta: number; cti: number; nsa: number; rcs_sms: number; rcs_lms: number; rcs_mms: number; rcs_tpl: number; }; type GetStatisticsResponse = { balance: number; point: number; monthlyBalanceAvg: number; monthlyPointAvg: number; monthPeriod: Array<{ date: string; balance: number; balanceAvg: number; point: number; pointAvg: number; dayPeriod: Array<{ _id: string; month: string; balance: number; point: number; statusCode: Record<string, MessageTypeRecord>; refund: { balance: number; point: number; }; total: StatisticsPeriodResult; successed: StatisticsPeriodResult; failed: StatisticsPeriodResult; }>; refund: { balance: number; balanceAvg: number; point: number; pointAvg: number; }; total: StatisticsPeriodResult; successed: StatisticsPeriodResult; failed: StatisticsPeriodResult; }>; total: StatisticsPeriodResult; successed: StatisticsPeriodResult; failed: StatisticsPeriodResult; dailyBalanceAvg: number; dailyPointAvg: number; dailyTotalCountAvg: number; dailyFailedCountAvg: number; dailySuccessedCountAvg: number; }; type GetBalanceResponse = { balance: number; point: number; }; type FileUploadResponse = { fileId: string; type: string; link: string | null | undefined; }; export default class CoolsmsMessageService { constructor(apiKey: string, apiSecret: string); /** * 단일 메시지 발송 기능 * @param message 메시지(문자, 알림톡 등) * @param appId appstore용 app id */ sendOne(message: Message, appId?: string): Promise<SingleMessageSentResponse>; /** * 단일 메시지 예약 발송 기능 * @param message 메시지(문자, 알림톡 등) * @param scheduledDate */ sendOneFuture(message: Message, scheduledDate: string | Date): Promise<GroupMessageResponse>; /** * 여러 메시지 즉시 발송 기능 * 한번 요청으로 최대 10,000건의 메시지를 추가할 있습니다. * @param messages 여러 메시지(문자, 알림톡 등) * @param allowDuplicates 중복 수신번호 허용 * @param appId appstore용 app id */ sendMany(messages: Array<Message>, allowDuplicates?: boolean, appId?: string): Promise<GroupMessageResponse>; /** * 여러 메시지 예약 발송 기능 * 한번 요청으로 최대 10,000건의 메시지를 추가할 있습니다. * @param messages 여러 메시지(문자, 알림톡 등) * @param scheduledDate 예약 발송 일자 * @param allowDuplicates 중복 수신번호 허용 * @param appId appstore용 app id */ sendManyFuture(messages: Array<Message>, scheduledDate: string | Date, allowDuplicates?: boolean, appId?: string): Promise<GroupMessageResponse>; /** * 그룹 생성 */ createGroup(allowDuplicates?: boolean, appId?: string): Promise<GroupId>; /** * 그룹 메시지 추가 * 한번 요청으로 최대 10,000건의 메시지를 추가할 있습니다. * @param groupId 생성 Group ID * @param messages 여러 메시지(문자, 알림톡 등) */ addMessagesToGroup(groupId: GroupId, messages: Required<Array<Message>>): Promise<AddMessageResponse>; /** * 그룹 메시지 전송 요청 * @param groupId 생성 Group ID */ sendGroup(groupId: GroupId): Promise<GroupMessageResponse>; /** * 그룹 예약 발송 설정 * @param groupId 생성 Group ID * @param scheduledDate 예약발송 날짜 */ reserveGroup(groupId: GroupId, scheduledDate: Date): Promise<GroupMessageResponse>; /** * 그룹 통계 정보 조회 * @param data 그룹 정보 상세 조회용 request 데이터, date 관련 파라미터는 iso8601 포맷으로 보내야 */ getGroups(data?: GetGroupsRequest): Promise<GetGroupsResponse>; /** * 그룹 메시지 목록 조회 * @param groupId 생성 Group ID * @param data startkey, limit 쿼리 조건 파라미터 */ getGroupMessages(groupId: GroupId, data?: GetGroupMessagesRequest): Promise<GetMessagesResponse>; /** * 그룹 특정 메시지 삭제 * @param groupId 생성 Group Id * @param messageIds 생성 메시지 ID 목록 */ removeGroupMessages(groupId: GroupId, messageIds: Required<Array<string>>): Promise<RemoveGroupMessagesResponse>; /** * 그룹 예약 발송 취소(메시지 실패 전체 처리 됨) * @param groupId 생성 Group ID */ removeReservationToGroup(groupId: GroupId): Promise<GroupMessageResponse>; /** * 그룹 삭제 * @param groupId */ removeGroup(groupId: GroupId): Promise<GroupMessageResponse>; /** * 메시지 목록 조회 * @param data 목록 조회 상세조건 파라미터 */ getMessages(data?: Readonly<GetMessagesRequestType>): Promise<GetMessagesResponse>; /** * 통계 조회 * @param data 통계 상세 조건 파라미터 * @returns GetStatisticsResponse 통계 결과 */ getStatistics(data?: Readonly<GetStatisticsRequestType>): Promise<GetStatisticsResponse>; /** * 잔액조회 * @returns GetBalanceResponse */ getBalance(): Promise<GetBalanceResponse>; /** * 파일(이미지) 업로드 * 카카오 친구톡 이미지는 500kb, MMS는 200kb, 발신번호 서류 인증용 파일은 2mb의 제한이 있음 * @param filePath 해당 파일의 경로 또는 접근 가능한 이미지 URL * @param fileType 저장할 파일의 유형, 예) 카카오 친구톡 이미지 -> KAKAO, MMS용 사진 -> MMS, 발신번호 서류 인증에 쓰이는 문서 -> DOCUMENT, RCS 이미지 -> RCS * @param name 파일 이름 * @param link 파일 링크, 친구톡의 경우 필수 */ uploadFile(filePath: string, fileType: FileType, name?: string, link?: string): Promise<FileUploadResponse>; } //# sourceMappingURL=index.d.ts.map