any_sms-backend-aws 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +19 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/Guardfile +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/any_sms-backend-aws.gemspec +43 -0
- data/lib/any_sms/backend/aws/version.rb +5 -0
- data/lib/any_sms/backend/aws.rb +42 -0
- data/lib/any_sms-backend-aws.rb +1 -0
- data/permissions_screenshot.png +0 -0
- data/screenshot.png +0 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2bcec159b70d4fba5abe670571ac31a458eeaae
|
4
|
+
data.tar.gz: 991da348a4f1988dc6b4175b4eab9fa0c1ba32ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a58c20681e17fa46351f6a0ebaa04887e75a40197e0658ec44686ada60f9ae97b53105fcc7451fdbd1f669d4ab8d51e0b7e30b2bbff590422b3c97faa20ada2
|
7
|
+
data.tar.gz: c7c11f79c30ec45d3e9bea31a3ecb66a70c4ac0541e04a29433d54cd6a66aee06bed9cf5c68a3ce3bd6cf37ef2f75ac871c7f1f12fbfccb69d87a96e98894f0e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.1
|
3
|
+
Exclude:
|
4
|
+
- "lib/any_sms/backend/aws/version.rb"
|
5
|
+
- "lib/any_sms-backend-aws.rb"
|
6
|
+
|
7
|
+
Metrics/BlockLength:
|
8
|
+
Exclude:
|
9
|
+
- "spec/**/*"
|
10
|
+
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 90
|
13
|
+
|
14
|
+
Style/StringLiterals:
|
15
|
+
EnforcedStyle: double_quotes
|
16
|
+
ConsistentQuotesInMultiline: true
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
EnforcedStyle: compact
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Lib files
|
12
|
+
watch(%r{^lib/any_sms.rb$}) { rspec.spec_dir }
|
13
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| rspec.spec.call(m[1]) }
|
14
|
+
|
15
|
+
# Ruby files
|
16
|
+
ruby = dsl.ruby
|
17
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
18
|
+
end
|
19
|
+
|
20
|
+
guard "yard" do
|
21
|
+
watch(%r{lib/.+\.rb})
|
22
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016-2017 Fedcomp
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# AnySMS::Backend::AWS
|
2
|
+
[![Build Status](https://travis-ci.org/Fedcomp/any_sms-backend-aws.svg?branch=master)](https://travis-ci.org/Fedcomp/any_sms-backend-aws)
|
3
|
+
|
4
|
+
AnySMS backend to send sms using [Amazon Web Services](https://aws.amazon.com).
|
5
|
+
**At this point gem does not support SenderID**. If you know how to specify it - open issue or make pull request, all contributions are welcome!
|
6
|
+
|
7
|
+
## Before installation - obtaining token
|
8
|
+
|
9
|
+
Before you can use this gem, you should get tokens from amazon web services (AWS).
|
10
|
+
Here are steps to achieve that:
|
11
|
+
|
12
|
+
1. Go to [AWS registration page](https://goo.gl/HG8Y9s)
|
13
|
+
2. After you registered and logged in, go to [IAM users](https://goo.gl/u4hrzj)
|
14
|
+
3. Click "Create new users", enter username of your wish (in my case `testuser`) and then click "Create".
|
15
|
+
4. You should see similar picture:
|
16
|
+
|
17
|
+
![security credentials](screenshot.png)
|
18
|
+
|
19
|
+
save **access key id** and **secret acces key** somwhere.
|
20
|
+
5. Now close popup and click on the user.
|
21
|
+
6. Click **Permissions** tab. It will look like this
|
22
|
+
|
23
|
+
![permissions tab](permissions_screenshot.png)
|
24
|
+
|
25
|
+
7. Click on **Attach Policy**, then filter by **SNS**.
|
26
|
+
8. Check **AmazonSNSFullAccess**, click **Attach Policy** (at the bottom)
|
27
|
+
|
28
|
+
This is simple example on how to get them and make things work quick.
|
29
|
+
In reality AWS support various access options,
|
30
|
+
you may read them [here](https://goo.gl/sajJgL) and configure it more strict or closer to your needs.
|
31
|
+
|
32
|
+
## Installation & usage
|
33
|
+
|
34
|
+
Add this line to your application's Gemfile:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
gem "any_sms-backend-aws"
|
38
|
+
```
|
39
|
+
|
40
|
+
Then somewhere in your initialization code:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require "any_sms"
|
44
|
+
require "any_sms-backend-aws"
|
45
|
+
|
46
|
+
AnySMS.configure do |c|
|
47
|
+
c.register_backend(:my_main_backend,
|
48
|
+
AnySMS::Backend::AWS,
|
49
|
+
access_key: ENV["AWS_ACCESS_KEY"],
|
50
|
+
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
|
51
|
+
region: ENV["AWS_REGION"] # Optional, default will be "us-east-1"
|
52
|
+
)
|
53
|
+
|
54
|
+
c.default_backend = :my_main_backend
|
55
|
+
end
|
56
|
+
```
|
57
|
+
This is an simple example of configuration.
|
58
|
+
Before running application you should specify
|
59
|
+
`AWS_ACCESS_KEY`, `AWS_SECRET_ACCESS_KEY` and `AWS_REGION`
|
60
|
+
environment variables.
|
61
|
+
You may change initializer code to suit your needs more,
|
62
|
+
just make sure **you never store credentials commited to your codebase**.
|
63
|
+
It should be stored separately from application.
|
64
|
+
|
65
|
+
Now, whenever you need to send SMS, just do:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
# Will immediately send sms
|
69
|
+
AnySMS.send_sms("+10000000000", "My sms text")
|
70
|
+
```
|
71
|
+
|
72
|
+
For more advanced usage please
|
73
|
+
go to [AnySMS documentation](https://github.com/Fedcomp/any_sms#real-life-example)
|
74
|
+
|
75
|
+
## Contributing
|
76
|
+
|
77
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Fedcomp/any_sms-backend-aws.
|
78
|
+
|
79
|
+
## License
|
80
|
+
|
81
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "any_sms/backend/aws/version"
|
6
|
+
|
7
|
+
# rubocop:disable Metrics/BlockLength
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "any_sms-backend-aws"
|
10
|
+
spec.version = AnySMS::Backend::AWS_VERSION
|
11
|
+
spec.authors = ["Fedcomp"]
|
12
|
+
spec.email = ["aglergen@gmail.com"]
|
13
|
+
|
14
|
+
spec.summary = "AnySMS backend for using amazon web services sms delivery"
|
15
|
+
spec.homepage = "https://github.com/Fedcomp/any_sms-backend-aws"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
unless spec.respond_to?(:metadata)
|
19
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "any_sms"
|
32
|
+
spec.add_dependency "aws-sdk", "~> 2.6"
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rubocop"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "webmock", "~> 2.1"
|
39
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
40
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
41
|
+
spec.add_development_dependency "guard-yard"
|
42
|
+
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
require "any_sms"
|
3
|
+
require "any_sms/backend/aws/version"
|
4
|
+
|
5
|
+
# AnySMS backend class to send sms using amazon web services
|
6
|
+
class AnySMS::Backend::AWS < AnySMS::Backend::Base
|
7
|
+
# To use class, you need access key from AWS.
|
8
|
+
# Go to README for instructions on how to obtain them.
|
9
|
+
#
|
10
|
+
# @param access_key [String] AWS access key
|
11
|
+
# @param secret_access_key [String] AWS secret access key
|
12
|
+
# @param region [String] AWS region. Full list: https://goo.gl/Ys5XMi
|
13
|
+
def initialize(access_key:, secret_access_key:, region: "us-east-1")
|
14
|
+
@access_key = access_key
|
15
|
+
@secret_access_key = secret_access_key
|
16
|
+
@region = region
|
17
|
+
end
|
18
|
+
|
19
|
+
# Sends sms using amazon web services
|
20
|
+
#
|
21
|
+
# @phone [String] Phone number in E.164 format
|
22
|
+
# @text [String] Sms text
|
23
|
+
def send_sms(phone, text)
|
24
|
+
resp = sns_client.publish(phone_number: phone, message: text)
|
25
|
+
|
26
|
+
if resp.error.nil? && resp.message_id
|
27
|
+
respond_with_status :success
|
28
|
+
else
|
29
|
+
respond_with_status :unknown_failure
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def sns_client
|
36
|
+
Aws::SNS::Client.new(
|
37
|
+
access_key_id: @access_key,
|
38
|
+
secret_access_key: @secret_access_key,
|
39
|
+
region: @region
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "any_sms/backend/aws"
|
Binary file
|
data/screenshot.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: any_sms-backend-aws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fedcomp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: any_sms
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.14'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.14'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.7'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.7'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-byebug
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.4'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.4'
|
167
|
+
description:
|
168
|
+
email:
|
169
|
+
- aglergen@gmail.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".gitignore"
|
175
|
+
- ".rspec"
|
176
|
+
- ".rubocop.yml"
|
177
|
+
- ".travis.yml"
|
178
|
+
- Gemfile
|
179
|
+
- Guardfile
|
180
|
+
- LICENSE.txt
|
181
|
+
- README.md
|
182
|
+
- Rakefile
|
183
|
+
- any_sms-backend-aws.gemspec
|
184
|
+
- lib/any_sms-backend-aws.rb
|
185
|
+
- lib/any_sms/backend/aws.rb
|
186
|
+
- lib/any_sms/backend/aws/version.rb
|
187
|
+
- permissions_screenshot.png
|
188
|
+
- screenshot.png
|
189
|
+
homepage: https://github.com/Fedcomp/any_sms-backend-aws
|
190
|
+
licenses:
|
191
|
+
- MIT
|
192
|
+
metadata:
|
193
|
+
allowed_push_host: https://rubygems.org
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 2.6.8
|
211
|
+
signing_key:
|
212
|
+
specification_version: 4
|
213
|
+
summary: AnySMS backend for using amazon web services sms delivery
|
214
|
+
test_files: []
|