@ingestkorea/client-sens 1.6.0 → 1.8.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 (149) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +114 -68
  3. package/dist-cjs/SensClient.js +59 -31
  4. package/dist-cjs/commands/GetAlimtalkResultCommand.js +8 -33
  5. package/dist-cjs/commands/GetAlimtalkStatusCommand.js +9 -33
  6. package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +9 -33
  7. package/dist-cjs/commands/GetSMSResultCommand.js +8 -33
  8. package/dist-cjs/commands/GetSMSStatusCommand.js +8 -33
  9. package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +6 -33
  10. package/dist-cjs/commands/ListAlimtalkStatusCommand.js +27 -0
  11. package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +8 -33
  12. package/dist-cjs/commands/SendAlimtalkCommand.js +36 -40
  13. package/dist-cjs/commands/SendMMSCommand.js +67 -103
  14. package/dist-cjs/commands/SendSMSCommand.js +38 -71
  15. package/dist-cjs/commands/constants.js +1 -4
  16. package/dist-cjs/commands/index.js +11 -10
  17. package/dist-cjs/index.js +2 -2
  18. package/dist-cjs/middleware/constants.js +10 -0
  19. package/dist-cjs/middleware/index.js +3 -4
  20. package/dist-cjs/middleware/middleware-metadata.js +4 -5
  21. package/dist-cjs/middleware/middleware-retry.js +32 -27
  22. package/dist-cjs/middleware/middleware-sign.js +10 -9
  23. package/dist-cjs/models/SendAlimtalk.js +5 -0
  24. package/dist-cjs/models/SendMMS.js +3 -0
  25. package/dist-cjs/models/SensClient.js +2 -0
  26. package/dist-cjs/models/SensErrorInfo.js +13 -0
  27. package/dist-cjs/models/SensMiddleware.js +2 -0
  28. package/dist-cjs/models/index.js +16 -13
  29. package/dist-cjs/protocols/GetAlimtalkResult.js +19 -40
  30. package/dist-cjs/protocols/GetAlimtalkStatus.js +40 -50
  31. package/dist-cjs/protocols/GetAlimtalkTemplate.js +60 -22
  32. package/dist-cjs/protocols/GetSMSResult.js +30 -48
  33. package/dist-cjs/protocols/GetSMSStatus.js +31 -34
  34. package/dist-cjs/protocols/ListAlimtalkChannels.js +27 -31
  35. package/dist-cjs/protocols/ListAlimtalkStatus.js +48 -0
  36. package/dist-cjs/protocols/ListAlimtalkTemplates.js +36 -62
  37. package/dist-cjs/protocols/SendAlimtalk.js +33 -35
  38. package/dist-cjs/protocols/SendMMS.js +8 -38
  39. package/dist-cjs/protocols/SendSMS.js +19 -21
  40. package/dist-cjs/protocols/constants.js +98 -34
  41. package/dist-es/SensClient.js +65 -33
  42. package/dist-es/commands/GetAlimtalkResultCommand.js +10 -20
  43. package/dist-es/commands/GetAlimtalkStatusCommand.js +15 -20
  44. package/dist-es/commands/GetAlimtalkTemplateCommand.js +11 -20
  45. package/dist-es/commands/GetSMSResultCommand.js +10 -20
  46. package/dist-es/commands/GetSMSStatusCommand.js +10 -20
  47. package/dist-es/commands/ListAlimtalkChannelsCommand.js +10 -22
  48. package/dist-es/commands/ListAlimtalkStatusCommand.js +39 -0
  49. package/dist-es/commands/ListAlimtalkTemplatesCommand.js +10 -20
  50. package/dist-es/commands/SendAlimtalkCommand.js +40 -32
  51. package/dist-es/commands/SendMMSCommand.js +70 -100
  52. package/dist-es/commands/SendSMSCommand.js +51 -66
  53. package/dist-es/commands/constants.js +9 -6
  54. package/dist-es/commands/index.js +27 -10
  55. package/dist-es/index.js +18 -2
  56. package/dist-es/middleware/constants.js +10 -0
  57. package/dist-es/middleware/index.js +19 -4
  58. package/dist-es/middleware/middleware-metadata.js +11 -5
  59. package/dist-es/middleware/middleware-retry.js +39 -30
  60. package/dist-es/middleware/middleware-sign.js +19 -14
  61. package/dist-es/models/GetAlimtalkResult.js +2 -1
  62. package/dist-es/models/GetAlimtalkStatus.js +2 -1
  63. package/dist-es/models/GetAlimtalkTemplate.js +2 -1
  64. package/dist-es/models/GetSMSResult.js +2 -1
  65. package/dist-es/models/GetSMSStatus.js +2 -1
  66. package/dist-es/models/ListAlimtalkChannels.js +2 -1
  67. package/dist-es/models/ListAlimtalkStatus.js +2 -0
  68. package/dist-es/models/ListAlimtalkTemplates.js +2 -1
  69. package/dist-es/models/MetadataBearer.js +2 -1
  70. package/dist-es/models/SendAlimtalk.js +7 -1
  71. package/dist-es/models/SendMMS.js +5 -1
  72. package/dist-es/models/SendSMS.js +2 -1
  73. package/dist-es/models/SensClient.js +2 -0
  74. package/dist-es/models/SensCommand.js +5 -1
  75. package/dist-es/models/SensErrorInfo.js +13 -0
  76. package/dist-es/models/SensMiddleware.js +2 -0
  77. package/dist-es/models/index.js +32 -13
  78. package/dist-es/protocols/GetAlimtalkResult.js +24 -38
  79. package/dist-es/protocols/GetAlimtalkStatus.js +54 -50
  80. package/dist-es/protocols/GetAlimtalkTemplate.js +82 -23
  81. package/dist-es/protocols/GetSMSResult.js +44 -47
  82. package/dist-es/protocols/GetSMSStatus.js +35 -34
  83. package/dist-es/protocols/ListAlimtalkChannels.js +31 -31
  84. package/dist-es/protocols/ListAlimtalkStatus.js +42 -0
  85. package/dist-es/protocols/ListAlimtalkTemplates.js +41 -61
  86. package/dist-es/protocols/SendAlimtalk.js +37 -35
  87. package/dist-es/protocols/SendMMS.js +10 -49
  88. package/dist-es/protocols/SendSMS.js +23 -30
  89. package/dist-es/protocols/constants.js +112 -37
  90. package/dist-types/SensClient.d.ts +3 -20
  91. package/dist-types/commands/GetAlimtalkResultCommand.d.ts +5 -10
  92. package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +5 -10
  93. package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +5 -10
  94. package/dist-types/commands/GetSMSResultCommand.d.ts +5 -10
  95. package/dist-types/commands/GetSMSStatusCommand.d.ts +5 -10
  96. package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +5 -10
  97. package/dist-types/commands/ListAlimtalkStatusCommand.d.ts +11 -0
  98. package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +5 -10
  99. package/dist-types/commands/SendAlimtalkCommand.d.ts +5 -10
  100. package/dist-types/commands/SendMMSCommand.d.ts +5 -10
  101. package/dist-types/commands/SendSMSCommand.d.ts +9 -10
  102. package/dist-types/commands/constants.d.ts +0 -3
  103. package/dist-types/commands/index.d.ts +11 -10
  104. package/dist-types/index.d.ts +2 -2
  105. package/dist-types/middleware/constants.d.ts +7 -0
  106. package/dist-types/middleware/index.d.ts +3 -4
  107. package/dist-types/middleware/middleware-metadata.d.ts +2 -2
  108. package/dist-types/middleware/middleware-retry.d.ts +2 -2
  109. package/dist-types/middleware/middleware-sign.d.ts +2 -2
  110. package/dist-types/models/GetAlimtalkResult.d.ts +3 -4
  111. package/dist-types/models/GetAlimtalkStatus.d.ts +13 -5
  112. package/dist-types/models/GetAlimtalkTemplate.d.ts +42 -3
  113. package/dist-types/models/GetSMSResult.d.ts +5 -9
  114. package/dist-types/models/GetSMSStatus.d.ts +4 -4
  115. package/dist-types/models/ListAlimtalkChannels.d.ts +4 -4
  116. package/dist-types/models/ListAlimtalkStatus.d.ts +16 -0
  117. package/dist-types/models/ListAlimtalkTemplates.d.ts +2 -22
  118. package/dist-types/models/MetadataBearer.d.ts +3 -3
  119. package/dist-types/models/SendAlimtalk.d.ts +19 -10
  120. package/dist-types/models/SendMMS.d.ts +5 -3
  121. package/dist-types/models/SendSMS.d.ts +2 -2
  122. package/dist-types/models/SensClient.d.ts +17 -0
  123. package/dist-types/models/SensCommand.d.ts +4 -6
  124. package/dist-types/models/SensErrorInfo.d.ts +21 -0
  125. package/dist-types/models/SensMiddleware.d.ts +8 -0
  126. package/dist-types/models/index.d.ts +16 -13
  127. package/dist-types/protocols/GetAlimtalkResult.d.ts +4 -11
  128. package/dist-types/protocols/GetAlimtalkStatus.d.ts +6 -11
  129. package/dist-types/protocols/GetAlimtalkTemplate.d.ts +4 -10
  130. package/dist-types/protocols/GetSMSResult.d.ts +4 -12
  131. package/dist-types/protocols/GetSMSStatus.d.ts +5 -11
  132. package/dist-types/protocols/ListAlimtalkChannels.d.ts +4 -11
  133. package/dist-types/protocols/ListAlimtalkStatus.d.ts +4 -0
  134. package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -13
  135. package/dist-types/protocols/SendAlimtalk.d.ts +5 -11
  136. package/dist-types/protocols/SendMMS.d.ts +4 -10
  137. package/dist-types/protocols/SendSMS.d.ts +5 -10
  138. package/dist-types/protocols/constants.d.ts +3 -2
  139. package/package.json +22 -5
  140. package/.github/pull_request_template.md +0 -19
  141. package/dist-cjs/middleware/middleware-sort-headers.js +0 -25
  142. package/dist-cjs/protocols/index.js +0 -26
  143. package/dist-es/middleware/middleware-sort-headers.js +0 -12
  144. package/dist-es/models/Middleware.js +0 -1
  145. package/dist-es/protocols/index.js +0 -10
  146. package/dist-types/middleware/middleware-sort-headers.d.ts +0 -2
  147. package/dist-types/models/Middleware.d.ts +0 -12
  148. package/dist-types/protocols/index.d.ts +0 -10
  149. /package/dist-cjs/models/{Middleware.js → ListAlimtalkStatus.js} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 INGESTKOREA LLC.
3
+ Copyright (c) 2024-2026 INGESTKOREA LLC. All Rights Reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,7 +7,15 @@
7
7
 
8
8
  ## Description
9
9
 
10
- INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
10
+ INGESTKOREA SDK - Naver Cloud Platform SENS Client for Node.js.
11
+
12
+ INGESTKOREA SDK - SENS Client for Node.js is a lightweight library that contains only the essential features frequently used in SENS.
13
+
14
+ This SDK performs tasks such as the following automatically.
15
+
16
+ - Authentication using an API Signature
17
+ - Retrying requests
18
+ - Handling error responses
11
19
 
12
20
  ## Installing
13
21
 
@@ -34,6 +42,7 @@ npm install @ingestkorea/client-sens
34
42
  - GetAlimtalkStatus
35
43
  - GetAlimtalkResult
36
44
  - GetAlimtalkTemplate
45
+ - ListAlimtalkStatus
37
46
  - ListAlimtalkTemplates
38
47
  - ListAlimtalkChannels
39
48
 
@@ -46,16 +55,12 @@ npm install @ingestkorea/client-sens
46
55
 
47
56
  ### Import
48
57
 
58
+ The INGESTKOREA SDK - SENS Client is modulized by `client` and `commands`.
59
+
60
+ To send a request, you only need to import the SensClient and the commands you need, for example SendMessageCommand:
61
+
49
62
  ```ts
50
- import {
51
- SensClient,
52
- SendAlimtalkCommand,
53
- SendAlimtalkCommandInput,
54
- SendSMSCommand,
55
- SendSMSCommandInput,
56
- SendMMSCommand,
57
- SendMMSCommandInput,
58
- } from "@ingestkorea/client-sens";
63
+ import { SensClient, SendAlimtalkCommand } from "@ingestkorea/client-sens";
59
64
  ```
60
65
 
61
66
  ### Usage
@@ -67,88 +72,123 @@ To send a request, you:
67
72
  - Call `send` operation on client with command object as input.
68
73
 
69
74
  ```ts
70
- // a client can be shared by different commands.
71
75
  const client = new SensClient({
76
+ /**
77
+ * AccessKey, SecretKey: https://www.ncloud.com/mypage/manage/authkey
78
+ * serviceId: https://console.ncloud.com/sens/project
79
+ */
72
80
  credentials: {
73
- accessKey: ACCESS_KEY,
74
- secretKey: SECRET_KEY,
81
+ accessKey: "YOUR_ACCESS_KEY",
82
+ secretKey: "YOUR_SECRET_KEY",
75
83
  },
84
+ /**
85
+ * at least one serviceId required
86
+ * if you call send operation without serviceId, sdk throw error
87
+ */
76
88
  serviceId: {
77
- sms: "ncp:sms:kr:123456789xxx:your-service-name", // optional
78
- kakao: "ncp:kkobizmsg:kr:9876xxx:your-service-name", // optional
89
+ kakao: "ncp:kkobizmsg:kr:xxxxxx:your-service-name",
90
+ sms: "ncp:sms:kr:xxxxxx:your-service-name",
79
91
  },
80
92
  });
81
-
82
- /**
83
- * accessKey, secretKey: https://www.ncloud.com/mypage/manage/authkey
84
- * serviceId: https://console.ncloud.com/sens/project
85
- *
86
- * at least one serviceId required
87
- * if you call send operation without serviceId, sdk throw error
88
- */
89
93
  ```
90
94
 
91
95
  #### SendAlimtalk
92
96
 
93
97
  ```ts
94
- let params: SendAlimtalkCommandInput = {
95
- plusFriendId: PLUS_FRIEND_ID,
96
- templateCode: TEMPLATE_CODE,
97
- messages: [{ to: "01012345678", content: CONTENT }],
98
- };
99
- let command = new SendAlimtalkCommand(params);
98
+ const command = new SendAlimtalkCommand({
99
+ /** Required: Kakao PlusFriend ID (e.g., @kakao) */
100
+ plusFriendId: "PLUS_FRIEND_ID",
101
+
102
+ /** Required: Kakao Alimtalk TemplateCode ID (e.g., welcomeTemplate) */
103
+ templateCode: "TEMPLATE_CODE",
104
+
105
+ /** Required: List of messages to send (Max 100) */
106
+ messages: [
107
+ /** Recipient phone number (digits only), Message content */
108
+ { to: "01012345678", content: "YOUR_CONTENT" },
109
+ ],
110
+ });
111
+ ```
112
+
113
+ #### ListAlimtalkStatus
114
+
115
+ ```ts
116
+ const command = new ListAlimtalkStatusCommand({
117
+ /** Required: Kakao PlusFriend ID (e.g., @kakao) */
118
+ plusFriendId: "CHANNEL_ID",
119
+
120
+ /**
121
+ * Optional: Start time in KST (Format: yyyy-MM-ddTHH:mm:ss.SSS)
122
+ * Defaults to 24 hours prior to requestEndTime if not provided.
123
+ */
124
+ requestStartTime: "yyyy-MM-ddTHH:mm:ss.SSS",
125
+
126
+ /**
127
+ * Optional: End time in KST (Format: yyyy-MM-ddTHH:mm:ss.SSS)
128
+ * Defaults to the current system time if not provided.
129
+ */
130
+ requestEndTime: "yyyy-MM-ddTHH:mm:ss.SSS",
131
+ });
132
+ ```
133
+
134
+ #### GetAlimtalkStatus
135
+
136
+ ```ts
137
+ const command = new GetAlimtalkStatusCommand({ requestId: "ALIMTALK_REQUEST_ID" });
100
138
  ```
101
139
 
102
140
  #### SendSMS (SMS, LMS)
103
141
 
142
+ - **Message Type Automation**: The SDK automatically determines the message type ('SMS' or 'LMS') based on the content length (EUC-KR encoding)
143
+
144
+ - SMS: Up to 90 bytes
145
+ - LMS: Up to 2,000 bytes
146
+
147
+ - **Default Value Policy**: If `subject` or `content` is not defined within the individual message object, the SDK uses the **top-level** `content` and the default subject ('제목없음').
148
+
104
149
  ```ts
105
- /**
106
- * Automatically set message type('SMS' | 'LMS') according to content-length(euc-kr)
107
- * SMS: max 90bytes
108
- * LMS: max 2000bytes
109
- */
110
- let params: SendSMSCommandInput = {
111
- from: '01012345678',
112
- content: DEFAULT_CONTENT,
150
+ const command = new SendSMSCommand({
151
+ /** Sender's phone number (digits only) for all messages in the batch. */
152
+ from: "01012345678",
153
+
154
+ /** Default message content */
155
+ content: "DEFAULT_CONTENT",
113
156
  messages: [
114
- { to: '0109182xxxx' },
115
- { to: '0104321xxxx', content?: OPTIONAL_CONTENT_01 }
116
- { to: '0108765xxxx', content?: OPTIONAL_CONTENT_02, subject?: OPTIONAL_SUBJECT_01 },
117
- ]
118
- };
119
- /**
120
- * If you do not define the subject and content within the messages,
121
- * it is sent with the value specified as the default subject('제목없음') and content.
122
- */
123
- let command = new SendSMSCommand(params);
157
+ /** Uses default message content */
158
+ { to: "0101111xxxx" },
159
+
160
+ /** Overrides with specific content */
161
+ { to: "0102222xxxx", content: "CONTENT_01" },
162
+
163
+ /** Overrides content & subject */
164
+ { to: "0103333xxxx", content: "CONTENT_02", subject: "SUBJECT_01" },
165
+ ],
166
+ });
124
167
  ```
125
168
 
126
169
  #### SendMMS (MMS)
127
170
 
171
+ - **Multimedia Messaging**: Supports sending images along with your message. (Supported formats: `.jpg`, `.jpeg`)
172
+
173
+ - **Default Value Policy**: Same as `SendSMSCommand`, individual messages will inherit the top-level `content` and `subject` if not specified.
174
+
128
175
  ```ts
129
- import { readFileSync } from 'node:fs';
176
+ import { readFileSync } from "node:fs";
130
177
 
131
- let params: SendMMSCommandInput = {
132
- from: '01012345678',
133
- content: DEFAULT_CONTENT,
134
- messages: [
135
- { to: '0109182xxxx' },
136
- { to: '0104321xxxx', content?: OPTIONAL_CONTENT_01 }
137
- { to: '0108765xxxx', content?: OPTIONAL_CONTENT_02, subject?: OPTIONAL_SUBJECT_01 },
138
- ],
139
- files: [ // support jpg, jpeg
140
- { name: '/your/absolute/path/sample-image-1.jpg' },
178
+ const command = new SendMMSCommand({
179
+ /** Same as SendSMSCommand */
180
+ ...
181
+ files: [
182
+ // 1. Specify the absolute path (The SDK will handle the file reading)
183
+ { name: "/your/absolute/path/sample-image-1.jpg" },
184
+
185
+ // 2. Pass base64 encoded data directly
141
186
  {
142
- name: '/your/absolute/path/sample-image-2.jpg',
143
- body?: readFileSync('/your/absolute/path/sample-image-2.jpg', { encoding: 'base64' })
144
- }
145
- ]
146
- };
147
- /**
148
- * If you do not define the subject and content within the messages,
149
- * it is sent with the value specified as the default subject('제목없음') and content.
150
- */
151
- let command = new SendMMSCommand(params);
187
+ name: "custom-image-name.jpg",
188
+ body: readFileSync("/your/absolute/path/sample-image-2.jpg", { encoding: "base64" }),
189
+ },
190
+ ],
191
+ });
152
192
  ```
153
193
 
154
194
  #### Async/await
@@ -173,6 +213,12 @@ client
173
213
  .catch((err) => console.dir(err, { depth: 4 }));
174
214
  ```
175
215
 
216
+ ## Getting Help
217
+
218
+ We use the GitHub issues for tracking bugs and feature requests.
219
+
220
+ If it turns out that you may have found a bug, please open an issue.
221
+
176
222
  ## License
177
223
 
178
224
  This SDK is distributed under the [MIT License](https://opensource.org/licenses/MIT), see LICENSE for more information.
@@ -11,55 +11,83 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SensClient = void 0;
13
13
  const util_http_handler_1 = require("@ingestkorea/util-http-handler");
14
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
15
- const middleware_1 = require("./middleware");
14
+ const index_js_1 = require("./models/index.js");
15
+ const index_js_2 = require("./middleware/index.js");
16
16
  class SensClient {
17
17
  constructor(config) {
18
- const resolvedCredentials = resolveCredentials(config);
19
- const resolvedServiceId = resolveServiceId(config);
18
+ this.httpHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
19
+ this.requestHandler = (input, context) => __awaiter(this, void 0, void 0, function* () { return this.httpHandler.handle(input.request); });
20
20
  this.config = {
21
- credentials: Object.assign({}, resolvedCredentials),
22
- serviceId: Object.assign({}, resolvedServiceId),
21
+ credentials: resolveCredentials(config),
22
+ serviceId: resolveServiceId(config),
23
23
  };
24
- this.requestHandler = new util_http_handler_1.NodeHttpHandler({ connectionTimeout: 3000, socketTimeout: 3000 });
25
24
  }
26
25
  send(command) {
27
26
  return __awaiter(this, void 0, void 0, function* () {
28
- let input = command.input;
29
- let request = yield command.serialize(input, this.config);
30
- request = yield (0, middleware_1.middlewareNcpSigner)(request, this.config);
31
- request = yield (0, middleware_1.middlewareIngestkoreaMetadata)(request, this.config);
32
- request = yield (0, middleware_1.middlewareSortHeaders)(request, this.config);
33
- let response = yield (0, middleware_1.middlewareRetry)(request, this.config, this.requestHandler);
34
- let output = yield command.deserialize(response);
35
- return output;
27
+ const { input, serializer, deserializer } = command;
28
+ const middlewares = [index_js_2.middlewareIngestkoreaMetadata, index_js_2.middlewareNcpSign, index_js_2.middlewareRetry];
29
+ const handler = composeMiddleware(middlewares, this.requestHandler);
30
+ try {
31
+ const request = yield serializer(input, this.config);
32
+ const { response } = yield handler({ request }, this.config);
33
+ const output = yield deserializer(response, this.config);
34
+ return output;
35
+ }
36
+ catch (e) {
37
+ throw e;
38
+ }
36
39
  });
37
40
  }
38
41
  }
39
42
  exports.SensClient = SensClient;
43
+ const composeMiddleware = (middlewares, finalHandler) => {
44
+ const handler = middlewares.reduceRight((next, middleware) => {
45
+ return middleware(next);
46
+ }, finalHandler);
47
+ return handler;
48
+ };
40
49
  const resolveCredentials = (config) => {
41
50
  const { credentials } = config;
51
+ let error = new index_js_1.SensError({
52
+ code: 401,
53
+ type: "Unauthorized",
54
+ message: "Invalid Credentials",
55
+ invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 인증 정보를 확인해주세요" }],
56
+ });
42
57
  if (!credentials)
43
- throw new util_error_handler_1.IngestkoreaError({
44
- code: 401,
45
- type: "Unauthorized",
46
- message: "Invalid Credentials",
47
- description: "Invalid Credentials",
48
- });
49
- return credentials;
58
+ throw error;
59
+ if (!credentials.accessKey) {
60
+ error.invalidInputs[0].message = "AccessKey 정보를 확인해주세요";
61
+ throw error;
62
+ }
63
+ if (!credentials.secretKey) {
64
+ error.invalidInputs[0].message = "SecretKey 정보를 확인해주세요";
65
+ throw error;
66
+ }
67
+ return {
68
+ accessKey: credentials.accessKey,
69
+ secretKey: credentials.secretKey,
70
+ };
50
71
  };
51
72
  const resolveServiceId = (config) => {
73
+ var _a, _b, _c;
52
74
  const { serviceId } = config;
75
+ let error = new index_js_1.SensError({
76
+ code: 400,
77
+ type: "Bad Request",
78
+ message: "Invalid ServiceId",
79
+ invalidInputs: [{ type: "not-valid.args", message: "SensClient 초기화시 서비스 정보를 확인해주세요" }],
80
+ });
53
81
  if (!serviceId)
54
- throw new util_error_handler_1.IngestkoreaError({
55
- code: 401,
56
- type: "Unauthorized",
57
- message: "Invalid Credentials",
58
- description: "Invalid ServiceId",
59
- });
82
+ throw error;
83
+ const isReady = !!Object.values(serviceId).filter((d) => !!d).length;
84
+ if (!isReady) {
85
+ error.invalidInputs[0].message = "최소 1개 이상의 서비스 정보가 필요합니다";
86
+ throw error;
87
+ }
60
88
  return {
61
- push: serviceId.push != undefined ? serviceId.push : undefined,
62
- sms: serviceId.sms != undefined ? serviceId.sms : undefined,
63
- kakao: serviceId.kakao != undefined ? serviceId.kakao : undefined,
89
+ kakao: (_a = serviceId.kakao) !== null && _a !== void 0 ? _a : "",
90
+ push: (_b = serviceId.push) !== null && _b !== void 0 ? _b : "",
91
+ sms: (_c = serviceId.sms) !== null && _c !== void 0 ? _c : "",
64
92
  };
65
93
  };
@@ -1,41 +1,16 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkResultCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkResult_1 = require("../protocols/GetAlimtalkResult");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkResultCommand extends models_1.SensCommand {
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 {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.kakao)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check Kakao ServiceId",
29
- });
30
- let request = yield (0, GetAlimtalkResult_1.serializeIngestkorea_restJson_GetAlimtalkResultCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetAlimtalkResult_1.deserializeIngestkorea_restJson_GetAlimtalkResultCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ messageId: input.messageId,
11
+ };
12
+ this.serializer = GetAlimtalkResult_js_1.se_GetAlimtalkResultCommand;
13
+ this.deserializer = GetAlimtalkResult_js_1.de_GetAlimtalkResultCommand;
39
14
  }
40
15
  }
41
16
  exports.GetAlimtalkResultCommand = GetAlimtalkResultCommand;
@@ -1,41 +1,17 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkStatusCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkStatus_1 = require("../protocols/GetAlimtalkStatus");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkStatusCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetAlimtalkStatus_js_1 = require("../protocols/GetAlimtalkStatus.js");
6
+ const MAX_LIMIT = 100;
7
+ const DEFAULT_LIMIT = 20;
8
+ class GetAlimtalkStatusCommand extends index_js_1.SensCommand {
17
9
  constructor(input) {
10
+ var _a;
18
11
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.kakao)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check Kakao ServiceId",
29
- });
30
- let request = yield (0, GetAlimtalkStatus_1.serializeIngestkorea_restJson_GetAlimtalkStatusCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetAlimtalkStatus_1.deserializeIngestkorea_restJson_GetAlimtalkStatusCommand)(response);
37
- return output;
38
- });
12
+ this.input = Object.assign({ requestId: input.requestId, pageSize: Math.min(MAX_LIMIT, Math.max(1, (_a = input.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_LIMIT)) }, (input.nextToken && { nextToken: input.nextToken }));
13
+ this.serializer = GetAlimtalkStatus_js_1.se_GetAlimtalkStatusCommand;
14
+ this.deserializer = GetAlimtalkStatus_js_1.de_GetAlimtalkStatusCommand;
39
15
  }
40
16
  }
41
17
  exports.GetAlimtalkStatusCommand = GetAlimtalkStatusCommand;
@@ -1,41 +1,17 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetAlimtalkTemplateCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetAlimtalkTemplate_1 = require("../protocols/GetAlimtalkTemplate");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetAlimtalkTemplateCommand extends models_1.SensCommand {
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 {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.kakao)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check Kakao ServiceId",
29
- });
30
- let request = yield (0, GetAlimtalkTemplate_1.serializeIngestkorea_restJson_GetAlimtalkTemplateCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetAlimtalkTemplate_1.deserializeIngestkorea_restJson_GetAlimtalkTemplateCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ channelId: input.channelId,
11
+ templateCode: input.templateCode,
12
+ };
13
+ this.serializer = GetAlimtalkTemplate_js_1.se_GetAlimtalkTemplateCommand;
14
+ this.deserializer = GetAlimtalkTemplate_js_1.de_GetAlimtalkTemplateCommand;
39
15
  }
40
16
  }
41
17
  exports.GetAlimtalkTemplateCommand = GetAlimtalkTemplateCommand;
@@ -1,41 +1,16 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetSMSResultCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetSMSResult_1 = require("../protocols/GetSMSResult");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetSMSResultCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetSMSResult_js_1 = require("../protocols/GetSMSResult.js");
6
+ class GetSMSResultCommand extends index_js_1.SensCommand {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.sms)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check SMS ServiceId",
29
- });
30
- let request = yield (0, GetSMSResult_1.serializeIngestkorea_restJson_GetSMSResultCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetSMSResult_1.deserializeIngestkorea_restJson_GetSMSResultCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ messageId: input.messageId,
11
+ };
12
+ this.serializer = GetSMSResult_js_1.se_GetSMSResultCommand;
13
+ this.deserializer = GetSMSResult_js_1.de_GetSMSResultCommand;
39
14
  }
40
15
  }
41
16
  exports.GetSMSResultCommand = GetSMSResultCommand;
@@ -1,41 +1,16 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.GetSMSStatusCommand = void 0;
13
- const models_1 = require("../models");
14
- const GetSMSStatus_1 = require("../protocols/GetSMSStatus");
15
- const util_error_handler_1 = require("@ingestkorea/util-error-handler");
16
- class GetSMSStatusCommand extends models_1.SensCommand {
4
+ const index_js_1 = require("../models/index.js");
5
+ const GetSMSStatus_js_1 = require("../protocols/GetSMSStatus.js");
6
+ class GetSMSStatusCommand extends index_js_1.SensCommand {
17
7
  constructor(input) {
18
8
  super(input);
19
- this.input = Object.assign({}, input);
20
- }
21
- serialize(input, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!config.serviceId.sms)
24
- throw new util_error_handler_1.IngestkoreaError({
25
- code: 400,
26
- type: "Bad Request",
27
- message: "Invalid Params",
28
- description: "Please Check SMS ServiceId",
29
- });
30
- let request = yield (0, GetSMSStatus_1.serializeIngestkorea_restJson_GetSMSStatusCommand)(input, config);
31
- return request;
32
- });
33
- }
34
- deserialize(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let output = yield (0, GetSMSStatus_1.deserializeIngestkorea_restJson_GetSMSStatusCommand)(response);
37
- return output;
38
- });
9
+ this.input = {
10
+ requestId: input.requestId,
11
+ };
12
+ this.serializer = GetSMSStatus_js_1.se_GetSMSStatusCommand;
13
+ this.deserializer = GetSMSStatus_js_1.de_GetSMSStatusCommand;
39
14
  }
40
15
  }
41
16
  exports.GetSMSStatusCommand = GetSMSStatusCommand;