Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions app/controllers/api/verify/password_confirm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def create
user = User.find_by(uuid: result.extra[:user_uuid])
add_proofing_component(user)
store_session_last_gpo_code(form.gpo_code)
save_in_person_enrollment(user, form.profile)
render json: {
personal_key: personal_key,
completion_url: completion_url(result, user),
Expand Down Expand Up @@ -59,6 +60,52 @@ def in_person_enrollment?(user)
# WILLFIX: After LG-6872 and we have enrollment saved, reference enrollment instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything we need to think about here? I think the assumption at the time this was written was that we might create an enrollment earlier in the process.

Copy link
Contributor Author

@sheldon-b sheldon-b Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine as-is. This method gets used twice: once before the enrollment is created and once after. The enrollment is only a useful indicator of this being an in-person flow after it is created

I'm going to leave it as-is in this file and will begin using the enrollment on the next page, in the personal key controller

ProofingComponent.find_by(user: user)&.document_check == Idp::Constants::Vendors::USPS
end

def usps_proofer
if IdentityConfig.store.usps_mock_fallback
UspsInPersonProofing::Mock::Proofer.new
else
UspsInPersonProofing::Proofer.new
end
end

def create_usps_enrollment(enrollment)
pii = user_session[:idv][:pii]
applicant = UspsInPersonProofing::Applicant.new(
{
unique_id: enrollment.usps_unique_id,
first_name: pii.first_name,
last_name: pii.last_name,
address: pii.address1,
# do we need address2?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, I just didn't have time to add it in this PR. Will add in a follow-up

city: pii.city,
state: pii.state,
zip_code: pii.zipcode,
email: 'no-reply@login.gov',
},
)
proofer = usps_proofer

response = proofer.request_enroll(applicant)
response['enrollmentCode']
Comment on lines +89 to +90
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on adding error handling in a follow-up PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of creating a Struct-like object to repesent the response here so we could do a direct property access response.enrollment_code rather than digging into a hash? Makes mocking responses easier as well

end

def save_in_person_enrollment(user, profile)
return unless in_person_enrollment?(user)

enrollment = InPersonEnrollment.create!(
profile: profile,
user: user,
)
Comment on lines +96 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I had a thought I dropped in slack this morning about maybe we flip the order of these.. could be a future PR if needed!


enrollment_code = create_usps_enrollment(enrollment)
return unless enrollment_code

# update the enrollment to status pending
enrollment.enrollment_code = enrollment_code
enrollment.status = :pending
enrollment.save!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need error handling here too, in case there's an existing pending enrollment.

end
end
end
end
2 changes: 1 addition & 1 deletion app/jobs/get_usps_proofing_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GetUspsProofingResultsJob < ApplicationJob
def perform(_now)
return true unless IdentityConfig.store.in_person_proofing_enabled

proofer = UspsInPersonProofer.new
proofer = UspsInPersonProofing::Proofer.new

InPersonEnrollment.needs_usps_status_check(...5.minutes.ago).each do |enrollment|
# Record and commit attempt to check enrollment status to database
Expand Down
2 changes: 1 addition & 1 deletion app/models/in_person_enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def needs_usps_status_check?(check_interval)

# Returns the value to use for the USPS enrollment ID
def usps_unique_id
user_id.to_s
user.uuid.delete('-').slice(0, 18)
Copy link
Contributor Author

@sheldon-b sheldon-b Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a temporary solution. There's a separate ticket to think through the best way to generate unique IDs

end

private
Expand Down
184 changes: 0 additions & 184 deletions app/services/usps_in_person_proofer.rb

This file was deleted.

6 changes: 6 additions & 0 deletions app/services/usps_in_person_proofing/applicant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module UspsInPersonProofing
Applicant = Struct.new(
:unique_id, :first_name, :last_name, :address, :city, :state, :zip_code,
:email, keyword_init: true
)
end
11 changes: 11 additions & 0 deletions app/services/usps_in_person_proofing/mock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module UspsInPersonProofing
module Mock
class Proofer
def request_enroll(_applicant)
JSON.load_file(
Rails.root.join('spec/fixtures/usps_ipp_responses/request_enroll_response.json'),
)
end
end
end
end
5 changes: 5 additions & 0 deletions app/services/usps_in_person_proofing/post_office.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module UspsInPersonProofing
PostOffice = Struct.new(
:distance, :address, :city, :phone, :name, :zip_code, :state, keyword_init: true
)
end
Loading