turbosms 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/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +33 -0
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/lib/turbosms.rb +9 -0
- data/lib/turbosms/api.rb +22 -0
- data/lib/turbosms/client.rb +39 -0
- data/lib/turbosms/error.rb +6 -0
- data/lib/turbosms/options.rb +4 -0
- data/lib/turbosms/version.rb +3 -0
- data/turbosms.gemspec +18 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 06d71d5578c5f31c5e7fa3451b03e87cd120476b
|
4
|
+
data.tar.gz: ab835d6e54ee06cb754b18dbf15dc307d6428faa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 794888a6c4d6db0a89236f5e620230b73e5d6c4a0c8b73fea98a656f3b5051dfbe77c868630859feb625885f5d9f0f0a8bb7f3f024fc094a0a366371b63aa5b3
|
7
|
+
data.tar.gz: fabd2d3c7a892737fe8a6117e7400896a8282928c6e76a17508f3a4b5d1cf85184f181fdb88139fec72eb353e265eac1bff1a3ad38337192afa9ffcd98e65cde
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
akami (1.2.2)
|
5
|
+
gyoku (>= 0.4.0)
|
6
|
+
nokogiri
|
7
|
+
builder (3.2.2)
|
8
|
+
gyoku (1.0.0)
|
9
|
+
builder (>= 2.1.2)
|
10
|
+
httpi (2.0.2)
|
11
|
+
rack
|
12
|
+
mini_portile (0.6.1)
|
13
|
+
nokogiri (1.6.5)
|
14
|
+
mini_portile (~> 0.6.0)
|
15
|
+
nori (2.1.0)
|
16
|
+
rack (1.5.2)
|
17
|
+
savon (2.2.0)
|
18
|
+
akami (~> 1.2.0)
|
19
|
+
builder (>= 2.1.2)
|
20
|
+
gyoku (~> 1.0.0)
|
21
|
+
httpi (~> 2.0.2)
|
22
|
+
nokogiri (>= 1.4.0)
|
23
|
+
nori (~> 2.1.0)
|
24
|
+
wasabi (~> 3.1.0)
|
25
|
+
wasabi (3.1.0)
|
26
|
+
httpi (~> 2.0)
|
27
|
+
nokogiri (>= 1.4.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
savon
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Vitalik Danchenko
|
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,21 @@
|
|
1
|
+
turbosms
|
2
|
+
========
|
3
|
+
|
4
|
+
Ruby gem implements TurboSMS soap gateway http://turbosms.ua
|
5
|
+
|
6
|
+
------------------------------------------------------------------------------
|
7
|
+
Usage
|
8
|
+
------------------------------------------------------------------------------
|
9
|
+
You should have registered account at http://turbosms.ua/
|
10
|
+
|
11
|
+
gem install turbosms
|
12
|
+
|
13
|
+
require 'turbosms'
|
14
|
+
|
15
|
+
TurboSMS.default_options[:login] = 'login'
|
16
|
+
TurboSMS.default_options[:password] = 'password'
|
17
|
+
TurboSMS.default_options[:sender] = 'sender' # should be approved by administrator and no larger than 11 characters
|
18
|
+
|
19
|
+
TurboSMS.send_sms '+380998765432', 'test message'
|
20
|
+
|
21
|
+
|
data/lib/turbosms.rb
ADDED
data/lib/turbosms/api.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module TurboSMS
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def balance
|
5
|
+
authorize unless authorized?
|
6
|
+
authorised_call(:get_credit_balance).to_f
|
7
|
+
end
|
8
|
+
|
9
|
+
def send_sms(destination, text = nil, sender = nil)
|
10
|
+
authorize unless authorized?
|
11
|
+
message = {
|
12
|
+
sender: sender || default_options[:sender],
|
13
|
+
destination: destination,
|
14
|
+
text: text
|
15
|
+
}
|
16
|
+
result = authorised_call(:send_sms, message: message)
|
17
|
+
raise SendingSMSError, result unless result.instance_of?(Array)
|
18
|
+
result[1] # message id
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
module TurboSMS
|
4
|
+
class << self
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def client
|
9
|
+
@client ||= Savon.client(wsdl: default_options[:wsdl], log: false)
|
10
|
+
end
|
11
|
+
|
12
|
+
def authorized?
|
13
|
+
!@cookies.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def auth_message
|
17
|
+
keys = [:login, :password]
|
18
|
+
default_options.select{|key,_| keys.include? key}
|
19
|
+
end
|
20
|
+
|
21
|
+
def authorize
|
22
|
+
response = client.call(:auth, message: auth_message)
|
23
|
+
result = response.body[:auth_response][:auth_result]
|
24
|
+
@cookies = response.http.cookies if (result.length == 27) # Ridiculous # Вы успешно авторизировались
|
25
|
+
raise AuthError, result unless authorized?
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorised_call(method_name, args = {})
|
29
|
+
response_key = "#{method_name}_response".to_sym
|
30
|
+
result_key = "#{method_name}_result".to_sym
|
31
|
+
response = client.call(method_name, args.merge(cookies: @cookies))
|
32
|
+
result = response.body[response_key][result_key]
|
33
|
+
result = result[:result_array] if result.instance_of?(Hash) and !result[:result_array].nil?
|
34
|
+
@cookies = nil if !result.instance_of?(Array) and result.length == 20 # Ridiculous # Вы не авторизированы
|
35
|
+
result
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/turbosms.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'turbosms/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'turbosms'
|
6
|
+
s.version = TurboSMS::VERSION
|
7
|
+
s.date = '2014-12-11'
|
8
|
+
s.summary = 'TurboSMS'
|
9
|
+
s.description = "Ruby gem implements TurboSMS soap gateway http://turbosms.ua"
|
10
|
+
s.authors = ["Vitalik Danchenko"]
|
11
|
+
s.email = 'vitalik.danchenko@gmail.com'
|
12
|
+
s.homepage = 'https://github.com/vitalikdanchenko/turbosms'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
|
17
|
+
s.add_dependency 'savon'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: turbosms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vitalik Danchenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
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
|
+
description: Ruby gem implements TurboSMS soap gateway http://turbosms.ua
|
28
|
+
email: vitalik.danchenko@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- lib/turbosms.rb
|
39
|
+
- lib/turbosms/api.rb
|
40
|
+
- lib/turbosms/client.rb
|
41
|
+
- lib/turbosms/error.rb
|
42
|
+
- lib/turbosms/options.rb
|
43
|
+
- lib/turbosms/version.rb
|
44
|
+
- turbosms.gemspec
|
45
|
+
homepage: https://github.com/vitalikdanchenko/turbosms
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.0.14
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: TurboSMS
|
69
|
+
test_files: []
|