Class: Kanaui::EngineController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Kanaui::EngineController
show all
- Defined in:
- app/controllers/kanaui/engine_controller.rb
Instance Method Summary
collapse
Instance Method Details
#as_string(e) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'app/controllers/kanaui/engine_controller.rb', line 34
def as_string(e)
if e.is_a?(KillBillClient::API::ResponseError)
"Error #{e.response.code}: #{as_string_from_response(e.response.body)}"
else
log_rescue_error(e)
e.message
end
end
|
#as_string_from_response(response) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/kanaui/engine_controller.rb', line 47
def as_string_from_response(response)
error_message = response
begin
error_message = JSON.parse response
rescue StandardError => _e
end
if error_message.respond_to?(:[]) && error_message['message'].present?
error_message = error_message['message']
end
error_message[0..1000]
end
|
#current_tenant_user ⇒ Object
11
12
13
14
15
16
|
# File 'app/controllers/kanaui/engine_controller.rb', line 11
def current_tenant_user
user = current_user if respond_to?(:current_user)
Kanaui.current_tenant_user.call(session, user)
end
|
#get_layout ⇒ Object
7
8
9
|
# File 'app/controllers/kanaui/engine_controller.rb', line 7
def get_layout
layout ||= Kanaui.config[:layout]
end
|
#log_rescue_error(error) ⇒ Object
43
44
45
|
# File 'app/controllers/kanaui/engine_controller.rb', line 43
def log_rescue_error(error)
Rails.logger.warn "#{error.class} #{error}. #{error.backtrace.join("\n")}"
end
|
#options_for_klient ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/kanaui/engine_controller.rb', line 18
def options_for_klient
user = current_tenant_user
{
username: user[:username],
password: user[:password],
session_id: user[:session_id],
api_key: user[:api_key],
api_secret: user[:api_secret]
}
end
|