Class: Avo::DebugController

Inherits:
ApplicationController show all
Defined in:
app/controllers/avo/debug_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#exception_logger, #hello, #turbo_frame_request?

Methods included from Concerns::Breadcrumbs

#add_breadcrumb, #avo_breadcrumbs

Methods included from UrlHelpers

#edit_resource_path, #new_resource_path, #preview_resource_path, #related_resources_path, #resource_attach_path, #resource_detach_path, #resource_path, #resource_view_path, #resources_path

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table

Methods included from InitializesAvo

#_current_user, #context, #init_app

Instance Method Details

#refresh_licenseObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/avo/debug_controller.rb', line 23

def refresh_license
  license = Licensing::LicenseManager.refresh_license request

  if license.valid?
    flash[:notice] = "avohq.io responded: \"#{license.id.humanize} license is valid\"."
  elsif license.response["reason"].present?
    flash[:error] = "avohq.io responded: \"#{license.response["reason"]}\"."
  else
    flash[:error] = license.response["error"]
  end

  redirect_back fallback_location: avo.avo_private_status_path
end

#reportObject



20
21
# File 'app/controllers/avo/debug_controller.rb', line 20

def report
end

#send_to_hqObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/avo/debug_controller.rb', line 8

def send_to_hq
  url = "#{ENV["HQ_URL"]}/api/v3/debug_requests"
  timeout = 10 # seconds
  license_key = Avo::Services::DebugService.debug_report(request)[:hq_payload][:license_key]
  body = params[:body]
  body = {license_key: license_key, body: body, payload: Avo::Services::DebugService.debug_report(request).to_json}.to_json

  HTTParty.post url, body: body, headers: {"Content-Type": "application/json"}, timeout: timeout

  render turbo_stream: turbo_stream.replace(:send_to_hq, plain: "Payload sent to Avo HQ.")
end

#statusObject



5
6
# File 'app/controllers/avo/debug_controller.rb', line 5

def status
end