Skip to content

Commit

Permalink
add d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliytv committed Oct 8, 2022
1 parent 07e0d5a commit bf88bef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "smsc",
"version": "2.0.0",
"version": "2.0.1",
"description": "Vodafone & SMSC.ru api",
"type": "module",
"main": "./src/index.js",
"types": "./types/index.d.ts",
"exports": {
".": "./src/index.js"
},
Expand Down Expand Up @@ -48,6 +49,7 @@
"node": ">=18.0.0"
},
"files": [
"src"
"src",
"types"
]
}
21 changes: 17 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import { isProd } from '@nitra/isenv'

const charset = 'utf-8'

// Отправка CMC
/**
* Отправка CMC
*
* @param {String} phones
* @param {String} message
* @param {String} sender
* @param {Number} distributionId
*
* @return {Promise<{cnt: number?,error_code:number? }>} результат отправки
*/
export const sendSms = async (phones, message, sender = null, distributionId = null) => {
let data

Expand Down Expand Up @@ -132,7 +141,12 @@ const masks = {
999: 'ru'
}

// получить страну по коду оператора из телефона
/**
* Получить страну по коду оператора из телефона
*
* @param {String} phone
* @return {String} ua или ru
*/
export const getCountry = phone => {
const mask = phone.slice(-10, -7)
if (mask && masks[mask]) {
Expand Down Expand Up @@ -242,9 +256,8 @@ const sendFromSmsc = async (phones, message, sender) => {
method: 'POST',
body: params
})
const data = await response.json()

return data
return response.json()
} catch (err) {
console.error(err)
return err
Expand Down
5 changes: 5 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function sendSms(phones: string, message: string, sender?: string, distributionId?: number): Promise<{
cnt: number;
error_code: number | null;
}>;
export function getCountry(phone: string): string;
1 change: 1 addition & 0 deletions types/keyv.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const keyv: any;

0 comments on commit bf88bef

Please sign in to comment.