aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/compliance_check.rb
blob: f0a78839fe12847dd6e6fb1efa2d14c7a7f63208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class ComplianceCheck
  include JobConcern

  def report
    Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do
      report_path = links["action_report"]
      if report_path      
        response = Ievkit.get(report_path)
        ComplianceCheckReport.new(response)
      else
        nil
      end
    end
  end
  
  def compliance_check_validation_report
    Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
      report_path = links["validation_report"]
      if report_path      
        response = Ievkit.get(report_path)
        ComplianceCheckResult.new(response)
      else
        nil
      end
    end
  end

  def rule_parameter_set
    Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do
      rule_parameter_set = links["validation_params"]
      if rule_parameter_set
        response = Ievkit.get(rule_parameter_set)
        rule_parameter_set = RuleParameterSet.new.tap { |rps| rps.parameters = response.validation }
      else
        nil
      end
    end
  end

  def destroy
    delete_path =  links["delete"]
    cancel_path = links["cancel"]
    
    if delete_path
      Ievkit.delete(delete_path)
    elsif cancel_path
      Ievkit.delete(cancel_path)
    else
      nil
    end
  end

  def format
    datas.type
  end

end