turbosms_ruby 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 +14 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +68 -0
- data/README.md +44 -0
- data/Rakefile +4 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/turbosms_ruby/client.rb +39 -0
- data/lib/turbosms_ruby/config.rb +10 -0
- data/lib/turbosms_ruby/turbo_sms.rb +30 -0
- data/lib/turbosms_ruby/version.rb +5 -0
- data/lib/turbosms_ruby.rb +28 -0
- data/turbosms_ruby.gemspec +40 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7162a15e6c952da25e4f059970b382edff4460da410186827f46e408cdcb661a
|
4
|
+
data.tar.gz: a46dbe76b37e0216dae06cc19d415afe295f19ccdbdaf55beda064784ca9f878
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8aebcdeacdb9f4d784462ed26ffa072650acaa0d05e02142bc04e2d1f75b9f92d684614180c8ad100671749a07113e66ea884b87ace0bddef1c574593306b61f
|
7
|
+
data.tar.gz: 6b82ef9ff7ded61b2e3a787652cadca4b3914dcb3a342cc2a952ead2cbd540efba14a5113b74c080a044aca850bc71966748085c35ceeafc03ba8cdf9346f568
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
turbosms_ruby (0.1.0)
|
5
|
+
httparty
|
6
|
+
rake (~> 13.0)
|
7
|
+
rspec (~> 3.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.2)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
dotenv (2.7.6)
|
15
|
+
httparty (0.18.1)
|
16
|
+
mime-types (~> 3.0)
|
17
|
+
multi_xml (>= 0.5.2)
|
18
|
+
mime-types (3.3.1)
|
19
|
+
mime-types-data (~> 3.2015)
|
20
|
+
mime-types-data (3.2021.0901)
|
21
|
+
multi_xml (0.6.0)
|
22
|
+
parallel (1.21.0)
|
23
|
+
parser (3.0.2.0)
|
24
|
+
ast (~> 2.4.1)
|
25
|
+
rainbow (3.0.0)
|
26
|
+
rake (13.0.6)
|
27
|
+
regexp_parser (2.1.1)
|
28
|
+
rexml (3.2.5)
|
29
|
+
rspec (3.10.0)
|
30
|
+
rspec-core (~> 3.10.0)
|
31
|
+
rspec-expectations (~> 3.10.0)
|
32
|
+
rspec-mocks (~> 3.10.0)
|
33
|
+
rspec-core (3.10.1)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-expectations (3.10.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-mocks (3.10.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-support (3.10.2)
|
42
|
+
rubocop (1.23.0)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.0.0.0)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.12.0)
|
52
|
+
parser (>= 3.0.1.1)
|
53
|
+
ruby-progressbar (1.11.0)
|
54
|
+
unicode-display_width (2.1.0)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
x86_64-linux
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
dotenv
|
61
|
+
httparty
|
62
|
+
rake (~> 13.0)
|
63
|
+
rspec (~> 3.2)
|
64
|
+
rubocop (~> 1.7)
|
65
|
+
turbosms_ruby!
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.2.14
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# TurbosmsRuby
|
2
|
+
|
3
|
+
Send SMS and Viber message via TurboSMS ([turbosms.ua](https://turbosms.ua))
|
4
|
+
|
5
|
+
NOW work only sms
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'turbosms_ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install turbosms_ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
add
|
26
|
+
|
27
|
+
TURBOSMS_TOKEN= <TURBO SMS TOKE>
|
28
|
+
TURBOSMS_SENDER="<SENDER>"
|
29
|
+
|
30
|
+
sender not required if not add then use base "IT Alarm"
|
31
|
+
[reg own sender](https://turbosms.ua/sign)
|
32
|
+
|
33
|
+
::TurbosmsRuby.new.send_message(phones,text)
|
34
|
+
phones - array with strings
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
|
+
|
40
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/turbosms_ruby.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "turbosms_ruby"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module TurbosmsRuby
|
2
|
+
class Client
|
3
|
+
|
4
|
+
require "httparty"
|
5
|
+
API_URL = 'https://api.turbosms.ua'
|
6
|
+
attr_accessor :module_name, :method_name
|
7
|
+
|
8
|
+
def send_message(phones,text)
|
9
|
+
@module_name = 'message'
|
10
|
+
@method_name = 'send.json'
|
11
|
+
|
12
|
+
params = {
|
13
|
+
recipients: phones,
|
14
|
+
sms: {
|
15
|
+
sender: ::TurbosmsRuby.config.sender,
|
16
|
+
text: text
|
17
|
+
}
|
18
|
+
}
|
19
|
+
response = post(params)
|
20
|
+
JSON.parse(response.body)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def http_api_url
|
26
|
+
[API_URL, @module_name, @method_name].join('/')
|
27
|
+
end
|
28
|
+
|
29
|
+
def post(params)
|
30
|
+
HTTParty.post(http_api_url,
|
31
|
+
{
|
32
|
+
body: params,
|
33
|
+
headers: { 'Content-Type' => 'application/x-www-form-urlencoded',
|
34
|
+
'Authorization' => "Basic #{::TurbosmsRuby.config.token}" }
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module TurbosmsRuby
|
2
|
+
class TurbosmsRuby
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(_options = {})
|
6
|
+
@client = ::TurbosmsRuby.client
|
7
|
+
# TODO: send request and check balance
|
8
|
+
# message if balance small
|
9
|
+
end
|
10
|
+
|
11
|
+
def send_message(phones, text)
|
12
|
+
phones = phones.map { |phone| phone_to_standart(phone) }
|
13
|
+
client.send_message(phones, text)
|
14
|
+
end
|
15
|
+
|
16
|
+
def config
|
17
|
+
@config ||= ::TurbosmsRuby.config
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def phone_to_standart(phone)
|
23
|
+
replacements = {
|
24
|
+
'+' => '', ')' => '',
|
25
|
+
'(' => '', '-' => ''
|
26
|
+
}
|
27
|
+
phone.gsub(Regexp.union(replacements.keys), replacements)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'turbosms_ruby/version'
|
4
|
+
require "turbosms_ruby/config"
|
5
|
+
require "turbosms_ruby/client"
|
6
|
+
require "turbosms_ruby/turbo_sms"
|
7
|
+
|
8
|
+
module TurbosmsRuby
|
9
|
+
class Error < StandardError; end
|
10
|
+
# Your code goes here...
|
11
|
+
|
12
|
+
def self.config
|
13
|
+
@config ||= ::TurbosmsRuby::Config.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
yield config
|
18
|
+
@config
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.client
|
22
|
+
@client ||= ::TurbosmsRuby::Client.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.new(*options)
|
26
|
+
::TurbosmsRuby::TurbosmsRuby.new(*options)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/turbosms_ruby/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "turbosms_ruby"
|
7
|
+
spec.version = TurbosmsRuby::VERSION
|
8
|
+
spec.authors = ["civil21"]
|
9
|
+
spec.email = ["diusolexander@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Send SMS via TurboSMS (turbosms.ua)"
|
12
|
+
spec.description = "Send SMS and Viber message via TurboSMS (turbosms.ua) using ruby"
|
13
|
+
spec.homepage = "https://github.com/Civil21/turbosms_ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/Civil21/turbosms_ruby"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/Civil21/turbosms_ruby/blob/main/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
spec.add_dependency "rspec", "~> 3.2"
|
35
|
+
spec.add_dependency 'httparty'
|
36
|
+
spec.add_dependency 'rake', '~> 13.0'
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, checkout our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: turbosms_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- civil21
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
description: Send SMS and Viber message via TurboSMS (turbosms.ua) using ruby
|
56
|
+
email:
|
57
|
+
- diusolexander@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/turbosms_ruby.rb
|
71
|
+
- lib/turbosms_ruby/client.rb
|
72
|
+
- lib/turbosms_ruby/config.rb
|
73
|
+
- lib/turbosms_ruby/turbo_sms.rb
|
74
|
+
- lib/turbosms_ruby/version.rb
|
75
|
+
- turbosms_ruby.gemspec
|
76
|
+
homepage: https://github.com/Civil21/turbosms_ruby
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata:
|
80
|
+
homepage_uri: https://github.com/Civil21/turbosms_ruby
|
81
|
+
source_code_uri: https://github.com/Civil21/turbosms_ruby
|
82
|
+
changelog_uri: https://github.com/Civil21/turbosms_ruby/blob/main/CHANGELOG.md
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 2.4.0
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.1.6
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Send SMS via TurboSMS (turbosms.ua)
|
102
|
+
test_files: []
|