Module: Eloan::Helper::Service
- Included in:
- Api
- Defined in:
- lib/eloan/helper/service.rb
Instance Attribute Summary collapse
-
#chaxue ⇒ Object
Returns the value of attribute chaxue.
Instance Method Summary collapse
- #generate_request_url(url = '') ⇒ Object
- #handle_params(options = {}) ⇒ Object
- #raw_response(response) ⇒ Object
Instance Attribute Details
#chaxue ⇒ Object
Returns the value of attribute chaxue.
4 5 6 |
# File 'lib/eloan/helper/service.rb', line 4 def chaxue @chaxue end |
Instance Method Details
#generate_request_url(url = '') ⇒ Object
5 6 7 |
# File 'lib/eloan/helper/service.rb', line 5 def generate_request_url(url='') [default_url, url] * '' end |
#handle_params(options = {}) ⇒ Object
9 10 11 |
# File 'lib/eloan/helper/service.rb', line 9 def handle_params(={}) ActiveSupport::HashWithIndifferentAccess.new() end |
#raw_response(response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eloan/helper/service.rb', line 13 def raw_response(response) return {status: :fail, code: 502, message: '请求失败,请稍后重试'} unless response.code.to_i == 200 response = JSON.parse response.body response_code = response['response_code'] if response_code.last(2).to_s == '00' status, code, = 'success', 200, 'success' else if request_params(response_code.first(3))[:notify] && response_code.last(2).to_s == '01' status, code, = 'success', 201, '处理中' else = response['bind_error_message'].present? ? response['bind_error_message'] : response['response_message'] status, code = 'fail', 202 end end response = {status: status, code: code, message: , data: response} unless configurate.production? = instance_variable_get(:@eloan_message) response = response.merge(eloan_message: ) end end |