Class: EgovUtils::RegistrationRequests::HandleRequest

Inherits:
ActiveInteraction::Base
  • Object
show all
Defined in:
app/services/egov_utils/registration_requests/handle_request.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/egov_utils/registration_requests/handle_request.rb', line 15

def execute
  registration_request.update(
    status: status,
    reason: reason,
    internal_reason: internal_reason
  )

  case status
  when 'accepted'
    user = create_user!
    EgovUtils::RegistrationRequestMailer
      .accepted(registration_request.id, user.id, password)
      .deliver_now
  when 'rejected'
    EgovUtils::RegistrationRequestMailer
      .rejected(registration_request.id)
      .deliver_now
  end

  registration_request
end