Class: Minfraud::HTTPService::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/minfraud/http_service/response.rb

Overview

Response class for HTTP requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Response

Returns a new instance of Response.

Parameters:

  • params (Hash) (defaults to: {})

    Hash of parameters. :status, :endpoint, :body, :locales, and :headers are used.



30
31
32
33
34
35
36
37
38
# 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

Instance Attribute Details

#bodyMinfraud::Model::Score, ... (readonly)

HTTP response model.



21
22
23
# File 'lib/minfraud/http_service/response.rb', line 21

def body
  @body
end

#headersHash? (readonly)

HTTP response headers.

Returns:

  • (Hash, nil)


26
27
28
# File 'lib/minfraud/http_service/response.rb', line 26

def headers
  @headers
end

#statusInteger? (readonly)

HTTP response status.

Returns:

  • (Integer, nil)


15
16
17
# File 'lib/minfraud/http_service/response.rb', line 15

def status
  @status
end

Instance Method Details

#codeSymbol?

Return the minFraud-specific response code.

Returns:

  • (Symbol, nil)


43
44
45
46
47
# 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