@ingestkorea/client-sens 1.5.3 → 1.6.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/dist-cjs/SensClient.js +12 -12
- package/dist-cjs/middleware/index.js +4 -2
- package/dist-cjs/middleware/{metadata-ingestkorea.js → middleware-metadata.js} +3 -12
- package/dist-cjs/middleware/middleware-retry.js +58 -0
- package/dist-cjs/middleware/middleware-sort-headers.js +25 -0
- package/dist-cjs/models/MetadataBearer.js +2 -0
- package/dist-cjs/models/Middleware.js +2 -0
- package/dist-cjs/models/index.js +2 -0
- package/dist-cjs/protocols/GetAlimtalkResult.js +7 -9
- package/dist-cjs/protocols/GetAlimtalkStatus.js +7 -9
- package/dist-cjs/protocols/GetAlimtalkTemplate.js +6 -6
- package/dist-cjs/protocols/GetSMSResult.js +7 -9
- package/dist-cjs/protocols/GetSMSStatus.js +7 -9
- package/dist-cjs/protocols/ListAlimtalkChannels.js +6 -6
- package/dist-cjs/protocols/ListAlimtalkTemplates.js +6 -6
- package/dist-cjs/protocols/SendAlimtalk.js +7 -9
- package/dist-cjs/protocols/SendMMS.js +6 -6
- package/dist-cjs/protocols/SendSMS.js +6 -6
- package/dist-cjs/protocols/constants.js +7 -1
- package/dist-es/SensClient.js +15 -15
- package/dist-es/commands/SendMMSCommand.js +1 -1
- package/dist-es/commands/SendSMSCommand.js +1 -1
- package/dist-es/index.js +2 -2
- package/dist-es/middleware/index.js +4 -2
- package/dist-es/middleware/middleware-metadata.js +6 -0
- package/dist-es/middleware/middleware-retry.js +51 -0
- package/dist-es/middleware/middleware-sort-headers.js +12 -0
- package/dist-es/models/MetadataBearer.js +1 -0
- package/dist-es/models/Middleware.js +1 -0
- package/dist-es/models/index.js +2 -0
- package/dist-es/protocols/GetAlimtalkResult.js +12 -10
- package/dist-es/protocols/GetAlimtalkStatus.js +12 -10
- package/dist-es/protocols/GetAlimtalkTemplate.js +11 -7
- package/dist-es/protocols/GetSMSResult.js +12 -10
- package/dist-es/protocols/GetSMSStatus.js +12 -10
- package/dist-es/protocols/ListAlimtalkChannels.js +11 -7
- package/dist-es/protocols/ListAlimtalkTemplates.js +11 -7
- package/dist-es/protocols/SendAlimtalk.js +12 -10
- package/dist-es/protocols/SendMMS.js +11 -7
- package/dist-es/protocols/SendSMS.js +11 -7
- package/dist-es/protocols/constants.js +5 -0
- package/dist-types/SensClient.d.ts +2 -2
- package/dist-types/commands/GetAlimtalkResultCommand.d.ts +6 -3
- package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +6 -3
- package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +6 -3
- package/dist-types/commands/GetSMSResultCommand.d.ts +6 -3
- package/dist-types/commands/GetSMSStatusCommand.d.ts +6 -3
- package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +6 -3
- package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +6 -3
- package/dist-types/commands/SendAlimtalkCommand.d.ts +6 -3
- package/dist-types/commands/SendMMSCommand.d.ts +6 -3
- package/dist-types/commands/SendSMSCommand.d.ts +6 -3
- package/dist-types/index.d.ts +2 -2
- package/dist-types/middleware/index.d.ts +4 -2
- package/dist-types/middleware/middleware-metadata.d.ts +2 -0
- package/dist-types/middleware/middleware-retry.d.ts +2 -0
- package/dist-types/middleware/middleware-sign.d.ts +2 -0
- package/dist-types/middleware/middleware-sort-headers.d.ts +2 -0
- package/dist-types/models/MetadataBearer.d.ts +8 -0
- package/dist-types/models/Middleware.d.ts +12 -0
- package/dist-types/models/SensCommand.d.ts +5 -1
- package/dist-types/models/index.d.ts +2 -0
- package/dist-types/protocols/GetAlimtalkResult.d.ts +5 -2
- package/dist-types/protocols/GetAlimtalkStatus.d.ts +5 -2
- package/dist-types/protocols/GetAlimtalkTemplate.d.ts +5 -2
- package/dist-types/protocols/GetSMSResult.d.ts +5 -2
- package/dist-types/protocols/GetSMSStatus.d.ts +5 -2
- package/dist-types/protocols/ListAlimtalkChannels.d.ts +5 -2
- package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -2
- package/dist-types/protocols/SendAlimtalk.d.ts +5 -2
- package/dist-types/protocols/SendMMS.d.ts +5 -2
- package/dist-types/protocols/SendSMS.d.ts +5 -2
- package/dist-types/protocols/constants.d.ts +2 -0
- package/package.json +1 -1
- package/.prettierignore +0 -3
- package/dist-es/middleware/metadata-ingestkorea.js +0 -19
- package/dist-types/middleware/metadata-ingestkorea.d.ts +0 -3
- package/dist-types/middleware/signer-ncp.d.ts +0 -3
- /package/dist-cjs/middleware/{signer-ncp.js → middleware-sign.js} +0 -0
- /package/dist-es/middleware/{signer-ncp.js → middleware-sign.js} +0 -0
package/dist-cjs/SensClient.js
CHANGED
|
@@ -13,40 +13,38 @@ exports.SensClient = void 0;
|
|
|
13
13
|
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
14
14
|
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
15
15
|
const middleware_1 = require("./middleware");
|
|
16
|
-
;
|
|
17
|
-
;
|
|
18
16
|
class SensClient {
|
|
19
17
|
constructor(config) {
|
|
20
18
|
const resolvedCredentials = resolveCredentials(config);
|
|
21
19
|
const resolvedServiceId = resolveServiceId(config);
|
|
22
20
|
this.config = {
|
|
23
21
|
credentials: Object.assign({}, resolvedCredentials),
|
|
24
|
-
serviceId: Object.assign({}, resolvedServiceId)
|
|
22
|
+
serviceId: Object.assign({}, resolvedServiceId),
|
|
25
23
|
};
|
|
26
24
|
this.requestHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
|
|
27
25
|
}
|
|
28
|
-
;
|
|
29
26
|
send(command) {
|
|
30
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
28
|
let input = command.input;
|
|
32
29
|
let request = yield command.serialize(input, this.config);
|
|
33
30
|
request = yield (0, middleware_1.middlewareNcpSigner)(request, this.config);
|
|
34
31
|
request = yield (0, middleware_1.middlewareIngestkoreaMetadata)(request, this.config);
|
|
35
|
-
|
|
32
|
+
request = yield (0, middleware_1.middlewareSortHeaders)(request, this.config);
|
|
33
|
+
let response = yield (0, middleware_1.middlewareRetry)(request, this.config, this.requestHandler);
|
|
36
34
|
let output = yield command.deserialize(response);
|
|
37
35
|
return output;
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
|
-
;
|
|
41
38
|
}
|
|
42
39
|
exports.SensClient = SensClient;
|
|
43
|
-
;
|
|
44
40
|
const resolveCredentials = (config) => {
|
|
45
41
|
const { credentials } = config;
|
|
46
42
|
if (!credentials)
|
|
47
43
|
throw new util_error_handler_1.IngestkoreaError({
|
|
48
|
-
code: 401,
|
|
49
|
-
|
|
44
|
+
code: 401,
|
|
45
|
+
type: "Unauthorized",
|
|
46
|
+
message: "Invalid Credentials",
|
|
47
|
+
description: "Invalid Credentials",
|
|
50
48
|
});
|
|
51
49
|
return credentials;
|
|
52
50
|
};
|
|
@@ -54,12 +52,14 @@ const resolveServiceId = (config) => {
|
|
|
54
52
|
const { serviceId } = config;
|
|
55
53
|
if (!serviceId)
|
|
56
54
|
throw new util_error_handler_1.IngestkoreaError({
|
|
57
|
-
code: 401,
|
|
58
|
-
|
|
55
|
+
code: 401,
|
|
56
|
+
type: "Unauthorized",
|
|
57
|
+
message: "Invalid Credentials",
|
|
58
|
+
description: "Invalid ServiceId",
|
|
59
59
|
});
|
|
60
60
|
return {
|
|
61
61
|
push: serviceId.push != undefined ? serviceId.push : undefined,
|
|
62
62
|
sms: serviceId.sms != undefined ? serviceId.sms : undefined,
|
|
63
|
-
kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined
|
|
63
|
+
kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined,
|
|
64
64
|
};
|
|
65
65
|
};
|
|
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./metadata
|
|
17
|
+
__exportStar(require("./middleware-sign"), exports);
|
|
18
|
+
__exportStar(require("./middleware-metadata"), exports);
|
|
19
|
+
__exportStar(require("./middleware-retry"), exports);
|
|
20
|
+
__exportStar(require("./middleware-sort-headers"), exports);
|
|
@@ -10,19 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.middlewareIngestkoreaMetadata = void 0;
|
|
13
|
+
const REQUEST_HEADER = "x-ingestkorea-request";
|
|
13
14
|
const middlewareIngestkoreaMetadata = (request, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
|
|
15
|
-
request.headers
|
|
15
|
+
request.headers["x-ingestkorea-user-agent"] = "@ingestkorea/client-sens/1.6.x";
|
|
16
|
+
request.headers[REQUEST_HEADER] = "attempt=1";
|
|
16
17
|
return request;
|
|
17
18
|
});
|
|
18
19
|
exports.middlewareIngestkoreaMetadata = middlewareIngestkoreaMetadata;
|
|
19
|
-
/**
|
|
20
|
-
* @param input milliseconds
|
|
21
|
-
*/
|
|
22
|
-
const convertFormatDate = (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
let milliseconds = input ? Number(input) : new Date().getTime();
|
|
24
|
-
let iso8601 = new Date(milliseconds).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
25
|
-
let longDate = iso8601.replace(/[\-:]/g, "");
|
|
26
|
-
let shortDate = longDate.slice(0, 8);
|
|
27
|
-
return { longDate, shortDate };
|
|
28
|
-
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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.middlewareRetry = void 0;
|
|
13
|
+
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
14
|
+
const REQUEST_HEADER = "x-ingestkorea-request";
|
|
15
|
+
const middlewareRetry = (request, config, handler) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const maxAttempts = 3;
|
|
17
|
+
let attempts = 0;
|
|
18
|
+
let totalRetryDelay = 0;
|
|
19
|
+
let lastError = new util_error_handler_1.IngestkoreaError({
|
|
20
|
+
code: 400,
|
|
21
|
+
type: "Bad Request",
|
|
22
|
+
message: "Invalid Request",
|
|
23
|
+
description: { attempts, maxAttempts, totalRetryDelay },
|
|
24
|
+
});
|
|
25
|
+
while (true) {
|
|
26
|
+
try {
|
|
27
|
+
request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}; totalRetryDelay=${totalRetryDelay}`;
|
|
28
|
+
let { response } = yield handler.handle(request);
|
|
29
|
+
return {
|
|
30
|
+
output: {
|
|
31
|
+
$metadata: {
|
|
32
|
+
attempts: attempts + 1,
|
|
33
|
+
totalRetryDelay: totalRetryDelay,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
response,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
attempts++;
|
|
41
|
+
if (attempts == maxAttempts) {
|
|
42
|
+
lastError.error.description.attempts = attempts;
|
|
43
|
+
throw lastError;
|
|
44
|
+
}
|
|
45
|
+
const delay = attempts * 1000;
|
|
46
|
+
totalRetryDelay += delay;
|
|
47
|
+
lastError.error.description = { attempts, maxAttempts, totalRetryDelay };
|
|
48
|
+
if (err instanceof util_error_handler_1.IngestkoreaError) {
|
|
49
|
+
lastError.error.description = Object.assign(Object.assign({}, lastError.error.description), { detail: err.error.description });
|
|
50
|
+
}
|
|
51
|
+
if (err instanceof Error) {
|
|
52
|
+
lastError.error.description = Object.assign(Object.assign({}, lastError.error.description), { detail: err.message });
|
|
53
|
+
}
|
|
54
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
exports.middlewareRetry = middlewareRetry;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.middlewareSortHeaders = void 0;
|
|
13
|
+
const middlewareSortHeaders = (request, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
let { headers } = request;
|
|
15
|
+
let init = {};
|
|
16
|
+
const resolvedHeaders = Object.keys(headers)
|
|
17
|
+
.sort()
|
|
18
|
+
.reduce((acc, curr) => {
|
|
19
|
+
acc[curr] = headers[curr];
|
|
20
|
+
return acc;
|
|
21
|
+
}, init);
|
|
22
|
+
request.headers = resolvedHeaders;
|
|
23
|
+
return request;
|
|
24
|
+
});
|
|
25
|
+
exports.middlewareSortHeaders = middlewareSortHeaders;
|
package/dist-cjs/models/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MetadataBearer"), exports);
|
|
18
|
+
__exportStar(require("./Middleware"), exports);
|
|
17
19
|
__exportStar(require("./SensCommand"), exports);
|
|
18
20
|
__exportStar(require("./SendAlimtalk"), exports);
|
|
19
21
|
__exportStar(require("./GetAlimtalkStatus"), exports);
|
|
@@ -27,14 +27,14 @@ const serializeIngestkorea_restJson_GetAlimtalkResultCommand = (input, config) =
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
exports.serializeIngestkorea_restJson_GetAlimtalkResultCommand = serializeIngestkorea_restJson_GetAlimtalkResultCommand;
|
|
30
|
-
const deserializeIngestkorea_restJson_GetAlimtalkResultCommand = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const deserializeIngestkorea_restJson_GetAlimtalkResultCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const { response: httpResponse, output } = response;
|
|
32
|
+
if (httpResponse.statusCode > 300)
|
|
33
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
34
|
+
const data = yield (0, constants_1.parseBody)(httpResponse);
|
|
34
35
|
let contents = {};
|
|
35
36
|
contents = yield (0, exports.deserializeIngestkorea_restJson_GetAlimtalkResultOutput)(data);
|
|
36
|
-
|
|
37
|
-
return response;
|
|
37
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
38
38
|
});
|
|
39
39
|
exports.deserializeIngestkorea_restJson_GetAlimtalkResultCommand = deserializeIngestkorea_restJson_GetAlimtalkResultCommand;
|
|
40
40
|
const deserializeIngestkorea_restJson_GetAlimtalkResultOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -55,9 +55,7 @@ const deserializeIngestkorea_restJson_GetAlimtalkResultOutput = (output) => __aw
|
|
|
55
55
|
messageStatusCode: output.messageStatusCode != undefined ? output.messageStatusCode : undefined,
|
|
56
56
|
messageStatusName: output.messageStatusName != undefined ? output.messageStatusName : undefined,
|
|
57
57
|
messageStatusDesc: output.messageStatusDesc != undefined ? output.messageStatusDesc : undefined,
|
|
58
|
-
failover: output.failover != undefined
|
|
59
|
-
? (0, exports.deserializeIngestkorea_restJson_AlimtalkFailover)(output.failover)
|
|
60
|
-
: undefined,
|
|
58
|
+
failover: output.failover != undefined ? (0, exports.deserializeIngestkorea_restJson_AlimtalkFailover)(output.failover) : undefined,
|
|
61
59
|
};
|
|
62
60
|
});
|
|
63
61
|
exports.deserializeIngestkorea_restJson_GetAlimtalkResultOutput = deserializeIngestkorea_restJson_GetAlimtalkResultOutput;
|
|
@@ -31,14 +31,14 @@ const serializeIngestkorea_restJson_GetAlimtalkStatusCommand = (input, config) =
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
exports.serializeIngestkorea_restJson_GetAlimtalkStatusCommand = serializeIngestkorea_restJson_GetAlimtalkStatusCommand;
|
|
34
|
-
const deserializeIngestkorea_restJson_GetAlimtalkStatusCommand = (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const deserializeIngestkorea_restJson_GetAlimtalkStatusCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const { response: httpResponse, output } = response;
|
|
36
|
+
if (httpResponse.statusCode > 300)
|
|
37
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
38
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // GetAlimtalkStatusOutput
|
|
38
39
|
let contents = {};
|
|
39
40
|
contents = yield (0, exports.deserializeIngestkorea_restJson_GetAlimtalkStatusOutput)(data);
|
|
40
|
-
|
|
41
|
-
return response;
|
|
41
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
42
42
|
});
|
|
43
43
|
exports.deserializeIngestkorea_restJson_GetAlimtalkStatusCommand = deserializeIngestkorea_restJson_GetAlimtalkStatusCommand;
|
|
44
44
|
const deserializeIngestkorea_restJson_GetAlimtalkStatusOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -47,9 +47,7 @@ const deserializeIngestkorea_restJson_GetAlimtalkStatusOutput = (output) => __aw
|
|
|
47
47
|
requestId: requestId != undefined ? requestId : undefined,
|
|
48
48
|
statusCode: statusCode != undefined ? statusCode : undefined,
|
|
49
49
|
statusName: statusName != undefined ? statusName : undefined,
|
|
50
|
-
messages: messages != undefined
|
|
51
|
-
? (0, exports.deserializeIngestkorea_restJson_GetAlimtalkStatusMessages)(messages)
|
|
52
|
-
: undefined,
|
|
50
|
+
messages: messages != undefined ? (0, exports.deserializeIngestkorea_restJson_GetAlimtalkStatusMessages)(messages) : undefined,
|
|
53
51
|
};
|
|
54
52
|
});
|
|
55
53
|
exports.deserializeIngestkorea_restJson_GetAlimtalkStatusOutput = deserializeIngestkorea_restJson_GetAlimtalkStatusOutput;
|
|
@@ -33,14 +33,14 @@ const serializeIngestkorea_restJson_GetAlimtalkTemplateCommand = (input, config)
|
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
exports.serializeIngestkorea_restJson_GetAlimtalkTemplateCommand = serializeIngestkorea_restJson_GetAlimtalkTemplateCommand;
|
|
36
|
-
const deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand = (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const { response: httpResponse, output } = response;
|
|
38
|
+
if (httpResponse.statusCode > 300)
|
|
39
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
40
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // GetAlimtalkTemplateOutput
|
|
40
41
|
let contents = {};
|
|
41
42
|
contents = yield (0, exports.deserializeIngestkorea_restJson_GetAlimtalkTemplateOutput)(data);
|
|
42
|
-
|
|
43
|
-
return response;
|
|
43
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
44
44
|
});
|
|
45
45
|
exports.deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand = deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand;
|
|
46
46
|
const deserializeIngestkorea_restJson_GetAlimtalkTemplateOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -27,23 +27,21 @@ const serializeIngestkorea_restJson_GetSMSResultCommand = (input, config) => __a
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
exports.serializeIngestkorea_restJson_GetSMSResultCommand = serializeIngestkorea_restJson_GetSMSResultCommand;
|
|
30
|
-
const deserializeIngestkorea_restJson_GetSMSResultCommand = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const deserializeIngestkorea_restJson_GetSMSResultCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const { response: httpResponse, output } = response;
|
|
32
|
+
if (httpResponse.statusCode > 300)
|
|
33
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
34
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // GetSMSResultOutput
|
|
34
35
|
let contents = {};
|
|
35
36
|
contents = yield (0, exports.deserializeIngestkorea_restJson_GetSMSResultOutput)(data);
|
|
36
|
-
|
|
37
|
-
return response;
|
|
37
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
38
38
|
});
|
|
39
39
|
exports.deserializeIngestkorea_restJson_GetSMSResultCommand = deserializeIngestkorea_restJson_GetSMSResultCommand;
|
|
40
40
|
const deserializeIngestkorea_restJson_GetSMSResultOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
return {
|
|
42
42
|
statusCode: output.statusCode ? output.statusCode : undefined,
|
|
43
43
|
statusName: output.statusName ? output.statusName : undefined,
|
|
44
|
-
messages: output.messages
|
|
45
|
-
? (0, exports.deserializeIngestkorea_restJson_SMSResultMessage)(output.messages)
|
|
46
|
-
: undefined,
|
|
44
|
+
messages: output.messages ? (0, exports.deserializeIngestkorea_restJson_SMSResultMessage)(output.messages) : undefined,
|
|
47
45
|
};
|
|
48
46
|
});
|
|
49
47
|
exports.deserializeIngestkorea_restJson_GetSMSResultOutput = deserializeIngestkorea_restJson_GetSMSResultOutput;
|
|
@@ -31,14 +31,14 @@ const serializeIngestkorea_restJson_GetSMSStatusCommand = (input, config) => __a
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
exports.serializeIngestkorea_restJson_GetSMSStatusCommand = serializeIngestkorea_restJson_GetSMSStatusCommand;
|
|
34
|
-
const deserializeIngestkorea_restJson_GetSMSStatusCommand = (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const deserializeIngestkorea_restJson_GetSMSStatusCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const { response: httpResponse, output } = response;
|
|
36
|
+
if (httpResponse.statusCode > 300)
|
|
37
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
38
|
+
const data = yield (0, constants_1.parseBody)(httpResponse);
|
|
38
39
|
let contents = {};
|
|
39
40
|
contents = yield (0, exports.deserializeIngestkorea_restJson_GetSMSStatusOutput)(data);
|
|
40
|
-
|
|
41
|
-
return response;
|
|
41
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
42
42
|
});
|
|
43
43
|
exports.deserializeIngestkorea_restJson_GetSMSStatusCommand = deserializeIngestkorea_restJson_GetSMSStatusCommand;
|
|
44
44
|
const deserializeIngestkorea_restJson_GetSMSStatusOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -46,9 +46,7 @@ const deserializeIngestkorea_restJson_GetSMSStatusOutput = (output) => __awaiter
|
|
|
46
46
|
requestId: output.requestId ? output.requestId : undefined,
|
|
47
47
|
statusCode: output.statusCode ? output.statusCode : undefined,
|
|
48
48
|
statusName: output.statusName ? output.statusName : undefined,
|
|
49
|
-
messages: output.messages
|
|
50
|
-
? (0, exports.deserializeIngestkorea_restJson_SMSStatusMessage)(output.messages)
|
|
51
|
-
: undefined,
|
|
49
|
+
messages: output.messages ? (0, exports.deserializeIngestkorea_restJson_SMSStatusMessage)(output.messages) : undefined,
|
|
52
50
|
};
|
|
53
51
|
});
|
|
54
52
|
exports.deserializeIngestkorea_restJson_GetSMSStatusOutput = deserializeIngestkorea_restJson_GetSMSStatusOutput;
|
|
@@ -27,14 +27,14 @@ const serializeIngestkorea_restJson_ListAlimtalkChannelsCommand = (input, config
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
exports.serializeIngestkorea_restJson_ListAlimtalkChannelsCommand = serializeIngestkorea_restJson_ListAlimtalkChannelsCommand;
|
|
30
|
-
const deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const { response: httpResponse, output } = response;
|
|
32
|
+
if (httpResponse.statusCode > 300)
|
|
33
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
34
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // ListAlimtalkChannelsOutput
|
|
34
35
|
let contents = {};
|
|
35
36
|
contents = yield (0, exports.deserializeIngestkorea_restJson_ListAlimtalkChannelsOutput)(data);
|
|
36
|
-
|
|
37
|
-
return response;
|
|
37
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
38
38
|
});
|
|
39
39
|
exports.deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand = deserializeIngestkorea_restJson_ListAlimtalkChannelsCommand;
|
|
40
40
|
const deserializeIngestkorea_restJson_ListAlimtalkChannelsOutput = (outputs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -31,14 +31,14 @@ const serializeIngestkorea_restJson_ListAlimtalkTemplatesCommand = (input, confi
|
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
exports.serializeIngestkorea_restJson_ListAlimtalkTemplatesCommand = serializeIngestkorea_restJson_ListAlimtalkTemplatesCommand;
|
|
34
|
-
const deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand = (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const { response: httpResponse, output } = response;
|
|
36
|
+
if (httpResponse.statusCode > 300)
|
|
37
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
38
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // ListAlimtalkTemplatesOutput
|
|
38
39
|
let contents = {};
|
|
39
40
|
contents = yield (0, exports.deserializeIngestkorea_restJson_ListAlimtalkTemplatesOutput)(data);
|
|
40
|
-
|
|
41
|
-
return response;
|
|
41
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
42
42
|
});
|
|
43
43
|
exports.deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand = deserializeIngestkorea_restJson_ListAlimtalkTemplatesCommand;
|
|
44
44
|
const deserializeIngestkorea_restJson_ListAlimtalkTemplatesOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -34,14 +34,14 @@ const serializeIngestkorea_restJson_SendAlimtalkCommand = (input, config) => __a
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
exports.serializeIngestkorea_restJson_SendAlimtalkCommand = serializeIngestkorea_restJson_SendAlimtalkCommand;
|
|
37
|
-
const deserializeIngestkorea_restJson_SendAlimtalkCommand = (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const deserializeIngestkorea_restJson_SendAlimtalkCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const { response: httpResponse, output } = response;
|
|
39
|
+
if (httpResponse.statusCode > 300)
|
|
40
|
+
yield (0, constants_1.parseErrorBody)(httpResponse);
|
|
41
|
+
const data = yield (0, constants_1.parseBody)(httpResponse); // SendAlimtalkCommandOutput
|
|
41
42
|
let contents = {};
|
|
42
43
|
contents = yield (0, exports.deserializeIngestkorea_restJson_SendMessageOutput)(data);
|
|
43
|
-
|
|
44
|
-
return response;
|
|
44
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
45
45
|
});
|
|
46
46
|
exports.deserializeIngestkorea_restJson_SendAlimtalkCommand = deserializeIngestkorea_restJson_SendAlimtalkCommand;
|
|
47
47
|
const deserializeIngestkorea_restJson_SendMessageOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -50,9 +50,7 @@ const deserializeIngestkorea_restJson_SendMessageOutput = (output) => __awaiter(
|
|
|
50
50
|
requestTime: output.requestTime != undefined ? output.requestTime : undefined,
|
|
51
51
|
statusCode: output.statusCode != undefined ? output.statusCode : undefined,
|
|
52
52
|
statusName: output.statusName != undefined ? output.statusName : undefined,
|
|
53
|
-
messages: output.messages != undefined
|
|
54
|
-
? (0, exports.deserializeIngestkorea_restJson_ReceivedMessages)(output.messages)
|
|
55
|
-
: undefined,
|
|
53
|
+
messages: output.messages != undefined ? (0, exports.deserializeIngestkorea_restJson_ReceivedMessages)(output.messages) : undefined,
|
|
56
54
|
};
|
|
57
55
|
});
|
|
58
56
|
exports.deserializeIngestkorea_restJson_SendMessageOutput = deserializeIngestkorea_restJson_SendMessageOutput;
|
|
@@ -30,14 +30,14 @@ const serializeIngestkorea_restJson_SendMMSCommand = (input, config) => __awaite
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
exports.serializeIngestkorea_restJson_SendMMSCommand = serializeIngestkorea_restJson_SendMMSCommand;
|
|
33
|
-
const deserializeIngestkorea_restJson_SendMMSCommand = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
37
38
|
let contents = {};
|
|
38
39
|
contents = yield (0, exports.deserializeIngestkorea_restJson_SendMMSOutput)(data);
|
|
39
|
-
|
|
40
|
-
return response;
|
|
40
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
41
41
|
});
|
|
42
42
|
exports.deserializeIngestkorea_restJson_SendMMSCommand = deserializeIngestkorea_restJson_SendMMSCommand;
|
|
43
43
|
const deserializeIngestkorea_restJson_SendMMSOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -30,14 +30,14 @@ const serializeIngestkorea_restJson_SendSMSCommand = (input, config) => __awaite
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
exports.serializeIngestkorea_restJson_SendSMSCommand = serializeIngestkorea_restJson_SendSMSCommand;
|
|
33
|
-
const deserializeIngestkorea_restJson_SendSMSCommand = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const deserializeIngestkorea_restJson_SendSMSCommand = (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
|
|
37
38
|
let contents = {};
|
|
38
39
|
contents = yield (0, exports.deserializeIngestkorea_restJson_SendSMSOutput)(data);
|
|
39
|
-
|
|
40
|
-
return response;
|
|
40
|
+
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
|
|
41
41
|
});
|
|
42
42
|
exports.deserializeIngestkorea_restJson_SendSMSCommand = deserializeIngestkorea_restJson_SendSMSCommand;
|
|
43
43
|
const deserializeIngestkorea_restJson_SendSMSOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.parseErrorBody = exports.parseBody = void 0;
|
|
12
|
+
exports.deserializeMetadata = exports.parseErrorBody = exports.parseBody = void 0;
|
|
13
13
|
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
14
14
|
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
15
15
|
const parseBody = (output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -56,3 +56,9 @@ exports.parseErrorBody = parseErrorBody;
|
|
|
56
56
|
const verifyJsonHeader = (contentType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
57
|
return /application\/json/gi.exec(contentType) ? true : false;
|
|
58
58
|
});
|
|
59
|
+
const deserializeMetadata = (response) => {
|
|
60
|
+
return {
|
|
61
|
+
httpStatusCode: response.statusCode,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.deserializeMetadata = deserializeMetadata;
|
package/dist-es/SensClient.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
import { NodeHttpHandler } from
|
|
2
|
-
import { IngestkoreaError } from
|
|
3
|
-
import { middlewareNcpSigner, middlewareIngestkoreaMetadata } from
|
|
4
|
-
;
|
|
5
|
-
;
|
|
1
|
+
import { NodeHttpHandler } from "@ingestkorea/util-http-handler";
|
|
2
|
+
import { IngestkoreaError } from "@ingestkorea/util-error-handler";
|
|
3
|
+
import { middlewareNcpSigner, middlewareIngestkoreaMetadata, middlewareSortHeaders, middlewareRetry, } from "./middleware";
|
|
6
4
|
export class SensClient {
|
|
7
5
|
constructor(config) {
|
|
8
6
|
const resolvedCredentials = resolveCredentials(config);
|
|
9
7
|
const resolvedServiceId = resolveServiceId(config);
|
|
10
8
|
this.config = {
|
|
11
9
|
credentials: { ...resolvedCredentials },
|
|
12
|
-
serviceId: { ...resolvedServiceId }
|
|
10
|
+
serviceId: { ...resolvedServiceId },
|
|
13
11
|
};
|
|
14
12
|
this.requestHandler = new NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
|
|
15
13
|
}
|
|
16
|
-
;
|
|
17
14
|
async send(command) {
|
|
18
15
|
let input = command.input;
|
|
19
16
|
let request = await command.serialize(input, this.config);
|
|
20
17
|
request = await middlewareNcpSigner(request, this.config);
|
|
21
18
|
request = await middlewareIngestkoreaMetadata(request, this.config);
|
|
22
|
-
|
|
19
|
+
request = await middlewareSortHeaders(request, this.config);
|
|
20
|
+
let response = await middlewareRetry(request, this.config, this.requestHandler);
|
|
23
21
|
let output = await command.deserialize(response);
|
|
24
22
|
return output;
|
|
25
23
|
}
|
|
26
|
-
;
|
|
27
24
|
}
|
|
28
|
-
;
|
|
29
25
|
const resolveCredentials = (config) => {
|
|
30
26
|
const { credentials } = config;
|
|
31
27
|
if (!credentials)
|
|
32
28
|
throw new IngestkoreaError({
|
|
33
|
-
code: 401,
|
|
34
|
-
|
|
29
|
+
code: 401,
|
|
30
|
+
type: "Unauthorized",
|
|
31
|
+
message: "Invalid Credentials",
|
|
32
|
+
description: "Invalid Credentials",
|
|
35
33
|
});
|
|
36
34
|
return credentials;
|
|
37
35
|
};
|
|
@@ -39,12 +37,14 @@ const resolveServiceId = (config) => {
|
|
|
39
37
|
const { serviceId } = config;
|
|
40
38
|
if (!serviceId)
|
|
41
39
|
throw new IngestkoreaError({
|
|
42
|
-
code: 401,
|
|
43
|
-
|
|
40
|
+
code: 401,
|
|
41
|
+
type: "Unauthorized",
|
|
42
|
+
message: "Invalid Credentials",
|
|
43
|
+
description: "Invalid ServiceId",
|
|
44
44
|
});
|
|
45
45
|
return {
|
|
46
46
|
push: serviceId.push != undefined ? serviceId.push : undefined,
|
|
47
47
|
sms: serviceId.sms != undefined ? serviceId.sms : undefined,
|
|
48
|
-
kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined
|
|
48
|
+
kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined,
|
|
49
49
|
};
|
|
50
50
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SensCommand
|
|
1
|
+
import { SensCommand } from "../models";
|
|
2
2
|
import { serializeIngestkorea_restJson_SendMMSCommand, deserializeIngestkorea_restJson_SendMMSCommand, } from "../protocols/SendMMS";
|
|
3
3
|
import { IngestkoreaError } from "@ingestkorea/util-error-handler";
|
|
4
4
|
import { LMS_MAX, MMS_FILE_MAX, trimText, prettyPhoneNum, getContentLength } from "./constants";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SensCommand
|
|
1
|
+
import { SensCommand } from "../models";
|
|
2
2
|
import { serializeIngestkorea_restJson_SendSMSCommand, deserializeIngestkorea_restJson_SendSMSCommand, } from "../protocols/SendSMS";
|
|
3
3
|
import { IngestkoreaError } from "@ingestkorea/util-error-handler";
|
|
4
4
|
import { SMS_MAX, LMS_MAX, trimText, prettyPhoneNum, getContentLength } from "./constants";
|
package/dist-es/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./commands";
|
|
2
|
+
export * from "./SensClient";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const REQUEST_HEADER = "x-ingestkorea-request";
|
|
2
|
+
export const middlewareIngestkoreaMetadata = async (request, config) => {
|
|
3
|
+
request.headers["x-ingestkorea-user-agent"] = "@ingestkorea/client-sens/1.6.x";
|
|
4
|
+
request.headers[REQUEST_HEADER] = "attempt=1";
|
|
5
|
+
return request;
|
|
6
|
+
};
|