Skip to content

Commit

Permalink
feat/sms: Minor fix on jsDocs, notes & Documentation updated.
Browse files Browse the repository at this point in the history
UPDATE README, CHANGELOG
CHANGE incorrectly stated jsDocs and notes

RELEASE v1.0.5
  • Loading branch information
hubtwork committed Apr 20, 2021
1 parent b2407df commit 561ea02
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 46 deletions.
30 changes: 24 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
## Changes

## v1.0.5 ( 2021. 4. 19 )
## v1.0.5 ( 2021. 4. 20 )

#### [ SENS - SMS service ] SendSMS support Reservation
#### NCPClient will support service's unique error types

- If you want to use SMS Reservation, just pass the **nullable Reservation parameter**
- NCPClient's request module, `ApiRequest` can handle service's unique errors now

> **service's unique error** means almost parameter validation.
>
> If given parameter is incorrect with NCP-defined format, It will return **ApiClientResponse with error** and request won't send.
#### [ SENS - SMS service ] SearchMessageRequest / SearchMessageResult now supported

- Using **SendSMS API** , you can get `requestId` of request from response

- **SearchMessageRequest** with requestId from **SendSMS API's response** will return the detail delivery request

~~~typescript
const { isSuccess, data } = await smsService.searchMessageRequest('requestId')
~~~

- **SearchMessageResponse** with messageId from **SearchMessageRequest API's response** will return the detail delivery results

~~~typescript
const { isSuccess, data } = await smsService.searchMessageResult('messageId')
~~~


#### Dependency changed

- **crypto** changed to built-in module, so deprecated in dependency



## v 1.0.4 ( 2021. 4. 18 )
## v1.0.4 ( 2021. 4. 18 )

#### ApiRequest clarity guaranteed

Expand Down
138 changes: 108 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ An easy-to-use typescript wrapper for [Naver Cloud Platform API](https://api.ncl
## Dependency

- axios
- crypto



Expand Down Expand Up @@ -66,33 +65,60 @@ const smsService = sens.smsService(ncpAuthKey, smsAuthKey)

- **SMS Send**

~~~javascript
// type your SMS send parameter
const sendSMSparam = {
to: 'recipient phoneNumber',
content: 'message to send'
}
// to send to multiple people
const multipleSMSparam = [
{ to: 'r1', content: 'c1'},
{ to: 'r2', content: 'c2'},
{ to: 'r3', content: 'c3'}
]

async function sendMessage() {
// if you don't pass countryCode, default countryCode is 82.
const {isSuccess, data, errorMessage } = await smsService.sendSMS( sendSMSparam, countryCode )
// write something after async function
if (isSuccess) {
// do something with data
} else {
// handle with errorMessage
}
}

~~~


~~~javascript
// type your SMS send parameter
const sendSMSparam = {
to: 'recipient phoneNumber',
content: 'message to send'
}
// to send to multiple people
const multipleSMSparam = [
{ to: 'r1', content: 'c1'},
{ to: 'r2', content: 'c2'},
{ to: 'r3', content: 'c3'}
]

async function sendMessage() {
// if you don't pass countryCode, default countryCode is 82.
const {isSuccess, data, errorMessage } = await smsService.sendSMS( sendSMSparam, countryCode )
// write something after async function
if (isSuccess) {
// do something with data
} else {
// handle with errorMessage
}
}
~~~

- **Search message delivery request**

~~~javascript
async function searchMessageDeliveryRequest() {
const {isSuccess, data, errorMessage } = await smsService.searchMessageRequest('requestId')
// write something after async function
if (isSuccess) {
// do something with data
} else {
// handle with errorMessage
}
}
~~~

- **Search message delivery results**

~~~javascript
async function searchMessageDeliveryResults() {
const {isSuccess, data, errorMessage } = await smsService.searchMessageResult('messageId')
// write something after async function
if (isSuccess) {
// do something with data
} else {
// handle with errorMessage
}
}
~~~



## Types

Expand Down Expand Up @@ -140,7 +166,57 @@ type SendSMSReturnType = {
}
~~~


**Search message delivery request**

~~~typescript
export type SearchMessageRequestReturnType = {
requestId: string
statusCode: string
statusName: string
// `messages` contains messages associated with requestId
messages: MessageRequestType[]
}
// Each message's summary
type MessageRequestType = {
messageId: string
requestTime: string
contentType: string
countryCode: string
from: string
to: string
}
~~~

**Search message delivery results**

~~~typescript
export type SearchMessageResultReturnType = {
statusCode: string
statusName: string
// `messages` contains messages associated with messageId
messages: MessageResultType[]
}
// Each message's detail
type MessageResultType = {
requestTime: string
// `contentType` will be 'COMM' | 'AD', but currently not supported with AD message api
contentType: string
content: string
countryCode: string
from: string
to: string
status: string
statusCode: string
statusMessage: string
statusName: string
// `completeTime` means the time when request completed
completeTime: string
// `telcoCode` means telecommunication Provider Info
telcoCode: string
}
~~~



## API Response statuses

Expand All @@ -162,7 +238,9 @@ API Response status provided by Naver Cloud Platform

#### (SENS) SMS API v2

- **SMS Send**
- **Send SMS**
- **Search message delivery request**
- **Search message delivery results**



Expand Down
3 changes: 1 addition & 2 deletions src/__test__/sms/searchsmsrequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const axios = require('axios')
import { MockSMS } from '../mock/mock_smsClient';
import { SendSMSParamType } from '../../types/param_types';
import { SearchMessageRequestReturnType, SearchMessageResultReturnType, SendSMSReturnType } from '../../types/return_types';
import { SearchMessageRequestReturnType } from '../../types/return_types';
import { NCPAuthKeyType, SMSserviceAuthType } from '../../types/auth_types';

jest.mock('axios')
Expand Down
3 changes: 1 addition & 2 deletions src/__test__/sms/searchsmsresult.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const axios = require('axios')
import { MockSMS } from '../mock/mock_smsClient';
import { SendSMSParamType } from '../../types/param_types';
import { SearchMessageRequestReturnType, SearchMessageResultReturnType, SendSMSReturnType } from '../../types/return_types';
import { SearchMessageResultReturnType } from '../../types/return_types';
import { NCPAuthKeyType, SMSserviceAuthType } from '../../types/auth_types';

jest.mock('axios')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios')
import { MockSMS } from '../mock/mock_smsClient';
import { SendSMSParamType } from '../../types/param_types';
import { SearchMessageRequestReturnType, SearchMessageResultReturnType, SendSMSReturnType } from '../../types/return_types';
import { SendSMSReturnType } from '../../types/return_types';
import { NCPAuthKeyType, SMSserviceAuthType } from '../../types/auth_types';

jest.mock('axios')
Expand Down
6 changes: 3 additions & 3 deletions src/clients/sens/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ export class SMS {

/**
* Construct searchMessageResult Service apiRequest. Generate signature for signing, pass requestId for search.
* return the requestData for given messageId. It also returns messages info refer to the request.
* It's response data is more detail than searchMessageRequest with completeTime, statuses, telcoCode, etc.
* return the requestData for given messageId. It also returns messages info refer to the message.
* It's response data is more detail than searchMessageResult with completeTime, statuses, telcoCode, etc.
* @async
* @access public
* @param {string} messageId - messageId which get from response of sendSMS API
* @param {string} messageId - messageId which get from response of searchMessageRequest API
* @returns {Promise<ApiClientResponse<SearchMessageRequestReturnType>>} return Promise response of http request with current ApiRequest configs and handle errors
* @memberof SMS
*/
Expand Down
2 changes: 0 additions & 2 deletions src/types/return_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,4 @@ type MessageResultType = {
completeTime: string
// ISP
telcoCode: string
// MMS only
files?: { name: string }[]
}

0 comments on commit 561ea02

Please sign in to comment.