lib/lumberg/format_whm.rb in lumberg-2.0.0.pre20 vs lib/lumberg/format_whm.rb in lumberg-2.0.0
- old
+ new
@@ -37,28 +37,30 @@
def format_response(response)
success, message, params = false, nil, {}
case @type || response_type(response)
- when :action
- success, message, params = format_action_response(response)
- when :query
- success, message, params = format_query_response(response)
- when :ssl
- success, message, params = format_ssl_response(response)
- when :whostmgr
- success, message, params = format_whostmgr_response(response)
- when :error
- message = response['error']
- when :unknown
- message = "Unknown error occurred #{response.inspect}"
+ when :action
+ success, message, params = format_action_response(response)
+ when :query
+ success, message, params = format_query_response(response)
+ when :ssl
+ success, message, params = format_ssl_response(response)
+ when :whostmgr
+ success, message, params = format_whostmgr_response(response)
+ when :error
+ message = response['error']
+ when :xfer
+ success, message, params = format_xfer_response(response)
+ else
+ message = "Unknown error occurred #{response.inspect}"
end
params = Whm::symbolize_keys(params)
params = Whm::to_bool(params, @boolean_params)
- {success: success, message: message, params: params}
+ { success: success, message: message, params: params }
end
def response_type(response)
if !response.respond_to?(:has_key?)
:unknown
@@ -147,8 +149,14 @@
if res = response.match(/(?<message>#{message})/)
return true, res[:message], []
else
return false, "", []
end
+ end
+
+ def format_xfer_response(response)
+ metadata = response['metadata']
+
+ return metadata['result'].to_i == 1, metadata['reason'], response['data']
end
end
end