Class: ApiProviderFactory
Defined Under Namespace
Classes: UndefinedFactoryTypeError
Constant Summary
collapse
- API_PROVIDER =
{
evss: :evss,
lighthouse: :lighthouse
}.freeze
- FACTORIES =
{
rated_disabilities: :rated_disabilities,
intent_to_file: :intent_to_file,
ppiu: :ppiu,
claims: :claims,
brd: :brd,
generate_pdf: :generate_pdf,
supplemental_document_upload: :supplemental_document_upload
}.freeze
- FEATURE_TOGGLE_RATED_DISABILITIES_FOREGROUND =
Splitting the rated disabilities functionality into two use cases:
-
foreground tasks (i.e. web requests)
-
the background jobs (i.e. submit526 job)
'disability_compensation_lighthouse_rated_disabilities_provider_foreground'
- FEATURE_TOGGLE_RATED_DISABILITIES_BACKGROUND =
'disability_compensation_lighthouse_rated_disabilities_provider_background'
- FEATURE_TOGGLE_INTENT_TO_FILE =
'disability_compensation_lighthouse_intent_to_file_provider'
- FEATURE_TOGGLE_CLAIMS_SERVICE =
'disability_compensation_lighthouse_claims_service_provider'
- FEATURE_TOGGLE_PPIU_DIRECT_DEPOSIT =
PPIU calls out to Direct Deposit APIs in Lighthouse
'disability_compensation_lighthouse_ppiu_direct_deposit_provider'
- FEATURE_TOGGLE_BRD =
'disability_compensation_lighthouse_brd'
- FEATURE_TOGGLE_GENERATE_PDF =
'disability_compensation_lighthouse_generate_pdf'
- FEATURE_TOGGLE_UPLOAD_BDD_INSTRUCTIONS =
'disability_compensation_upload_bdd_instructions_to_lighthouse'
- FEATURE_TOGGLE_UPLOAD_0781 =
'disability_compensation_upload_0781_to_lighthouse'
- FEATURE_TOGGLE_SUBMIT_VETERAN_UPLOADS =
'disability_compensation_upload_veteran_evidence_to_lighthouse'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
wrap_with_logging
Constructor Details
#initialize(type:, current_user:, feature_toggle:, provider: nil, options: {}) ⇒ ApiProviderFactory
Returns a new instance of ApiProviderFactory.
86
87
88
89
90
91
92
93
94
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 86
def initialize(type:, current_user:, feature_toggle:, provider: nil, options: {})
@type = type
@api_provider = provider
@options = options
@current_user = current_user
@feature_toggle = feature_toggle
end
|
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
63
64
65
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 63
def type
@type
end
|
Class Method Details
.call ⇒ Object
82
83
84
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 82
def self.call(**)
new(**).call
end
|
Instance Method Details
#api_provider ⇒ Object
209
210
211
212
213
214
215
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 209
def api_provider
@api_provider ||= if Flipper.enabled?(@feature_toggle, @current_user)
API_PROVIDER[:lighthouse]
else
API_PROVIDER[:evss]
end
end
|
#brd_service_provider ⇒ Object
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 163
def brd_service_provider
case api_provider
when API_PROVIDER[:evss]
EvssBRDProvider.new(@current_user)
when API_PROVIDER[:lighthouse]
LighthouseBRDProvider.new(@current_user)
else
raise NotImplementedError, 'No known BRD Api Provider type provided'
end
end
|
#call ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 96
def call
case @type
when FACTORIES[:rated_disabilities]
rated_disabilities_service_provider
when FACTORIES[:intent_to_file]
intent_to_file_service_provider
when FACTORIES[:ppiu]
ppiu_service_provider
when FACTORIES[:claims]
claims_service_provider
when FACTORIES[:brd]
brd_service_provider
when FACTORIES[:generate_pdf]
generate_pdf_service_provider
when FACTORIES[:supplemental_document_upload]
supplemental_document_upload_service_provider
else
raise UndefinedFactoryTypeError
end
end
|
#claims_service_provider ⇒ Object
#generate_pdf_service_provider ⇒ Object
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 174
def generate_pdf_service_provider
case api_provider
when API_PROVIDER[:evss]
if @options[:auth_headers].nil? || @options[:auth_headers]&.empty?
raise StandardError, 'options[:auth_headers] is required to create a generate an EVSS pdf provider'
end
EvssGeneratePdfProvider.new(@options[:auth_headers], breakered: @options[:breakered])
when API_PROVIDER[:lighthouse]
LighthouseGeneratePdfProvider.new(@current_user[:icn])
else
raise NotImplementedError, 'No known Generate Pdf Api Provider type provided'
end
end
|
#intent_to_file_service_provider ⇒ Object
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 130
def intent_to_file_service_provider
case api_provider
when API_PROVIDER[:evss]
EvssIntentToFileProvider.new(@current_user, nil)
when API_PROVIDER[:lighthouse]
LighthouseIntentToFileProvider.new(@current_user)
else
raise NotImplementedError, 'No known Intent to File Api Provider type provided'
end
end
|
#ppiu_service_provider ⇒ Object
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 141
def ppiu_service_provider
case api_provider
when API_PROVIDER[:evss]
EvssPPIUProvider.new(@current_user)
when API_PROVIDER[:lighthouse]
LighthousePPIUProvider.new(@current_user)
else
raise NotImplementedError, 'No known PPIU Api Provider type provided'
end
end
|
#rated_disabilities_service_provider ⇒ Object
#supplemental_document_upload_service_provider ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/disability_compensation/factories/api_provider_factory.rb', line 191
def supplemental_document_upload_service_provider
provider_options = [
@options[:form526_submission],
@options[:document_type],
@options[:statsd_metric_prefix],
@options[:supporting_evidence_attachment]
]
case api_provider
when API_PROVIDER[:evss]
EVSSSupplementalDocumentUploadProvider.new(*provider_options)
when API_PROVIDER[:lighthouse]
LighthouseSupplementalDocumentUploadProvider.new(*provider_options)
else
raise NotImplementedError, 'No known Supplemental Document Upload Api Provider type provided'
end
end
|