beepsend 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/beepsend.gemspec +25 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/lib/beepsend.rb +24 -0
- data/lib/beepsend/client.rb +49 -0
- data/lib/beepsend/configuration.rb +12 -0
- data/lib/beepsend/version.rb +3 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d5e95e80efd49044368c14b8a2031c63aec7842
|
4
|
+
data.tar.gz: a8b96f2f97b22d8a08fd5addb0501e1ae8cf666e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e28b3b343f4e0cb7f09f674537df1056edb2bfc6eb7487c7d4f5b526f248f78b9daddf14b6b878ac33e239b9d7197683b6124624f138fb9f15c0ea7de432f17
|
7
|
+
data.tar.gz: 4f120d02269a0b37245d895986d3bd5158fb47a734a3806d21d9a5ff017e20636157d1141077a1067128093b4e00a8cf9fe4157c7a2955c65db0ef3831b5d2b7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Rushplay AB
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Beepsend
|
2
|
+
|
3
|
+
Simple gem that implements sending SMS using Beepsend API [api.beepsend.com/docs.html](http://api.beepsend.com/docs.html#send-sms)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'beepsend'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install beepsend
|
20
|
+
|
21
|
+
## Configuaration
|
22
|
+
|
23
|
+
You can configurate by adding this code to Rails initializer for example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Beepsend.configure do |config|
|
27
|
+
config.token = 'XXX' # you get this token after registering in Beepsend
|
28
|
+
config.from = 'Mailman' # when you don't specify 'from' argument in `Beepsend::Client#send_sms` it will use value from here
|
29
|
+
config.receive_dlr = 0 # Specify whether delivery reports should be sent to your DLR Callback URL, 0 by default
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
Here is example usage of this gem:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
beepsend = Beepsend::Client.new
|
39
|
+
beepsend.send_sms(to: '000xxx555', from: 'Mailman', message: 'Hello world!')
|
40
|
+
# => ["201", "[{"id": ["TX ID number"], "from": "Mailman", "to": "000xxx555"}]"]
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RushPlay/beepsend.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
MIT
|
data/Rakefile
ADDED
data/beepsend.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'beepsend/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'beepsend'
|
8
|
+
spec.version = Beepsend::VERSION
|
9
|
+
spec.authors = ['Anatoliy Kukul']
|
10
|
+
spec.email = ['anatoliy.kukul@herogaming.com']
|
11
|
+
|
12
|
+
spec.summary = %q{For sending SMS using Beepsend API}
|
13
|
+
spec.description = %q{Simple gem that implements sending SMS using Beepsend API api.beepsend.com/docs.html}
|
14
|
+
spec.homepage = 'https://github.com/RushPlay/beepsend'
|
15
|
+
spec.files = `git ls-files -z`.split("\0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = 'exe'
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
spec.add_development_dependency 'rspec'
|
23
|
+
spec.add_development_dependency 'pry'
|
24
|
+
spec.add_development_dependency 'webmock'
|
25
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/beepsend.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'beepsend/version'
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'beepsend/configuration'
|
7
|
+
require 'beepsend/client'
|
8
|
+
|
9
|
+
module Beepsend
|
10
|
+
class ServerResponseError < RuntimeError; end
|
11
|
+
|
12
|
+
def self.configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.reset_configuration
|
17
|
+
@configuration = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configure
|
21
|
+
self.configuration ||= Configuration.new
|
22
|
+
yield(configuration)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Beepsend
|
2
|
+
class Client
|
3
|
+
def send_sms(to:, from: configuration.from, message:)
|
4
|
+
response = http.request request(to, from, message)
|
5
|
+
handle_response response
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def request(to, from, message)
|
11
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
12
|
+
request['Authorization'] = "Token #{configuration.token}"
|
13
|
+
request['Content-Type'] = 'application/json'
|
14
|
+
request.body = default_options.merge(to: to, from: from, message: message).to_json
|
15
|
+
request
|
16
|
+
end
|
17
|
+
|
18
|
+
def handle_response(response)
|
19
|
+
unless response.code =~ /\A2\d\d\Z/ # all 2xx codes
|
20
|
+
raise ServerResponseError, "Response code: #{response.code}. Body: #{response.body}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def configuration
|
25
|
+
@configuration ||= Beepsend.configuration
|
26
|
+
end
|
27
|
+
|
28
|
+
def uri
|
29
|
+
@uri ||= URI.parse(configuration.endpoint)
|
30
|
+
end
|
31
|
+
|
32
|
+
def http
|
33
|
+
@http ||= Net::HTTP.new(uri.host, uri.port)
|
34
|
+
@http.use_ssl = use_ssl?
|
35
|
+
@http
|
36
|
+
end
|
37
|
+
|
38
|
+
def use_ssl?
|
39
|
+
'https' == uri.scheme
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_options
|
43
|
+
{
|
44
|
+
encoding: configuration.encoding,
|
45
|
+
receive_dlr: configuration.receive_dlr
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beepsend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anatoliy Kukul
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
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: pry
|
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: webmock
|
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: Simple gem that implements sending SMS using Beepsend API api.beepsend.com/docs.html
|
84
|
+
email:
|
85
|
+
- anatoliy.kukul@herogaming.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- beepsend.gemspec
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- lib/beepsend.rb
|
100
|
+
- lib/beepsend/client.rb
|
101
|
+
- lib/beepsend/configuration.rb
|
102
|
+
- lib/beepsend/version.rb
|
103
|
+
homepage: https://github.com/RushPlay/beepsend
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.5.1
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: For sending SMS using Beepsend API
|
126
|
+
test_files: []
|
127
|
+
has_rdoc:
|