yx-smart_sms 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/.rdoc_options +21 -0
  4. data/.travis.yml +9 -0
  5. data/CONTRIBUTING.md +32 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +145 -0
  8. data/LICENSE +21 -0
  9. data/README.md +283 -0
  10. data/Rakefile +11 -0
  11. data/lib/generators/smart_sms/config_generator.rb +16 -0
  12. data/lib/generators/smart_sms/install_generator.rb +36 -0
  13. data/lib/generators/smart_sms/templates/add_uid_to_smart_sms_messages.rb +6 -0
  14. data/lib/generators/smart_sms/templates/create_smart_sms_messages.rb +19 -0
  15. data/lib/generators/smart_sms/templates/smart_sms_config.rb +15 -0
  16. data/lib/smart_sms.rb +35 -0
  17. data/lib/smart_sms/account.rb +25 -0
  18. data/lib/smart_sms/config.rb +49 -0
  19. data/lib/smart_sms/has_sms_verification.rb +149 -0
  20. data/lib/smart_sms/helpers/fake_sms.rb +31 -0
  21. data/lib/smart_sms/helpers/verification_code.rb +42 -0
  22. data/lib/smart_sms/message_service.rb +98 -0
  23. data/lib/smart_sms/model/message.rb +9 -0
  24. data/lib/smart_sms/request.rb +48 -0
  25. data/lib/smart_sms/template.rb +44 -0
  26. data/lib/smart_sms/version.rb +3 -0
  27. data/smart_sms.gemspec +35 -0
  28. data/spec/account_spec.rb +80 -0
  29. data/spec/config/config_spec.rb +172 -0
  30. data/spec/fake_app/active_record/config.rb +9 -0
  31. data/spec/fake_app/active_record/models.rb +44 -0
  32. data/spec/fake_app/initializers/smart_sms.rb +15 -0
  33. data/spec/fake_app/rails_app.rb +23 -0
  34. data/spec/has_sms_verificaton_spec.rb +275 -0
  35. data/spec/helpers/fake_sms_spec.rb +15 -0
  36. data/spec/helpers/verification_code_spec.rb +62 -0
  37. data/spec/smart_sms_spec.rb +261 -0
  38. data/spec/spec_helper.rb +26 -0
  39. data/spec/support/database_cleaner.rb +13 -0
  40. data/spec/template_spec.rb +168 -0
  41. metadata +264 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3274a1583d9b1fd36bd59845884770235d327629ec16cb1c2763fa33587c6143
4
+ data.tar.gz: 23c12535c527e895f2ee1135cdc8c1b2b1f48fafb8394de177411ba1e16ffe64
5
+ SHA512:
6
+ metadata.gz: 1c12415532b5fdf4a040bc6ce9e92b7987df29ac57bfe22c1b5a386d4a23fb15e5d0d43f8aef576be50733dd688b750899e2640a792555a3b16d098a1e591948
7
+ data.tar.gz: 6cad04a9a55948cc4780565187d7a756c942b9b1d4a7fb4340cd6f06fd5f5fb76fc58d4fbc6ce30d52e0fe0319d11235503413010b606f0c351ff7cc93eb2d15
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+ spec/fake_app/log/
@@ -0,0 +1,21 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - "./lib"
6
+ charset: UTF-8
7
+ exclude:
8
+ - './spec'
9
+ hyperlink_all: true
10
+ line_numbers: true
11
+ main_page:
12
+ markup: markdown
13
+ output_decoration: true
14
+ page_dir:
15
+ search_index: true
16
+ show_hash: false
17
+ tab_width: 8
18
+ template_stylesheets: []
19
+ title:
20
+ visibility: :private
21
+ webcvs:
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+
8
+ script:
9
+ - bundle exec rspec spec --format documentation
@@ -0,0 +1,32 @@
1
+ # Contributing
2
+
3
+ ## Issues
4
+
5
+ When opening an issue:
6
+
7
+ * include the full **backtrace** with your error
8
+ * include your SmartSMS initializer
9
+ * list versions you are using: Ruby, Rails, Gem, SmartSMS, OS, etc.
10
+
11
+ It's always better to include more info rather than less.
12
+
13
+ ## Code
14
+
15
+ It's always best to open an issue before investing a lot of time into a
16
+ fix or new functionality. Functionality must meet my design goals and
17
+ vision for the project to be accepted; I would be happy to discuss how
18
+ your idea can best fit into SmartSMS.
19
+
20
+ ## Legal
21
+
22
+ By submitting a Pull Request, you disavow any rights or claims to any changes
23
+ submitted to the SmartSMS project and assign the copyright of
24
+ those changes to Contributed Systems LLC.
25
+
26
+ If you cannot or do not want to reassign those rights (your employment
27
+ contract for your employer may not allow this), you should not submit a PR.
28
+ Open an issue and someone else can do the work.
29
+
30
+ This is a legal way of saying "If you submit a PR to us, that code becomes ours".
31
+ 99.9% of the time that's what you intend anyways; we hope it doesn't scare you
32
+ away from contributing.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smart_sms.gemspec
4
+ gemspec
@@ -0,0 +1,145 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yx-smart_sms (0.1.2)
5
+ activerecord (>= 3.0)
6
+ activesupport (>= 3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.1)
12
+ actionpack (= 4.1.1)
13
+ actionview (= 4.1.1)
14
+ mail (~> 2.5.4)
15
+ actionpack (4.1.1)
16
+ actionview (= 4.1.1)
17
+ activesupport (= 4.1.1)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.1)
21
+ activesupport (= 4.1.1)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activemodel (4.1.1)
25
+ activesupport (= 4.1.1)
26
+ builder (~> 3.1)
27
+ activerecord (4.1.1)
28
+ activemodel (= 4.1.1)
29
+ activesupport (= 4.1.1)
30
+ arel (~> 5.0.0)
31
+ activesupport (4.1.1)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 1.1)
37
+ addressable (2.3.6)
38
+ arel (5.0.1.20140414130214)
39
+ builder (3.2.2)
40
+ coderay (1.1.0)
41
+ crack (0.4.2)
42
+ safe_yaml (~> 1.0.0)
43
+ database_cleaner (1.2.0)
44
+ diff-lcs (1.2.5)
45
+ erubis (2.7.0)
46
+ hike (1.2.3)
47
+ i18n (0.6.9)
48
+ json (1.8.1)
49
+ mail (2.5.4)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ method_source (0.8.2)
53
+ mime-types (1.25.1)
54
+ minitest (5.3.3)
55
+ multi_json (1.10.0)
56
+ polyglot (0.3.4)
57
+ pry (0.9.12.6)
58
+ coderay (~> 1.0)
59
+ method_source (~> 0.8)
60
+ slop (~> 3.4)
61
+ rack (1.5.2)
62
+ rack-test (0.6.2)
63
+ rack (>= 1.0)
64
+ rails (4.1.1)
65
+ actionmailer (= 4.1.1)
66
+ actionpack (= 4.1.1)
67
+ actionview (= 4.1.1)
68
+ activemodel (= 4.1.1)
69
+ activerecord (= 4.1.1)
70
+ activesupport (= 4.1.1)
71
+ bundler (>= 1.3.0, < 2.0)
72
+ railties (= 4.1.1)
73
+ sprockets-rails (~> 2.0)
74
+ railties (4.1.1)
75
+ actionpack (= 4.1.1)
76
+ activesupport (= 4.1.1)
77
+ rake (>= 0.8.7)
78
+ thor (>= 0.18.1, < 2.0)
79
+ rake (10.3.1)
80
+ rdoc (4.1.1)
81
+ json (~> 1.4)
82
+ rspec-core (3.1.7)
83
+ rspec-support (~> 3.1.0)
84
+ rspec-expectations (3.1.2)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.1.0)
87
+ rspec-its (1.1.0)
88
+ rspec-core (>= 3.0.0)
89
+ rspec-expectations (>= 3.0.0)
90
+ rspec-mocks (3.1.3)
91
+ rspec-support (~> 3.1.0)
92
+ rspec-rails (3.1.0)
93
+ actionpack (>= 3.0)
94
+ activesupport (>= 3.0)
95
+ railties (>= 3.0)
96
+ rspec-core (~> 3.1.0)
97
+ rspec-expectations (~> 3.1.0)
98
+ rspec-mocks (~> 3.1.0)
99
+ rspec-support (~> 3.1.0)
100
+ rspec-support (3.1.2)
101
+ safe_yaml (1.0.3)
102
+ sdoc (0.4.0)
103
+ json (~> 1.8)
104
+ rdoc (~> 4.0, < 5.0)
105
+ slop (3.5.0)
106
+ sprockets (2.12.1)
107
+ hike (~> 1.2)
108
+ multi_json (~> 1.0)
109
+ rack (~> 1.0)
110
+ tilt (~> 1.1, != 1.3.0)
111
+ sprockets-rails (2.1.3)
112
+ actionpack (>= 3.0)
113
+ activesupport (>= 3.0)
114
+ sprockets (~> 2.8)
115
+ sqlite3 (1.3.9)
116
+ thor (0.19.1)
117
+ thread_safe (0.3.3)
118
+ tilt (1.4.1)
119
+ treetop (1.4.15)
120
+ polyglot
121
+ polyglot (>= 0.3.1)
122
+ tzinfo (1.1.0)
123
+ thread_safe (~> 0.1)
124
+ webmock (1.17.4)
125
+ addressable (>= 2.2.7)
126
+ crack (>= 0.3.2)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ bundler (>= 1.0.0)
133
+ database_cleaner (~> 1.2.0)
134
+ pry
135
+ rails (>= 3.1.0)
136
+ rake
137
+ rspec-its (>= 1.0.0)
138
+ rspec-rails (>= 3.0.0)
139
+ sdoc
140
+ sqlite3
141
+ webmock (~> 1.17.0)
142
+ yx-smart_sms!
143
+
144
+ BUNDLED WITH
145
+ 1.15.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 Felix Liu
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,283 @@
1
+ SmartSMS
2
+ ========
3
+ [![Build Status](https://travis-ci.org/lyfeyaj/smart_sms.svg?branch=master)](https://travis-ci.org/lyfeyaj/smart_sms)
4
+ [![Code Climate](https://codeclimate.com/github/lyfeyaj/smart_sms/badges/gpa.svg)](https://codeclimate.com/github/lyfeyaj/smart_sms)
5
+
6
+ 提供在中国境内发送短信([云片网络](http://www.yunpian.com)), 校验, 集成 ActiveRecord
7
+
8
+ 功能特点
9
+ --------
10
+
11
+ * 集成了 [云片网络](http://www.yunpian.com) 的所有短信服务API
12
+ - 发送, 查询模板短信, 通用短信
13
+ - 查询, 修改用户信息
14
+ - 查询默认模板, 自定义模板
15
+ - 新增, 修改, 删除自定义模板
16
+ - 查询用户短信回复
17
+ * 集成了 ActiveRecord 支持
18
+ * 集成了方便的验证码生成工具
19
+ * 强大的配置选项, 几行代码即可集成所有功能
20
+
21
+ ## 安装
22
+
23
+ gem install smart_sms
24
+
25
+ ### 或者从 `github` 安装最新的开发版本
26
+
27
+ git clone http://github.com/lyfeyaj/smart_sms.git
28
+ cd smart_sms
29
+ rake install
30
+
31
+ ## 使用
32
+
33
+ ### 结合 Rails 使用
34
+
35
+ ##### 安装
36
+
37
+ 在您的 `Gemfile` 里面添加:
38
+
39
+ ```
40
+ gem 'smart_sms'
41
+ ```
42
+
43
+ 然后, 在 console 中执行下面的代码:
44
+
45
+ ``` bash
46
+ # 安装gem
47
+ bundle
48
+
49
+ rails g smart_sms:config # 将会拷贝配置文件至 `config/initializers/smart_sms_config.rb`
50
+
51
+ # 如果, 需要将所有短信都在本地存储, 则需要将配置文件中的 `store_sms_in_local` 设置为 true, 然后运行
52
+ rails g smart_sms:install # 程序将会拷贝相应的 migration 文件到 `db/migrate` 目录下
53
+ rake db:migrate
54
+ ```
55
+
56
+ ##### 配置
57
+
58
+ ``` ruby
59
+ SmartSMS.configure do |config|
60
+ config.api_key = nil # 授权 API KEY
61
+ config.api_version = :v1 # API 的版本, 当前仅有v1
62
+ config.template_id = '2' # 指定发送信息时使用的模板
63
+ config.template_value = [:code, :company] # 用于指定信息文本中的可替换内容, 数组形势: [:code, :company]
64
+ config.page_num = 1 # 获取信息时, 指定默认的页数
65
+ config.page_size = 20 # 获取信息时, 一页包含信息数量
66
+ config.company = '云片网' # 默认公司名称
67
+ config.expires_in = 1.hour # 短信验证过期时间
68
+ config.default_interval = 1.day # 查询短信时的默认时间段: end_time - start_time
69
+ config.store_sms_in_local = false # 是否存储SMS信息在本地: true or false
70
+ config.verification_code_algorithm = :simple # 提供三种形式的验证码: `:simple, :middle, :complex`
71
+ end
72
+ ```
73
+
74
+ ##### API 汇总(ActiveRecord)
75
+
76
+ 当在您现有的 model 中声明 `has_sms_verification` 的时候, 您将获得以下方法:
77
+ ``` ruby
78
+ class User < ActiveRecord::Base
79
+ # 在您的Model里面声明这个方法, 以添加SMS短信验证功能
80
+ # moible_column: mobile 绑定的字段, 用于获取发送短信所需的手机号码, 默认是 :phone
81
+ # verification_column: 验证绑定的字段, 用于判断是否已验证,
82
+ #
83
+ # Options:
84
+ # :class_name 自定义的Message类名称. 默认是 `SmartSMS::Message`
85
+ # :messages 自定义的Message关联名称. 默认是 `:messages`.
86
+ #
87
+ has_sms_verification
88
+ end
89
+
90
+ # 发送短信验证码
91
+ user.deliver # 将会生成一个随机的验证码发送至手机, 并保存在messages表中
92
+ user.deliver '内容' # 可以发送指定内容至手机
93
+
94
+ # 查询历史短信记录
95
+ user.messages
96
+
97
+ # 查询是否已经验证
98
+ user.verified? # ture : false
99
+
100
+ # 校验验证码
101
+ user.verify '123456' # 返回 true 或者 false, 不修改数据库的 verified_at 关联字段
102
+ user.verify! '123456' # 返回 true 或者 false, 同时修改数据库的 verified_at 关联字段为当前时间
103
+
104
+ # 查询验证日期
105
+ user.verified_at
106
+
107
+ # 查询最新的一条有效短信记录
108
+ user.latest_message # 返回有效期内的最近一条短信, 若无则返回nil
109
+
110
+ # 发送假信息, 方便非国内用户测试用
111
+ user.deliver_fake_sms # messages中会保存一条新的短信记录, 但是不会发送短信到手机
112
+ ```
113
+
114
+ ### 基本用法(不依赖Rails)
115
+
116
+ ##### 设置api_key
117
+ ``` ruby
118
+ SmartSMS.configure { |c| c.api_key = 'fure8423n4324uoj432n4324' }
119
+ ```
120
+
121
+ ##### 短信
122
+
123
+ ``` ruby
124
+
125
+ # 发送短信到手机, 默认使用模板发送, 提供通用接口支持
126
+ # phone: 需要接受短信的手机号码
127
+ # content: 短信验证内容
128
+ #
129
+ # Options:
130
+ # :method 如若要使用通用短信接口, 需要 method: :general
131
+ # :tpl_id 选择发送短信的模板, 默认是2
132
+ SmartSMS.deliver 13522948742, 'SmartSMS WOW!'
133
+ SmartSMS.deliver 13522948742, 'SmartSMS WOW!', tpl_id: 1
134
+ SmartSMS.deliver 13522948742, 'SmartSMS WOW!', method: :general # 使用通用短信发送方式, 需申请
135
+
136
+ # 根据sid来查询短信记录
137
+ SmartSMS.find_by_sid 13232
138
+ # => {"code"=>0,
139
+ # "msg"=>"OK",
140
+ # "sms"=>
141
+ # {"sid"=>13232,
142
+ # "mobile"=>"13522948742",
143
+ # "send_time"=>"2014-04-06 13:29:33",
144
+ # "text"=>"您的验证码是668965。如非本人操作,请忽略本短信【SmartSMS】",
145
+ # "send_status"=>"SUCCESS",
146
+ # "report_status"=>"SUCCESS",
147
+ # "fee"=>1,
148
+ # "user_receive_time"=>"2014-04-06 13:29:49",
149
+ # "error_msg"=>nil}}
150
+
151
+ # 批量查短信, 参数:
152
+ # start_time: 短信提交开始时间
153
+ # end_time: 短信提交结束时间
154
+ # page_num: 页码,从1开始
155
+ # page_size: 每页个数,最大100个
156
+ # mobile: 接收短信的手机号
157
+ SmartSMS.find
158
+ SmartSMS.find start_time: Time.now.yesterday, end_time: Time.now
159
+ SmartSMS.find start_time: Time.now.yesterday, end_time: Time.now, mobile: 13522948742
160
+
161
+ # 查询屏蔽词
162
+ SmartSMS.get_black_word '这是一条测试短信'
163
+ # => {"code"=>0, "msg"=>"OK", "result"=>{"black_word"=>"测试"}}
164
+
165
+ # 查回复的短信, 参数与批量查短信一致, 可以查询用户回复的短信
166
+ SmartSMS.get_reply
167
+ SmartSMS.get_reply start_time: Time.now.yesterday, end_time: Time.now
168
+ SmartSMS.get_reply start_time: Time.now.yesterday, end_time: Time.now, mobile: 13522948742
169
+
170
+ ```
171
+
172
+ ##### 账户
173
+
174
+ ``` ruby
175
+
176
+ # 获取用户信息
177
+ SmartSMS::Account.info
178
+ # =>
179
+ #{
180
+ # "code" => 0,
181
+ # "msg" => "OK",
182
+ # "user" => {
183
+ # "nick" => "Jacky",
184
+ # "gmt_created" => "2012-09-11 15:14:00",
185
+ # "mobile" => "13764071479",
186
+ # "email" => "jacky@taovip.com",
187
+ # "ip_whitelist" => null, //IP白名单,推荐使用
188
+ # "api_version" => "v1", //api版本号
189
+ # "send_count" => 0, //当天已发送的短信数
190
+ # "balance" => 0, //短信剩余条数
191
+ # "alarm_balance" => 0, //剩余条数低于该值时提醒
192
+ # "emergency_contact" => "张三", //紧急联系人
193
+ # "emergency_mobile" => "13812341234" //紧急联系人电话
194
+ # }
195
+ #}
196
+
197
+ # 设置用户信息
198
+ # emergency_contact: 紧急联系人
199
+ # emergency_mobile: 紧急联系人手机号
200
+ # alarm_balance: 短信余额提醒阈值。一天只提示一次
201
+ SmartSMS::Account.set emergency_contact: 13764071479
202
+ # =>
203
+ #{
204
+ # "code" => 0,
205
+ # "msg" => "OK",
206
+ # "detail" => null
207
+ #}
208
+
209
+ ```
210
+
211
+ ##### 模板
212
+
213
+ ``` ruby
214
+
215
+ # 获取系统默认模板
216
+ # Options:
217
+ # tpl_id: 指定tpl_id时返回tpl_id对应的默认模板. 未指定时返回所有默认模板
218
+ #
219
+ SmartSMS::Template.find_default
220
+ SmartSMS::Template.find_default 2
221
+
222
+ # 获取自定义模板
223
+ # Options:
224
+ # tpl_id: 指定tpl_id时返回tpl_id对应的自定义模板. 未指定时返回所有自定义模板
225
+ #
226
+ SmartSMS::Template.find
227
+ SmartSMS::Template.find 3252
228
+
229
+ # 创建新模板
230
+ # 规则请参见: <http://www.yunpian.com/api/tpl.html>
231
+ #
232
+ SmartSMS::Template.create '您的验证码是: #code#'
233
+
234
+ # 更新模板, 需指定id和content
235
+ #
236
+ SmartSMS::Template.update 3252, '您的验证码是: #code#, 【SmartSMS】'
237
+
238
+ # 删除模板, 需指定id
239
+ #
240
+ SmartSMS::Template.destroy 3252
241
+
242
+ ```
243
+
244
+ ##### 校验码
245
+
246
+ ``` ruby
247
+
248
+ # 生成随机校验码
249
+ # 四个选项:
250
+ # short: 4位随机数字
251
+ # simple: 6位随机数字, 默认
252
+ # middle: 6位随机字母, 数字组合
253
+ # complex: 8位随机字母, 数字, 特殊字符组合
254
+
255
+ SmartSMS::VerificationCode.random # => "1708"
256
+ SmartSMS::VerificationCode.random :short # => "141068"
257
+ SmartSMS::VerificationCode.random :middle # => "xey7id"
258
+ SmartSMS::VerificationCode.random :complex # => "x+rkag6a"
259
+
260
+ SmartSMS::VerificationCode.short # => "1708"
261
+ SmartSMS::VerificationCode.simple # => "141068"
262
+ SmartSMS::VerificationCode.middle # => "xey7id"
263
+ SmartSMS::VerificationCode.complex # => "x+rkag6a"
264
+
265
+ ```
266
+
267
+ ## 贡献
268
+
269
+ + Fork
270
+ + 创建分支 (git checkout -b my-new-feature)
271
+ + 保存代码 (git commit -am 'Added some feature')
272
+ + 上传到分支 (git push origin my-new-feature)
273
+ + 创建一个新的合并请求
274
+
275
+ ## LICENCE
276
+
277
+ [MIT](https://github.com/lyfeyaj/smart_sms/blob/master/LICENSE)
278
+
279
+ ## 作者
280
+
281
+ [Felix Liu](https://github.com/lyfeyaj)
282
+
283
+ [作者博客](http://lyfeyaj.com)