@ingestkorea/client-sens 1.7.0 → 1.9.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 +1 -1
- package/README.md +98 -63
- package/dist-cjs/SensClient.js +57 -28
- package/dist-cjs/commands/GetAlimtalkResultCommand.js +5 -32
- package/dist-cjs/commands/GetAlimtalkStatusCommand.js +7 -35
- package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +5 -32
- package/dist-cjs/commands/GetSMSResultCommand.js +8 -33
- package/dist-cjs/commands/GetSMSStatusCommand.js +7 -33
- package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +6 -33
- package/dist-cjs/commands/ListAlimtalkStatusCommand.js +29 -35
- package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +5 -32
- package/dist-cjs/commands/ListSMSStatusCommand.js +37 -0
- package/dist-cjs/commands/SendAlimtalkCommand.js +36 -44
- package/dist-cjs/commands/SendMMSCommand.js +67 -103
- package/dist-cjs/commands/SendSMSCommand.js +38 -71
- package/dist-cjs/commands/constants.js +57 -14
- package/dist-cjs/commands/index.js +12 -11
- package/dist-cjs/index.js +2 -2
- package/dist-cjs/middleware/constants.js +10 -0
- package/dist-cjs/middleware/index.js +3 -4
- package/dist-cjs/middleware/middleware-metadata.js +4 -5
- package/dist-cjs/middleware/middleware-retry.js +32 -27
- package/dist-cjs/middleware/middleware-sign.js +10 -9
- package/dist-cjs/models/SendAlimtalk.js +3 -0
- package/dist-cjs/models/SendMMS.js +3 -0
- package/dist-cjs/models/SensClient.js +2 -0
- package/dist-cjs/models/SensErrorInfo.js +13 -0
- package/dist-cjs/models/SensMiddleware.js +2 -0
- package/dist-cjs/models/index.js +17 -14
- package/dist-cjs/protocols/GetAlimtalkResult.js +19 -22
- package/dist-cjs/protocols/GetAlimtalkStatus.js +39 -40
- package/dist-cjs/protocols/GetAlimtalkTemplate.js +56 -90
- package/dist-cjs/protocols/GetSMSResult.js +31 -48
- package/dist-cjs/protocols/GetSMSStatus.js +51 -37
- package/dist-cjs/protocols/ListAlimtalkChannels.js +27 -31
- package/dist-cjs/protocols/ListAlimtalkStatus.js +22 -19
- package/dist-cjs/protocols/ListAlimtalkTemplates.js +33 -25
- package/dist-cjs/protocols/ListSMSStatus.js +48 -0
- package/dist-cjs/protocols/SendAlimtalk.js +23 -27
- package/dist-cjs/protocols/SendMMS.js +8 -38
- package/dist-cjs/protocols/SendSMS.js +20 -22
- package/dist-cjs/protocols/constants.js +103 -34
- package/dist-es/SensClient.js +63 -30
- package/dist-es/commands/GetAlimtalkResultCommand.js +9 -19
- package/dist-es/commands/GetAlimtalkStatusCommand.js +12 -19
- package/dist-es/commands/GetAlimtalkTemplateCommand.js +9 -19
- package/dist-es/commands/GetSMSResultCommand.js +10 -20
- package/dist-es/commands/GetSMSStatusCommand.js +13 -20
- package/dist-es/commands/ListAlimtalkChannelsCommand.js +10 -22
- package/dist-es/commands/ListAlimtalkStatusCommand.js +39 -28
- package/dist-es/commands/ListAlimtalkTemplatesCommand.js +9 -19
- package/dist-es/commands/ListSMSStatusCommand.js +48 -0
- package/dist-es/commands/SendAlimtalkCommand.js +35 -30
- package/dist-es/commands/SendMMSCommand.js +70 -100
- package/dist-es/commands/SendSMSCommand.js +51 -66
- package/dist-es/commands/constants.js +65 -15
- package/dist-es/commands/index.js +28 -11
- package/dist-es/index.js +18 -2
- package/dist-es/middleware/constants.js +10 -0
- package/dist-es/middleware/index.js +19 -4
- package/dist-es/middleware/middleware-metadata.js +11 -5
- package/dist-es/middleware/middleware-retry.js +39 -30
- package/dist-es/middleware/middleware-sign.js +19 -14
- package/dist-es/models/GetAlimtalkResult.js +2 -1
- package/dist-es/models/GetAlimtalkStatus.js +2 -1
- package/dist-es/models/GetAlimtalkTemplate.js +2 -1
- package/dist-es/models/GetSMSResult.js +2 -1
- package/dist-es/models/GetSMSStatus.js +2 -1
- package/dist-es/models/ListAlimtalkChannels.js +2 -1
- package/dist-es/models/ListAlimtalkStatus.js +2 -1
- package/dist-es/models/ListAlimtalkTemplates.js +2 -1
- package/dist-es/models/ListSMSStatus.js +2 -0
- package/dist-es/models/MetadataBearer.js +2 -1
- package/dist-es/models/SendAlimtalk.js +5 -1
- package/dist-es/models/SendMMS.js +5 -1
- package/dist-es/models/SendSMS.js +2 -1
- package/dist-es/models/SensClient.js +2 -0
- package/dist-es/models/SensCommand.js +5 -1
- package/dist-es/models/SensErrorInfo.js +13 -0
- package/dist-es/models/SensMiddleware.js +2 -0
- package/dist-es/models/index.js +33 -14
- package/dist-es/protocols/GetAlimtalkResult.js +24 -23
- package/dist-es/protocols/GetAlimtalkStatus.js +51 -47
- package/dist-es/protocols/GetAlimtalkTemplate.js +78 -87
- package/dist-es/protocols/GetSMSResult.js +40 -47
- package/dist-es/protocols/GetSMSStatus.js +55 -37
- package/dist-es/protocols/ListAlimtalkChannels.js +31 -31
- package/dist-es/protocols/ListAlimtalkStatus.js +26 -32
- package/dist-es/protocols/ListAlimtalkTemplates.js +37 -24
- package/dist-es/protocols/ListSMSStatus.js +42 -0
- package/dist-es/protocols/SendAlimtalk.js +27 -26
- package/dist-es/protocols/SendMMS.js +10 -49
- package/dist-es/protocols/SendSMS.js +24 -31
- package/dist-es/protocols/constants.js +119 -39
- package/dist-types/SensClient.d.ts +3 -20
- package/dist-types/commands/GetAlimtalkResultCommand.d.ts +5 -10
- package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +5 -10
- package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +5 -10
- package/dist-types/commands/GetSMSResultCommand.d.ts +5 -10
- package/dist-types/commands/GetSMSStatusCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkStatusCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +5 -10
- package/dist-types/commands/ListSMSStatusCommand.d.ts +11 -0
- package/dist-types/commands/SendAlimtalkCommand.d.ts +5 -10
- package/dist-types/commands/SendMMSCommand.d.ts +5 -10
- package/dist-types/commands/SendSMSCommand.d.ts +9 -10
- package/dist-types/commands/constants.d.ts +14 -4
- package/dist-types/commands/index.d.ts +12 -11
- package/dist-types/index.d.ts +2 -2
- package/dist-types/middleware/constants.d.ts +7 -0
- package/dist-types/middleware/index.d.ts +3 -4
- package/dist-types/middleware/middleware-metadata.d.ts +2 -2
- package/dist-types/middleware/middleware-retry.d.ts +2 -2
- package/dist-types/middleware/middleware-sign.d.ts +2 -2
- package/dist-types/models/GetAlimtalkResult.d.ts +3 -3
- package/dist-types/models/GetAlimtalkStatus.d.ts +8 -5
- package/dist-types/models/GetAlimtalkTemplate.d.ts +5 -5
- package/dist-types/models/GetSMSResult.d.ts +7 -15
- package/dist-types/models/GetSMSStatus.d.ts +19 -4
- package/dist-types/models/ListAlimtalkChannels.d.ts +4 -4
- package/dist-types/models/ListAlimtalkStatus.d.ts +8 -8
- package/dist-types/models/ListAlimtalkTemplates.d.ts +2 -2
- package/dist-types/models/ListSMSStatus.d.ts +15 -0
- package/dist-types/models/MetadataBearer.d.ts +3 -3
- package/dist-types/models/SendAlimtalk.d.ts +7 -4
- package/dist-types/models/SendMMS.d.ts +5 -3
- package/dist-types/models/SendSMS.d.ts +2 -2
- package/dist-types/models/SensClient.d.ts +17 -0
- package/dist-types/models/SensCommand.d.ts +4 -6
- package/dist-types/models/SensErrorInfo.d.ts +21 -0
- package/dist-types/models/SensMiddleware.d.ts +8 -0
- package/dist-types/models/index.d.ts +17 -14
- package/dist-types/protocols/GetAlimtalkResult.d.ts +4 -11
- package/dist-types/protocols/GetAlimtalkStatus.d.ts +6 -12
- package/dist-types/protocols/GetAlimtalkTemplate.d.ts +4 -14
- package/dist-types/protocols/GetSMSResult.d.ts +4 -12
- package/dist-types/protocols/GetSMSStatus.d.ts +6 -11
- package/dist-types/protocols/ListAlimtalkChannels.d.ts +4 -11
- package/dist-types/protocols/ListAlimtalkStatus.d.ts +4 -10
- package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -12
- package/dist-types/protocols/ListSMSStatus.d.ts +4 -0
- package/dist-types/protocols/SendAlimtalk.d.ts +5 -12
- package/dist-types/protocols/SendMMS.d.ts +4 -10
- package/dist-types/protocols/SendSMS.d.ts +5 -10
- package/dist-types/protocols/constants.d.ts +4 -2
- package/package.json +20 -4
- package/.github/pull_request_template.md +0 -19
- package/dist-cjs/middleware/middleware-sort-headers.js +0 -25
- package/dist-cjs/protocols/index.js +0 -28
- package/dist-es/middleware/middleware-sort-headers.js +0 -12
- package/dist-es/models/Middleware.js +0 -1
- package/dist-es/protocols/index.js +0 -12
- package/dist-types/middleware/middleware-sort-headers.d.ts +0 -2
- package/dist-types/models/Middleware.d.ts +0 -12
- package/dist-types/protocols/index.d.ts +0 -12
- /package/dist-cjs/models/{Middleware.js → ListSMSStatus.js} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
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.de_ListSMSStatusCommand = exports.se_ListSMSStatusCommand = void 0;
|
|
13
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const GetSMSStatus_js_1 = require("./GetSMSStatus.js");
|
|
16
|
+
const se_ListSMSStatusCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const hostname = "sens.apigw.ntruss.com";
|
|
18
|
+
const path = "/sms/v2/services/" + config.serviceId.sms + "/messages";
|
|
19
|
+
const headers = {
|
|
20
|
+
host: hostname,
|
|
21
|
+
};
|
|
22
|
+
const query = Object.entries(input).reduce((acc, [key, value]) => {
|
|
23
|
+
if (value !== undefined && value !== null) {
|
|
24
|
+
acc[key] = String(value);
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
return new util_http_handler_1.HttpRequest({
|
|
29
|
+
protocol: "https:",
|
|
30
|
+
method: "GET",
|
|
31
|
+
hostname,
|
|
32
|
+
path,
|
|
33
|
+
query,
|
|
34
|
+
headers,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
exports.se_ListSMSStatusCommand = se_ListSMSStatusCommand;
|
|
38
|
+
const de_ListSMSStatusCommand = (response, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
if (response.statusCode >= 300)
|
|
40
|
+
yield (0, constants_js_1.parseErrorBody)(response);
|
|
41
|
+
const data = yield (0, constants_js_1.parseBody)(response);
|
|
42
|
+
const contents = de_ListSMSStatusResult(data);
|
|
43
|
+
return Object.assign({ $metadata: (0, constants_js_1.deserializeMetadata)(response) }, (0, constants_js_1.compact)(contents));
|
|
44
|
+
});
|
|
45
|
+
exports.de_ListSMSStatusCommand = de_ListSMSStatusCommand;
|
|
46
|
+
const de_ListSMSStatusResult = (output) => {
|
|
47
|
+
return (0, GetSMSStatus_js_1.de_GetSMSStatusResult)(output);
|
|
48
|
+
};
|
|
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.de_AlimtalkMessageRequestStatus = exports.de_SendAlimtalkCommand = exports.se_SendAlimtalkCommand = void 0;
|
|
13
13
|
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const se_SendAlimtalkCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const hostname = "sens.apigw.ntruss.com";
|
|
17
17
|
const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/messages";
|
|
18
18
|
const headers = {
|
|
@@ -27,39 +27,35 @@ const serializeIngestkorea_restJson_SendAlimtalkCommand = (input, config) => __a
|
|
|
27
27
|
return new util_http_handler_1.HttpRequest({
|
|
28
28
|
protocol: "https:",
|
|
29
29
|
method: "POST",
|
|
30
|
-
hostname
|
|
31
|
-
path
|
|
32
|
-
headers
|
|
33
|
-
body
|
|
30
|
+
hostname,
|
|
31
|
+
path,
|
|
32
|
+
headers,
|
|
33
|
+
body,
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
exports.
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
contents = yield (0, exports.deserializeIngestkorea_restJson_SendMessageOutput)(data);
|
|
44
|
-
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
36
|
+
exports.se_SendAlimtalkCommand = se_SendAlimtalkCommand;
|
|
37
|
+
const de_SendAlimtalkCommand = (response, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
if (response.statusCode >= 300)
|
|
39
|
+
yield (0, constants_js_1.parseErrorBody)(response);
|
|
40
|
+
const data = yield (0, constants_js_1.parseBody)(response);
|
|
41
|
+
const contents = de_SendAlimtalkResult(data);
|
|
42
|
+
return Object.assign({ $metadata: (0, constants_js_1.deserializeMetadata)(response) }, (0, constants_js_1.compact)(contents));
|
|
45
43
|
});
|
|
46
|
-
exports.
|
|
47
|
-
const
|
|
44
|
+
exports.de_SendAlimtalkCommand = de_SendAlimtalkCommand;
|
|
45
|
+
const de_SendAlimtalkResult = (output) => {
|
|
48
46
|
return {
|
|
49
47
|
requestId: output.requestId != undefined ? output.requestId : undefined,
|
|
50
|
-
requestTime: output.requestTime != undefined ? output.requestTime : undefined,
|
|
48
|
+
requestTime: output.requestTime != undefined ? (0, constants_js_1.convertToUtc)(output.requestTime) : undefined,
|
|
51
49
|
statusCode: output.statusCode != undefined ? output.statusCode : undefined,
|
|
52
50
|
statusName: output.statusName != undefined ? output.statusName : undefined,
|
|
53
|
-
messages: output.messages
|
|
51
|
+
messages: output.messages ? de_AlimtalkMessageRequestStatusList(output.messages) : [],
|
|
54
52
|
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const result = outputs.map(exports.parseReceivedMessage);
|
|
53
|
+
};
|
|
54
|
+
const de_AlimtalkMessageRequestStatusList = (output) => {
|
|
55
|
+
const result = (output || []).filter((e) => e != null).map((entry) => (0, exports.de_AlimtalkMessageRequestStatus)(entry));
|
|
59
56
|
return result;
|
|
60
57
|
};
|
|
61
|
-
|
|
62
|
-
const parseReceivedMessage = (output) => {
|
|
58
|
+
const de_AlimtalkMessageRequestStatus = (output) => {
|
|
63
59
|
return {
|
|
64
60
|
messageId: output.messageId != undefined ? output.messageId : undefined,
|
|
65
61
|
to: output.to != undefined ? output.to : undefined,
|
|
@@ -71,4 +67,4 @@ const parseReceivedMessage = (output) => {
|
|
|
71
67
|
useSmsFailover: output.useSmsFailover != undefined ? output.useSmsFailover : undefined,
|
|
72
68
|
};
|
|
73
69
|
};
|
|
74
|
-
exports.
|
|
70
|
+
exports.de_AlimtalkMessageRequestStatus = de_AlimtalkMessageRequestStatus;
|
|
@@ -9,43 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const hostname = "sens.apigw.ntruss.com";
|
|
17
|
-
const path = "/sms/v2/services/" + config.serviceId.sms + "/messages";
|
|
18
|
-
const headers = {
|
|
19
|
-
"content-type": "application/json; charset=utf-8",
|
|
20
|
-
host: hostname,
|
|
21
|
-
};
|
|
22
|
-
const body = JSON.stringify(Object.assign(Object.assign(Object.assign({ from: input.from, content: input.content, messages: input.messages, type: input.type != undefined ? input.type : "MMS", files: input.files }, (input.contentType != undefined && { contentType: input.contentType })), (input.countryCode != undefined && { countryCode: input.countryCode })), (input.subject != undefined && { subject: input.subject })));
|
|
23
|
-
return new util_http_handler_1.HttpRequest({
|
|
24
|
-
protocol: "https:",
|
|
25
|
-
method: "POST",
|
|
26
|
-
hostname: hostname,
|
|
27
|
-
path: path,
|
|
28
|
-
headers: headers,
|
|
29
|
-
body: body,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
exports.serializeIngestkorea_restJson_SendMMSCommand = serializeIngestkorea_restJson_SendMMSCommand;
|
|
33
|
-
const deserializeIngestkorea_restJson_SendMMSCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const { response: httpResponse, output } = response;
|
|
35
|
-
if (httpResponse.statusCode > 300)
|
|
36
|
-
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
37
|
-
const data = yield (0, constants_1.parseBody)(httpResponse); // SendSMSOutput
|
|
38
|
-
let contents = {};
|
|
39
|
-
contents = yield (0, exports.deserializeIngestkorea_restJson_SendMMSOutput)(data);
|
|
40
|
-
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
12
|
+
exports.de_SendMMSCommand = exports.se_SendMMSCommand = void 0;
|
|
13
|
+
const SendSMS_js_1 = require("./SendSMS.js");
|
|
14
|
+
const se_SendMMSCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (0, SendSMS_js_1.se_SendSMSCommand)(input, config);
|
|
41
16
|
});
|
|
42
|
-
exports.
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
requestId: output.requestId ? output.requestId : undefined,
|
|
46
|
-
requestTime: output.requestTime ? output.requestTime : undefined,
|
|
47
|
-
statusCode: output.statusCode ? output.statusCode : undefined,
|
|
48
|
-
statusName: output.statusName ? output.statusName : undefined,
|
|
49
|
-
};
|
|
17
|
+
exports.se_SendMMSCommand = se_SendMMSCommand;
|
|
18
|
+
const de_SendMMSCommand = (response, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
return (0, SendSMS_js_1.de_SendSMSCommand)(response, config);
|
|
50
20
|
});
|
|
51
|
-
exports.
|
|
21
|
+
exports.de_SendMMSCommand = de_SendMMSCommand;
|
|
@@ -9,43 +9,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.de_SendSMSResult = exports.de_SendSMSCommand = exports.se_SendSMSCommand = void 0;
|
|
13
13
|
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const se_SendSMSCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const hostname = "sens.apigw.ntruss.com";
|
|
17
17
|
const path = "/sms/v2/services/" + config.serviceId.sms + "/messages";
|
|
18
18
|
const headers = {
|
|
19
19
|
"content-type": "application/json; charset=utf-8",
|
|
20
20
|
host: hostname,
|
|
21
21
|
};
|
|
22
|
-
const body = JSON.stringify(Object.assign(
|
|
22
|
+
const body = JSON.stringify(Object.assign({}, input));
|
|
23
23
|
return new util_http_handler_1.HttpRequest({
|
|
24
24
|
protocol: "https:",
|
|
25
25
|
method: "POST",
|
|
26
|
-
hostname
|
|
27
|
-
path
|
|
28
|
-
headers
|
|
29
|
-
body
|
|
26
|
+
hostname,
|
|
27
|
+
path,
|
|
28
|
+
headers,
|
|
29
|
+
body,
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
exports.
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
contents = yield (0, exports.deserializeIngestkorea_restJson_SendSMSOutput)(data);
|
|
40
|
-
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
32
|
+
exports.se_SendSMSCommand = se_SendSMSCommand;
|
|
33
|
+
const de_SendSMSCommand = (response, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
if (response.statusCode >= 300)
|
|
35
|
+
yield (0, constants_js_1.parseErrorBody)(response);
|
|
36
|
+
const data = yield (0, constants_js_1.parseBody)(response);
|
|
37
|
+
const contents = (0, exports.de_SendSMSResult)(data);
|
|
38
|
+
return Object.assign({ $metadata: (0, constants_js_1.deserializeMetadata)(response) }, (0, constants_js_1.compact)(contents));
|
|
41
39
|
});
|
|
42
|
-
exports.
|
|
43
|
-
const
|
|
40
|
+
exports.de_SendSMSCommand = de_SendSMSCommand;
|
|
41
|
+
const de_SendSMSResult = (output) => {
|
|
44
42
|
return {
|
|
45
43
|
requestId: output.requestId ? output.requestId : undefined,
|
|
46
|
-
requestTime: output.requestTime ? output.requestTime : undefined,
|
|
44
|
+
requestTime: output.requestTime ? (0, constants_js_1.convertToUtc)(output.requestTime) : undefined,
|
|
47
45
|
statusCode: output.statusCode ? output.statusCode : undefined,
|
|
48
46
|
statusName: output.statusName ? output.statusName : undefined,
|
|
49
47
|
};
|
|
50
|
-
}
|
|
51
|
-
exports.
|
|
48
|
+
};
|
|
49
|
+
exports.de_SendSMSResult = de_SendSMSResult;
|
|
@@ -9,56 +9,125 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
12
|
+
exports.convertToUtc = exports.compact = exports.parseErrorBody = exports.parseBody = exports.deserializeMetadata = void 0;
|
|
14
13
|
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
|
+
const index_js_1 = require("../models/index.js");
|
|
15
|
+
const constants_js_1 = require("../middleware/constants.js");
|
|
16
|
+
const deserializeMetadata = (response) => {
|
|
17
|
+
const attempts = response.headers[constants_js_1.INGESTKOREA_RETRY] || "1";
|
|
18
|
+
const totalRetryDelay = response.headers[constants_js_1.INGESTKOREA_RETRY_DELAY] || "0";
|
|
19
|
+
return {
|
|
20
|
+
httpStatusCode: response.statusCode,
|
|
21
|
+
attempts: Number(attempts),
|
|
22
|
+
totalRetryDelay: Number(totalRetryDelay),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.deserializeMetadata = deserializeMetadata;
|
|
15
26
|
const parseBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
27
|
const { statusCode, headers, body: streamBody } = output;
|
|
17
|
-
|
|
18
|
-
if (!isValid) {
|
|
28
|
+
if (!isJsonResponse(headers["content-type"])) {
|
|
19
29
|
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
20
|
-
|
|
21
|
-
code: 400,
|
|
30
|
+
throw new index_js_1.SensError({
|
|
31
|
+
code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
|
|
22
32
|
type: "Bad Request",
|
|
23
|
-
message: "
|
|
24
|
-
description: "content-type is not application/json",
|
|
33
|
+
message: "response content-type is not application/json",
|
|
25
34
|
});
|
|
26
|
-
if ((0, util_error_handler_1.ingestkoreaErrorCodeChecker)(statusCode))
|
|
27
|
-
customError.error.code = statusCode;
|
|
28
|
-
throw customError;
|
|
29
35
|
}
|
|
30
36
|
const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
|
|
31
|
-
if (data.length)
|
|
32
|
-
|
|
37
|
+
if (data.length) {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(data);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
43
|
+
throw new index_js_1.SensError({
|
|
44
|
+
code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
|
|
45
|
+
type: "Bad Request",
|
|
46
|
+
message: "parse response body error",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
33
50
|
return {};
|
|
34
51
|
});
|
|
35
52
|
exports.parseBody = parseBody;
|
|
36
53
|
const parseErrorBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
54
|
const { statusCode, headers, body: streamBody } = output;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
let customError = new util_error_handler_1.IngestkoreaError({
|
|
41
|
-
code: 400,
|
|
55
|
+
const error = new index_js_1.SensError({
|
|
56
|
+
code: statusCode !== null && statusCode !== void 0 ? statusCode : 400,
|
|
42
57
|
type: "Bad Request",
|
|
43
|
-
message: "
|
|
44
|
-
description: "content-type is not application/json",
|
|
58
|
+
message: "something wrong",
|
|
45
59
|
});
|
|
46
|
-
if ((
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw
|
|
60
|
+
if (!isJsonResponse(headers["content-type"])) {
|
|
61
|
+
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
62
|
+
error.message = "response content-type is not application/json";
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
50
65
|
const data = yield (0, util_http_handler_1.collectBodyString)(streamBody);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
yield (0, util_http_handler_1.destroyStream)(streamBody);
|
|
67
|
+
const sensErrorBody = isSensErrorBody(data);
|
|
68
|
+
if (!sensErrorBody) {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
throw new index_js_1.SensError(Object.assign({ code: sensErrorBody.status, type: SENS_ERROR_CODE_SPEC[sensErrorBody.status] || "Unknown Error", message: sensErrorBody.errorMessage || "Something wrong" }, (sensErrorBody.errors &&
|
|
72
|
+
Array.isArray(sensErrorBody.errors) && {
|
|
73
|
+
invalidInputs: sensErrorBody.errors.map((msg) => {
|
|
74
|
+
return { type: "not-valid.args", message: msg };
|
|
75
|
+
}),
|
|
76
|
+
})));
|
|
54
77
|
});
|
|
55
78
|
exports.parseErrorBody = parseErrorBody;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
const SENS_ERROR_CODE_SPEC = {
|
|
80
|
+
400: "Bad Request",
|
|
81
|
+
401: "Unauthorized",
|
|
82
|
+
403: "Forbidden",
|
|
83
|
+
404: "Not Found",
|
|
84
|
+
429: "Too Many Requests",
|
|
85
|
+
500: "Internal Server Error",
|
|
86
|
+
};
|
|
87
|
+
const SENS_ERROR_BODY_SPEC = [
|
|
88
|
+
["status", "number", true],
|
|
89
|
+
["errorMessage", "string", false],
|
|
90
|
+
["errors", "object", false],
|
|
91
|
+
];
|
|
92
|
+
const isSensErrorBody = (input) => {
|
|
93
|
+
if (typeof input !== "string")
|
|
94
|
+
return null;
|
|
95
|
+
try {
|
|
96
|
+
const data = JSON.parse(input);
|
|
97
|
+
if (!data || typeof data !== "object")
|
|
98
|
+
return null;
|
|
99
|
+
const isValid = SENS_ERROR_BODY_SPEC.every(([key, type, required]) => {
|
|
100
|
+
const value = data[key];
|
|
101
|
+
if (required && (value === undefined || value === null))
|
|
102
|
+
return false;
|
|
103
|
+
if (value !== undefined && typeof value !== type)
|
|
104
|
+
return false;
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
return isValid ? data : null;
|
|
108
|
+
}
|
|
109
|
+
catch (_a) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const compact = (obj) => {
|
|
114
|
+
if (Array.isArray(obj)) {
|
|
115
|
+
return obj.map((item) => (0, exports.compact)(item));
|
|
116
|
+
}
|
|
117
|
+
if (typeof obj === "object" && obj !== null) {
|
|
118
|
+
return Object.fromEntries(Object.entries(obj)
|
|
119
|
+
.filter(([_, value]) => value !== undefined) // undefined 필드 제거
|
|
120
|
+
.map(([key, value]) => [key, (0, exports.compact)(value)]) // 내부 값 재귀 처리
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return obj;
|
|
124
|
+
};
|
|
125
|
+
exports.compact = compact;
|
|
126
|
+
const convertToUtc = (input) => {
|
|
127
|
+
const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
128
|
+
return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
|
|
129
|
+
};
|
|
130
|
+
exports.convertToUtc = convertToUtc;
|
|
131
|
+
const isJsonResponse = (contentType) => {
|
|
132
|
+
return /application\/json/gi.exec(contentType || "") ? true : false;
|
|
63
133
|
};
|
|
64
|
-
exports.deserializeMetadata = deserializeMetadata;
|
package/dist-es/SensClient.js
CHANGED
|
@@ -1,49 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SensClient = void 0;
|
|
4
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
5
|
+
const index_js_1 = require("./models/index.js");
|
|
6
|
+
const index_js_2 = require("./middleware/index.js");
|
|
7
|
+
class SensClient {
|
|
5
8
|
constructor(config) {
|
|
9
|
+
this.httpHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
|
|
10
|
+
this.requestHandler = async (input, context) => this.httpHandler.handle(input.request);
|
|
6
11
|
this.config = {
|
|
7
12
|
credentials: resolveCredentials(config),
|
|
8
13
|
serviceId: resolveServiceId(config),
|
|
9
14
|
};
|
|
10
|
-
this.requestHandler = new NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
|
|
11
15
|
}
|
|
12
16
|
async send(command) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const { input, serializer, deserializer } = command;
|
|
18
|
+
const middlewares = [index_js_2.middlewareIngestkoreaMetadata, index_js_2.middlewareNcpSign, index_js_2.middlewareRetry];
|
|
19
|
+
const handler = composeMiddleware(middlewares, this.requestHandler);
|
|
20
|
+
try {
|
|
21
|
+
const request = await serializer(input, this.config);
|
|
22
|
+
const { response } = await handler({ request }, this.config);
|
|
23
|
+
const output = await deserializer(response, this.config);
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
30
|
}
|
|
31
|
+
exports.SensClient = SensClient;
|
|
32
|
+
const composeMiddleware = (middlewares, finalHandler) => {
|
|
33
|
+
const handler = middlewares.reduceRight((next, middleware) => {
|
|
34
|
+
return middleware(next);
|
|
35
|
+
}, finalHandler);
|
|
36
|
+
return handler;
|
|
37
|
+
};
|
|
23
38
|
const resolveCredentials = (config) => {
|
|
24
39
|
const { credentials } = config;
|
|
40
|
+
let error = new index_js_1.SensError({
|
|
41
|
+
code: 401,
|
|
42
|
+
type: "Unauthorized",
|
|
43
|
+
message: "Invalid Credentials",
|
|
44
|
+
invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 인증 정보를 확인해주세요" }],
|
|
45
|
+
});
|
|
25
46
|
if (!credentials)
|
|
26
|
-
throw
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
throw error;
|
|
48
|
+
if (!credentials.accessKey) {
|
|
49
|
+
error.invalidInputs[0].message = "AccessKey 정보를 확인해주세요";
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
if (!credentials.secretKey) {
|
|
53
|
+
error.invalidInputs[0].message = "SecretKey 정보를 확인해주세요";
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
accessKey: credentials.accessKey,
|
|
58
|
+
secretKey: credentials.secretKey,
|
|
59
|
+
};
|
|
33
60
|
};
|
|
34
61
|
const resolveServiceId = (config) => {
|
|
62
|
+
var _a, _b, _c;
|
|
35
63
|
const { serviceId } = config;
|
|
36
|
-
|
|
37
|
-
code:
|
|
38
|
-
type: "
|
|
39
|
-
message: "Invalid
|
|
40
|
-
|
|
64
|
+
let error = new index_js_1.SensError({
|
|
65
|
+
code: 400,
|
|
66
|
+
type: "Bad Request",
|
|
67
|
+
message: "Invalid ServiceId",
|
|
68
|
+
invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 서비스 정보를 확인해주세요" }],
|
|
41
69
|
});
|
|
42
|
-
if (!serviceId
|
|
43
|
-
throw
|
|
70
|
+
if (!serviceId)
|
|
71
|
+
throw error;
|
|
72
|
+
const isReady = !!Object.values(serviceId).filter((d) => !!d).length;
|
|
73
|
+
if (!isReady) {
|
|
74
|
+
error.invalidInputs[0].message = "최소 1개 이상의 서비스 정보가 필요합니다";
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
44
77
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
kakao: (_a = serviceId.kakao) !== null && _a !== void 0 ? _a : "",
|
|
79
|
+
push: (_b = serviceId.push) !== null && _b !== void 0 ? _b : "",
|
|
80
|
+
sms: (_c = serviceId.sms) !== null && _c !== void 0 ? _c : "",
|
|
48
81
|
};
|
|
49
82
|
};
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAlimtalkResultCommand = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
5
|
+
const GetAlimtalkResult_js_1 = require("../protocols/GetAlimtalkResult.js");
|
|
6
|
+
class GetAlimtalkResultCommand extends index_js_1.SensCommand {
|
|
5
7
|
constructor(input) {
|
|
6
8
|
super(input);
|
|
7
9
|
this.input = {
|
|
8
10
|
messageId: input.messageId,
|
|
9
11
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!config.serviceId.kakao)
|
|
13
|
-
throw new IngestkoreaError({
|
|
14
|
-
code: 400,
|
|
15
|
-
type: "Bad Request",
|
|
16
|
-
message: "Invalid Params",
|
|
17
|
-
description: "Please Check Kakao ServiceId",
|
|
18
|
-
});
|
|
19
|
-
let request = await serializeIngestkorea_restJson_GetAlimtalkResultCommand(input, config);
|
|
20
|
-
return request;
|
|
21
|
-
}
|
|
22
|
-
async deserialize(response) {
|
|
23
|
-
let output = await deserializeIngestkorea_restJson_GetAlimtalkResultCommand(response);
|
|
24
|
-
return output;
|
|
12
|
+
this.serializer = GetAlimtalkResult_js_1.se_GetAlimtalkResultCommand;
|
|
13
|
+
this.deserializer = GetAlimtalkResult_js_1.de_GetAlimtalkResultCommand;
|
|
25
14
|
}
|
|
26
15
|
}
|
|
16
|
+
exports.GetAlimtalkResultCommand = GetAlimtalkResultCommand;
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAlimtalkStatusCommand = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
5
|
+
const GetAlimtalkStatus_js_1 = require("../protocols/GetAlimtalkStatus.js");
|
|
6
|
+
const MAX_LIMIT = 100;
|
|
7
|
+
class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
|
|
5
8
|
constructor(input) {
|
|
6
9
|
super(input);
|
|
7
10
|
this.input = {
|
|
8
11
|
requestId: input.requestId,
|
|
12
|
+
pageSize: input.pageSize ? Math.min(MAX_LIMIT, Math.max(1, input.pageSize)) : MAX_LIMIT,
|
|
13
|
+
...(input.nextToken && { nextToken: input.nextToken }),
|
|
9
14
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!config.serviceId.kakao)
|
|
13
|
-
throw new IngestkoreaError({
|
|
14
|
-
code: 400,
|
|
15
|
-
type: "Bad Request",
|
|
16
|
-
message: "Invalid Params",
|
|
17
|
-
description: "Please Check Kakao ServiceId",
|
|
18
|
-
});
|
|
19
|
-
let request = await serializeIngestkorea_restJson_GetAlimtalkStatusCommand(input, config);
|
|
20
|
-
return request;
|
|
21
|
-
}
|
|
22
|
-
async deserialize(response) {
|
|
23
|
-
let output = await deserializeIngestkorea_restJson_GetAlimtalkStatusCommand(response);
|
|
24
|
-
return output;
|
|
15
|
+
this.serializer = GetAlimtalkStatus_js_1.se_GetAlimtalkStatusCommand;
|
|
16
|
+
this.deserializer = GetAlimtalkStatus_js_1.de_GetAlimtalkStatusCommand;
|
|
25
17
|
}
|
|
26
18
|
}
|
|
19
|
+
exports.GetAlimtalkStatusCommand = GetAlimtalkStatusCommand;
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAlimtalkTemplateCommand = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
5
|
+
const GetAlimtalkTemplate_js_1 = require("../protocols/GetAlimtalkTemplate.js");
|
|
6
|
+
class GetAlimtalkTemplateCommand extends index_js_1.SensCommand {
|
|
5
7
|
constructor(input) {
|
|
6
8
|
super(input);
|
|
7
9
|
this.input = {
|
|
8
10
|
channelId: input.channelId,
|
|
9
11
|
templateCode: input.templateCode,
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!config.serviceId.kakao)
|
|
14
|
-
throw new IngestkoreaError({
|
|
15
|
-
code: 400,
|
|
16
|
-
type: "Bad Request",
|
|
17
|
-
message: "Invalid Params",
|
|
18
|
-
description: "Please Check Kakao ServiceId",
|
|
19
|
-
});
|
|
20
|
-
let request = await serializeIngestkorea_restJson_GetAlimtalkTemplateCommand(input, config);
|
|
21
|
-
return request;
|
|
22
|
-
}
|
|
23
|
-
async deserialize(response) {
|
|
24
|
-
let output = await deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand(response);
|
|
25
|
-
return output;
|
|
13
|
+
this.serializer = GetAlimtalkTemplate_js_1.se_GetAlimtalkTemplateCommand;
|
|
14
|
+
this.deserializer = GetAlimtalkTemplate_js_1.de_GetAlimtalkTemplateCommand;
|
|
26
15
|
}
|
|
27
16
|
}
|
|
17
|
+
exports.GetAlimtalkTemplateCommand = GetAlimtalkTemplateCommand;
|