@ingestkorea/client-sens 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/dist-cjs/SensClient.js +60 -0
- package/dist-cjs/commands/GetRequestResultCommand.js +39 -0
- package/dist-cjs/commands/GetRequestStatusCommand.js +39 -0
- package/dist-cjs/commands/ListChannelsCommand.js +39 -0
- package/dist-cjs/commands/SendAlimtalkCommand.js +39 -0
- package/dist-cjs/commands/index.js +20 -0
- package/dist-cjs/index.js +18 -0
- package/dist-cjs/middleware/index.js +17 -0
- package/dist-cjs/middleware/signer.js +31 -0
- package/dist-cjs/models/GetRequestResult.js +5 -0
- package/dist-cjs/models/GetRequestStatus.js +5 -0
- package/dist-cjs/models/ListChannels.js +5 -0
- package/dist-cjs/models/SendAlimtalk.js +7 -0
- package/dist-cjs/models/SensCommand.js +11 -0
- package/dist-cjs/models/index.js +21 -0
- package/dist-cjs/protocols/GetRequestResult.js +77 -0
- package/dist-cjs/protocols/GetRequestStatus.js +76 -0
- package/dist-cjs/protocols/ListChannels.js +60 -0
- package/dist-cjs/protocols/SendAlimtalk.js +73 -0
- package/dist-cjs/protocols/constants.js +55 -0
- package/dist-cjs/protocols/index.js +20 -0
- package/dist-es/SensClient.js +45 -0
- package/dist-es/commands/GetRequestResultCommand.js +24 -0
- package/dist-es/commands/GetRequestStatusCommand.js +24 -0
- package/dist-es/commands/ListChannelsCommand.js +24 -0
- package/dist-es/commands/SendAlimtalkCommand.js +24 -0
- package/dist-es/commands/index.js +4 -0
- package/dist-es/index.js +2 -0
- package/dist-es/middleware/index.js +1 -0
- package/dist-es/middleware/signer.js +23 -0
- package/dist-es/models/GetRequestResult.js +4 -0
- package/dist-es/models/GetRequestStatus.js +4 -0
- package/dist-es/models/ListChannels.js +4 -0
- package/dist-es/models/SendAlimtalk.js +6 -0
- package/dist-es/models/SensCommand.js +7 -0
- package/dist-es/models/index.js +5 -0
- package/dist-es/protocols/GetRequestResult.js +63 -0
- package/dist-es/protocols/GetRequestStatus.js +62 -0
- package/dist-es/protocols/ListChannels.js +46 -0
- package/dist-es/protocols/SendAlimtalk.js +59 -0
- package/dist-es/protocols/constants.js +41 -0
- package/dist-es/protocols/index.js +4 -0
- package/dist-types/SensClient.d.ts +21 -0
- package/dist-types/commands/GetRequestResultCommand.d.ts +13 -0
- package/dist-types/commands/GetRequestStatusCommand.d.ts +13 -0
- package/dist-types/commands/ListChannelsCommand.d.ts +13 -0
- package/dist-types/commands/SendAlimtalkCommand.d.ts +13 -0
- package/dist-types/commands/index.d.ts +4 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/middleware/index.d.ts +1 -0
- package/dist-types/middleware/signer.d.ts +3 -0
- package/dist-types/models/GetRequestResult.d.ts +20 -0
- package/dist-types/models/GetRequestStatus.d.ts +19 -0
- package/dist-types/models/ListChannels.d.ts +14 -0
- package/dist-types/models/SendAlimtalk.d.ts +33 -0
- package/dist-types/models/SensCommand.d.ts +7 -0
- package/dist-types/models/index.d.ts +5 -0
- package/dist-types/protocols/GetRequestResult.d.ts +8 -0
- package/dist-types/protocols/GetRequestStatus.d.ts +8 -0
- package/dist-types/protocols/ListChannels.d.ts +8 -0
- package/dist-types/protocols/SendAlimtalk.d.ts +8 -0
- package/dist-types/protocols/constants.d.ts +3 -0
- package/dist-types/protocols/index.d.ts +4 -0
- package/package.json +33 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.deserializeIngestkorea_restJson_ListChannelsChannelInfo = exports.deserializeIngestkorea_restJson_ListChannelsOutput = exports.deserializeIngestkorea_restJson_ListChannelsCommand = exports.serializeIngestkorea_restJson_ListChannelsCommand = void 0;
|
|
13
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const serializeIngestkorea_restJson_ListChannelsCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
17
|
+
const path = "/alimtalk/v2/services/" + config.serviceId + "/channels";
|
|
18
|
+
const headers = {
|
|
19
|
+
"host": hostname
|
|
20
|
+
};
|
|
21
|
+
return new util_http_handler_1.HttpRequest({
|
|
22
|
+
protocol: 'https:',
|
|
23
|
+
method: 'GET',
|
|
24
|
+
hostname: hostname,
|
|
25
|
+
path: path,
|
|
26
|
+
headers: headers
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
exports.serializeIngestkorea_restJson_ListChannelsCommand = serializeIngestkorea_restJson_ListChannelsCommand;
|
|
30
|
+
const deserializeIngestkorea_restJson_ListChannelsCommand = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
if (output.statusCode > 300)
|
|
32
|
+
yield (0, constants_1.parseErrorBody)(output);
|
|
33
|
+
const data = yield (0, constants_1.parseBody)(output); // ListChannelsOutput
|
|
34
|
+
let contents = {};
|
|
35
|
+
contents = yield (0, exports.deserializeIngestkorea_restJson_ListChannelsOutput)(data);
|
|
36
|
+
const response = Object.assign({}, contents);
|
|
37
|
+
return response;
|
|
38
|
+
});
|
|
39
|
+
exports.deserializeIngestkorea_restJson_ListChannelsCommand = deserializeIngestkorea_restJson_ListChannelsCommand;
|
|
40
|
+
const deserializeIngestkorea_restJson_ListChannelsOutput = (outputs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
return {
|
|
42
|
+
channels: (0, exports.deserializeIngestkorea_restJson_ListChannelsChannelInfo)(outputs)
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
exports.deserializeIngestkorea_restJson_ListChannelsOutput = deserializeIngestkorea_restJson_ListChannelsOutput;
|
|
46
|
+
const deserializeIngestkorea_restJson_ListChannelsChannelInfo = (outputs) => {
|
|
47
|
+
const result = outputs.map(output => {
|
|
48
|
+
return {
|
|
49
|
+
createTime: output.createTime != undefined ? output.createTime : undefined,
|
|
50
|
+
updateTime: output.updateTime != undefined ? output.updateTime : undefined,
|
|
51
|
+
serviceId: output.serviceId != undefined ? output.serviceId : undefined,
|
|
52
|
+
channelId: output.channelId != undefined ? output.channelId : undefined,
|
|
53
|
+
channelName: output.channelName != undefined ? output.channelName : undefined,
|
|
54
|
+
channelStatus: output.channelStatus != undefined ? output.channelStatus : undefined,
|
|
55
|
+
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
exports.deserializeIngestkorea_restJson_ListChannelsChannelInfo = deserializeIngestkorea_restJson_ListChannelsChannelInfo;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.deserializeIngestkorea_restJson_ReceivedMessages = exports.deserializeIngestkorea_restJson_SendMessageOutput = exports.deserializeIngestkorea_restJson_SendAlimtalkCommand = exports.serializeIngestkorea_restJson_SendAlimtalkCommand = void 0;
|
|
13
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const serializeIngestkorea_restJson_SendAlimtalkCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
17
|
+
const path = "/alimtalk/v2/services/" + config.serviceId + "/messages";
|
|
18
|
+
const headers = {
|
|
19
|
+
"content-type": "application/json; charset=utf-8",
|
|
20
|
+
"host": hostname
|
|
21
|
+
};
|
|
22
|
+
const body = JSON.stringify({
|
|
23
|
+
plusFriendId: input.plusFriendId,
|
|
24
|
+
templateCode: input.templateCode,
|
|
25
|
+
messages: input.messages
|
|
26
|
+
});
|
|
27
|
+
return new util_http_handler_1.HttpRequest({
|
|
28
|
+
protocol: 'https:',
|
|
29
|
+
method: 'POST',
|
|
30
|
+
hostname: hostname,
|
|
31
|
+
path: path,
|
|
32
|
+
headers: headers,
|
|
33
|
+
body: body
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
exports.serializeIngestkorea_restJson_SendAlimtalkCommand = serializeIngestkorea_restJson_SendAlimtalkCommand;
|
|
37
|
+
const deserializeIngestkorea_restJson_SendAlimtalkCommand = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
if (output.statusCode > 300)
|
|
39
|
+
yield (0, constants_1.parseErrorBody)(output);
|
|
40
|
+
const data = yield (0, constants_1.parseBody)(output); // SendAlimtalkCommandOutput
|
|
41
|
+
let contents = {};
|
|
42
|
+
contents = yield (0, exports.deserializeIngestkorea_restJson_SendMessageOutput)(data);
|
|
43
|
+
const response = Object.assign({}, contents);
|
|
44
|
+
return response;
|
|
45
|
+
});
|
|
46
|
+
exports.deserializeIngestkorea_restJson_SendAlimtalkCommand = deserializeIngestkorea_restJson_SendAlimtalkCommand;
|
|
47
|
+
const deserializeIngestkorea_restJson_SendMessageOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
return {
|
|
49
|
+
requestId: output.requestId != undefined ? output.requestId : undefined,
|
|
50
|
+
requestTime: output.requestTime != undefined ? output.requestTime : undefined,
|
|
51
|
+
statusCode: output.statusCode != undefined ? output.statusCode : undefined,
|
|
52
|
+
statusName: output.statusName != undefined ? output.statusName : undefined,
|
|
53
|
+
messages: output.messages != undefined ?
|
|
54
|
+
(0, exports.deserializeIngestkorea_restJson_ReceivedMessages)(output.messages) : undefined,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
exports.deserializeIngestkorea_restJson_SendMessageOutput = deserializeIngestkorea_restJson_SendMessageOutput;
|
|
58
|
+
const deserializeIngestkorea_restJson_ReceivedMessages = (outputs) => {
|
|
59
|
+
const result = outputs.map(output => {
|
|
60
|
+
return {
|
|
61
|
+
messageId: output.messageId != undefined ? output.messageId : undefined,
|
|
62
|
+
to: output.to != undefined ? output.to : undefined,
|
|
63
|
+
countryCode: output.countryCode != undefined ? output.countryCode : undefined,
|
|
64
|
+
content: output.content != undefined ? output.content : undefined,
|
|
65
|
+
requestStatusCode: output.requestStatusCode != undefined ? output.requestStatusCode : undefined,
|
|
66
|
+
requestStatusName: output.requestStatusName != undefined ? output.requestStatusName : undefined,
|
|
67
|
+
requestStatusDesc: output.requestStatusDesc != undefined ? output.requestStatusDesc : undefined,
|
|
68
|
+
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
exports.deserializeIngestkorea_restJson_ReceivedMessages = deserializeIngestkorea_restJson_ReceivedMessages;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseErrorBody = exports.parseBody = void 0;
|
|
13
|
+
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
14
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
15
|
+
const parseBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { statusCode, headers, body: streamBody } = output;
|
|
17
|
+
const isValid = yield verifyJsonHeader(headers['content-type']);
|
|
18
|
+
if (!isValid) {
|
|
19
|
+
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
20
|
+
let customError = new util_error_handler_1.IngestkoreaError({
|
|
21
|
+
code: 400, type: 'Bad Request',
|
|
22
|
+
message: 'Invalid Request', description: 'content-type is not application/json'
|
|
23
|
+
});
|
|
24
|
+
if ((0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode))
|
|
25
|
+
customError.error.code = statusCode;
|
|
26
|
+
throw customError;
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
|
|
30
|
+
if (data.length)
|
|
31
|
+
return JSON.parse(data);
|
|
32
|
+
return {};
|
|
33
|
+
});
|
|
34
|
+
exports.parseBody = parseBody;
|
|
35
|
+
const parseErrorBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const { statusCode, headers, body: streamBody } = output;
|
|
37
|
+
const isValid = yield verifyJsonHeader(headers['content-type']);
|
|
38
|
+
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
39
|
+
let customError = new util_error_handler_1.IngestkoreaError({
|
|
40
|
+
code: 400, type: 'Bad Request',
|
|
41
|
+
message: 'Invalid Request', description: 'content-type is not application/json'
|
|
42
|
+
});
|
|
43
|
+
if ((0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode))
|
|
44
|
+
customError.error.code = statusCode;
|
|
45
|
+
if (!isValid)
|
|
46
|
+
throw customError;
|
|
47
|
+
const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
|
|
48
|
+
if (data.length)
|
|
49
|
+
customError.error.description = JSON.parse(data);
|
|
50
|
+
throw customError;
|
|
51
|
+
});
|
|
52
|
+
exports.parseErrorBody = parseErrorBody;
|
|
53
|
+
const verifyJsonHeader = (contentType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
return /application\/json/gi.exec(contentType) ? true : false;
|
|
55
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SendAlimtalk"), exports);
|
|
18
|
+
__exportStar(require("./GetRequestStatus"), exports);
|
|
19
|
+
__exportStar(require("./GetRequestResult"), exports);
|
|
20
|
+
__exportStar(require("./ListChannels"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NodeHttpHandler } from '@ingestkorea/util-http-handler';
|
|
2
|
+
import { IngestkoreaError } from '@ingestkorea/util-error-handler';
|
|
3
|
+
import { middlewareSigner } from './middleware';
|
|
4
|
+
;
|
|
5
|
+
;
|
|
6
|
+
export class SensClient {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
const resolvedCredentials = resolveCredentials(config);
|
|
9
|
+
const resolvedServiceId = resolveServiceId(config);
|
|
10
|
+
this.config = {
|
|
11
|
+
credentials: { ...resolvedCredentials },
|
|
12
|
+
serviceId: resolvedServiceId
|
|
13
|
+
};
|
|
14
|
+
this.httpHandler = new NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
|
|
15
|
+
}
|
|
16
|
+
;
|
|
17
|
+
async send(command) {
|
|
18
|
+
let input = command.input;
|
|
19
|
+
let request = await command.serialize(input, this.config);
|
|
20
|
+
request = await middlewareSigner(request, this.config);
|
|
21
|
+
let { response } = await this.httpHandler.handle(request);
|
|
22
|
+
let output = await command.deserialize(response);
|
|
23
|
+
return output;
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
const resolveCredentials = (config) => {
|
|
29
|
+
const { credentials } = config;
|
|
30
|
+
if (!credentials)
|
|
31
|
+
throw new IngestkoreaError({
|
|
32
|
+
code: 401, type: 'Unauthorized',
|
|
33
|
+
message: 'Invalid Credentials', description: 'Invalid Credentials'
|
|
34
|
+
});
|
|
35
|
+
return credentials;
|
|
36
|
+
};
|
|
37
|
+
const resolveServiceId = (config) => {
|
|
38
|
+
const { serviceId } = config;
|
|
39
|
+
if (!serviceId)
|
|
40
|
+
throw new IngestkoreaError({
|
|
41
|
+
code: 401, type: 'Unauthorized',
|
|
42
|
+
message: 'Invalid Credentials', description: 'Invalid ServiceId'
|
|
43
|
+
});
|
|
44
|
+
return serviceId;
|
|
45
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SensCommand } from '../models';
|
|
2
|
+
import { serializeIngestkorea_restJson_GetRequestResultCommand, deserializeIngestkorea_restJson_GetRequestResultCommand } from '../protocols/GetRequestResult';
|
|
3
|
+
;
|
|
4
|
+
;
|
|
5
|
+
export class GetRequestResultCommand extends SensCommand {
|
|
6
|
+
constructor(input) {
|
|
7
|
+
super(input);
|
|
8
|
+
this.input = {
|
|
9
|
+
...input
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
async serialize(input, config) {
|
|
14
|
+
let request = await serializeIngestkorea_restJson_GetRequestResultCommand(input, config);
|
|
15
|
+
return request;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
async deserialize(response) {
|
|
19
|
+
let output = await deserializeIngestkorea_restJson_GetRequestResultCommand(response);
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
}
|
|
24
|
+
;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SensCommand } from '../models';
|
|
2
|
+
import { serializeIngestkorea_restJson_GetRequestStatusCommand, deserializeIngestkorea_restJson_GetRequestStatusCommand } from '../protocols/GetRequestStatus';
|
|
3
|
+
;
|
|
4
|
+
;
|
|
5
|
+
export class GetRequestStatusCommand extends SensCommand {
|
|
6
|
+
constructor(input) {
|
|
7
|
+
super(input);
|
|
8
|
+
this.input = {
|
|
9
|
+
...input
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
async serialize(input, config) {
|
|
14
|
+
let request = await serializeIngestkorea_restJson_GetRequestStatusCommand(input, config);
|
|
15
|
+
return request;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
async deserialize(response) {
|
|
19
|
+
let output = await deserializeIngestkorea_restJson_GetRequestStatusCommand(response);
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
}
|
|
24
|
+
;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SensCommand } from '../models';
|
|
2
|
+
import { serializeIngestkorea_restJson_ListChannelsCommand, deserializeIngestkorea_restJson_ListChannelsCommand, } from '../protocols/ListChannels';
|
|
3
|
+
;
|
|
4
|
+
;
|
|
5
|
+
export class ListChannelsCommand extends SensCommand {
|
|
6
|
+
constructor(input) {
|
|
7
|
+
super(input);
|
|
8
|
+
this.input = {
|
|
9
|
+
...input
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
async serialize(input, config) {
|
|
14
|
+
let request = await serializeIngestkorea_restJson_ListChannelsCommand(input, config);
|
|
15
|
+
return request;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
async deserialize(response) {
|
|
19
|
+
let output = await deserializeIngestkorea_restJson_ListChannelsCommand(response);
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
}
|
|
24
|
+
;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SensCommand } from '../models';
|
|
2
|
+
import { serializeIngestkorea_restJson_SendAlimtalkCommand, deserializeIngestkorea_restJson_SendAlimtalkCommand } from '../protocols/SendAlimtalk';
|
|
3
|
+
;
|
|
4
|
+
;
|
|
5
|
+
export class SendAlimtalkCommand extends SensCommand {
|
|
6
|
+
constructor(input) {
|
|
7
|
+
super(input);
|
|
8
|
+
this.input = {
|
|
9
|
+
...input
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
async serialize(input, config) {
|
|
14
|
+
let request = await serializeIngestkorea_restJson_SendAlimtalkCommand(input, config);
|
|
15
|
+
return request;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
async deserialize(response) {
|
|
19
|
+
let output = await deserializeIngestkorea_restJson_SendAlimtalkCommand(response);
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
;
|
|
23
|
+
}
|
|
24
|
+
;
|
package/dist-es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './signer';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createHmac } from 'crypto';
|
|
2
|
+
export const middlewareSigner = async (request, config) => {
|
|
3
|
+
const { accessKey, secretKey } = config.credentials;
|
|
4
|
+
const method = request.method;
|
|
5
|
+
const queryString = new URLSearchParams(request.query).toString();
|
|
6
|
+
const path = queryString ? `${request.path}?${queryString}` : request.path;
|
|
7
|
+
const space = " ";
|
|
8
|
+
const newLine = "\n";
|
|
9
|
+
const timestamp = new Date().getTime().toString();
|
|
10
|
+
const stringToSign = [
|
|
11
|
+
method + space + path,
|
|
12
|
+
timestamp,
|
|
13
|
+
accessKey
|
|
14
|
+
].join(newLine);
|
|
15
|
+
const signature = createHmac("sha256", secretKey).update(stringToSign).digest('base64');
|
|
16
|
+
request.headers = {
|
|
17
|
+
...request.headers,
|
|
18
|
+
['x-ncp-iam-access-key']: accessKey,
|
|
19
|
+
['x-ncp-apigw-timestamp']: timestamp,
|
|
20
|
+
['x-ncp-apigw-signature-v2']: signature
|
|
21
|
+
};
|
|
22
|
+
return request;
|
|
23
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { HttpRequest } from '@ingestkorea/util-http-handler';
|
|
2
|
+
import { parseBody, parseErrorBody } from './constants';
|
|
3
|
+
export const serializeIngestkorea_restJson_GetRequestResultCommand = async (input, config) => {
|
|
4
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
5
|
+
const path = "/alimtalk/v2/services/" + config.serviceId + "/messages/" + input.messageId;
|
|
6
|
+
const headers = {
|
|
7
|
+
"host": hostname
|
|
8
|
+
};
|
|
9
|
+
return new HttpRequest({
|
|
10
|
+
protocol: 'https:',
|
|
11
|
+
method: 'GET',
|
|
12
|
+
hostname: hostname,
|
|
13
|
+
path: path,
|
|
14
|
+
headers: headers
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const deserializeIngestkorea_restJson_GetRequestResultCommand = async (output) => {
|
|
18
|
+
if (output.statusCode > 300)
|
|
19
|
+
await parseErrorBody(output);
|
|
20
|
+
const data = await parseBody(output); // GetRequestResultOutput
|
|
21
|
+
let contents = {};
|
|
22
|
+
contents = await deserializeIngestkorea_restJson_GetRequestResultOutput(data);
|
|
23
|
+
const response = {
|
|
24
|
+
...contents
|
|
25
|
+
};
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
|
+
export const deserializeIngestkorea_restJson_GetRequestResultOutput = async (output) => {
|
|
29
|
+
return {
|
|
30
|
+
requestId: output.requestId != undefined ? output.requestId : undefined,
|
|
31
|
+
messageId: output.messageId != undefined ? output.messageId : undefined,
|
|
32
|
+
to: output.to != undefined ? output.to : undefined,
|
|
33
|
+
countryCode: output.countryCode != undefined ? output.countryCode : undefined,
|
|
34
|
+
content: output.content != undefined ? output.content : undefined,
|
|
35
|
+
requestStatusCode: output.requestStatusCode != undefined ? output.requestStatusCode : undefined,
|
|
36
|
+
requestStatusName: output.requestStatusName != undefined ? output.requestStatusName : undefined,
|
|
37
|
+
requestStatusDesc: output.requestStatusDesc != undefined ? output.requestStatusDesc : undefined,
|
|
38
|
+
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined,
|
|
39
|
+
requestTime: output.requestTime != undefined ? output.requestTime : undefined,
|
|
40
|
+
plusFriendId: output.plusFriendId != undefined ? output.plusFriendId : undefined,
|
|
41
|
+
templateCode: output.templateCode != undefined ? output.templateCode : undefined,
|
|
42
|
+
completeTime: output.completeTime != undefined ? output.completeTime : undefined,
|
|
43
|
+
messageStatusCode: output.messageStatusCode != undefined ? output.messageStatusCode : undefined,
|
|
44
|
+
messageStatusName: output.messageStatusName != undefined ? output.messageStatusName : undefined,
|
|
45
|
+
messageStatusDesc: output.messageStatusDesc != undefined ? output.messageStatusDesc : undefined,
|
|
46
|
+
failover: output.failover != undefined ?
|
|
47
|
+
deserializeIngestkorea_restJson_GetRequestResultFailover(output.failover) : undefined,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export const deserializeIngestkorea_restJson_GetRequestResultFailover = (output) => {
|
|
51
|
+
return {
|
|
52
|
+
smsServiceId: output.smsServiceId != undefined ? output.smsServiceId : undefined,
|
|
53
|
+
requestId: output.requestId != undefined ? output.requestId : undefined,
|
|
54
|
+
requestStatusCode: output.requestStatusCode != undefined ? output.requestStatusCode : undefined,
|
|
55
|
+
requestStatusName: output.requestStatusName != undefined ? output.requestStatusName : undefined,
|
|
56
|
+
requestStatusDesc: output.requestStatusDesc != undefined ? output.requestStatusDesc : undefined,
|
|
57
|
+
messageId: output.messageId != undefined ? output.messageId : undefined,
|
|
58
|
+
messageStatus: output.messageStatus != undefined ? output.messageStatus : undefined,
|
|
59
|
+
messageStatusCode: output.messageStatusCode != undefined ? output.messageStatusCode : undefined,
|
|
60
|
+
messageStatusName: output.messageStatusName != undefined ? output.messageStatusName : undefined,
|
|
61
|
+
messageStatusDesc: output.messageStatusDesc != undefined ? output.messageStatusDesc : undefined,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { HttpRequest } from '@ingestkorea/util-http-handler';
|
|
2
|
+
import { parseBody, parseErrorBody } from './constants';
|
|
3
|
+
export const serializeIngestkorea_restJson_GetRequestStatusCommand = async (input, config) => {
|
|
4
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
5
|
+
const path = "/alimtalk/v2/services/" + config.serviceId + "/messages";
|
|
6
|
+
const headers = {
|
|
7
|
+
"host": hostname
|
|
8
|
+
};
|
|
9
|
+
const query = {
|
|
10
|
+
requestId: input.requestId
|
|
11
|
+
};
|
|
12
|
+
return new HttpRequest({
|
|
13
|
+
protocol: 'https:',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
hostname: hostname,
|
|
16
|
+
path: path,
|
|
17
|
+
headers: headers,
|
|
18
|
+
query: query
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export const deserializeIngestkorea_restJson_GetRequestStatusCommand = async (output) => {
|
|
22
|
+
if (output.statusCode > 300)
|
|
23
|
+
await parseErrorBody(output);
|
|
24
|
+
const data = await parseBody(output); // GetRequestStatusOutput
|
|
25
|
+
let contents = {};
|
|
26
|
+
contents = await deserializeIngestkorea_restJson_GetRequestStatusOutput(data);
|
|
27
|
+
const response = {
|
|
28
|
+
...contents
|
|
29
|
+
};
|
|
30
|
+
return response;
|
|
31
|
+
};
|
|
32
|
+
export const deserializeIngestkorea_restJson_GetRequestStatusOutput = async (output) => {
|
|
33
|
+
const { requestId, statusCode, statusName, messages } = output;
|
|
34
|
+
return {
|
|
35
|
+
requestId: requestId != undefined ? requestId : undefined,
|
|
36
|
+
statusCode: statusCode != undefined ? statusCode : undefined,
|
|
37
|
+
statusName: statusName != undefined ? statusName : undefined,
|
|
38
|
+
messages: messages != undefined ? deserializeIngestkorea_restJson_GetRequestStatusMessages(messages) : undefined
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export const deserializeIngestkorea_restJson_GetRequestStatusMessages = (outputs) => {
|
|
42
|
+
const result = outputs.map(output => {
|
|
43
|
+
return {
|
|
44
|
+
messageId: output.messageId != undefined ? output.messageId : undefined,
|
|
45
|
+
to: output.to != undefined ? output.to : undefined,
|
|
46
|
+
countryCode: output.countryCode != undefined ? output.countryCode : undefined,
|
|
47
|
+
content: output.content != undefined ? output.content : undefined,
|
|
48
|
+
requestStatusCode: output.requestStatusCode != undefined ? output.requestStatusCode : undefined,
|
|
49
|
+
requestStatusName: output.requestStatusName != undefined ? output.requestStatusName : undefined,
|
|
50
|
+
requestStatusDesc: output.requestStatusDesc != undefined ? output.requestStatusDesc : undefined,
|
|
51
|
+
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined,
|
|
52
|
+
requestTime: output.requestTime != undefined ? output.requestTime : undefined,
|
|
53
|
+
plusFriendId: output.plusFriendId != undefined ? output.plusFriendId : undefined,
|
|
54
|
+
templateCode: output.templateCode != undefined ? output.templateCode : undefined,
|
|
55
|
+
completeTime: output.completeTime != undefined ? output.completeTime : undefined,
|
|
56
|
+
messageStatusCode: output.messageStatusCode != undefined ? output.messageStatusCode : undefined,
|
|
57
|
+
messageStatusName: output.messageStatusName != undefined ? output.messageStatusName : undefined,
|
|
58
|
+
messageStatusDesc: output.messageStatusDesc != undefined ? output.messageStatusDesc : undefined,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { HttpRequest } from '@ingestkorea/util-http-handler';
|
|
2
|
+
import { parseBody, parseErrorBody } from './constants';
|
|
3
|
+
export const serializeIngestkorea_restJson_ListChannelsCommand = async (input, config) => {
|
|
4
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
5
|
+
const path = "/alimtalk/v2/services/" + config.serviceId + "/channels";
|
|
6
|
+
const headers = {
|
|
7
|
+
"host": hostname
|
|
8
|
+
};
|
|
9
|
+
return new HttpRequest({
|
|
10
|
+
protocol: 'https:',
|
|
11
|
+
method: 'GET',
|
|
12
|
+
hostname: hostname,
|
|
13
|
+
path: path,
|
|
14
|
+
headers: headers
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const deserializeIngestkorea_restJson_ListChannelsCommand = async (output) => {
|
|
18
|
+
if (output.statusCode > 300)
|
|
19
|
+
await parseErrorBody(output);
|
|
20
|
+
const data = await parseBody(output); // ListChannelsOutput
|
|
21
|
+
let contents = {};
|
|
22
|
+
contents = await deserializeIngestkorea_restJson_ListChannelsOutput(data);
|
|
23
|
+
const response = {
|
|
24
|
+
...contents
|
|
25
|
+
};
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
|
+
export const deserializeIngestkorea_restJson_ListChannelsOutput = async (outputs) => {
|
|
29
|
+
return {
|
|
30
|
+
channels: deserializeIngestkorea_restJson_ListChannelsChannelInfo(outputs)
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export const deserializeIngestkorea_restJson_ListChannelsChannelInfo = (outputs) => {
|
|
34
|
+
const result = outputs.map(output => {
|
|
35
|
+
return {
|
|
36
|
+
createTime: output.createTime != undefined ? output.createTime : undefined,
|
|
37
|
+
updateTime: output.updateTime != undefined ? output.updateTime : undefined,
|
|
38
|
+
serviceId: output.serviceId != undefined ? output.serviceId : undefined,
|
|
39
|
+
channelId: output.channelId != undefined ? output.channelId : undefined,
|
|
40
|
+
channelName: output.channelName != undefined ? output.channelName : undefined,
|
|
41
|
+
channelStatus: output.channelStatus != undefined ? output.channelStatus : undefined,
|
|
42
|
+
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return result;
|
|
46
|
+
};
|