Class: Dingtalk::EcoResultHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/dingtalk/handler/eco_result_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(m, response = {}) ⇒ EcoResultHandler

Returns a new instance of EcoResultHandler.



5
6
7
8
9
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 5

def initialize(m, response={})
  @response_name = "#{m.gsub(/\./, '_')}_response"
  @response = package_result(response)
  @result = @response[@response_name]
end

Instance Attribute Details

#cn_msgObject

Returns the value of attribute cn_msg.



3
4
5
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 3

def cn_msg
  @cn_msg
end

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 3

def code
  @code
end

#en_msgObject

Returns the value of attribute en_msg.



3
4
5
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 3

def en_msg
  @en_msg
end

#response_nameObject

Returns the value of attribute response_name.



3
4
5
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 3

def response_name
  @response_name
end

#resultObject

Returns the value of attribute result.



3
4
5
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 3

def result
  @result
end

Instance Method Details

#full_error_messageObject Also known as: full_error_messages



41
42
43
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 41

def full_error_message
  full_message if !is_ok?
end

#full_messageObject Also known as: full_messages



32
33
34
35
36
37
38
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 32

def full_message
  if is_ok?
    "SUCCESS, Please use #result to get result."
  else
    "#{code}: #{en_msg}(#{sub_code}:#{cn_msg})."
  end
end

#is_ok?Boolean Also known as: ok?

Returns:

  • (Boolean)


11
12
13
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 11

def is_ok?
  @response[:error_response].nil?
end

#sub_codeObject



28
29
30
# File 'lib/dingtalk/handler/eco_result_handler.rb', line 28

def sub_code
  @response[:error_response][:sub_code]
end