-
Notifications
You must be signed in to change notification settings - Fork 19
/
legacy_appeal_representative.rb
61 lines (50 loc) · 1.6 KB
/
legacy_appeal_representative.rb
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
58
59
60
61
# frozen_string_literal: true
class LegacyAppealRepresentative
def initialize(power_of_attorney:, case_record:)
@power_of_attorney = power_of_attorney
@case_record = case_record
end
# This references VACOLS::Representative table
delegate :vacols_representatives, to: :case_record
# This references Caseflow organizations table
def representatives
Representative.where(participant_id: [representative_participant_id] - [nil])
end
def representative_participant_id
power_of_attorney.bgs_participant_id
end
REPRESENTATIVE_METHOD_NAMES = [
:representative_name,
:representative_type,
:representative_address
].freeze
REPRESENTATIVE_METHOD_NAMES.each do |method_name|
define_method(method_name) do
if use_representative_info_from_bgs?
power_of_attorney.public_send("bgs_#{method_name}".to_sym)
else
power_of_attorney.public_send("vacols_#{method_name}".to_sym)
end
end
end
def representative_to_hash
{
name: representative_name,
type: representative_type,
code: vacols_representative_code,
participant_id: representative_participant_id,
address: representative_address
}
end
private
attr_reader :power_of_attorney, :case_record
def use_representative_info_from_bgs?
RequestStore.store[:application] == "queue" ||
RequestStore.store[:application] == "hearings" ||
RequestStore.store[:application] == "hearing_schedule_job" ||
RequestStore.store[:application] == "idt"
end
def vacols_representative_code
power_of_attorney.vacols_representative_code
end
end