@ingestkorea/client-sens 1.0.0 → 1.2.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.
Files changed (58) hide show
  1. package/README.md +9 -2
  2. package/dist-cjs/SensClient.js +6 -2
  3. package/dist-cjs/commands/GetRequestResultCommand.js +5 -0
  4. package/dist-cjs/commands/GetRequestStatusCommand.js +5 -0
  5. package/dist-cjs/commands/GetTemplateCommand.js +44 -0
  6. package/dist-cjs/commands/ListChannelsCommand.js +5 -0
  7. package/dist-cjs/commands/ListTemplatesCommand.js +44 -0
  8. package/dist-cjs/commands/SendAlimtalkCommand.js +15 -1
  9. package/dist-cjs/commands/SendSMSCommand.js +70 -0
  10. package/dist-cjs/commands/index.js +3 -0
  11. package/dist-cjs/models/GetTemplate.js +4 -0
  12. package/dist-cjs/models/ListTemplates.js +7 -0
  13. package/dist-cjs/models/SendSMS.js +4 -0
  14. package/dist-cjs/models/index.js +3 -0
  15. package/dist-cjs/protocols/GetRequestResult.js +1 -1
  16. package/dist-cjs/protocols/GetRequestStatus.js +1 -1
  17. package/dist-cjs/protocols/GetTemplate.js +51 -0
  18. package/dist-cjs/protocols/ListChannels.js +1 -1
  19. package/dist-cjs/protocols/ListTemplates.js +94 -0
  20. package/dist-cjs/protocols/SendAlimtalk.js +1 -1
  21. package/dist-cjs/protocols/SendSMS.js +51 -0
  22. package/dist-cjs/protocols/index.js +3 -0
  23. package/dist-es/SensClient.js +6 -2
  24. package/dist-es/commands/GetRequestResultCommand.js +5 -0
  25. package/dist-es/commands/GetRequestStatusCommand.js +5 -0
  26. package/dist-es/commands/GetTemplateCommand.js +29 -0
  27. package/dist-es/commands/ListChannelsCommand.js +5 -0
  28. package/dist-es/commands/ListTemplatesCommand.js +29 -0
  29. package/dist-es/commands/SendAlimtalkCommand.js +22 -1
  30. package/dist-es/commands/SendSMSCommand.js +63 -0
  31. package/dist-es/commands/index.js +3 -0
  32. package/dist-es/models/GetTemplate.js +3 -0
  33. package/dist-es/models/ListTemplates.js +6 -0
  34. package/dist-es/models/SendSMS.js +3 -0
  35. package/dist-es/models/index.js +3 -0
  36. package/dist-es/protocols/GetRequestResult.js +1 -1
  37. package/dist-es/protocols/GetRequestStatus.js +1 -1
  38. package/dist-es/protocols/GetTemplate.js +38 -0
  39. package/dist-es/protocols/ListChannels.js +1 -1
  40. package/dist-es/protocols/ListTemplates.js +78 -0
  41. package/dist-es/protocols/SendAlimtalk.js +1 -1
  42. package/dist-es/protocols/SendSMS.js +46 -0
  43. package/dist-es/protocols/index.js +3 -0
  44. package/dist-types/SensClient.d.ts +5 -1
  45. package/dist-types/commands/GetTemplateCommand.d.ts +13 -0
  46. package/dist-types/commands/ListTemplatesCommand.d.ts +13 -0
  47. package/dist-types/commands/SendSMSCommand.d.ts +13 -0
  48. package/dist-types/commands/index.d.ts +3 -0
  49. package/dist-types/models/GetTemplate.d.ts +6 -0
  50. package/dist-types/models/ListTemplates.d.ts +33 -0
  51. package/dist-types/models/SendAlimtalk.d.ts +2 -2
  52. package/dist-types/models/SendSMS.d.ts +23 -0
  53. package/dist-types/models/index.d.ts +3 -0
  54. package/dist-types/protocols/GetTemplate.d.ts +7 -0
  55. package/dist-types/protocols/ListTemplates.d.ts +10 -0
  56. package/dist-types/protocols/SendSMS.d.ts +7 -0
  57. package/dist-types/protocols/index.d.ts +3 -0
  58. package/package.json +2 -2
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![NPM downloads](https://img.shields.io/npm/dm/@ingestkorea/client-sens?style=flat-square)](https://www.npmjs.com/package/@ingestkorea/client-sens)
5
5
 
6
6
  ## Description
7
- INGESTKOREA SDK NCP SENS Client for Node.js.
7
+ INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
8
8
 
9
9
  ## Installing
10
10
  ```sh
@@ -25,6 +25,9 @@ npm install @ingestkorea/client-sens
25
25
  + GetRequestStatus
26
26
  + GetRequestResult
27
27
  + ListChannels
28
+ + SendSMS
29
+ + ListTemplates
30
+ + GetTemplate
28
31
 
29
32
  ### Import
30
33
  ```ts
@@ -47,7 +50,11 @@ const client = new SensClient({
47
50
  accessKey: ACCESS_KEY,
48
51
  secretKey: SECRET_KEY
49
52
  },
50
- serviceId: 'ncp:kkobizmsg:kr:1234567:your-service-name'
53
+ serviceId: { // at least one serviceId required
54
+ sms: 'ncp:sms:kr:123456789xxx:your-service-name', // optional
55
+ kakao: 'ncp:kkobizmsg:kr:9876xxx:your-service-name' // optional
56
+ // if you call send operation without serviceId, sdk throw error
57
+ }
51
58
  });
52
59
 
53
60
  let params: SendAlimtalkCommandInput = {
@@ -21,7 +21,7 @@ class SensClient {
21
21
  const resolvedServiceId = resolveServiceId(config);
22
22
  this.config = {
23
23
  credentials: Object.assign({}, resolvedCredentials),
24
- serviceId: resolvedServiceId
24
+ serviceId: Object.assign({}, resolvedServiceId)
25
25
  };
26
26
  this.httpHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
27
27
  }
@@ -56,5 +56,9 @@ const resolveServiceId = (config) => {
56
56
  code: 401, type: 'Unauthorized',
57
57
  message: 'Invalid Credentials', description: 'Invalid ServiceId'
58
58
  });
59
- return serviceId;
59
+ return {
60
+ push: serviceId.push != undefined ? serviceId.push : undefined,
61
+ sms: serviceId.sms != undefined ? serviceId.sms : undefined,
62
+ kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined
63
+ };
60
64
  };
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GetRequestResultCommand = void 0;
13
13
  const models_1 = require("../models");
14
14
  const GetRequestResult_1 = require("../protocols/GetRequestResult");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
16
  ;
16
17
  ;
17
18
  class GetRequestResultCommand extends models_1.SensCommand {
@@ -22,6 +23,10 @@ class GetRequestResultCommand extends models_1.SensCommand {
22
23
  ;
23
24
  serialize(input, config) {
24
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
25
30
  let request = yield (0, GetRequestResult_1.serializeIngestkorea_restJson_GetRequestResultCommand)(input, config);
26
31
  return request;
27
32
  });
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GetRequestStatusCommand = void 0;
13
13
  const models_1 = require("../models");
14
14
  const GetRequestStatus_1 = require("../protocols/GetRequestStatus");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
16
  ;
16
17
  ;
17
18
  class GetRequestStatusCommand extends models_1.SensCommand {
@@ -22,6 +23,10 @@ class GetRequestStatusCommand extends models_1.SensCommand {
22
23
  ;
23
24
  serialize(input, config) {
24
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
25
30
  let request = yield (0, GetRequestStatus_1.serializeIngestkorea_restJson_GetRequestStatusCommand)(input, config);
26
31
  return request;
27
32
  });
@@ -0,0 +1,44 @@
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.GetTemplateCommand = void 0;
13
+ const models_1 = require("../models");
14
+ const GetTemplate_1 = require("../protocols/GetTemplate");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
+ ;
17
+ ;
18
+ class GetTemplateCommand extends models_1.SensCommand {
19
+ constructor(input) {
20
+ super(input);
21
+ this.input = Object.assign({}, input);
22
+ }
23
+ ;
24
+ serialize(input, config) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
30
+ let request = yield (0, GetTemplate_1.serializeIngestkorea_restJson_GetTemplateCommand)(input, config);
31
+ return request;
32
+ });
33
+ }
34
+ ;
35
+ deserialize(response) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ let output = yield (0, GetTemplate_1.deserializeIngestkorea_restJson_GetTemplateCommand)(response);
38
+ return output;
39
+ });
40
+ }
41
+ ;
42
+ }
43
+ exports.GetTemplateCommand = GetTemplateCommand;
44
+ ;
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ListChannelsCommand = void 0;
13
13
  const models_1 = require("../models");
14
14
  const ListChannels_1 = require("../protocols/ListChannels");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
16
  ;
16
17
  ;
17
18
  class ListChannelsCommand extends models_1.SensCommand {
@@ -22,6 +23,10 @@ class ListChannelsCommand extends models_1.SensCommand {
22
23
  ;
23
24
  serialize(input, config) {
24
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
25
30
  let request = yield (0, ListChannels_1.serializeIngestkorea_restJson_ListChannelsCommand)(input, config);
26
31
  return request;
27
32
  });
@@ -0,0 +1,44 @@
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.ListTemplatesCommand = void 0;
13
+ const models_1 = require("../models");
14
+ const ListTemplates_1 = require("../protocols/ListTemplates");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
+ ;
17
+ ;
18
+ class ListTemplatesCommand extends models_1.SensCommand {
19
+ constructor(input) {
20
+ super(input);
21
+ this.input = Object.assign({}, input);
22
+ }
23
+ ;
24
+ serialize(input, config) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
30
+ let request = yield (0, ListTemplates_1.serializeIngestkorea_restJson_ListTemplatesCommand)(input, config);
31
+ return request;
32
+ });
33
+ }
34
+ ;
35
+ deserialize(response) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ let output = yield (0, ListTemplates_1.deserializeIngestkorea_restJson_ListTemplatesCommand)(response);
38
+ return output;
39
+ });
40
+ }
41
+ ;
42
+ }
43
+ exports.ListTemplatesCommand = ListTemplatesCommand;
44
+ ;
@@ -12,16 +12,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SendAlimtalkCommand = void 0;
13
13
  const models_1 = require("../models");
14
14
  const SendAlimtalk_1 = require("../protocols/SendAlimtalk");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
16
  ;
16
17
  ;
17
18
  class SendAlimtalkCommand extends models_1.SensCommand {
18
19
  constructor(input) {
19
20
  super(input);
20
- this.input = Object.assign({}, input);
21
+ this.input = Object.assign(Object.assign({}, input), { plusFriendId: input.plusFriendId, templateCode: input.templateCode, messages: input.messages.map(resolveAlimtalkMessage) });
21
22
  }
22
23
  ;
23
24
  serialize(input, config) {
24
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ if (!config.serviceId.kakao)
27
+ throw new util_error_handler_1.IngestkoreaError({
28
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
29
+ });
25
30
  let request = yield (0, SendAlimtalk_1.serializeIngestkorea_restJson_SendAlimtalkCommand)(input, config);
26
31
  return request;
27
32
  });
@@ -37,3 +42,12 @@ class SendAlimtalkCommand extends models_1.SensCommand {
37
42
  }
38
43
  exports.SendAlimtalkCommand = SendAlimtalkCommand;
39
44
  ;
45
+ const resolveAlimtalkMessage = (message) => {
46
+ const MAXIMUM_STRING_LENGTH = 1000;
47
+ if (message.content.length > MAXIMUM_STRING_LENGTH)
48
+ throw new util_error_handler_1.IngestkoreaError({
49
+ code: 400, type: 'Bad Request',
50
+ message: 'Invalid Params', description: `Maximum message length is ${MAXIMUM_STRING_LENGTH}`
51
+ });
52
+ return Object.assign({ to: message.to.replace(/\-/gi, ""), content: message.content }, (message.buttons != undefined && { buttons: message.buttons }));
53
+ };
@@ -0,0 +1,70 @@
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.SendSMSCommand = void 0;
13
+ const models_1 = require("../models");
14
+ const SendSMS_1 = require("../protocols/SendSMS");
15
+ const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
+ ;
17
+ ;
18
+ class SendSMSCommand extends models_1.SensCommand {
19
+ constructor(input) {
20
+ super(input);
21
+ const content = textTrimming(input.content);
22
+ const messageType = messageTypeChecker(content);
23
+ this.input = Object.assign(Object.assign({}, input), { from: phoneNumPretty(input.from), content: content, type: input.type === messageType ? input.type : messageType, messages: input.messages.map(message => {
24
+ return Object.assign(Object.assign({ to: phoneNumPretty(message.to) }, (message.content != undefined && { content: textTrimming(message.content) })), (message.subject != undefined && messageType === 'LMS' && { subject: textTrimming(message.subject) }));
25
+ }) });
26
+ }
27
+ ;
28
+ serialize(input, config) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ if (!config.serviceId.sms)
31
+ throw new util_error_handler_1.IngestkoreaError({
32
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check SMS ServiceId'
33
+ });
34
+ let request = yield (0, SendSMS_1.serializeIngestkorea_restJson_SendSMSCommand)(input, config);
35
+ return request;
36
+ });
37
+ }
38
+ ;
39
+ deserialize(response) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ let output = yield (0, SendSMS_1.deserializeIngestkorea_restJson_SendSMSCommand)(response);
42
+ return output;
43
+ });
44
+ }
45
+ ;
46
+ }
47
+ exports.SendSMSCommand = SendSMSCommand;
48
+ ;
49
+ const textTrimming = (input) => input.trim();
50
+ const phoneNumPretty = (input) => input.replace(/\-/gi, "");
51
+ const messageTypeChecker = (input) => {
52
+ const MAXIMUM = 2000;
53
+ const euckrByte = input.split('').reduce((acc, text) => {
54
+ let byte = Buffer.from(text).length;
55
+ let modulo = byte % 3;
56
+ modulo ? acc += 1 : acc += 2;
57
+ return acc;
58
+ }, 0);
59
+ if (!euckrByte)
60
+ throw new util_error_handler_1.IngestkoreaError({
61
+ code: 400, type: 'Bad Request',
62
+ message: 'Invalid Request', description: `Please check input message`
63
+ });
64
+ if (euckrByte > MAXIMUM)
65
+ throw new util_error_handler_1.IngestkoreaError({
66
+ code: 400, type: 'Bad Request',
67
+ message: 'Invalid Request', description: `Maximum message length is ${MAXIMUM}bytes`
68
+ });
69
+ return euckrByte > 80 ? 'LMS' : 'SMS';
70
+ };
@@ -18,3 +18,6 @@ __exportStar(require("./SendAlimtalkCommand"), exports);
18
18
  __exportStar(require("./GetRequestStatusCommand"), exports);
19
19
  __exportStar(require("./GetRequestResultCommand"), exports);
20
20
  __exportStar(require("./ListChannelsCommand"), exports);
21
+ __exportStar(require("./SendSMSCommand"), exports);
22
+ __exportStar(require("./ListTemplatesCommand"), exports);
23
+ __exportStar(require("./GetTemplateCommand"), exports);
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
5
+ ;
6
+ ;
7
+ ;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
@@ -19,3 +19,6 @@ __exportStar(require("./SendAlimtalk"), exports);
19
19
  __exportStar(require("./GetRequestStatus"), exports);
20
20
  __exportStar(require("./GetRequestResult"), exports);
21
21
  __exportStar(require("./ListChannels"), exports);
22
+ __exportStar(require("./SendSMS"), exports);
23
+ __exportStar(require("./ListTemplates"), exports);
24
+ __exportStar(require("./GetTemplate"), exports);
@@ -14,7 +14,7 @@ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
14
  const constants_1 = require("./constants");
15
15
  const serializeIngestkorea_restJson_GetRequestResultCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const hostname = "sens.apigw.ntruss.com";
17
- const path = "/alimtalk/v2/services/" + config.serviceId + "/messages/" + input.messageId;
17
+ const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/messages/" + input.messageId;
18
18
  const headers = {
19
19
  "host": hostname
20
20
  };
@@ -14,7 +14,7 @@ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
14
  const constants_1 = require("./constants");
15
15
  const serializeIngestkorea_restJson_GetRequestStatusCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const hostname = "sens.apigw.ntruss.com";
17
- const path = "/alimtalk/v2/services/" + config.serviceId + "/messages";
17
+ const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/messages";
18
18
  const headers = {
19
19
  "host": hostname
20
20
  };
@@ -0,0 +1,51 @@
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_GetTemplateOutput = exports.deserializeIngestkorea_restJson_GetTemplateCommand = exports.serializeIngestkorea_restJson_GetTemplateCommand = void 0;
13
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
+ const ListTemplates_1 = require("../protocols/ListTemplates");
15
+ const constants_1 = require("./constants");
16
+ const serializeIngestkorea_restJson_GetTemplateCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const hostname = "sens.apigw.ntruss.com";
18
+ const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/templates";
19
+ const headers = {
20
+ "host": hostname
21
+ };
22
+ const query = {
23
+ channelId: input.channelId,
24
+ templateCode: input.templateCode
25
+ };
26
+ return new util_http_handler_1.HttpRequest({
27
+ protocol: 'https:',
28
+ method: 'GET',
29
+ hostname: hostname,
30
+ path: path,
31
+ query: query,
32
+ headers: headers
33
+ });
34
+ });
35
+ exports.serializeIngestkorea_restJson_GetTemplateCommand = serializeIngestkorea_restJson_GetTemplateCommand;
36
+ const deserializeIngestkorea_restJson_GetTemplateCommand = (output) => __awaiter(void 0, void 0, void 0, function* () {
37
+ if (output.statusCode > 300)
38
+ yield (0, constants_1.parseErrorBody)(output);
39
+ const data = yield (0, constants_1.parseBody)(output); // GetTemplateOutput
40
+ let contents = {};
41
+ contents = yield (0, exports.deserializeIngestkorea_restJson_GetTemplateOutput)(data);
42
+ const response = Object.assign({}, contents);
43
+ return response;
44
+ });
45
+ exports.deserializeIngestkorea_restJson_GetTemplateCommand = deserializeIngestkorea_restJson_GetTemplateCommand;
46
+ const deserializeIngestkorea_restJson_GetTemplateOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
47
+ return {
48
+ templates: (0, ListTemplates_1.deserializeIngestkorea_restJson_Template)(output)
49
+ };
50
+ });
51
+ exports.deserializeIngestkorea_restJson_GetTemplateOutput = deserializeIngestkorea_restJson_GetTemplateOutput;
@@ -14,7 +14,7 @@ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
14
  const constants_1 = require("./constants");
15
15
  const serializeIngestkorea_restJson_ListChannelsCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const hostname = "sens.apigw.ntruss.com";
17
- const path = "/alimtalk/v2/services/" + config.serviceId + "/channels";
17
+ const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/channels";
18
18
  const headers = {
19
19
  "host": hostname
20
20
  };
@@ -0,0 +1,94 @@
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_Button = exports.deserializeIngestkorea_restJson_Comment = exports.deserializeIngestkorea_restJson_Template = exports.deserializeIngestkorea_restJson_ListTemplatesOutput = exports.deserializeIngestkorea_restJson_ListTemplatesCommand = exports.serializeIngestkorea_restJson_ListTemplatesCommand = void 0;
13
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
+ const constants_1 = require("./constants");
15
+ const serializeIngestkorea_restJson_ListTemplatesCommand = (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.kakao + "/templates";
18
+ const headers = {
19
+ "host": hostname
20
+ };
21
+ const query = {
22
+ channelId: input.channelId
23
+ };
24
+ return new util_http_handler_1.HttpRequest({
25
+ protocol: 'https:',
26
+ method: 'GET',
27
+ hostname: hostname,
28
+ path: path,
29
+ query: query,
30
+ headers: headers
31
+ });
32
+ });
33
+ exports.serializeIngestkorea_restJson_ListTemplatesCommand = serializeIngestkorea_restJson_ListTemplatesCommand;
34
+ const deserializeIngestkorea_restJson_ListTemplatesCommand = (output) => __awaiter(void 0, void 0, void 0, function* () {
35
+ if (output.statusCode > 300)
36
+ yield (0, constants_1.parseErrorBody)(output);
37
+ const data = yield (0, constants_1.parseBody)(output); // ListTemplatesOutput
38
+ let contents = {};
39
+ contents = yield (0, exports.deserializeIngestkorea_restJson_ListTemplatesOutput)(data);
40
+ const response = Object.assign({}, contents);
41
+ return response;
42
+ });
43
+ exports.deserializeIngestkorea_restJson_ListTemplatesCommand = deserializeIngestkorea_restJson_ListTemplatesCommand;
44
+ const deserializeIngestkorea_restJson_ListTemplatesOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
45
+ return {
46
+ templates: (0, exports.deserializeIngestkorea_restJson_Template)(output)
47
+ };
48
+ });
49
+ exports.deserializeIngestkorea_restJson_ListTemplatesOutput = deserializeIngestkorea_restJson_ListTemplatesOutput;
50
+ const deserializeIngestkorea_restJson_Template = (outputs) => {
51
+ return outputs.map(output => {
52
+ return {
53
+ createTime: output.createTime != undefined ? output.createTime : undefined,
54
+ updateTime: output.updateTime != undefined ? output.updateTime : undefined,
55
+ channelId: output.channelId != undefined ? output.channelId : undefined,
56
+ templateCode: output.templateCode != undefined ? output.templateCode : undefined,
57
+ templateName: output.templateName != undefined ? output.templateName : undefined,
58
+ content: output.content != undefined ? output.content : undefined,
59
+ comments: output.comments != undefined
60
+ ? (0, exports.deserializeIngestkorea_restJson_Comment)(output.comments) : undefined,
61
+ templateInspectionStatus: output.templateInspectionStatus != undefined
62
+ ? output.templateInspectionStatus : undefined,
63
+ templateStatus: output.templateStatus != undefined ? output.templateStatus : undefined,
64
+ buttons: output.buttons != undefined
65
+ ? (0, exports.deserializeIngestkorea_restJson_Button)(output.buttons) : undefined
66
+ };
67
+ });
68
+ };
69
+ exports.deserializeIngestkorea_restJson_Template = deserializeIngestkorea_restJson_Template;
70
+ const deserializeIngestkorea_restJson_Comment = (outputs) => {
71
+ return outputs.map(output => {
72
+ return {
73
+ commentId: output.commentId != undefined ? output.commentId : undefined,
74
+ content: output.content != undefined ? output.content : undefined,
75
+ status: output.status != undefined ? output.status : undefined,
76
+ createTime: output.createTime != undefined ? output.createTime : undefined
77
+ };
78
+ });
79
+ };
80
+ exports.deserializeIngestkorea_restJson_Comment = deserializeIngestkorea_restJson_Comment;
81
+ const deserializeIngestkorea_restJson_Button = (outputs) => {
82
+ return outputs.map(output => {
83
+ return {
84
+ order: output.order != undefined ? output.order : undefined,
85
+ type: output.type != undefined ? output.type : undefined,
86
+ name: output.name != undefined ? output.name : undefined,
87
+ linkMobile: output.linkMobile != undefined ? output.linkMobile : undefined,
88
+ linkPc: output.linkPc != undefined ? output.linkPc : undefined,
89
+ schemeIos: output.schemeIos != undefined ? output.schemeIos : undefined,
90
+ schemeAndroid: output.schemeAndroid != undefined ? output.schemeAndroid : undefined
91
+ };
92
+ });
93
+ };
94
+ exports.deserializeIngestkorea_restJson_Button = deserializeIngestkorea_restJson_Button;
@@ -14,7 +14,7 @@ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
14
  const constants_1 = require("./constants");
15
15
  const serializeIngestkorea_restJson_SendAlimtalkCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const hostname = "sens.apigw.ntruss.com";
17
- const path = "/alimtalk/v2/services/" + config.serviceId + "/messages";
17
+ const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/messages";
18
18
  const headers = {
19
19
  "content-type": "application/json; charset=utf-8",
20
20
  "host": hostname
@@ -0,0 +1,51 @@
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_SendSMSOutput = exports.deserializeIngestkorea_restJson_SendSMSCommand = exports.serializeIngestkorea_restJson_SendSMSCommand = void 0;
13
+ const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
+ const constants_1 = require("../protocols/constants");
15
+ const serializeIngestkorea_restJson_SendSMSCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
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 : 'SMS' }, (input.contentType != undefined && { contentType: input.contentType })), (input.countryCode != undefined && { countryCode: input.countryCode })), (input.subject != undefined && input.type === 'LMS' && { 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_SendSMSCommand = serializeIngestkorea_restJson_SendSMSCommand;
33
+ const deserializeIngestkorea_restJson_SendSMSCommand = (output) => __awaiter(void 0, void 0, void 0, function* () {
34
+ if (output.statusCode > 300)
35
+ yield (0, constants_1.parseErrorBody)(output);
36
+ const data = yield (0, constants_1.parseBody)(output); // SendSMSOutput
37
+ let contents = {};
38
+ contents = yield (0, exports.deserializeIngestkorea_restJson_SendSMSOutput)(data);
39
+ const response = Object.assign({}, contents);
40
+ return response;
41
+ });
42
+ exports.deserializeIngestkorea_restJson_SendSMSCommand = deserializeIngestkorea_restJson_SendSMSCommand;
43
+ const deserializeIngestkorea_restJson_SendSMSOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
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
+ };
50
+ });
51
+ exports.deserializeIngestkorea_restJson_SendSMSOutput = deserializeIngestkorea_restJson_SendSMSOutput;
@@ -18,3 +18,6 @@ __exportStar(require("./SendAlimtalk"), exports);
18
18
  __exportStar(require("./GetRequestStatus"), exports);
19
19
  __exportStar(require("./GetRequestResult"), exports);
20
20
  __exportStar(require("./ListChannels"), exports);
21
+ __exportStar(require("./SendSMS"), exports);
22
+ __exportStar(require("./ListTemplates"), exports);
23
+ __exportStar(require("./GetTemplate"), exports);
@@ -9,7 +9,7 @@ export class SensClient {
9
9
  const resolvedServiceId = resolveServiceId(config);
10
10
  this.config = {
11
11
  credentials: { ...resolvedCredentials },
12
- serviceId: resolvedServiceId
12
+ serviceId: { ...resolvedServiceId }
13
13
  };
14
14
  this.httpHandler = new NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
15
15
  }
@@ -41,5 +41,9 @@ const resolveServiceId = (config) => {
41
41
  code: 401, type: 'Unauthorized',
42
42
  message: 'Invalid Credentials', description: 'Invalid ServiceId'
43
43
  });
44
- return serviceId;
44
+ return {
45
+ push: serviceId.push != undefined ? serviceId.push : undefined,
46
+ sms: serviceId.sms != undefined ? serviceId.sms : undefined,
47
+ kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined
48
+ };
45
49
  };
@@ -1,5 +1,6 @@
1
1
  import { SensCommand } from '../models';
2
2
  import { serializeIngestkorea_restJson_GetRequestResultCommand, deserializeIngestkorea_restJson_GetRequestResultCommand } from '../protocols/GetRequestResult';
3
+ import { IngestkoreaError } from '@ingestkorea/util-error-handler';
3
4
  ;
4
5
  ;
5
6
  export class GetRequestResultCommand extends SensCommand {
@@ -11,6 +12,10 @@ export class GetRequestResultCommand extends SensCommand {
11
12
  }
12
13
  ;
13
14
  async serialize(input, config) {
15
+ if (!config.serviceId.kakao)
16
+ throw new IngestkoreaError({
17
+ code: 400, type: 'Bad Request', message: 'Invalid Params', description: 'Please Check Kakao ServiceId'
18
+ });
14
19
  let request = await serializeIngestkorea_restJson_GetRequestResultCommand(input, config);
15
20
  return request;
16
21
  }