sms_bao_alt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/lib/sms_bao.rb +18 -0
- data/lib/sms_bao/base.rb +12 -0
- data/lib/sms_bao/config.rb +24 -0
- data/lib/sms_bao/version.rb +3 -0
- data/sms_bao_alt.gemspec +22 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Scott Ballantyne
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# SmsBao
|
2
|
+
|
3
|
+
This is a quick wrapper for http://www.smsbao.com/openapi
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sms_bao_alt'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install sms_bao_alt
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Make a config/sms_bao.yml file that looks like this
|
23
|
+
|
24
|
+
development:
|
25
|
+
username: 'username'
|
26
|
+
password: 'password'
|
27
|
+
|
28
|
+
production:
|
29
|
+
username: 'username'
|
30
|
+
password: 'password'
|
31
|
+
|
32
|
+
Then you can send messages like this:
|
33
|
+
|
34
|
+
$ SmsBao::Base.send_message('phone number', 'messages')
|
35
|
+
|
36
|
+
There is also a callback url that you need to set to receive replies... I don't the link handy, take a look around.
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sms_bao.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "sms_bao/version"
|
2
|
+
require "sms_bao/config"
|
3
|
+
require "sms_bao/base"
|
4
|
+
|
5
|
+
module SmsBao
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
if File.exists?('config/sms_bao.yml')
|
10
|
+
config = YAML.load_file('config/sms_bao.yml')[ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"]
|
11
|
+
SmsBao::Config.username = config["username"]
|
12
|
+
SmsBao::Config.password = config["password"]
|
13
|
+
else
|
14
|
+
puts "\n\n=========================================================\n\n" +
|
15
|
+
" You haven't made a config/sms_bao.yml file.\n\n You should. \n\n The sms_bao gem will work much better if you do\n\n" +
|
16
|
+
" Please set SmsBao::Config.username and \n SmsBao::Config.password\n somewhere in your initialization process\n\n" +
|
17
|
+
"=========================================================\n\n"
|
18
|
+
end
|
data/lib/sms_bao/base.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
module SmsBao
|
3
|
+
class Base
|
4
|
+
def self.send_message(phone, message)
|
5
|
+
RestClient.get 'http://api.smsbao.com/sms?u='+SmsBao::Config.username+'&p='+SmsBao::Config.pass_md5+'&m='+phone+'&c='+URI.escape(message)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.check_balance
|
9
|
+
RestClient.get('http://www.smsbao.com/query?u='+SmsBao::Config.username+'&p='+SmsBao::Config.pass_md5).split(',')[1].to_i
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
module SmsBao
|
3
|
+
module Config
|
4
|
+
def self.username=(val)
|
5
|
+
@@api_username = val
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.username
|
9
|
+
@@api_username
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.password=(val)
|
13
|
+
@@api_password = val
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.password
|
17
|
+
@@api_password
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.pass_md5
|
21
|
+
Digest::MD5.hexdigest(@@api_password)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/sms_bao_alt.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sms_bao/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sms_bao_alt"
|
8
|
+
gem.version = SmsBao::VERSION
|
9
|
+
gem.authors = ["Scott Ballantyne"]
|
10
|
+
gem.email = ["ussballantyne@gmail.com"]
|
11
|
+
gem.description = %q{SmsBao gem}
|
12
|
+
gem.summary = %q{SmsBao gem}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency('rest-client')
|
20
|
+
gem.add_dependency(%q<hashie>, [">= 0"])
|
21
|
+
gem.add_dependency(%q<multi_json>, [">= 0"])
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sms_bao_alt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Ballantyne
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hashie
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: multi_json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: SmsBao gem
|
63
|
+
email:
|
64
|
+
- ussballantyne@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/sms_bao.rb
|
75
|
+
- lib/sms_bao/base.rb
|
76
|
+
- lib/sms_bao/config.rb
|
77
|
+
- lib/sms_bao/version.rb
|
78
|
+
- sms_bao_alt.gemspec
|
79
|
+
homepage: ''
|
80
|
+
licenses: []
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.8.25
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: SmsBao gem
|
103
|
+
test_files: []
|