Package Exports
- @ingestkorea/client-sens
- @ingestkorea/client-sens/dist-cjs/index.js
- @ingestkorea/client-sens/dist-es/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ingestkorea/client-sens) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@ingestkorea/client-sens
Description
INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
Installing
npm install @ingestkorea/client-sensGetting Started
Pre-requisites
- Use TypeScript v4.x
- Includes the TypeScript definitions for node.
npm install -D @types/node # save dev mode
Support Commands
Kakao Alimtalk
- SendAlimtalk
- GetAlimtalkStatus (
GetRequestStatusis deprecated) - GetAlimtalkResult (
GetRequestResultis deprecated) - GetAlimtalkTemplate (
GetTemplateis deprecated) - ListAlimtalkTemplates (
ListTemplatesis deprecated) - ListAlimtalkChannels (
ListChannelsis deprecated)
SMS(LMS)
- SendSMS
- GetSMSStatus
- GetSMSResult
Import
import {
SensClient,
SendAlimtalkCommand, SendAlimtalkCommandInput,
SendSMSCommand, SendSMSCommandInput,
} from '@ingestkorea/client-sens';Usage
To send a request, you:
- Initiate client with configuration.
- Initiate command with input parameters.
- Call
sendoperation on client with command object as input.
// a client can be shared by different commands.
const client = new SensClient({
credentials: {
accessKey: ACCESS_KEY,
secretKey: SECRET_KEY
},
serviceId: {
sms: 'ncp:sms:kr:123456789xxx:your-service-name', // optional
kakao: 'ncp:kkobizmsg:kr:9876xxx:your-service-name' // optional
// at least one serviceId required
// if you call send operation without serviceId, sdk throw error
}
});SendAlimtalk
let params: SendAlimtalkCommandInput = {
plusFriendId: PLUS_FRIEND_ID,
templateCode: TEMPLATE_CODE,
messages: [
{ to: '01012345678', content: CONTENT }
]
};
let command = new SendAlimtalkCommand(params);SendSMS
/**
* Automatically set message type('SMS' | 'LMS') according to content-length(euc-kr)
* SMS: max 80bytes
* LMS: max 2000bytes
*/
let params: SendSMSCommandInput = {
from: '01012345678',
content: CONTENT,
messages: [
{ to: '01087654321' }
]
};
let command = new SendSMSCommand(params);Async/await
(async () => {
try {
const data = await client.send(command);
console.dir(data, { depth: 4 });
} catch (err){
console.dir(err, { depth: 4 });
};
})();Promises
client.send(command)
.then(data => console.dir(data, { depth: 4 }))
.catch(err => console.dir(err, { depth: 4 }));License
This SDK is distributed under the MIT License, see LICENSE for more information.