rapporto 0.1.0
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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -0
- data/lib/rapporto.rb +3 -0
- data/lib/rapporto/sms.rb +66 -0
- data/lib/rapporto/version.rb +11 -0
- data/rapporto.gemspec +20 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 395d8421501f5cd013ed02c0f81e169a4af3ebed
|
4
|
+
data.tar.gz: 7917d44f23576b58c6f4506330c5d5e9da98e33e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b2636d6e117f280a24b51b057005981a52a28b381ce368407685bc5114a396a321f94a9d8cc770bfd033f2306a25ae2cc8c044de1a55db8de4cb89b8b19bfaa
|
7
|
+
data.tar.gz: 94853a31b0fc8769dad067447fdc7edc2f4192b916e271dc61ae11cb5a4748d68eec220d7321043b0fcdfae6b92925f6e773a354a14860fc9709aa9037e824e9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Fokin Eugene
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Rapporto
|
2
|
+
|
3
|
+
Library to communicate with Mobile Finance Management Solutions
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
$ gem 'rapporto'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rapporto
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Define settings:
|
22
|
+
|
23
|
+
Rapporto::SMS.settings = {
|
24
|
+
:server => 'lk.rapporto.ru',
|
25
|
+
:port => 9002,
|
26
|
+
}
|
27
|
+
|
28
|
+
Initialize sms:
|
29
|
+
|
30
|
+
sms = Rapporto::SMS.new('phone','title','text') # initialize sms
|
31
|
+
sms = Rapporto::SMS.new('phone','title','text') # last parameter overrides 'translit' option
|
32
|
+
|
33
|
+
Send it and get sent sms id and dispatch code:
|
34
|
+
|
35
|
+
sms.send # send sms. returns sms id or dispatch code if something went wrong
|
36
|
+
sms.id # get sms id
|
37
|
+
|
38
|
+
Ex.:
|
39
|
+
|
40
|
+
sms = Rapporto::SMS.new('79031111111','MyFavouriteCompany','Testing rapporto gem')
|
41
|
+
sms.send # => 1032
|
42
|
+
sms.id # => 1032
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rapporto.rb
ADDED
data/lib/rapporto/sms.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'openssl'
|
4
|
+
require 'uri'
|
5
|
+
require 'russian'
|
6
|
+
|
7
|
+
module Rapporto
|
8
|
+
class SMS
|
9
|
+
|
10
|
+
attr_accessor :phone, :subject, :message
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
def initialize(phone, subject, message, translit = @@translit)
|
14
|
+
@phone = phone
|
15
|
+
@subject = subject
|
16
|
+
@message = message
|
17
|
+
@translit = translit
|
18
|
+
|
19
|
+
validate!
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.settings=(settings={})
|
23
|
+
@@server = settings[:server]
|
24
|
+
@@port = settings[:port]
|
25
|
+
@@translit = !settings[:translit].nil? ? settings[:translit] : false # use translit or not
|
26
|
+
validate_settings!
|
27
|
+
end
|
28
|
+
|
29
|
+
def send
|
30
|
+
self.class.establish_connection.start do |http|
|
31
|
+
request = Net::HTTP::Get.new(send_url)
|
32
|
+
response = http.request(request)
|
33
|
+
response_text = response.body.strip
|
34
|
+
if response_text =~ /^\d+$/
|
35
|
+
@id = response_text
|
36
|
+
else
|
37
|
+
raise StandardError, response_text
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def self.establish_connection
|
45
|
+
Net::HTTP.new(@@server, @@port)
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate!
|
49
|
+
raise ArgumentError, "Phone should be assigned to #{self.class}." if @phone.nil?
|
50
|
+
raise ArgumentError, "Phone number should contain only numbers. Minimum length is 10. #{@phone.inspect} is given." unless @phone =~ /^[0-9]{10,}$/
|
51
|
+
raise ArgumentError, "Subject should be assigned to #{self.class}." if @subject.nil?
|
52
|
+
raise ArgumentError, "Message should be assigned to #{self.class}." if @message.nil?
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.validate_settings!
|
56
|
+
raise ArgumentError, "Server should be defined for #{self}." if @@server.nil?
|
57
|
+
raise ArgumentError, "Port should be defined for #{self}." if @@port.nil?
|
58
|
+
raise ArgumentError, "Port should contain only numbers. #{@@port.inspect} is given." unless @@port.instance_of?(Fixnum)
|
59
|
+
end
|
60
|
+
|
61
|
+
def send_url
|
62
|
+
message = @translit ? Russian.translit(@message) : @message
|
63
|
+
"/revoup?msisdn=#{@phone}&sn=#{@subject}&message=#{URI.encode(message)}&send_time=#{Time.now.strftime("%Y%d%m%H%M%S")}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/rapporto.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rapporto/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rapporto"
|
8
|
+
spec.version = Rapporto::Version.to_s
|
9
|
+
spec.authors = ["Fokin Eugene"]
|
10
|
+
spec.email = ["e.fokin@revoup.ru"]
|
11
|
+
spec.description = %q{This library helps to send sms via Rapporto service}
|
12
|
+
spec.summary = %q{Send sms via Rapporto service}
|
13
|
+
spec.homepage = "https://github.com/RevoTechnology/rapporto"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency 'russian', '0.6.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapporto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fokin Eugene
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: russian
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.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.6.0
|
27
|
+
description: This library helps to send sms via Rapporto service
|
28
|
+
email:
|
29
|
+
- e.fokin@revoup.ru
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/rapporto.rb
|
40
|
+
- lib/rapporto/sms.rb
|
41
|
+
- lib/rapporto/version.rb
|
42
|
+
- rapporto.gemspec
|
43
|
+
homepage: https://github.com/RevoTechnology/rapporto
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.4.3
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Send sms via Rapporto service
|
67
|
+
test_files: []
|