dvla-application_helper 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.drone.yml +481 -0
- data/.env.template +4 -0
- data/.rspec +3 -0
- data/.rubocop.yml +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +674 -0
- data/Rakefile +31 -0
- data/config/settings/drone-dev.yml +41 -0
- data/config/settings/drone-ext.yml +35 -0
- data/config/settings/drone-link.yml +35 -0
- data/config/settings/drone-perf.yml +35 -0
- data/config/settings/local-dev.yml +40 -0
- data/config/settings/local-ext.yml +35 -0
- data/config/settings/local-link.yml +35 -0
- data/config/settings/local-perf.yml +35 -0
- data/config/settings.yml +29 -0
- data/config/yarp.yml +6 -0
- data/functional-tests/Rakefile +74 -0
- data/functional-tests/chutney.yml +110 -0
- data/functional-tests/features/codl.feature +170 -0
- data/functional-tests/features/codl_image_review_states.feature +140 -0
- data/functional-tests/features/csudl.feature +54 -0
- data/functional-tests/features/csudl_image_review_states.feature +20 -0
- data/functional-tests/features/step_definitions/app_domain_steps.rb +213 -0
- data/functional-tests/features/step_definitions/application_creation_steps.rb +115 -0
- data/functional-tests/features/step_definitions/image_steps.rb +144 -0
- data/functional-tests/features/step_definitions/state_machine_steps.rb +43 -0
- data/functional-tests/features/support/data/artefacts.rb +27 -0
- data/functional-tests/features/support/data/image_helpers.rb +20 -0
- data/functional-tests/features/support/data/schema_helpers.rb +3 -0
- data/functional-tests/features/support/data/string_manipulation.rb +9 -0
- data/functional-tests/features/support/env.rb +25 -0
- data/functional-tests/features/support/hooks.rb +56 -0
- data/functional-tests/features/support/yarp_integration/yarp_helpers.rb +23 -0
- data/functional-tests/features/uodl_image_review_states.feature +244 -0
- data/functional-tests/features/uodl_non_processable.feature +441 -0
- data/functional-tests/features/uodl_processable.feature +416 -0
- data/lib/dvla/application_helper/builders/V1/application_builder.rb +298 -0
- data/lib/dvla/application_helper/builders/V1/codl_application_builder.rb +205 -0
- data/lib/dvla/application_helper/builders/V1/csudl_application_builder.rb +329 -0
- data/lib/dvla/application_helper/builders/V2/base_uodl_v2_application_builder.rb +357 -0
- data/lib/dvla/application_helper/builders/V2/cop_v2_application_builder.rb +59 -0
- data/lib/dvla/application_helper/builders/V2/dup_v2_application_builder.rb +84 -0
- data/lib/dvla/application_helper/builders/V2/exc_v2_application_builder.rb +55 -0
- data/lib/dvla/application_helper/builders/V2/rep_v2_application_builder.rb +84 -0
- data/lib/dvla/application_helper/builders/V2/tyr_v2_application_builder.rb +62 -0
- data/lib/dvla/application_helper/builders/V2/uodl_v2_application_builder.rb +278 -0
- data/lib/dvla/application_helper/builders/V3/base_uodl_v3_application_builder.rb +342 -0
- data/lib/dvla/application_helper/builders/V3/cop_v3_application_builder.rb +56 -0
- data/lib/dvla/application_helper/builders/V3/dup_v3_application_builder.rb +78 -0
- data/lib/dvla/application_helper/builders/V3/exc_v3_application_builder.rb +56 -0
- data/lib/dvla/application_helper/builders/V3/rep_v3_application_builder.rb +81 -0
- data/lib/dvla/application_helper/builders/V3/tyr_v3_application_builder.rb +59 -0
- data/lib/dvla/application_helper/builders/dup_rep_builder_mixin.rb +71 -0
- data/lib/dvla/application_helper/builders/photo_builder_mixin.rb +49 -0
- data/lib/dvla/application_helper/builders/photo_signature_builder_mixin.rb +68 -0
- data/lib/dvla/application_helper/configuration.rb +37 -0
- data/lib/dvla/application_helper/constants.rb +21 -0
- data/lib/dvla/application_helper/enums/review_state.rb +30 -0
- data/lib/dvla/application_helper/enums/unable_to_prove_licence_possession_reasons.rb +8 -0
- data/lib/dvla/application_helper/factories/address.rb +21 -0
- data/lib/dvla/application_helper/factories/application_details.rb +353 -0
- data/lib/dvla/application_helper/factories/casework.rb +7 -0
- data/lib/dvla/application_helper/factories/csudl_photo_signature_image.rb +156 -0
- data/lib/dvla/application_helper/factories/csudl_photo_signature_images.rb +85 -0
- data/lib/dvla/application_helper/factories/organ_donor.rb +32 -0
- data/lib/dvla/application_helper/factories/person.rb +73 -0
- data/lib/dvla/application_helper/factories/photo_image.rb +147 -0
- data/lib/dvla/application_helper/factories/photo_images.rb +183 -0
- data/lib/dvla/application_helper/factories/photo_signature_image.rb +158 -0
- data/lib/dvla/application_helper/factories/photo_signature_images.rb +64 -0
- data/lib/dvla/application_helper/fixtures/photo/comparison_image.jpeg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/passport_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/photocard_back.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/photocard_front.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/rejected_user_uploaded_image.jpeg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/csudl_signature_image.tiff +0 -0
- data/lib/dvla/application_helper/fixtures/signature/passport_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/rejected_user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/processors/application_status.rb +45 -0
- data/lib/dvla/application_helper/processors/application_task.rb +301 -0
- data/lib/dvla/application_helper/services/application_diary.rb +123 -0
- data/lib/dvla/application_helper/services/application_domain.rb +239 -0
- data/lib/dvla/application_helper/services/application_process_engine.rb +120 -0
- data/lib/dvla/application_helper/services/check_aws_credentials.rb +24 -0
- data/lib/dvla/application_helper/services/driving_licence_channel_api.rb +67 -0
- data/lib/dvla/application_helper/services/image_service.rb +116 -0
- data/lib/dvla/application_helper/services/image_utility.rb +82 -0
- data/lib/dvla/application_helper/services/state_machine_helpers.rb +146 -0
- data/lib/dvla/application_helper/version.rb +5 -0
- data/lib/dvla/application_helper.rb +92 -0
- data/renovate.json +4 -0
- data/scripts/application-login.sh +56 -0
- data/scripts/drone-aws-login.sh +18 -0
- data/scripts/seed_application.rb +268 -0
- data/sonar-project.properties +4 -0
- metadata +343 -0
@@ -0,0 +1,342 @@
|
|
1
|
+
module DVLA
|
2
|
+
module Application
|
3
|
+
class BaseUODLV3ApplicationBuilder
|
4
|
+
def initialize
|
5
|
+
@applicant = nil
|
6
|
+
@application_id = SecureRandom::uuid
|
7
|
+
@application_status = 'Preparing'
|
8
|
+
@bfpo_address = false
|
9
|
+
@change_of_address = false
|
10
|
+
@customer_id = nil
|
11
|
+
@driver_id = nil
|
12
|
+
@extend_application_deadline = false
|
13
|
+
@free_key_address = false
|
14
|
+
@identity_confidence_level = 'MEDIUM'
|
15
|
+
@organ_donor = nil
|
16
|
+
@payments = nil
|
17
|
+
@product_type = 'Driving Licence'
|
18
|
+
@processable = false
|
19
|
+
@phone_number = false
|
20
|
+
@transaction_outcome = nil
|
21
|
+
@unique_images = false
|
22
|
+
@update_reason = nil
|
23
|
+
@welsh_language = false
|
24
|
+
end
|
25
|
+
|
26
|
+
# Marks the application as processable, doing this will ensure that real services are used to create the
|
27
|
+
# application. For example, the channel api will process the tasks rather than stub data being provided.
|
28
|
+
# Whilst this results in a more complete application, this option is more expensive.
|
29
|
+
# Avoid excessive use in QA tests.
|
30
|
+
# @return [Builder]
|
31
|
+
def processable
|
32
|
+
@processable = true
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# Marks the application as non-processable. This will result in the application being created using the test application endpoint.
|
37
|
+
# These applications cannot be actioned via the task service.
|
38
|
+
# This is typically the default option to be used.
|
39
|
+
# @return [Builder]
|
40
|
+
def non_processable
|
41
|
+
@processable = false
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
# APE uses very specific generated uuid to test with, the inspectable hooks filter the last 12 integers to return specific responses
|
46
|
+
# @param application_id [UUID]
|
47
|
+
def with_application_id(application_id)
|
48
|
+
@application_id = application_id
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
# The application will be made for the given customer
|
53
|
+
# @param customer_id [String] The customer ID to use
|
54
|
+
# @return [Builder]
|
55
|
+
def with_customer_id(customer_id)
|
56
|
+
@customer_id = customer_id
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
# The application will be made for the given driver
|
61
|
+
# @param driver_id [String] The driver ID to use
|
62
|
+
# @return [Builder]
|
63
|
+
def with_driver_id(driver_id)
|
64
|
+
@driver_id = driver_id
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
# The application will contain a specific application status.
|
69
|
+
# How this state is reached will depend on if the application has been marked as processable or not.
|
70
|
+
# If processable is used here, we will also contain all actions.
|
71
|
+
# @param application_status [String] The application status the application should be in.
|
72
|
+
# @param update_reason [String] The reason for the change in status.
|
73
|
+
# @return [Builder].
|
74
|
+
def with_application_status(application_status, update_reason = nil)
|
75
|
+
@application_status = application_status
|
76
|
+
@update_reason = update_reason
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
# The application will be updated with a call to action field which is used to extend an application
|
81
|
+
def extend_application_deadline
|
82
|
+
@extend_application_deadline = true
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
# The application will contain the provided payments.
|
87
|
+
# @param payments [PaymentObject] Payment status.
|
88
|
+
# @return [Builder]
|
89
|
+
def with_payments(payments)
|
90
|
+
@payments = payments
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
# The application will contain the provided applicant data.
|
95
|
+
# @param applicant [ApplicantObject] Application data.
|
96
|
+
# @return [Builder]
|
97
|
+
def with_applicant(applicant)
|
98
|
+
@applicant = applicant
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# The application will contain a bfpo address.
|
103
|
+
# @return [Builder]
|
104
|
+
def with_bfpo_address
|
105
|
+
@bfpo_address = true
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
109
|
+
# The application will contain a free key address.
|
110
|
+
# @return [Builder]
|
111
|
+
def with_free_key_address
|
112
|
+
@free_key_address = true
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
# The application will contain a change of address.
|
117
|
+
# @return [Builder]
|
118
|
+
def with_change_of_address
|
119
|
+
@change_of_address = true
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
# Sets the organ donor status of the application.
|
124
|
+
# By default, no organ donation is made
|
125
|
+
# Passing true will cause all_organs to be selected.
|
126
|
+
# Passing false will ensure no organs are selected.
|
127
|
+
# @param donor [boolean] Organ donor status.
|
128
|
+
# @return [Builder]
|
129
|
+
def is_organ_donor(donor)
|
130
|
+
@organ_donor = donor
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
def is_welsh_language
|
135
|
+
@welsh_language = true
|
136
|
+
self
|
137
|
+
end
|
138
|
+
|
139
|
+
# The application will contain a phone number.
|
140
|
+
# @return [Builder]
|
141
|
+
def has_phone_number
|
142
|
+
@phone_number = true
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
def with_low_confidence_level
|
147
|
+
@identity_confidence_level = 'LOW'
|
148
|
+
self
|
149
|
+
end
|
150
|
+
|
151
|
+
# Allows specific product type to be passed in
|
152
|
+
# Used during APE testing for inspectable hooks
|
153
|
+
# @param product [Enum] one of: [Vehicles,Driving Licence,Test]
|
154
|
+
# @return [Builder]
|
155
|
+
def with_product_type(product)
|
156
|
+
if !Settings.test.product_type.include?(product)
|
157
|
+
raise "Unknown Product_type: #{product}, must be one of: #{Settings.test.product_type}"
|
158
|
+
end
|
159
|
+
@product_type = product
|
160
|
+
self
|
161
|
+
end
|
162
|
+
|
163
|
+
# The application will contain unique imageIds
|
164
|
+
# Allows images to be interacted with during test, e.g. deleted
|
165
|
+
def unique_images
|
166
|
+
@unique_images = true
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
170
|
+
def with_transaction_outcome(outcome)
|
171
|
+
@transaction_outcome = outcome
|
172
|
+
self
|
173
|
+
end
|
174
|
+
|
175
|
+
def build
|
176
|
+
# Sense check to ensure AWS credentials are present.
|
177
|
+
DVLA::Application.check_aws_credentials
|
178
|
+
|
179
|
+
check_application_validity
|
180
|
+
|
181
|
+
factory = if @processable
|
182
|
+
FM[:uodl_v3_processable_application]
|
183
|
+
else
|
184
|
+
non_processable_application_factory
|
185
|
+
end
|
186
|
+
|
187
|
+
# pass in uodl_v3 FM factory to build data attribute
|
188
|
+
app = factory.build(attributes: { data: FM[:uodl_v3_application_data].build }) do |b|
|
189
|
+
@driver_id = default_application_driver_id if @driver_id.nil?
|
190
|
+
update_driver_id!(b)
|
191
|
+
|
192
|
+
update_main_properties!(b)
|
193
|
+
|
194
|
+
b.data.customer_context = application_customer_context
|
195
|
+
update_customer_context!(b)
|
196
|
+
|
197
|
+
update_applicant!(b)
|
198
|
+
|
199
|
+
update_address!(b)
|
200
|
+
|
201
|
+
update_organ_donor!(b)
|
202
|
+
|
203
|
+
update_payments!(b)
|
204
|
+
|
205
|
+
update_no_fee!(b) unless @no_fee_application.nil?
|
206
|
+
|
207
|
+
b.images = application_images
|
208
|
+
|
209
|
+
calculate_default_update_reason
|
210
|
+
|
211
|
+
set_application_specific_fields!(b)
|
212
|
+
end
|
213
|
+
|
214
|
+
process_application_tasks(app)
|
215
|
+
process_application(app)
|
216
|
+
|
217
|
+
extend_deadline(app) if @extend_application_deadline
|
218
|
+
|
219
|
+
DVLA::Application::ApplicationDomain.retrieve_application_by_app_id(application_id: app.application_id)
|
220
|
+
end
|
221
|
+
|
222
|
+
# -- Overridable methods used by sub-types --
|
223
|
+
|
224
|
+
def check_application_validity
|
225
|
+
# Allows a sub-type to optionally run checks on the flags of the application before building any resourcses
|
226
|
+
end
|
227
|
+
|
228
|
+
def non_processable_application_factory
|
229
|
+
raise 'The specific application type builder should override this method and return the factory specific to the application type'
|
230
|
+
end
|
231
|
+
|
232
|
+
def default_application_driver_id
|
233
|
+
raise 'The specific application type builder should override this method and return the driver id specific for the application type, this usually is hardcoded in channel-api-stub'
|
234
|
+
end
|
235
|
+
|
236
|
+
def application_images
|
237
|
+
raise 'The specific application type builder should override this method and return the images needed for the specific application type'
|
238
|
+
end
|
239
|
+
|
240
|
+
def application_customer_context
|
241
|
+
raise 'The specific application type builder should override this method and return the customer context of the specific application type'
|
242
|
+
end
|
243
|
+
|
244
|
+
def set_application_specific_fields!(app)
|
245
|
+
# Allows a sub-type to populate or override specific fields of an application
|
246
|
+
end
|
247
|
+
|
248
|
+
def process_application_tasks(app)
|
249
|
+
# Allows a sub-type to advance any tasks specific of the application type
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
# -- Methods allowing specific actions that occur during the application build process --
|
254
|
+
def update_main_properties!(app)
|
255
|
+
app.application_id = @application_id
|
256
|
+
app.customer_id = @customer_id if @customer_id
|
257
|
+
unless @processable
|
258
|
+
app.data_schema = Settings.application.v3_schema
|
259
|
+
app.product_type = @product_type
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def update_driver_id!(app)
|
264
|
+
if @processable && @driver_id
|
265
|
+
app.driver_id = @driver_id
|
266
|
+
elsif @driver_id
|
267
|
+
app.product_id = @driver_id
|
268
|
+
app.product_key = @driver_id
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def update_customer_context!(app)
|
273
|
+
if !@processable && !@transaction_outcome.nil?
|
274
|
+
app.data.customer_context[:transactionOutcome] = @transaction_outcome
|
275
|
+
app.data.customer_context[:customerIntent] = @transaction_outcome
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def update_address!(app)
|
280
|
+
new_address = if @change_of_address || @free_key_address
|
281
|
+
{ unstructuredAddress: FM[:application_unstructured_address].build }
|
282
|
+
elsif @bfpo_address
|
283
|
+
{ bfpoAddress: FM[:bfpo_address].build }
|
284
|
+
end
|
285
|
+
unless new_address.nil?
|
286
|
+
# Dynamically add updateAddress field into object
|
287
|
+
app.data.instance_variable_set(:@updateAddress, { newAddress: new_address })
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
def update_applicant!(app)
|
292
|
+
app.data.applicant = @applicant if @applicant
|
293
|
+
app.data.applicant[:phoneNumber] = Faker::PhoneNumber.phone_number if @phone_number
|
294
|
+
app.data.applicant[:languagePreference] = 'Welsh' if @welsh_language
|
295
|
+
app.data.applicant[:identityTokenData][:confidenceLevel] = @identity_confidence_level
|
296
|
+
end
|
297
|
+
|
298
|
+
def update_organ_donor!(app)
|
299
|
+
app.data.organ_donor = if @organ_donor
|
300
|
+
set_any_organs(any_organs_bool: @organ_donor)
|
301
|
+
elsif @application_status == 'Rejected'
|
302
|
+
FM[:organ_donor_d90_response].build(attributes: { kidneys: true })
|
303
|
+
elsif @application_status == 'Returned'
|
304
|
+
FM[:organ_donor_d90_response].build(attributes: { cornea: true })
|
305
|
+
elsif @application_status == 'Unapproved'
|
306
|
+
FM[:organ_donor_d90_response].build(attributes: { heart: true })
|
307
|
+
else
|
308
|
+
{}
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def update_payments!(app)
|
313
|
+
if !@processable && !@payments.nil?
|
314
|
+
app.payments = @payments
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def update_no_fee!(app)
|
319
|
+
app.no_fee_application = true if @no_fee_application
|
320
|
+
end
|
321
|
+
|
322
|
+
def calculate_default_update_reason
|
323
|
+
if !@processable && !@application_status.nil? && @application_status == 'Cancelled'
|
324
|
+
@update_reason = @update_reason || 'Timed out'
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def process_application(app)
|
329
|
+
if !@processable
|
330
|
+
DVLA::Application::ApplicationStatusProcessor.process_to(app.application_id, @application_status, update_reason: @update_reason)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
# updates call to action date on domain
|
335
|
+
def extend_deadline(app)
|
336
|
+
extend_date = Time.now + 21.days
|
337
|
+
DVLA::Application.logger.info("Updating application call to action deadline date to: #{extend_date}".blue)
|
338
|
+
DVLA::Application::ApplicationDomain.update_call_to_action_deadline_date(application_id: app.application_id, call_to_action_deadline_date: extend_date.utc.iso8601)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative('../photo_signature_builder_mixin.rb')
|
2
|
+
|
3
|
+
module DVLA
|
4
|
+
module Application
|
5
|
+
class COPV3ApplicationBuilder < BaseUODLV3ApplicationBuilder
|
6
|
+
# Including all properties and methods needed to support photos
|
7
|
+
include DVLA::Application::PhotoBuilderMixin
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
init_photo_properties
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some builder methods are automatically included from PhotoBuilderMixin
|
15
|
+
|
16
|
+
# -- Overridden methods --
|
17
|
+
private
|
18
|
+
|
19
|
+
# Defining the non-processable application factory that the BaseUODLV3ApplicationBuilder will use
|
20
|
+
def non_processable_application_factory
|
21
|
+
FM[:cop_application]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Defining the default driver_id, used to pass the validation in channel-api-stub
|
25
|
+
def default_application_driver_id
|
26
|
+
Settings.test.driver_id.optional_cop
|
27
|
+
end
|
28
|
+
|
29
|
+
# Defining the data to put in customer_context
|
30
|
+
def application_customer_context
|
31
|
+
{
|
32
|
+
customerIntent: 'Change of photo',
|
33
|
+
transactionOutcome: 'Change of photo',
|
34
|
+
applicationsEligibilityResponse: [{
|
35
|
+
applicationType: 'update-ordinary-licence',
|
36
|
+
isRequired: true,
|
37
|
+
availableActions: [
|
38
|
+
actionType: 'update-photo',
|
39
|
+
isRequired: true,
|
40
|
+
],
|
41
|
+
}],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creating the images that the BaseUODLV3ApplicationBuilder will include in the app
|
46
|
+
def application_images
|
47
|
+
generate_photo_images(@processable, @unique_images)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Advance and submits the tasks based on the photo review state specified
|
51
|
+
def process_application_tasks(app)
|
52
|
+
process_photo_tasks(app) if @processable
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative('../photo_signature_builder_mixin.rb')
|
2
|
+
require_relative('../dup_rep_builder_mixin.rb')
|
3
|
+
|
4
|
+
module DVLA
|
5
|
+
module Application
|
6
|
+
class DUPV3ApplicationBuilder < BaseUODLV3ApplicationBuilder
|
7
|
+
# Including all properties and methods needed to support photos and signatures in the case of a Paper DUP
|
8
|
+
include DVLA::Application::PhotoSignatureBuilderMixin
|
9
|
+
include DVLA::Application::DupRepBuilderMixin
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
dup_rep_init_properties
|
13
|
+
init_photo_signature_properties
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# -- Builder methods --
|
18
|
+
|
19
|
+
# Some builder methods are automatically included from PhotoSignatureBuilderMixin and DupRepBuilderMixin
|
20
|
+
|
21
|
+
# Acts as if the licence owner has a paper licence.
|
22
|
+
# The application will be eligible to be changed from a paper licence to a plastic one
|
23
|
+
# It will also upload a photo and a signature with the application, and enable the flags to control these images and their tasks
|
24
|
+
# Sets the driver id to the specific id required for channel api stub to recognise
|
25
|
+
# @return [DUPV3ApplicationBuilder]
|
26
|
+
def with_paper_to_plastic_driver_id
|
27
|
+
@eligibility_paper_to_plastic = true
|
28
|
+
@driver_id = Settings.test.driver_id.paper_duplicate
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
# -- Overridden methods --
|
33
|
+
private
|
34
|
+
|
35
|
+
# Defining the non-processable application factory that the BaseUODLV3ApplicationBuilder will use
|
36
|
+
def non_processable_application_factory
|
37
|
+
FM[:dup_application]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Defining the default driver_id, used to pass the validation in channel-api-stub
|
41
|
+
def default_application_driver_id
|
42
|
+
Settings.test.driver_id.always_duplicate
|
43
|
+
end
|
44
|
+
|
45
|
+
# Defining the data to put in customer_context
|
46
|
+
def application_customer_context
|
47
|
+
{
|
48
|
+
customerIntent: 'Duplicate licence',
|
49
|
+
transactionOutcome: 'Duplicate licence',
|
50
|
+
applicationsEligibilityResponse: [{
|
51
|
+
applicationType: 'update-ordinary-licence',
|
52
|
+
isRequired: true,
|
53
|
+
availableActions: [
|
54
|
+
actionType: 'update-photo',
|
55
|
+
isRequired: false,
|
56
|
+
],
|
57
|
+
}],
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_application_specific_fields!(app)
|
62
|
+
# Ensure DUP always has a reason for not providing licence
|
63
|
+
app.data.unable_to_prove_licence_possession_reason = 'LOST_OR_STOLEN'
|
64
|
+
|
65
|
+
unless @unable_to_prove_licence_possession_reason.nil?
|
66
|
+
app.data.unable_to_prove_licence_possession_reason = @unable_to_prove_licence_possession_reason
|
67
|
+
end
|
68
|
+
|
69
|
+
if @eligibility_paper_to_plastic
|
70
|
+
app.data.customer_context[:applicationsEligibilityResponse][0][:availableActions].push({
|
71
|
+
actionType: 'inform-paper-to-plastic',
|
72
|
+
isRequired: true,
|
73
|
+
})
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative('../photo_signature_builder_mixin.rb')
|
2
|
+
|
3
|
+
module DVLA
|
4
|
+
module Application
|
5
|
+
class EXCV3ApplicationBuilder < BaseUODLV3ApplicationBuilder
|
6
|
+
# Including all properties and methods needed to support photos and signatures
|
7
|
+
include DVLA::Application::PhotoSignatureBuilderMixin
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
init_photo_signature_properties
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some builder methods are automatically included from PhotoSignatureBuilderMixin
|
15
|
+
|
16
|
+
# -- Overridden methods --
|
17
|
+
private
|
18
|
+
|
19
|
+
# Defining the non-processable application factory that the BaseUODLV3ApplicationBuilder will use
|
20
|
+
def non_processable_application_factory
|
21
|
+
FM[:exc_application]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Defining the default driver_id, used to pass the validation in channel-api-stub
|
25
|
+
def default_application_driver_id
|
26
|
+
Settings.test.driver_id.always_exchange
|
27
|
+
end
|
28
|
+
|
29
|
+
# Defining the data to put in customer_context
|
30
|
+
def application_customer_context
|
31
|
+
{
|
32
|
+
customerIntent: 'Paper to photocard',
|
33
|
+
transactionOutcome: 'Paper to photocard',
|
34
|
+
applicationsEligibilityResponse: [{
|
35
|
+
applicationType: 'update-ordinary-licence',
|
36
|
+
isRequired: true,
|
37
|
+
availableActions: [
|
38
|
+
actionType: 'inform-paper-to-plastic',
|
39
|
+
isRequired: true,
|
40
|
+
],
|
41
|
+
}],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creating the images that the BaseUODLV3ApplicationBuilder will include in the app
|
46
|
+
def application_images
|
47
|
+
generate_photo_signature_images(@processable, @unique_images)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Advance and submits the tasks based on the phot and signature review state specified
|
51
|
+
def process_application_tasks(app)
|
52
|
+
process_photo_signature_tasks(app) if @processable
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require_relative('../photo_signature_builder_mixin.rb')
|
2
|
+
require_relative('../dup_rep_builder_mixin.rb')
|
3
|
+
|
4
|
+
module DVLA
|
5
|
+
module Application
|
6
|
+
class REPV3ApplicationBuilder < BaseUODLV3ApplicationBuilder
|
7
|
+
# Including all properties and methods needed to support photos and signatures in the case of a Paper DUP
|
8
|
+
include DVLA::Application::PhotoSignatureBuilderMixin
|
9
|
+
include DVLA::Application::DupRepBuilderMixin
|
10
|
+
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@unable_to_prove_licence_possession_reason = nil
|
14
|
+
@eligibility_paper_to_plastic = false
|
15
|
+
@change_of_address = true
|
16
|
+
init_photo_signature_properties
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# -- Builder methods --
|
21
|
+
|
22
|
+
# Some builder methods are automatically included from PhotoSignatureBuilderMixin
|
23
|
+
|
24
|
+
|
25
|
+
# Acts as if the licence owner has a paper licence.
|
26
|
+
# The application will be eligible to be changed from a paper licence to a plastic one and therefore have a normal fee
|
27
|
+
# It will also upload a photo and a signature with the application, and enable the flags to control these images and their tasks
|
28
|
+
# Sets the driver id to the specific id required for channel api stub to recognise
|
29
|
+
# @return [REPV3ApplicationBuilder]
|
30
|
+
def with_paper_to_plastic_driver_id
|
31
|
+
@eligibility_paper_to_plastic = true
|
32
|
+
@driver_id = Settings.test.driver_id.paper_replacement
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# -- Overridden methods --
|
37
|
+
private
|
38
|
+
|
39
|
+
# Defining the non-processable application factory that the BaseUODLV3ApplicationBuilder will use
|
40
|
+
def non_processable_application_factory
|
41
|
+
FM[:rep_application]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Defining the default driver_id, used to pass the validation in channel-api-stub
|
45
|
+
def default_application_driver_id
|
46
|
+
Settings.test.driver_id.always_replacement
|
47
|
+
end
|
48
|
+
|
49
|
+
# Defining the data to put in customer_context
|
50
|
+
def application_customer_context
|
51
|
+
{
|
52
|
+
customerIntent: 'Change of details',
|
53
|
+
transactionOutcome: 'Change of details',
|
54
|
+
applicationsEligibilityResponse: [{
|
55
|
+
applicationType: 'update-ordinary-licence',
|
56
|
+
isRequired: true,
|
57
|
+
availableActions: [
|
58
|
+
actionType: 'update-address',
|
59
|
+
isRequired: true,
|
60
|
+
],
|
61
|
+
}],
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_application_specific_fields!(app)
|
66
|
+
unless @unable_to_prove_licence_possession_reason.nil?
|
67
|
+
app.data.unable_to_prove_licence_possession_reason = @unable_to_prove_licence_possession_reason
|
68
|
+
end
|
69
|
+
|
70
|
+
app.no_fee_application = true
|
71
|
+
|
72
|
+
if @eligibility_paper_to_plastic
|
73
|
+
app.data.customer_context[:applicationsEligibilityResponse][0][:availableActions].push({
|
74
|
+
actionType: 'inform-paper-to-plastic',
|
75
|
+
isRequired: true,
|
76
|
+
})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative('../photo_signature_builder_mixin.rb')
|
2
|
+
|
3
|
+
module DVLA
|
4
|
+
module Application
|
5
|
+
class TYRV3ApplicationBuilder < BaseUODLV3ApplicationBuilder
|
6
|
+
# Including all properties and methods needed to support photos
|
7
|
+
include DVLA::Application::PhotoBuilderMixin
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@no_fee_application = false
|
11
|
+
init_photo_properties
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
# The application will be a no fee application
|
16
|
+
# @param no_fee [Boolean] If the application should be no-fee. Defaults to true.
|
17
|
+
# @return [TYRV3ApplicationBuilder]
|
18
|
+
def set_no_fee_application(no_fee: true)
|
19
|
+
@no_fee_application = no_fee
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
# -- Overridden methods --
|
24
|
+
private
|
25
|
+
|
26
|
+
def application_images
|
27
|
+
generate_photo_images(@processable, @unique_images)
|
28
|
+
end
|
29
|
+
|
30
|
+
def application_customer_context
|
31
|
+
{
|
32
|
+
customerIntent: 'Ten year renewal',
|
33
|
+
transactionOutcome: 'Ten year renewal',
|
34
|
+
applicationsEligibilityResponse: [{
|
35
|
+
applicationType: 'update-ordinary-licence',
|
36
|
+
isRequired: true,
|
37
|
+
availableActions: [
|
38
|
+
actionType: 'update-photo',
|
39
|
+
isRequired: true,
|
40
|
+
],
|
41
|
+
}],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def non_processable_application_factory
|
46
|
+
FM[:tyr_application]
|
47
|
+
end
|
48
|
+
|
49
|
+
def default_application_driver_id
|
50
|
+
Settings.test.driver_id.mandatory_tyr
|
51
|
+
end
|
52
|
+
|
53
|
+
def process_application_tasks(app)
|
54
|
+
process_photo_tasks(app) if @processable
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|