12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/sidekiq/evss/dependents_application_job.rb', line 12
def perform(app_id, encrypted_form, user_uuid)
@app_id = app_id
form = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_form))
user = User.find(user_uuid)
service = Dependents::Service.new(user)
cached_info = Dependents::RetrievedInfo.for_user(user)
merged_form = DependentsApplication.transform_form(form, cached_info.body)
merged_form = service.clean_form(merged_form)
service.validate(merged_form).tap do |res|
return dependents_application.update!(state: 'failed', response: res.to_json) if res['errors'].present?
end
form_id = service.save(merged_form)['formId']
res = service.submit(merged_form, form_id)
cached_info.delete
dependents_application.update!(state: 'success', response: res.to_json)
rescue
dependents_application.update!(state: 'failed')
raise
end
|