smsdigital 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5c8bdd0032fe46933f8ace964dc9c5e7097b9e1d69fbe4f5c2e313334f04c7fb
4
+ data.tar.gz: bd318be858bf6a343efdc40b1e1555123d86f6c041041090a325b3c0dab2ceb1
5
+ SHA512:
6
+ metadata.gz: 5d2c53da3bfba0a3890d7014cfcce695d5fcf2b4ac15e8eb5930b345889eb8a7d7af56269a7b8c0151f58cafd201f20f0cebac761cacaf66f69976c0351a0f33
7
+ data.tar.gz: 030566a9601889771f0edfc03373b3e5e70cd2798f93340162ca3be080354047092d41d4f4519efed3add52aeabc35be163fe7aa4066e7f9c6c932a2f78e7e88
@@ -0,0 +1,21 @@
1
+ c
2
+ response.parsed_response['Status']
3
+ response.parsed_response.status
4
+ response.parsed_response
5
+ response.Status
6
+ response.status
7
+ response
8
+ c
9
+ vcr
10
+ vr
11
+ response
12
+ c
13
+ response["Destinatarios"].map { |dest| dest.fetch("Celular") }
14
+ response["Destinatarios"].each { |dest| dest.fetch("Celular") }
15
+ response["Destinatarios"].each { |dest| dest.fetch("celular") }
16
+ response
17
+ c
18
+ response
19
+ c
20
+ smsdigital.username
21
+ c
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in smsdigital.gemspec
4
+ gemspec
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ smsdigital (1.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ byebug (11.0.1)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ hashdiff (1.0.0)
17
+ httparty (0.17.3)
18
+ mime-types (~> 3.0)
19
+ multi_xml (>= 0.5.2)
20
+ mime-types (3.3)
21
+ mime-types-data (~> 3.2015)
22
+ mime-types-data (3.2019.1009)
23
+ multi_xml (0.6.0)
24
+ public_suffix (4.0.1)
25
+ rake (12.3.3)
26
+ rspec (3.9.0)
27
+ rspec-core (~> 3.9.0)
28
+ rspec-expectations (~> 3.9.0)
29
+ rspec-mocks (~> 3.9.0)
30
+ rspec-core (3.9.0)
31
+ rspec-support (~> 3.9.0)
32
+ rspec-expectations (3.9.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-mocks (3.9.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-support (3.9.0)
39
+ safe_yaml (1.0.5)
40
+ vcr (5.0.0)
41
+ webmock (3.7.6)
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
+ byebug
51
+ rake (~> 12.0)
52
+ rspec (~> 3.2)
53
+ smsdigital!
54
+ vcr
55
+ webmock
56
+
57
+ BUNDLED WITH
58
+ 2.1.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
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,74 @@
1
+ #SMSDigital
2
+
3
+ Welcome to SMSDigital gem, a ruby gem to use Smsdigital service.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'smsdigital'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install SMSDigital
20
+
21
+ ## Usage
22
+
23
+
24
+ ### Configuring Credentials
25
+
26
+ To configure your credentials call `configure` on `SMSDigigal` as below:
27
+
28
+ ```ruby
29
+ SMSDigital.configure do |config|
30
+ config.username = 'my-username'
31
+ config.password = 'my-secure-password'
32
+ end
33
+ ```
34
+
35
+ ### Sending SMS to a single recipient
36
+
37
+ You can easily send SMS messages with the `send_sms` method:
38
+
39
+ ```ruby
40
+ SMSDigital.send_sms(phone, message)
41
+ ```
42
+
43
+ or you can create messages end send then individually
44
+
45
+ ```ruby
46
+ sms = SMSDigital::SMS.new '8899989898', 'Read the source, Luke'
47
+ sms.send!
48
+ ```
49
+
50
+ *Please, make sure you properly configure SMSDigital with your credentials*
51
+
52
+ ### Sending SMS to multiple recipients
53
+ Coming soon.
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ 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).
60
+
61
+ *make sure you properly configure SMSDigital with your credentials*
62
+ ```ruby
63
+ export USERNAME='your_username'
64
+ export PASSWORD='your_password'
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/brunotoral/smsdigital.
70
+
71
+
72
+ ## License
73
+
74
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "smsdigital"
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,37 @@
1
+ require "httparty"
2
+
3
+ require "smsdigital/version"
4
+ require "smsdigital/configuration"
5
+ require "smsdigital/sms"
6
+
7
+ module SMSDigital
8
+ class << self
9
+ extend Forwardable
10
+
11
+ attr_accessor :configuration
12
+
13
+ def_delegators :configuration, :username, :password
14
+
15
+ def configure
16
+ yield(configuration)
17
+ end
18
+
19
+ def configuration
20
+ @configuration ||= Configuration.new
21
+ end
22
+
23
+ def reset_configuration!
24
+ self.configuration = Configuration.new
25
+ end
26
+
27
+ def send_sms(phone, message)
28
+ sms = SMSDigital::SMS.new phone, message
29
+
30
+ sms.send
31
+
32
+ return sms.sent?
33
+ end
34
+ end
35
+
36
+ class Error < StandardError; end
37
+ end
@@ -0,0 +1,10 @@
1
+ module SMSDigital
2
+ class Configuration
3
+ attr_accessor :username, :password
4
+
5
+ def initialize
6
+ @username = nil
7
+ @password = nil
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ module SMSDigital
2
+ class SMS
3
+ include ::HTTParty
4
+
5
+ format :json
6
+
7
+ base_uri "https://ws.smsdigital.com.br/sms/"
8
+ debug_output $stdout
9
+
10
+ attr_accessor :phone, :message, :response
11
+
12
+ def initialize(phone = nil, message = nil)
13
+ @phone = phone
14
+ @message = message
15
+ end
16
+
17
+ def send
18
+ self.class.basic_auth SMSDigital.username, SMSDigital.password
19
+
20
+ params = {
21
+ headers: { "Content-Type" => "application/json" },
22
+ body: {
23
+ Destinatarios: [phone],
24
+ Mensagem: message,
25
+ }.to_json,
26
+ }
27
+
28
+ self.response = self.class.post("/envio", params)
29
+ end
30
+
31
+ def sent?
32
+ response.parsed_response['Status'] === 1 ? true : false
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module SMSDigital
2
+ VERSION = "1.1.1"
3
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'lib/smsdigital/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "smsdigital"
5
+ spec.version = SMSDigital::VERSION
6
+ spec.authors = ["Bruno Toral"]
7
+ spec.email = ["brunotoral89@gmail.com"]
8
+
9
+ spec.summary = "A ruby gem to use Smsdigital service."
10
+ spec.description = "A ruby gem to use Smsdigital service. In this first version only one message and one recipient are allowed"
11
+ spec.homepage = "https://github.com/brunotoral/smsdigital"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = "https://github.com/brunotoral/smsdigital"
16
+ spec.metadata["source_code_uri"] = "https://github.com/brunotoral/smsdigital"
17
+ spec.metadata["changelog_uri"] = "https://github.com/brunotoral/smsdigital"
18
+
19
+ spec.add_development_dependency "rspec", "~> 3.2"
20
+ spec.add_development_dependency "rake", "~> 12.0"
21
+ spec.add_development_dependency "byebug"
22
+ spec.add_development_dependency "vcr"
23
+ spec.add_development_dependency "webmock"
24
+
25
+ spec.add_dependency "httparty"
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
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smsdigital
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Toral
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-10 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: :development
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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
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: vcr
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: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A ruby gem to use Smsdigital service. In this first version only one
98
+ message and one recipient are allowed
99
+ email:
100
+ - brunotoral89@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".byebug_history"
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - lib/smsdigital.rb
116
+ - lib/smsdigital/configuration.rb
117
+ - lib/smsdigital/sms.rb
118
+ - lib/smsdigital/version.rb
119
+ - smsdigital.gemspec
120
+ homepage: https://github.com/brunotoral/smsdigital
121
+ licenses:
122
+ - MIT
123
+ metadata:
124
+ homepage_uri: https://github.com/brunotoral/smsdigital
125
+ source_code_uri: https://github.com/brunotoral/smsdigital
126
+ changelog_uri: https://github.com/brunotoral/smsdigital
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 2.3.0
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.0.3
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: A ruby gem to use Smsdigital service.
146
+ test_files: []