smsbroadcast 1.1.4

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
+ SHA1:
3
+ metadata.gz: c97e287dce2421a0301dd85e52b4bdfcc265c772
4
+ data.tar.gz: 8a40d215ccd885df4b3468f655b9b26b25a10325
5
+ SHA512:
6
+ metadata.gz: bcf6143d6bdfbe2409bb0a2168e8b8f104b6381ce2425ed39bc3157821b81d82475bb0078b09494ae72bfed032ee2a0d8fbd3e9acf4d904178b5d577b5d117a6
7
+ data.tar.gz: 5831fee56b3feed4575ea6529e7665dc25412851d4f4159a920a217edbadd8b6b09bdeacfbe0cf805c80c17ae1bbe4e688a872f3b713051d27668ebce7514344
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smsbroadcast.gemspec
4
+ gemspec
@@ -0,0 +1,18 @@
1
+ require 'pry'
2
+ require 'ostruct'
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+ require "guard/rspec/dsl"
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # Feel free to open issues for suggestions and improvements
8
+
9
+ # RSpec files
10
+ rspec = dsl.rspec
11
+ watch(rspec.spec_helper) { rspec.spec_dir }
12
+ watch(rspec.spec_support) { rspec.spec_dir }
13
+ watch(rspec.spec_files)
14
+
15
+ # Ruby files
16
+ ruby = dsl.ruby
17
+ dsl.watch_spec_files_for(ruby.lib_files)
18
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 sia.s.saj
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,41 @@
1
+ # Smsbroadcast
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/smsbroadcast`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'smsbroadcast'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install smsbroadcast
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/smsbroadcast.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -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,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pry'
4
+ require 'optparse'
5
+ require "smsbroadcast"
6
+ require "bundler/setup"
7
+
8
+
9
+ opt_parser = OptionParser.new do |opts|
10
+ opts.banner = "Usage: bin/console username password"
11
+ end
12
+
13
+ opts = opt_parser.parse!(ARGV)
14
+
15
+ Smsbroadcast.configure do |config|
16
+ config.username = opts[0]
17
+ config.password = opts[1]
18
+ end
19
+
20
+ Pry.start
@@ -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,15 @@
1
+ require "smsbroadcast/sms"
2
+ require "smsbroadcast/status"
3
+ require "smsbroadcast/version"
4
+ require "smsbroadcast/configurable"
5
+
6
+ module Smsbroadcast
7
+ extend Configurable
8
+ end
9
+
10
+ Smsbroadcast.configure do |config|
11
+ config.url = "https://api.smsbroadcast.com.au/"
12
+ config.from = "getFoodi"
13
+ config.maxsplit = "1"
14
+ config.delay = "0"
15
+ end
@@ -0,0 +1,12 @@
1
+ require "smsbroadcast/configuration"
2
+
3
+ module Smsbroadcast
4
+ module Configurable
5
+ attr_accessor :configuration
6
+
7
+ def configure
8
+ self.configuration ||= Configuration.new
9
+ yield(self.configuration)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Smsbroadcast
2
+ class Configuration
3
+ attr_accessor :url, :from, :delay, :maxsplit, :username, :password
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require 'faraday'
2
+
3
+ module Smsbroadcast
4
+ class Connection
5
+
6
+ def initialize
7
+ @conn = Faraday.new(url: Smsbroadcast.configuration.url) do |faraday|
8
+ faraday.request :url_encoded # form-encode POST params
9
+ faraday.response :logger # log requests to STDOUT
10
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,41 @@
1
+ require 'smsbroadcast/too_many_recipients_error'
2
+ require 'smsbroadcast/sms_response'
3
+ require 'smsbroadcast/connection'
4
+
5
+ module Smsbroadcast
6
+ class Sms < Connection
7
+
8
+ attr_accessor :to, :message, :ref, :from, :maxsplit, :delay
9
+
10
+ def initialize(to: nil, message: nil, ref: nil, from: nil, maxsplit: nil, delay: nil)
11
+ super()
12
+ @to = to
13
+ @message = message
14
+ @ref = ref
15
+ @from = from || Smsbroadcast.configuration.from
16
+ @maxsplit = maxsplit || Smsbroadcast.configuration.maxsplit
17
+ @delay = delay || Smsbroadcast.configuration.delay
18
+ end
19
+
20
+ def deliver
21
+ if @to.respond_to?(:each) && @to.count > 1000
22
+ raise TooManyRecipientsError, "Can only deliver in blocks of 1000 recipients"
23
+ end
24
+
25
+ to = @to.respond_to?(:each) ? @to.join(",") : @to
26
+
27
+ resp = @conn.post("/api-adv.php") do |req|
28
+ req.body = {to: to,
29
+ message: @message,
30
+ ref: @ref,
31
+ from: @from,
32
+ maxsplit: @maxsplit,
33
+ delay: @delay,
34
+ username: Smsbroadcast.configuration.username,
35
+ password: Smsbroadcast.configuration.password}
36
+ end
37
+
38
+ SmsResponse.new resp.body
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ module Smsbroadcast
2
+ class SmsResponse
3
+
4
+ attr_reader :status, :number, :ref, :message
5
+
6
+ def initialize(response_string)
7
+ @response_string = response_string
8
+ parse_response
9
+ end
10
+
11
+ private
12
+
13
+ def parse_response
14
+ arry = @response_string.split(":")
15
+ @status = arry.first.downcase.to_sym
16
+
17
+ case @status
18
+ when :ok
19
+ @number = arry[1]
20
+ @ref = arry[2]
21
+ when :bad
22
+ @number = arry[1]
23
+ @message = arry[2]
24
+ when :error
25
+ @message = arry[1]
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ require 'smsbroadcast/connection'
2
+
3
+ module Smsbroadcast
4
+ class Status < Smsbroadcast::Connection
5
+
6
+ attr_reader :status, :balance, :message
7
+
8
+ def call
9
+ resp = @conn.get "/api-adv.php" do |req|
10
+ req.body = {action: "balance",
11
+ username: Smsbroadcast.configuration.username,
12
+ password: Smsbroadcast.configuration.password}
13
+ end
14
+
15
+ @response_string = resp.body
16
+
17
+ parse_response
18
+ end
19
+
20
+ private
21
+
22
+ def parse_response
23
+ arry = @response_string.split(":")
24
+ @status = arry.first.downcase.to_sym
25
+
26
+ case @status
27
+ when :ok
28
+ @balance = arry[1]
29
+ when :error
30
+ @message = arry[1]
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module Smsbroadcast
2
+ class TooManyRecipientsError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Smsbroadcast
2
+ VERSION = "1.1.4"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'smsbroadcast/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "smsbroadcast"
8
+ spec.version = Smsbroadcast::VERSION
9
+ spec.authors = ["sia.s.saj"]
10
+ spec.email = ["sia.s.saj@gmail.com"]
11
+
12
+ spec.summary = %q{Library to consume smsbroadcast.com.au service.}
13
+ spec.description = %q{Send & receive sms, and monitor your account with smsbroadcast.com.au.}
14
+ spec.homepage = %q{https://github.com/siassaj/smsbroadcast.git}
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "faraday", "~> 0.9.2"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.12"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "guard-rspec"
28
+ spec.add_development_dependency "webmock"
29
+ spec.add_development_dependency "pry"
30
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smsbroadcast
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.4
5
+ platform: ruby
6
+ authors:
7
+ - sia.s.saj
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-30 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.9.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.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: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
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: webmock
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: Send & receive sms, and monitor your account with smsbroadcast.com.au.
112
+ email:
113
+ - sia.s.saj@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - Guardfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/smsbroadcast.rb
129
+ - lib/smsbroadcast/configurable.rb
130
+ - lib/smsbroadcast/configuration.rb
131
+ - lib/smsbroadcast/connection.rb
132
+ - lib/smsbroadcast/sms.rb
133
+ - lib/smsbroadcast/sms_response.rb
134
+ - lib/smsbroadcast/status.rb
135
+ - lib/smsbroadcast/too_many_recipients_error.rb
136
+ - lib/smsbroadcast/version.rb
137
+ - smsbroadcast.gemspec
138
+ homepage: https://github.com/siassaj/smsbroadcast.git
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Library to consume smsbroadcast.com.au service.
162
+ test_files: []