Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## v2.11.0

* Added `raw_body` to `Minfraud::HTTPService::Response`. It is the response
body as the web service sent it, before parsing. Use it to store or log
the full response, including any fields this library does not model yet.
* Added the `phone_verification_method`,
`phone_was_verification_successful`, and `phone_verification_time`
attributes to `Minfraud::Components::Billing` and
Expand Down
10 changes: 9 additions & 1 deletion lib/minfraud/http_service/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class Response
# Minfraud::Model::Factors, Minfraud::Model::Error, nil]
attr_reader :body

# The response body as the web service sent it, before parsing. Use it
# to store or log the full response, including any fields this library
# does not model yet.
#
# @return [String]
attr_reader :raw_body

# @param endpoint [Symbol, nil] endpoint name, like :score.
#
# @param locales [Array<String>, nil] locales, like ["en"].
Expand All @@ -33,7 +40,8 @@ class Response
#
# @raise [JSON::ParserError] if there was invalid JSON in the response.
def initialize(endpoint, locales, response, body)
@status = response.code
@status = response.code
@raw_body = body

@body = make_body(
endpoint,
Expand Down
5 changes: 3 additions & 2 deletions spec/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
},
)

score_model = assessment.score.body
response = assessment.score

expect(score_model.risk_score).to eq 42.1
expect(response.body.risk_score).to eq 42.1
expect(response.raw_body).to eq '{"risk_score":42.1}'
end

it 'makes an HTTP request resulting in an HTTP 401' do
Expand Down
Loading