Class: ApiErrorsController

Inherits:
ApplicationController show all
Defined in:
lib/nexmo_developer/app/controllers/api_errors_controller.rb

Constant Summary

Constants included from ApplicationHelper

ApplicationHelper::CONFIG

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin!, #not_found, #redirect_vonage_domain

Methods included from ApplicationHelper

#active_sidenav_item, #canonical_base, #canonical_base_from_config, #canonical_path, #canonical_url, #dashboard_cookie, #search_enabled?, #set_utm_cookie, #theme

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/nexmo_developer/app/controllers/api_errors_controller.rb', line 5

def index
  @errors_title = 'Generic Errors'
  @errors = generic_errors
  @scoped_errors = @error_config['products'].map do |key, config|
    {
      key: key,
      config: config,
      errors: scoped_errors(key),
    }
  end
end

#index_scopedObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/nexmo_developer/app/controllers/api_errors_controller.rb', line 17

def index_scoped
  oas = params[:definition]
  # At some point, the subaccounts OAS docs should move in to the account OAS docs
  oas = params[:subapi] if params[:subapi] == 'subaccounts'

  @errors_title = @error_config['products'][oas]['title']
  @hide_rfc7807_header = @error_config['products'][oas]['hide_rfc7807_header']
  @errors = scoped_errors(oas)
  render 'index'
end

#showObject



28
29
30
31
32
33
34
# File 'lib/nexmo_developer/app/controllers/api_errors_controller.rb', line 28

def show
  if params[:definition]
    @error = scoped_error(params[:definition], params[:id])
  else
    @error = ApiError.new(@error_config['generic_errors'][params[:id]])
  end
end