https://github.com/qnester/hey-you-nexmo
Nexmo extension for hey-you gem
https://github.com/qnester/hey-you-nexmo
nexmo nexmo-sms vonage vonage-sms
Last synced: 8 months ago
JSON representation
Nexmo extension for hey-you gem
- Host: GitHub
- URL: https://github.com/qnester/hey-you-nexmo
- Owner: QNester
- Created: 2020-07-01T08:53:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-31T17:10:07.000Z (over 4 years ago)
- Last Synced: 2025-01-21T19:14:44.695Z (10 months ago)
- Topics: nexmo, nexmo-sms, vonage, vonage-sms
- Language: Ruby
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Hey, You, Nexmo!
[](https://travis-ci.com/QNester/hey-you-nexmo#)
[](https://badge.fury.io/rb/hey-you-nexmo)
Send Nexmo (Vonage) sms via [hey-you gem](https://github.com/QNester/hey-you).
After 1.0.0 version gem depended on [vonage-ruby-sdk](https://github.com/Vonage/vonage-ruby-sdk).
Early versions of gem depended on [nexmo-ruby](https://github.com/Nexmo/nexmo-ruby).
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'hey-you-nexmo'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install hey-you-nexmo
## Usage
After load gem you can send Nexmo SMS via [hey-you](https://github.com/QNester/hey-you).
For example:
```yaml
# config/notifications.yml
events:
verified_code:
# ...
nexmo:
text: 'Your verification code: %{code}'
from: 'bestNumber'
is_unicode: false # has priority above this setting in config
```
```ruby
# config/initalizers/hey-you.rb
HeyYou::Config.configure do
# [String] required - your sender number
config.nexmo.from = 'myNumber'
# [Vonage::Client] required - Instance of Nexmo client (check https://github.com/Nexmo/nexmo-ruby for more info)
config.nexmo.client = Vonage::Client.new(...)
# [Boolean] optional - If you will send unicode texts
config.nexmo.is_unicode = true
# [Block] optional - Response handle (block which accept Vonage::Response object)
config.nexmo.response_hander = proc { |response| CheckActualBalanceJob.perform_async(response.http_response.body) }
# Check https://developer.nexmo.com/api/sms#delivery-receipt for more info about settings below
config.nexmo.ttl = 90000
config.nexmo.status_report_req = true
config.nexmo.callback = 'http://my_callback.url/'
end
```
```ruby
# // somewhere in your app
builder = Builder.new('events.verified_code', code: verified_code)
HeyYou::Channels::Nexmo.send!(builder, to: receiver_phone_number) #=> { success: true }
```
If you want send sms with Google hash for [sending verification SMS](https://developers.google.com/identity/sms-retriever/verify?hl=ru)
just use `google_autofill_code_hash` in your builder:
```ruby
builder = Builder.new('events.verified_code', code: verified_code, google_autofill_code_hash: 'MySigningHash')
builder.text => "Your verification code: %{code}\n\nMySigningHash"
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`.