module ConfirmationCode::Service::Lianzhong
Constants
- ACCOUNT_URL
- RECOGNITION_ERROR_URL
- UPLOAD_URL
Public Instance Methods
account(options = {})
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 46 def account(options = {}) options = lianzhong_options.merge options print options response = client.post(ACCOUNT_URL, options) result(JSON.parse(response.body)) end
client()
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 17 def client @client ||= HTTPClient.new end
lianzhong_options()
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 59 def lianzhong_options { yzm_minlen: '4', yzm_maxlen: '6', yzmtype_mark: '', zztool_token: '', } end
recognition_error(ret_id, options = {})
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 53 def recognition_error(ret_id, options = {}) options['yzm_id'] = ret_id response = client.post(RECOGNITION_ERROR_URL, options) result(JSON.parse(response.body)) end
result(body)
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 68 def result(body) { "success" => body['result'], "data" => body['data'] } end
set_extra_options(options)
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 21 def set_extra_options(options) end
upload(image_url, options = {})
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 25 def upload(image_url, options = {}) File.open("code.jpeg", "wb") do |f| f.write open(image_url).read end options = lianzhong_options.merge options File.open('code.jpeg') do |file| options['upload'] = file response = client.post(UPLOAD_URL, options) result(JSON.parse(response.body)) end end
upload_local(image_path, options = {})
click to toggle source
# File lib/confirmation_code/service/lianzhong.rb, line 37 def upload_local(image_path, options = {}) options = lianzhong_options.merge options File.open(image_path) do |file| options['upload'] = file response = client.post(UPLOAD_URL, options) result(JSON.parse(response.body)) end end