Class: BGS::Service
Constant Summary
collapse
- STATSD_KEY_PREFIX =
'api.bgs'
- JOURNAL_STATUS_TYPE_CODE =
Journal Status Type Code The alphabetic character representing the last action taken on the record (I = Input, U = Update, D = Delete)
'U'
- EMPTY_ROUTING_NUMBER =
It appears that a find_ch33_dd_eft that returns empty bank account information will set the routing number field to ‘0’ instead of ‘nil’, at least in certain cases
'0'
Exceptions::BGSErrors::MAX_ATTEMPTS
Instance Method Summary
collapse
-
#bgs_auth ⇒ Object
-
#create_address(address_params) ⇒ Object
-
#create_child_school(child_school_params) ⇒ Object
-
#create_child_student(child_student_params) ⇒ Object
-
#create_note(claim_id, note_text) ⇒ Object
-
#create_participant(proc_id, corp_ptcpnt_id = nil) ⇒ Object
-
#create_person(person_params) ⇒ Object
-
#create_phone(proc_id, participant_id, payload) ⇒ Object
-
#create_proc(proc_state: 'Started') ⇒ Object
-
#create_proc_form(vnp_proc_id, form_type_code) ⇒ Object
-
#create_relationship(relationship_params) ⇒ Object
-
#find_bank_name_by_routng_trnsit_nbr(routing_number) ⇒ Object
-
#find_benefit_claim_type_increment(claim_type_cd) ⇒ Object
-
#find_ch33_dd_eft ⇒ Object
-
#find_rating_data ⇒ Object
-
#find_regional_offices ⇒ Object
-
#get_ch33_dd_eft_info ⇒ Object
-
#get_regional_office_by_zip_code(zip_code, country, province, lob, ssn) ⇒ Object
-
#initialize(user) ⇒ Service
constructor
A new instance of Service.
-
#insert_benefit_claim(benefit_claim_params) ⇒ Object
-
#update_ch33_dd_eft(routing_number, acct_number, checking_acct) ⇒ Object
-
#update_manual_proc(proc_id) ⇒ Object
-
#update_proc(proc_id, proc_state: 'Ready') ⇒ Object
-
#user_ssn ⇒ Object
-
#vnp_benefit_claim_update(vnp_benefit_params) ⇒ Object
-
#vnp_create_benefit_claim(vnp_benefit_params) ⇒ Object
#with_monitoring
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
#notify_of_service_exception, #raise_backend_exception, #with_multiple_attempts_enabled
Constructor Details
#initialize(user) ⇒ Service
Returns a new instance of Service.
23
24
25
|
# File 'lib/bgs/service.rb', line 23
def initialize(user)
@user = user
end
|
Instance Method Details
#bgs_auth ⇒ Object
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/bgs/service.rb', line 170
def bgs_auth
auth_params = {
jrn_dt: Time.current.iso8601,
jrn_lctn_id: Settings.bgs.client_station_id,
jrn_status_type_cd: 'U',
jrn_user_id: Settings.bgs.client_username,
jrn_obj_id: Settings.bgs.application
}
auth_params.merge!(user_ssn) if Settings.bgs.mock_response == true
auth_params
end
|
#create_address(address_params) ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/bgs/service.rb', line 93
def create_address(address_params)
with_multiple_attempts_enabled do
service.vnp_ptcpnt_addrs.vnp_ptcpnt_addrs_create(
address_params.merge(bgs_auth)
)
end
end
|
#create_child_school(child_school_params) ⇒ Object
115
116
117
118
119
|
# File 'lib/bgs/service.rb', line 115
def create_child_school(child_school_params)
with_multiple_attempts_enabled do
service.vnp_child_school.child_school_create(child_school_params.merge(bgs_auth))
end
end
|
#create_child_student(child_student_params) ⇒ Object
121
122
123
124
125
|
# File 'lib/bgs/service.rb', line 121
def create_child_student(child_student_params)
with_multiple_attempts_enabled do
service.vnp_child_student.child_student_create(child_student_params.merge(bgs_auth))
end
end
|
#create_note(claim_id, note_text) ⇒ Object
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/bgs/service.rb', line 259
def create_note(claim_id, note_text)
option_hash = {
jrn_stt_tc: 'I',
name: 'Claim rejected by VA.gov',
bnft_clm_note_tc: 'CLMDVLNOTE',
clm_id: claim_id,
ptcpnt_id: @user.participant_id,
txt: note_text
}.merge!(bgs_auth).except!(:jrn_status_type_cd)
response = service.notes.create_note(option_hash)
message = if response[:note]
response[:note].slice(:clm_id, :txt)
else
response
end
log_message_to_sentry(message, :info, {}, { team: 'vfs-ebenefits' })
response
rescue => e
notify_of_service_exception(e, __method__, 1, :warn)
end
|
#create_participant(proc_id, corp_ptcpnt_id = nil) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/bgs/service.rb', line 74
def create_participant(proc_id, corp_ptcpnt_id = nil)
with_multiple_attempts_enabled do
service.vnp_ptcpnt.vnp_ptcpnt_create(
{
vnp_proc_id: proc_id,
ptcpnt_type_nm: 'Person',
corp_ptcpnt_id:,
ssn: @user.ssn
}.merge(bgs_auth)
)
end
end
|
#create_person(person_params) ⇒ Object
87
88
89
90
91
|
# File 'lib/bgs/service.rb', line 87
def create_person(person_params)
with_multiple_attempts_enabled do
service.vnp_person.vnp_person_create(person_params.merge(bgs_auth))
end
end
|
#create_phone(proc_id, participant_id, payload) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/bgs/service.rb', line 101
def create_phone(proc_id, participant_id, payload)
with_multiple_attempts_enabled do
service.vnp_ptcpnt_phone.vnp_ptcpnt_phone_create(
{
vnp_proc_id: proc_id,
vnp_ptcpnt_id: participant_id,
phone_type_nm: 'Daytime',
phone_nbr: payload['phone_number'],
efctv_dt: Time.current.iso8601
}.merge(bgs_auth)
)
end
end
|
#create_proc(proc_state: 'Started') ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/bgs/service.rb', line 27
def create_proc(proc_state: 'Started')
with_multiple_attempts_enabled do
service.vnp_proc_v2.vnp_proc_create(
{
vnp_proc_type_cd: 'DEPCHG',
vnp_proc_state_type_cd: proc_state,
creatd_dt: Time.current.iso8601,
last_modifd_dt: Time.current.iso8601,
submtd_dt: Time.current.iso8601
}.merge(bgs_auth)
)
end
end
|
49
50
51
52
53
54
55
56
57
|
# File 'lib/bgs/service.rb', line 49
def create_proc_form(vnp_proc_id, form_type_code)
log_message_to_sentry(vnp_proc_id, :warn, '', { team: 'vfs-ebenefits' })
with_multiple_attempts_enabled do
service.vnp_proc_form.vnp_proc_form_create(
{ vnp_proc_id:, form_type_cd: form_type_code }.merge(bgs_auth)
)
end
end
|
#create_relationship(relationship_params) ⇒ Object
127
128
129
130
131
|
# File 'lib/bgs/service.rb', line 127
def create_relationship(relationship_params)
with_multiple_attempts_enabled do
service.vnp_ptcpnt_rlnshp.vnp_ptcpnt_rlnshp_create(relationship_params.merge(bgs_auth))
end
end
|
#find_bank_name_by_routng_trnsit_nbr(routing_number) ⇒ Object
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/bgs/service.rb', line 206
def find_bank_name_by_routng_trnsit_nbr(routing_number)
return if routing_number.blank? || routing_number == EMPTY_ROUTING_NUMBER
with_monitoring do
res = StatsD.measure("#{self.class::STATSD_KEY_PREFIX}.find_bank_name_by_routng_trnsit_nbr.duration") do
service.ddeft.find_bank_name_by_routng_trnsit_nbr(routing_number)
end
res[:find_bank_name_by_routng_trnsit_nbr_response][:return][:bank_name]
end
end
|
#find_benefit_claim_type_increment(claim_type_cd) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/bgs/service.rb', line 133
def find_benefit_claim_type_increment(claim_type_cd)
increment_params = {
ptcpnt_id: @user.participant_id,
bnft_claim_type_cd: claim_type_cd,
pgm_type_cd: 'CPL'
}
increment_params.merge!(user_ssn) if Settings.bgs.mock_response == true
with_multiple_attempts_enabled do
service.share_data.find_benefit_claim_type_increment(**increment_params)
end
end
|
#find_ch33_dd_eft ⇒ Object
217
218
219
220
221
222
223
|
# File 'lib/bgs/service.rb', line 217
def find_ch33_dd_eft
with_monitoring do
StatsD.measure("#{self.class::STATSD_KEY_PREFIX}.find_ch33_dd_eft.duration") do
service.claims.send(:request, :find_ch33_dd_eft, fileNumber: @user.ssn)
end
end
end
|
#find_rating_data ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/bgs/service.rb', line 41
def find_rating_data
service.rating.find_rating_data(@user.ssn)
rescue BGS::ShareError => e
raise Common::Exceptions::RecordNotFound, @user.account_id if e.message =~ /No record found for/
raise e
end
|
#find_regional_offices ⇒ Object
253
254
255
256
257
|
# File 'lib/bgs/service.rb', line 253
def find_regional_offices
service.share_data.find_regional_offices[:return]
rescue => e
notify_of_service_exception(e, __method__, 1, :warn)
end
|
#get_ch33_dd_eft_info ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/bgs/service.rb', line 188
def get_ch33_dd_eft_info
find_ch33_dd_eft_res = find_ch33_dd_eft.body[:find_ch33_dd_eft_response][:return]
routing_number = find_ch33_dd_eft_res[:routng_trnsit_nbr]
find_ch33_dd_eft_res.slice(
:dposit_acnt_nbr,
:dposit_acnt_type_nm,
:routng_trnsit_nbr
).merge(
financial_institution_name: lambda do
BankName.get_bank_name(@user, routing_number)
rescue => e
log_exception_to_sentry(e, { routing_number: }, { error: 'ch33_dd' })
nil
end.call
)
end
|
#get_regional_office_by_zip_code(zip_code, country, province, lob, ssn) ⇒ Object
243
244
245
246
247
248
249
250
251
|
# File 'lib/bgs/service.rb', line 243
def get_regional_office_by_zip_code(zip_code, country, province, lob, ssn)
regional_office_response = service.routing.get_regional_office_by_zip_code(
zip_code, country, province, lob, ssn
)
regional_office_response[:regional_office][:number]
rescue => e
notify_of_service_exception(e, __method__, 1, :warn)
'347' end
|
#insert_benefit_claim(benefit_claim_params) ⇒ Object
166
167
168
|
# File 'lib/bgs/service.rb', line 166
def insert_benefit_claim(benefit_claim_params)
service.claims.insert_benefit_claim(benefit_claim_params)
end
|
#update_ch33_dd_eft(routing_number, acct_number, checking_acct) ⇒ Object
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
# File 'lib/bgs/service.rb', line 225
def update_ch33_dd_eft(routing_number, acct_number, checking_acct)
with_monitoring do
StatsD.measure("#{self.class::STATSD_KEY_PREFIX}.update_ch33_dd_eft.duration") do
service.claims.send(
:request,
:update_ch33_dd_eft,
ch33DdEftInput: {
dpositAcntNbr: acct_number,
dpositAcntTypeNm: checking_acct ? 'C' : 'S',
fileNumber: @user.ssn,
routngTrnsitNbr: routing_number,
tranCode: '2'
}
)
end
end
end
|
#update_manual_proc(proc_id) ⇒ Object
158
159
160
161
162
163
164
|
# File 'lib/bgs/service.rb', line 158
def update_manual_proc(proc_id)
service.vnp_proc_v2.vnp_proc_update(
{ vnp_proc_id: proc_id, vnp_proc_state_type_cd: 'MANUAL_VAGOV', vnp_proc_type_cd: 'DEPCHG' }.merge(bgs_auth)
)
rescue => e
notify_of_service_exception(e, __method__)
end
|
#update_proc(proc_id, proc_state: 'Ready') ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/bgs/service.rb', line 59
def update_proc(proc_id, proc_state: 'Ready')
with_multiple_attempts_enabled do
service.vnp_proc_v2.vnp_proc_update(
{
vnp_proc_id: proc_id,
vnp_proc_type_cd: 'DEPCHG',
vnp_proc_state_type_cd: proc_state,
creatd_dt: Time.current.iso8601,
last_modifd_dt: Time.current.iso8601,
submtd_dt: Time.current.iso8601
}.merge(bgs_auth)
)
end
end
|
#user_ssn ⇒ Object
184
185
186
|
# File 'lib/bgs/service.rb', line 184
def user_ssn
{ ssn: @user.ssn }
end
|
#vnp_benefit_claim_update(vnp_benefit_params) ⇒ Object
152
153
154
155
156
|
# File 'lib/bgs/service.rb', line 152
def vnp_benefit_claim_update(vnp_benefit_params)
with_multiple_attempts_enabled do
service.vnp_bnft_claim.vnp_bnft_claim_update(vnp_benefit_params.merge(bgs_auth))
end
end
|
#vnp_create_benefit_claim(vnp_benefit_params) ⇒ Object
146
147
148
149
150
|
# File 'lib/bgs/service.rb', line 146
def vnp_create_benefit_claim(vnp_benefit_params)
with_multiple_attempts_enabled do
service.vnp_bnft_claim.vnp_bnft_claim_create(vnp_benefit_params.merge(bgs_auth))
end
end
|