Class: Services::SltcRegistrationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/services/sltc_registrations_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::MAX_LIST_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#jwtObject (readonly)

Returns the value of attribute jwt.



6
7
8
# File 'app/controllers/services/sltc_registrations_controller.rb', line 6

def jwt
  @jwt
end

#registrationObject (readonly)

Returns the value of attribute registration.



4
5
6
# File 'app/controllers/services/sltc_registrations_controller.rb', line 4

def registration
  @registration
end

#valid_registration_requestObject (readonly)

Returns the value of attribute valid_registration_request.



5
6
7
# File 'app/controllers/services/sltc_registrations_controller.rb', line 5

def valid_registration_request
  @valid_registration_request
end

Instance Method Details

#completeObject



18
19
20
21
# File 'app/controllers/services/sltc_registrations_controller.rb', line 18

def complete
  CompleteSltcRegistrationProcessContext.call(registration, completion_params)
  render json: { id: registration.id }
end

#createObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/services/sltc_registrations_controller.rb', line 23

def create
  # We currently deal only with type 1
  if valid_registration_request[:type] != 1
    ServicesMailer.notify_sltc_client_registration_invalid_request_type(valid_registration_request[:type], jwt).deliver
    render(nothing: true, status:500) && return
  end

  result = CreateSltcRegistrationContext.call(safe_params(valid_registration_request))
  if result.errors.empty?
    render nothing: true, status: 200
  else
    ServicesMailer.notify_sltc_client_registration_validation_errors(result, jwt).deliver
    render nothing: true, status: 500
  end
end

#indexObject



14
15
16
# File 'app/controllers/services/sltc_registrations_controller.rb', line 14

def index
  @registrations = params[:status].present? ? SltcRegistration.where(status: params[:status]).order("created_at DESC").limit(MAX_LIST_LENGTH) : SltcRegistration.order("created_at DESC").limit(MAX_LIST_LENGTH)
end