{"analyzedAt":"2022-07-09T18:39:02.914Z","collected":{"metadata":{"name":"goip","scope":"unscoped","version":"0.2.0","description":"Simple server and client for goip gateways","keywords":["goip","sms","server","client"],"date":"2020-04-30T20:58:38.023Z","author":{"name":"Michal Styrylski"},"publisher":{"username":"styryl","email":"styryl88@gmail.com"},"maintainers":[{"username":"styryl","email":"styryl88@gmail.com"}],"repository":{"type":"git","url":"git://github.com/styryl/node-goip.git"},"links":{"npm":"https://www.npmjs.com/package/goip","homepage":"https://github.com/styryl/node-goip#readme","repository":"https://github.com/styryl/node-goip","bugs":"https://github.com/styryl/node-goip/issues"},"license":"MIT","dependencies":{"fast-xml-parser":"^3.16.0","node-fetch":"^2.6.0"},"devDependencies":{"chai":"^4.2.0","mocha":"^7.1.1","nock":"^12.0.3","proxyquire":"^2.1.3","sinon":"^9.0.2"},"releases":[{"from":"2022-06-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2022-04-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":1},{"from":"2022-01-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":1},{"from":"2021-07-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":1},{"from":"2020-07-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"This package allow to send and receive SMS messages using GSM / VOIP Goip1, Goip4, Goip8, Goip16 gateways from Hybertone / Dbltek company. SMS can be received via the UDP protocol. The SMS can be sent via UDP or HTTP. Additionally, it is possible to receive basic information about the state and status of individual GSM gates (lines).\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install goip\r\n```\r\n\r\n## Server usage instruction\r\n\r\nTo start receiving messages from Goip gateways you need to create and start a server.\r\n\r\n#### Example 1\r\n\r\n```javascript\r\nconst {ServerFactory, HttpSms, SocketSms} = require('goip');\r\n\r\nconst server = ServerFactory.make(333);\r\n\r\nserver.onAll( (message) => {\r\n    console.log(message);\r\n});\r\n\r\nserver.run();\r\n```\r\n\r\n#### Example 2\r\n\r\n```javascript\r\nconst {ServerFactory, MessageDispatcher, MessageFactory} = require('goip');\r\n\r\nconst server = ServerFactory.make(333, {\r\n    'address': '0.0.0.0', // server address\r\n    'messageDispatcher': new MessageDispatcher(), // Message Dispatcher implementation\r\n    'messageFactory': new MessageFactory() // Message Factory implementation\r\n});\r\n\r\nserver.onAll( (message) => {\r\n    console.log(message);\r\n});\r\n\r\nserver.run();\r\n```\r\n\r\n#### Register message listener\r\n\r\n```javascript\r\nconst {ServerFactory} = require('goip');\r\n\r\nconst server = ServerFactory.make(333);\r\n\r\n// All messages\r\nserver.onAll( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Goip not supported message\r\nserver.onNotSupported( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Keep Alive packets with gateway (line) information\r\nserver.onRequest( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Incoming SMS\r\nserver.onReceive( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// SMS delivery report\r\nserver.onDeliver( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// End telephone call\r\nserver.onHangup( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Start a phone call\r\nserver.onRecord( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Change of gate (line) status\r\nserver.onState( (message) => {\r\n    console.log(message);\r\n});\r\n\r\n// Socket server error message\r\nserver.onServerError( (message) => {\r\n    console.log(message);\r\n});\r\n\r\nserver.run();\r\n```\r\n\r\n## Sending a message\r\n\r\n#### Sending via UDP socket\r\n\r\n##### Example 1 - sending one message and close the connection\r\n\r\n```javascript\r\nconst {SocketSms} = require('goip');\r\n\r\nconst sms = new SocketSms(\r\n\t'192.168.0.11', // Goip address\r\n\t9991, // Goip port\r\n\t'goip_password' // Goip password\r\n);\r\n\r\nsms.sendOne('999999999','test sms message').then( response => {\r\n    console.log(response);\r\n}).catch(error => {\r\n    console.log(error);\r\n});\r\n```\r\n\r\n##### Example 2 - sending many messages\r\n\r\n```javascript\r\nconst {SocketSms} = require('goip');\r\n\r\nconst sms = new SocketSms(\r\n\t'192.168.0.11', // Goip address\r\n\t9991, // Goip port\r\n\t'goip_password' // Goip password\r\n);\r\n\r\n( async () => {\r\n\r\n    try {\r\n\r\n        const response1 = await sms.send('999999999','test sms message 1');\r\n        const response2 = await sms.send('999999999','test sms message 2');\r\n\r\n        console.log(response1);\r\n        console.log(response2);\r\n\r\n    } catch (error) {\r\n\r\n        console.log(error);\r\n\r\n    }\r\n\r\n    sms.close();\r\n})();\r\n```\r\n\r\n#### Sending via HTTP\r\n\r\n##### Example 1 - sending one message\r\n\r\n```javascript\r\nconst {HttpSms} = require('goip');\r\n\r\nconst sms = new HttpSms(\r\n    'http://192.168.0.11', // Goip http address\r\n    1, // Line number\r\n    'login', // Goip login\r\n    'password', // Goip password\r\n    {\r\n\t\t'waitForStatus': false, // Wait and check sending status\r\n\t\t'waitTries': 10, // Number of attempts\r\n\t\t'waitTime': 1000 // Time in  milliseconds\r\n\t});\r\n\r\nsms.send('999999999', 'test message').then((response) => {\r\n    console.log(response);\r\n}).catch((error) => {\r\n    console.log(error);\r\n});\r\n```\r\n\r\n##### Example 2 - sending many messages\r\n\r\n```javascript\r\nconst {HttpSms} = require('goip');\r\n\r\nconst sms = new HttpSms('http://192.168.0.11',1,'login','password',{\r\n    'waitForStatus': true\r\n});\r\n\r\n(async () => {\r\n\r\n    try {\r\n        const response1 = await sms.send('999999999','test sms message 1');\r\n        const response2 = await sms.send('999999999','test sms message 2');\r\n        console.log(response1);\r\n        console.log(response2);\r\n    } catch (error) {\r\n        console.log(error);\r\n    }\r\n\r\n})();\r\n```\r\n\r\n##### Example 3 - checking status by id\r\n\r\n```javascript\r\nconst {HttpSms} = require('goip');\r\nconst sms = new HttpSms(\r\n    'http://192.168.0.11', // Goip http address\r\n    1, // Line number\r\n    'login', // Goip login\r\n    'password', // Goip password\r\n);\r\n\r\n( async () => {\r\n\r\n    try {\r\n        const response = await sms.send('999999999', 'test message');\r\n\r\n        console.log(response);\r\n\r\n        setTimeout(async () => {\r\n            const isSend = await sms.isSend( response.id );\r\n\r\n            if( isSend ) {\r\n                console.log('sms sent')\r\n            }\r\n        \r\n            if( !isSend ) {\r\n                console.log('sms not sent')\r\n            }\r\n\r\n        }, 5000);\r\n\r\n    } catch (error) {\r\n        console.log(error);\r\n    }\r\n\r\n})();\r\n```"},"npm":{"downloads":[{"from":"2022-07-08T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2022-07-02T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":4},{"from":"2022-06-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":43},{"from":"2022-04-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":86},{"from":"2022-01-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":124},{"from":"2021-07-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":294}],"starsCount":0},"github":{"starsCount":6,"forksCount":4,"subscribersCount":2,"issues":{"count":4,"openCount":1,"distribution":{"3600":0,"10800":0,"32400":0,"97200":2,"291600":1,"874800":0,"2624400":0,"7873200":0,"23619600":1,"70858800":0,"212576400":0},"isDisabled":false},"contributors":[{"username":"styryl","commitsCount":18}],"commits":[{"from":"2022-07-02T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2022-06-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2022-04-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2022-01-10T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0},{"from":"2021-07-09T00:00:00.000Z","to":"2022-07-09T00:00:00.000Z","count":0}]},"source":{"files":{"readmeSize":4897,"testsSize":66549,"hasNpmIgnore":true},"outdatedDependencies":{"fast-xml-parser":{"required":"^3.16.0","stable":"4.0.8","latest":"4.0.8"},"node-fetch":{"required":"^2.6.0","stable":"3.2.6","latest":"4.0.0-beta.4"}}}},"evaluation":{"quality":{"carefulness":0.39499999999999996,"tests":0.6,"health":0.5,"branding":0},"popularity":{"communityInterest":13,"downloadsCount":28.666666666666668,"downloadsAcceleration":0.1278158295281583,"dependentsCount":0},"maintenance":{"releasesFrequency":0.28664383561643836,"commitsFrequency":0,"openIssues":0.9166666666666667,"issuesDistribution":0.7669609882305194}},"score":{"final":0.5069510183207798,"detail":{"quality":0.668725333862763,"popularity":0.04329701204414605,"maintenance":0.8319413255614281}}}