1.0.2 • Published 2 years ago

adonisjs-infobip v1.0.2

Weekly downloads
21
License
MIT
Repository
github
Last release
2 years ago

adonis-infobip

An addon/plugin package to provide InfoBip single/bulk SMS/Voice/WebRTC services in AdonisJS 4.0+

NPM Version Build Status Coveralls

Getting Started

Install from the NPM Registry

   $ adonis install adonisjs-infobip

Usage

Import and use

  'use strict'
  
  const Infobip = use('InfoBip')
  
  class MessageController {
  
      constructor(User){
          this.user = User
      }
      
      static get inject(){
          return [
              'App/Models/User'
          ]
      }
      
      async sendOneSms({ request, response }){

          let user = await this.user.find(1) // get user from database

          let response = await Infobip.sendSMS({
            messages: [{
              destinations: [{
                to: String(user.phone_number)
              }],
              from:"MESSANGER-NG",
              text:`Hello ${user.full_name}, Happy birthday!`
            }]
          })

          console.log("Bulk ID: ", response.body.bulkId)

          return response.status(200).json({
            status: 'success',
            data: `Message sent to ${user.full_name}`
          })
      }
  }
  
  module.exports = MessageController

License

MIT

Running Tests

    npm i
    npm run lint

    npm run test

Credits

Contributing

See the CONTRIBUTING.md file for info