Skip to content
Merged
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
23 changes: 18 additions & 5 deletions app/services/usps_in_person_proofing/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def request_facilities(location)
)

parse_facilities(
faraday.post(url, body, headers).body,
faraday.post(url, body, headers) do |req|
req.options.context = { service_name: 'usps_facilities' }
Copy link
Copy Markdown
Contributor

@NavaTim NavaTim Aug 3, 2022

Choose a reason for hiding this comment

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

You may want to verify in the tests that these blocks set the context.

end.body,
)
end

Expand Down Expand Up @@ -58,7 +60,9 @@ def request_enroll(applicant)
IPPAssuranceLevel: '1.5',
}

faraday.post(url, body, dynamic_headers).body
faraday.post(url, body, dynamic_headers) do |req|
req.options.context = { service_name: 'usps_enroll' }
end.body
end

# Makes HTTP request to retrieve proofing status
Expand All @@ -77,7 +81,9 @@ def request_proofing_results(unique_id, enrollment_code)
enrollmentCode: enrollment_code,
}

faraday.post(url, body, dynamic_headers).body
faraday.post(url, body, dynamic_headers) do |req|
req.options.context = { service_name: 'usps_proofing_results' }
end.body
end

# Makes HTTP request to retrieve enrollment code
Expand All @@ -94,7 +100,9 @@ def request_enrollment_code(unique_id)
uniqueID: unique_id,
}

faraday.post(url, body, dynamic_headers).body
faraday.post(url, body, dynamic_headers) do |req|
req.options.context = { service_name: 'usps_enrollment_code' }
end.body
end

# Makes a request to retrieve a new OAuth token
Expand All @@ -120,6 +128,9 @@ def faraday
conn.options.open_timeout = IdentityConfig.store.usps_ipp_request_timeout
conn.options.write_timeout = IdentityConfig.store.usps_ipp_request_timeout

# Log request metrics
conn.request :instrumentation, name: 'request_metric.faraday'

# Raise an error subclassing Faraday::Error on 4xx, 5xx, and malformed responses
# Note: The order of this matters for parsing the error response body.
conn.response :raise_error
Expand Down Expand Up @@ -162,7 +173,9 @@ def request_token
scope: 'ivs.ippaas.apis',
}

faraday.post(url, body).body
faraday.post(url, body) do |req|
req.options.context = { service_name: 'usps_token' }
end.body
end

def root_url
Expand Down