nexmo_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +24 -0
- data/README.md +78 -0
- data/Rakefile +27 -0
- data/lib/generators/nexmo_initializer/nexmo_initializer_generator.rb +20 -0
- data/lib/nexmo_rails.rb +20 -0
- data/lib/nexmo_rails/version.rb +3 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a99673a5cde8fd7793f3505a0d0f0d24a55ba251aa32adf6733e982d0582db5a
|
4
|
+
data.tar.gz: 88d0eeb00a51896414a58e7944d8a6ec0233aac78f0e0cb8f8c1f1293522dcf2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ed4cd5750e1341f47d133475f22a9c20d95189c7c48c0f4ecc58ae34dc084ee9cf55ed6ec710e9b6be4ddd8b3026270bc5dea69696bdc7c263681e1e831ae8c
|
7
|
+
data.tar.gz: 77092e3ecbe832ff51fe1598e8ca9d8f068f21b72da847f4dc8a989313d67375503db1cbfb78a28695f9eb5e99a5766fc714bf9bef698c6a838d623b8e1350f8
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016-2019 Nexmo Inc
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the "Software"), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Nexmo Rails Gem
|
2
|
+
|
3
|
+
This is the Nexmo Rails Gem for Nexmo's API. To use it you'll
|
4
|
+
need a Nexmo account. Sign up [for free at nexmo.com](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=nexmo-rails).
|
5
|
+
|
6
|
+
* [Requirements](#requirements)
|
7
|
+
* [Installation](#installation)
|
8
|
+
* [Usage](#usage)
|
9
|
+
* [License](#license)
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
Nexmo Rails requires:
|
14
|
+
|
15
|
+
* Rails 5.2+
|
16
|
+
* Ruby 2.5.3+
|
17
|
+
* [dotenv](https://github.com/bkeepers/dotenv)
|
18
|
+
* To use the Nexmo APIs, you [need an account](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=nexmo-rails)
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
To install the Nexmo Rails gem, add it, along with `dotenv-rails`, to your project's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
|
26
|
+
gem 'nexmo_rails'
|
27
|
+
gem 'dotenv-rails'
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
The `dotenv-rails` gem assists with environment variable management and utilization.
|
32
|
+
|
33
|
+
Then, run `bundle install` from the command line.
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
The Nexmo Rails gem will initialize a new instance of the Nexmo client inside your Rails application and make it globally accessible. To make this happen, first add the desired Nexmo credentials to your `.env` file. For example, if you are using only the `API_KEY` and `API_SECRET`, then add the following:
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
NEXMO_API_KEY = your_api_key
|
42
|
+
NEXMO_API_SECRET = your_api_secret
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
If you are also using a `SIGNATURE`, `APPLICATION_ID` and/or a `PRIVATE_KEY`, then add them as appropriate to your `.env` file:
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
NEXMO_API_SIGNATURE = your_signature
|
51
|
+
NEXMO_PRIVATE_KEY = your_private_key_file_path
|
52
|
+
NEXMO_APPLICATION_ID = your_application_id
|
53
|
+
|
54
|
+
```
|
55
|
+
|
56
|
+
To initialize your global Nexmo client in your application, run the following from your terminal:
|
57
|
+
|
58
|
+
```console
|
59
|
+
|
60
|
+
rails generate nexmo_initializer
|
61
|
+
|
62
|
+
```
|
63
|
+
|
64
|
+
This will create a `./config/initializers/nexmo.rb` file in your application that will make the variable `Nexmo` available across your application, which contains your fully credentialed Nexmo client.
|
65
|
+
|
66
|
+
At this point, you can access any of the Nexmo APIs by simply referring to `Nexmo` in your code. For example, instead of first initializing a Nexmo client with your credentials to send an SMS, all you need to do is add the following to your application:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
|
70
|
+
Nexmo.sms.send(from: 'YOUR_NUMBER', to: 'NUMBER', text: 'Hello world')
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
More information on the Nexmo Ruby client library and how to use it with the Nexmo APIs can be found [here](https://github.com/Nexmo/nexmo-ruby).
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
This project is under the [MIT License](LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'NexmoRails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class NexmoInitializerGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc "This generator creates a Nexmo initializer file at config/initializers and makes a configured Nexmo client globally available"
|
7
|
+
|
8
|
+
def create_nexmo_initializer
|
9
|
+
initializer "nexmo.rb" do <<~HEREDOC
|
10
|
+
Nexmo.setup do |config|
|
11
|
+
config.api_key = ENV['NEXMO_API_KEY'],
|
12
|
+
config.api_secret = ENV['NEXMO_API_SECRET'],
|
13
|
+
config.api_signature = ENV['NEXMO_API_SIGNATURE'],
|
14
|
+
config.application_id = ENV['NEXMO_APPLICATION_ID'],
|
15
|
+
config.private_key = ENV['NEXMO_PRIVATE_KEY']
|
16
|
+
end
|
17
|
+
HEREDOC
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/nexmo_rails.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'nexmo'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
class << self
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
attr_accessor :client
|
9
|
+
|
10
|
+
def_delegators :@client, :sms, :tfa, :calls, :verify,
|
11
|
+
:number_insight, :applications, :numbers,
|
12
|
+
:secrets, :redact, :signature
|
13
|
+
|
14
|
+
def setup
|
15
|
+
self.client = ::Nexmo::Client.new do |config|
|
16
|
+
yield config
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nexmo_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nexmo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nexmo
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: generator_spec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Rails Initializer for Nexmo's Ruby Client
|
84
|
+
email:
|
85
|
+
- devrel@nexmo.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- lib/generators/nexmo_initializer/nexmo_initializer_generator.rb
|
94
|
+
- lib/nexmo_rails.rb
|
95
|
+
- lib/nexmo_rails/version.rb
|
96
|
+
homepage: https://github.com/Nexmo/nexmo-rails
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata:
|
100
|
+
homepage: https://github.com/Nexmo/nexmo-rails
|
101
|
+
source_code_uri: https://github.com/Nexmo/nexmo-rails
|
102
|
+
bug_tracker_uri: https://github.com/Nexmo/nexmo-rails/issues
|
103
|
+
changelog_uri: https://github.com/Nexmo/nexmo-rails/blog/master/CHANGES.md
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.7.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: This is a Rails initializer for Nexmo's Ruby Gem. To use it you'll need a
|
124
|
+
Nexmo account. Sign up for free at https://www.nexmo.com
|
125
|
+
test_files: []
|