actie_smsc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3edefd3135e45664e0f9a23c8ae8368324fbe2e393f769566071ec786c5064d8
4
+ data.tar.gz: 84d17d515bda805f291616791c079c4ec958e2ddab8451a8bc8a6654a983280f
5
+ SHA512:
6
+ metadata.gz: b5696504356d4625a8b94dc26ce0add7f6a5b7020cbdcee3b940e6c9b05112c96af695476f1e2410b71bd4e328129891e419650e81e3e51b47a359975284b517
7
+ data.tar.gz: 2ee63b6c4d8f6888daabc099f2fb59235b5b319e7719a5e5d9783d46ea2a7d5e2cb90146656cc29800d20b5de547f31765eb98cd0b77edf633bd2df68c55f545
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## [0.0.1]
4
+ - Project initialization
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fedorkk@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in actie_smsc.gemspec
6
+ gemspec
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ actie_smsc (0.0.1)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ coderay (1.1.2)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ faraday (0.15.4)
17
+ multipart-post (>= 1.2, < 3)
18
+ hashdiff (1.0.0)
19
+ method_source (0.9.2)
20
+ multipart-post (2.1.1)
21
+ pry (0.12.2)
22
+ coderay (~> 1.1.0)
23
+ method_source (~> 0.9.0)
24
+ public_suffix (4.0.1)
25
+ rake (10.5.0)
26
+ rspec (3.8.0)
27
+ rspec-core (~> 3.8.0)
28
+ rspec-expectations (~> 3.8.0)
29
+ rspec-mocks (~> 3.8.0)
30
+ rspec-core (3.8.2)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-expectations (3.8.4)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-mocks (3.8.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-support (3.8.2)
39
+ safe_yaml (1.0.5)
40
+ timecop (0.9.1)
41
+ webmock (3.7.0)
42
+ addressable (>= 2.3.6)
43
+ crack (>= 0.3.2)
44
+ hashdiff (>= 0.4.0, < 2.0.0)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ actie_smsc!
51
+ bundler
52
+ pry
53
+ rake
54
+ rspec
55
+ timecop
56
+ webmock
57
+
58
+ BUNDLED WITH
59
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Alexey Naumov
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.
@@ -0,0 +1,143 @@
1
+ # ActieSmsc
2
+ ![Build Status](https://travis-ci.org/actie/actie_smsc.svg?branch=master)
3
+
4
+ This gem implements SMSC service API and based on this library: https://smsc.ru/api/code/libraries/http_smtp/ruby/
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'actie_smsc'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install actie_smsc
21
+
22
+ ## Configuration
23
+
24
+ To change the configuration, create the file `config/initializers/actie_smsc.rb` in your project. Like shown in example:
25
+
26
+ ```ruby
27
+ ActieSmsc.configure do |config|
28
+ config.login = ENV.fetch('SMSC_LOGIN')
29
+ config.password = ENV.fetch('SMSC_PASSWORD')
30
+ config.charset = 'windows-1251'
31
+ end
32
+ ```
33
+
34
+ There are two required parameters: `login` and `password`.
35
+
36
+ The full parameters list for configuration with default values:
37
+ ```
38
+ use_post = true # Use POST request instead of GET
39
+ use_https = true # Use HTTPS request instead of HTTP
40
+ charset = 'utf-8' # valid charsets are: utf-8, koi8-r and windows-1251
41
+ debug = false
42
+ logger = Logger.new($stdout)
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ There are four public methods for different API endpoints. Each method returns a result hash, or number (balance). In case of invalid response `SmscError` will be raised with error code in message.
48
+
49
+ ### Send sms
50
+
51
+ ```ruby
52
+ ActieSmsc.send_sms(phones, message, translit: 0, time: nil, id: 0, format: nil, sender: nil, fmt: 1, query_params: {})
53
+ ```
54
+
55
+ The required parameters are: `phones` - array or string separated by commas and `message` as string. Other parameters have default values and described in SMSC library.
56
+
57
+ * translit - transliterate message text. Values:1,2 or 0
58
+ * time - delivery time (could be a `Time, Date, DateTime` object, or a string). There are several string formats:
59
+ +m (e.g. `+10`) - Send the message 10 minutes later.
60
+ h1-h2 (e.g. `9-20`) - Message can be sent only in the period from 9 am to 20 pm. If it's too late, it'll be sent next day.
61
+ DDMMYYhhmm - string format for the exact time, it's also used for a Time object.
62
+ 0ts (e.g. `01568230028`) - UNIX time format with a `0` as a prefix.
63
+ * id - message id. Value - integer from 1 to 2147483647.
64
+ * format - message format. Values: [:flash, :push, :hlr, :bin, :bin_hex, :ping, :mms, :mail, :call, :viber, :soc]
65
+ * sender - Sender name. To disable default name use empty line, or '.'
66
+ * query - hash with additional parameters which will be added to the request (e.g. `{ valid: '01:00', maxsms: 3, tz: 2 }`)
67
+
68
+ Method returns result hash:
69
+ ```ruby
70
+ { id: 7600, cnt: 1, cost: 12.32, balance: 1234.12 }
71
+ ```
72
+
73
+ ### Sms cost
74
+
75
+ ```ruby
76
+ ActieSmsc.sms_cost(phones, message, translit: 0, format: nil, sender: nil, fmt: 1, query_params: {})
77
+ ```
78
+
79
+ This method checks the message cost. It receives the same parameters as `send_sms` method.
80
+
81
+ Returns the result hash:
82
+ ```ruby
83
+ { cost: 12.32, cnt: 2 }
84
+ ```
85
+
86
+ ### Status
87
+
88
+ ```ruby
89
+ ActieSmsc.status(id, phone, all: false, fmt: 1)
90
+ ```
91
+
92
+ Returns the delivery status for exact message and exact phone. Receives the message ID and phone number. The additional parameter `all` used to increase the number of returned values.
93
+
94
+ Returns the result hash:
95
+ ```ruby
96
+ { status: 1, change_time: 2019-09-08 15:00:00 +0300, error_code: 0 }
97
+ ```
98
+
99
+ If parameter `all` changed to `true`, result hash will additionaly include values:
100
+ ```ruby
101
+ {
102
+ send_time: 2019-09-08 15:00:00 +0300,
103
+ phone: '+71234567890',
104
+ cost: 2.12,
105
+ sender: 'GLOBUS',
106
+ status_message: 'Доставлено',
107
+ message: 'Текст собщения'
108
+ }
109
+ ```
110
+
111
+ ### Balance
112
+
113
+ ```ruby
114
+ ActieSmsc.balance(fmt: 1)
115
+ ```
116
+ This method returns the balance of your SMSC account as float number.
117
+
118
+ ### Response format
119
+
120
+ There is poorly described parameter `fmt` which changes the response format. (You can find description here: https://smsc.ru/api/http/send/sms/).
121
+
122
+ The default value is 1 - it returns the string with numbers, which then parsed to the result hash.
123
+
124
+ 2 - is an XML response, returned as a string.
125
+
126
+ 3 - json response, returned as parsed hash.
127
+
128
+ 0 - another form of string response `(OK - 1 SMS, ID - 1234)`.
129
+
130
+ Formats 2 and 3 are usefull for the debugging. Because you can find more detaild error descriptions:
131
+ ```
132
+ {"error"=>"duplicate request, wait a minute", "error_code"=>9}
133
+ ```
134
+
135
+ Additionaly you can use `fmt: :response` to get the full `Faraday::Response` object.
136
+
137
+ ## Contributing
138
+
139
+ Bug reports and pull requests are welcome on GitHub at https://github.com/actie/actie_smsc. T
140
+
141
+ ## License
142
+
143
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'actie_smsc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'actie_smsc'
8
+ spec.version = ActieSmsc::VERSION
9
+ spec.authors = ['Fedor Koshel']
10
+ spec.email = ['alexsnaumov@gmail.com']
11
+
12
+ spec.summary = 'Gem for using SMSC API in your ruby app'
13
+ spec.description = 'This gem based on the ruby library described on: https://smsc.ru/api/code/libraries/http_smtp/ruby/'
14
+ spec.homepage = 'https://github.com/actie/smsc'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = spec.homepage
22
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
23
+ else
24
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_runtime_dependency 'faraday'
37
+
38
+ spec.add_development_dependency 'bundler'
39
+ spec.add_development_dependency 'rake'
40
+ spec.add_development_dependency 'rspec'
41
+ spec.add_development_dependency 'webmock'
42
+ spec.add_development_dependency 'timecop'
43
+ spec.add_development_dependency 'pry'
44
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "actie_smsc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,202 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'actie_smsc/version'
4
+ require 'actie_smsc/configuration'
5
+ require 'faraday'
6
+ require 'json'
7
+ require 'date'
8
+
9
+ module ActieSmsc
10
+ class SmscError < StandardError; end
11
+
12
+ class << self
13
+ def config
14
+ @config ||= Configuration.new
15
+ end
16
+
17
+ def configure
18
+ yield(config)
19
+ end
20
+
21
+ def send_sms(phones, message, translit: 0, time: nil, id: 0, format: nil, sender: nil, fmt: 1, **query_params)
22
+ request_params = { cost: 3, phones: phones_string(phones), mes: message, id: id, fmt: fmt }
23
+ request_params[:translit] = (0..2).include?(translit) ? translit : 0
24
+ request_params[format] = format_value(format) if format_value(format)
25
+ request_params[:sender] = sender if sender
26
+ request_params[:time] = time_string(time) if time
27
+ request_params.merge!(query_params)
28
+
29
+ resp = request('send', request_params)
30
+
31
+ check_response_for_exception(resp.body)
32
+
33
+ case fmt
34
+ when 2,0
35
+ resp.body
36
+ when 3
37
+ JSON.parse(resp.body)
38
+ when :response
39
+ resp
40
+ else
41
+ body = resp.body.split(',')
42
+ {
43
+ id: body[0].to_i,
44
+ cnt: body[1].to_i,
45
+ cost: body[2].to_f,
46
+ balance: body[3].to_f
47
+ }
48
+ end
49
+ end
50
+
51
+ def sms_cost(phones, message, translit: 0, format: nil, sender: nil, fmt: 1, **query_params)
52
+ request_params = { cost: 1, phones: phones_string(phones), mes: message, fmt: fmt }
53
+ request_params[:translit] = (0..2).include?(translit) ? translit : 0
54
+ request_params[format] = format_value(format) if format_value(format)
55
+ request_params[:sender] = sender if sender
56
+ request_params.merge!(query_params)
57
+
58
+ resp = request('send', request_params)
59
+
60
+ check_response_for_exception(resp.body)
61
+
62
+ case fmt
63
+ when 2,0
64
+ resp.body
65
+ when 3
66
+ JSON.parse(resp.body)
67
+ when :response
68
+ resp
69
+ else
70
+ body = resp.body.split(',')
71
+ { cost: body[0].to_f, cnt: body[1].to_i }
72
+ end
73
+ end
74
+
75
+ def status(id, phone, all: false, fmt: 1)
76
+ request_params = { phone: phone, id: id, fmt: fmt }
77
+ request_params[:all] = (all && all != 0) ? 1 : 0
78
+
79
+ resp = request('status', request_params)
80
+
81
+ check_response_for_exception(resp.body)
82
+
83
+ case fmt
84
+ when 2,0
85
+ resp.body
86
+ when 3
87
+ JSON.parse(resp.body)
88
+ when :response
89
+ resp
90
+ else
91
+ body = resp.body.split(',')
92
+ result = {
93
+ status: body[0].to_i,
94
+ change_time: Time.at(body[1].to_i),
95
+ error_code: body[2].to_i
96
+ }
97
+ # TODO: Implement HLR requests data:
98
+ # для отправленного SMS (<статус>, <время изменения>, <код ошибки sms>)
99
+ # для HLR-запроса (<статус>, <время изменения>, <код ошибки sms>, <код IMSI SIM-карты>, <номер сервис-центра>,
100
+ # <код страны регистрации>, <код оператора абонента>, <название страны регистрации>, <название оператора абонента>,
101
+ # <название роуминговой страны>, <название роумингового оператора>)
102
+
103
+ if all != 0
104
+ result.merge!(
105
+ send_time: Time.at(body[-7].to_i),
106
+ phone: body[-6],
107
+ cost: body[-5].to_f,
108
+ sender: body[-4],
109
+ status_message: CGI.unescape(body[-3]),
110
+ message: body[-2]
111
+ )
112
+ end
113
+ result
114
+ end
115
+ end
116
+
117
+ def balance(fmt: 1)
118
+ resp = request('balance', fmt: fmt)
119
+
120
+ check_response_for_exception(resp.body)
121
+
122
+ case fmt
123
+ when 2,0
124
+ resp.body
125
+ when 3
126
+ JSON.parse(resp.body)
127
+ when :response
128
+ resp
129
+ else
130
+ resp.body.to_f
131
+ end
132
+ end
133
+
134
+ private
135
+
136
+ def base_url
137
+ "#{ !config.use_https ? 'http' : 'https' }://smsc.ru"
138
+ end
139
+
140
+ def base_params
141
+ {
142
+ login: config.login,
143
+ psw: config.password,
144
+ charset: config.charset
145
+ }
146
+ end
147
+
148
+ def connection
149
+ Faraday.new(url: base_url)
150
+ end
151
+
152
+ def request(endpoint, params = {})
153
+ req_method = !config.use_post ? :get : :post
154
+
155
+ connection.public_send(req_method, "/sys/#{endpoint}.php") do |req|
156
+ if req_method == :get
157
+ req.params = base_params.merge(params)
158
+ else
159
+ req.body = base_params.merge(params)
160
+ end
161
+ end
162
+ end
163
+
164
+ def format_value(format)
165
+ {
166
+ flash: 1,
167
+ push: 1,
168
+ hlr: 1,
169
+ bin: 1,
170
+ bin_hex: 2,
171
+ ping: 1,
172
+ mms: 1,
173
+ mail: 1,
174
+ call: 1,
175
+ viber: 1,
176
+ soc: 1
177
+ }[format]
178
+ end
179
+
180
+ def time_string(time)
181
+ if time.is_a?(Time) || time.is_a?(Date)
182
+ time.strftime('%d%m%y%H%M')
183
+ else
184
+ time
185
+ end
186
+ end
187
+
188
+ def phones_string(phones)
189
+ if phones.is_a?(Array)
190
+ phones.join(',')
191
+ else
192
+ phones
193
+ end
194
+ end
195
+
196
+ def check_response_for_exception(body)
197
+ code = body.split(',')[1].to_i
198
+
199
+ raise SmscError, "Error code: #{code.abs}" if code < 0
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module ActieSmsc
6
+ class InvalidConfigurationError < StandardError; end
7
+ class InvalidConfigurationError < StandardError; end
8
+
9
+ class Configuration
10
+ VALID_CHARSETS = %w[utf-8 koi8-r windows-1251].freeze
11
+
12
+ attr_accessor :use_post, :use_https, :debug, :logger
13
+ attr_writer :login, :password
14
+ attr_reader :charset
15
+
16
+ def initialize
17
+ @login = nil
18
+ @password = nil
19
+
20
+ @use_post = true
21
+ @use_https = true
22
+ @charset = 'utf-8'
23
+ @debug = false
24
+
25
+ @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout)
26
+ end
27
+
28
+ def login
29
+ return @login if @login
30
+
31
+ raise InvalidConfigurationError, 'login must be specified'
32
+ end
33
+
34
+ def password
35
+ return @password if @password
36
+
37
+ raise InvalidConfigurationError, 'password must be specified'
38
+ end
39
+
40
+
41
+ def charset=(new_charset)
42
+ unless VALID_CHARSETS.include?(new_charset)
43
+ raise InvalidConfigurationError, "charset should be one of #{VALID_CHARSETS}"
44
+ end
45
+
46
+ @charset = new_charset
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActieSmsc
4
+ VERSION = '0.0.1'
5
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actie_smsc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fedor Koshel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: '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: rspec
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
+ - !ruby/object:Gem::Dependency
84
+ name: timecop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: 'This gem based on the ruby library described on: https://smsc.ru/api/code/libraries/http_smtp/ruby/'
112
+ email:
113
+ - alexsnaumov@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CHANGELOG.md
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - actie_smsc.gemspec
129
+ - bin/console
130
+ - bin/setup
131
+ - lib/actie_smsc.rb
132
+ - lib/actie_smsc/configuration.rb
133
+ - lib/actie_smsc/version.rb
134
+ homepage: https://github.com/actie/smsc
135
+ licenses:
136
+ - MIT
137
+ metadata:
138
+ homepage_uri: https://github.com/actie/smsc
139
+ source_code_uri: https://github.com/actie/smsc
140
+ changelog_uri: https://github.com/actie/smsc/CHANGELOG.md
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.7.6
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Gem for using SMSC API in your ruby app
161
+ test_files: []