Module: ConfirmationCode::Service::Lianzhong
- Extended by:
- Lianzhong
- Includes:
- ConfirmationCode
- Included in:
- Lianzhong
- Defined in:
- lib/confirmation_code/service/lianzhong.rb
Constant Summary collapse
- UPLOAD_URL =
'http://bbb4.hyslt.com/api.php?mod=php&act=upload'- ACCOUNT_URL =
'http://bbb4.hyslt.com/api.php?mod=php&act=point'- RECOGNITION_ERROR_URL =
'http://bbb4.hyslt.com/api.php?mod=php&act=error'
Constants included from ConfirmationCode
Instance Attribute Summary
Attributes included from ConfirmationCode
Instance Method Summary collapse
- #account(options = {}) ⇒ Object
- #client ⇒ Object
- #lianzhong_options ⇒ Object
- #recognition_error(ret_id, options = {}) ⇒ Object
- #result(body) ⇒ Object
- #set_extra_options(options) ⇒ Object
- #upload(image_url, options = {}) ⇒ Object
- #upload_local(image_path, options = {}) ⇒ Object
Methods included from ConfirmationCode
Instance Method Details
#account(options = {}) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 46 def account( = {}) = .merge print response = client.post(ACCOUNT_URL, ) result(JSON.parse(response.body)) end |
#client ⇒ Object
17 18 19 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 17 def client @client ||= HTTPClient.new end |
#lianzhong_options ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 59 def { yzm_minlen: '4', yzm_maxlen: '6', yzmtype_mark: '', zztool_token: '', } end |
#recognition_error(ret_id, options = {}) ⇒ Object
53 54 55 56 57 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 53 def recognition_error(ret_id, = {}) ['yzm_id'] = ret_id response = client.post(RECOGNITION_ERROR_URL, ) result(JSON.parse(response.body)) end |
#result(body) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 68 def result(body) { "success" => body['result'], "data" => body['data'] } end |
#set_extra_options(options) ⇒ Object
21 22 23 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 21 def () end |
#upload(image_url, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 25 def upload(image_url, = {}) File.open("code.jpeg", "wb") do |f| f.write open(image_url).read end = .merge File.open('code.jpeg') do |file| ['upload'] = file response = client.post(UPLOAD_URL, ) result(JSON.parse(response.body)) end end |
#upload_local(image_path, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/confirmation_code/service/lianzhong.rb', line 37 def upload_local(image_path, = {}) = .merge File.open(image_path) do |file| ['upload'] = file response = client.post(UPLOAD_URL, ) result(JSON.parse(response.body)) end end |