-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2509 from DFE-Digital/AQTS-670-build-client-to-ma…
…ke-post-and-get-requests-for-trn-allocation Updating class names and secret names to move away from using DQT and instead refer to the teaching record system as TRS
- Loading branch information
Showing
41 changed files
with
525 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class UpdateTRSMatchJob < ApplicationJob | ||
def perform(application_form) | ||
unless application_form.submitted? && application_form.awarded_at.nil? && | ||
application_form.declined_at.nil? && | ||
application_form.withdrawn_at.nil? | ||
return | ||
end | ||
|
||
teachers = TRS::Client::FindTeachers.call(application_form:) | ||
|
||
if teachers.empty? | ||
teachers = | ||
TRS::Client::FindTeachers.call(application_form:, reverse_name: true) | ||
end | ||
|
||
application_form.update!(dqt_match: { teachers: }) | ||
|
||
UpdateTRSMatchJob.set(wait: 24.hours).perform_later(application_form) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
class UpdateTRSTRNRequestJob < ApplicationJob | ||
def perform(dqt_trn_request) | ||
return if dqt_trn_request.complete? | ||
|
||
application_form = dqt_trn_request.application_form | ||
|
||
response = fetch_response(dqt_trn_request) | ||
|
||
dqt_trn_request.pending! if dqt_trn_request.initial? | ||
|
||
potential_duplicate = response[:potential_duplicate] | ||
if potential_duplicate != dqt_trn_request.potential_duplicate | ||
dqt_trn_request.update!(potential_duplicate:) | ||
end | ||
|
||
ApplicationFormStatusUpdater.call(application_form:, user: "DQT") | ||
|
||
unless potential_duplicate | ||
AwardQTS.call( | ||
application_form:, | ||
user: "DQT", | ||
trn: response[:trn], | ||
access_your_teaching_qualifications_url: | ||
response[:access_your_teaching_qualifications_link], | ||
) | ||
dqt_trn_request.complete! | ||
end | ||
|
||
if dqt_trn_request.pending? | ||
UpdateTRSTRNRequestJob.set(wait: 1.hour).perform_later(dqt_trn_request) | ||
end | ||
end | ||
|
||
private | ||
|
||
def fetch_response(dqt_trn_request) | ||
if dqt_trn_request.initial? | ||
TRS::Client::CreateTRNRequest.call( | ||
request_id: dqt_trn_request.request_id, | ||
application_form: dqt_trn_request.application_form, | ||
) | ||
else | ||
TRS::Client::ReadTRNRequest.call(request_id: dqt_trn_request.request_id) | ||
end | ||
rescue Faraday::Error => e | ||
Sentry.configure_scope do |scope| | ||
scope.set_context( | ||
"response", | ||
{ | ||
status: e.response_status, | ||
headers: e.response_headers, | ||
body: e.response_body, | ||
}, | ||
) | ||
end | ||
|
||
raise | ||
end | ||
end |
6 changes: 3 additions & 3 deletions
6
app/lib/dqt/client/connection.rb → app/lib/trs/client/connection.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/lib/dqt/client/read_trn_request.rb → app/lib/trs/client/read_trn_request.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/lib/dqt/find_teachers_params.rb → app/lib/trs/find_teachers_params.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module DQT | ||
module TRS | ||
class FindTeachersParams | ||
include ServicePattern | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
app/lib/dqt/recognition_route.rb → app/lib/trs/recognition_route.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/lib/dqt/trn_request_params.rb → app/lib/trs/trn_request_params.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module DQT | ||
module TRS | ||
class TRNRequestParams | ||
include ServicePattern | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
development: | ||
url: <%= ENV.fetch("TRS_API_URL", "https://dev.teacher-qualifications-api.education.gov.uk") %> | ||
api_key: <%= ENV["TRS_API_KEY"] %> | ||
|
||
production: | ||
url: <%= ENV.fetch("TRS_API_URL", "https://teacher-qualifications-api.education.gov.uk") %> | ||
api_key: <%= ENV["TRS_API_KEY"] %> | ||
|
||
test: | ||
url: https://test-teacher-qualifications-api.education.gov.uk | ||
api_key: test-api-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.