class Minfraud::HTTPService::Response
Response
class for HTTP requests.
Constants
- ENDPOINT_TO_CLASS
Attributes
body[R]
HTTP response model.
@return [Minfraud::Model::Score, Minfraud::Model::Insights
,
Minfraud::Model::Factors, nil]
headers[R]
HTTP response headers.
@return [Hash, nil]
status[R]
HTTP response status.
@return [Integer, nil]
Public Class Methods
new(params = {})
click to toggle source
@param params [Hash] Hash of parameters. :status
, :endpoint
,
+:body+, +:locales+, and +:headers+ are used.
# File lib/minfraud/http_service/response.rb, line 30 def initialize(params = {}) @status = params[:status] @body = make_body( params[:endpoint], params[:body], params[:locales] ) @headers = params[:headers] end
Public Instance Methods
code()
click to toggle source
Return the minFraud-specific response code.
@return [Symbol, nil]
# File lib/minfraud/http_service/response.rb, line 43 def code return nil if body.nil? body.code.intern if body.respond_to?(:code) && body.code end
Private Instance Methods
make_body(endpoint, body, locales)
click to toggle source
# File lib/minfraud/http_service/response.rb, line 51 def make_body(endpoint, body, locales) if @status != 200 # Won't be a Hash when the body is not JSON. return nil unless body.is_a?(Hash) return Minfraud::Model::Error.new(body) end ENDPOINT_TO_CLASS[endpoint].new(body, locales) end