class Minfraud::Assessments

Assessments is used to perform minFraud Score, Insights, and Factors requests.

@see dev.maxmind.com/minfraud/

Attributes

account[RW]

The Account component.

@return [Minfraud::Components::Account, nil]

billing[RW]

The Billing component.

@return [Minfraud::Components::Billing, nil]

credit_card[RW]

The CreditCard component.

@return [Minfraud::Components::CreditCard, nil]

custom_inputs[RW]

The CustomInputs component.

@return [Minfraud::Components::CustomInputs, nil]

device[RW]

The Device component.

@return [Minfraud::Components::Device, nil]

email[RW]

The Email component.

@return [Minfraud::Components::Email, nil]

event[RW]

The Event component.

@return [Minfraud::Components::Event, nil]

order[RW]

The Order component.

@return [Minfraud::Components::Order, nil]

payment[RW]

The Payment component.

@return [Minfraud::Components::Payment, nil]

shipping[RW]

The Shipping component.

@return [Minfraud::Components::Shipping, nil]

shopping_cart[RW]

The ShoppingCart component.

@return [Minfraud::Components::ShoppingCart, nil]

Public Class Methods

new(params = {}, resolver = ::Minfraud::Resolver) click to toggle source

@param params [Hash] Hash of parameters. Each key is a symbol

corresponding to one of the available component attributes. Values may
be component objects or hashes that will be provided to the component
constructors.

@param resolver [Minfraud::Resolver] Resolver that maps parameters to

components.
# File lib/minfraud/assessments.rb, line 74
def initialize(params = {}, resolver = ::Minfraud::Resolver)
  @locales = params.delete('locales')
  @locales = ['en'] if @locales.nil?

  resolver.assign(self, params)
end

Public Instance Methods

factors() click to toggle source

Perform a minFraud Factors request.

@return [Minfraud::HTTPService::Response]

@raise [Minfraud::AuthorizationError] If there was an authentication

problem.

@raise [Minfraud::ClientError] If there was a critical problem with one

of your inputs.

@raise [Minfraud::ServerError] If the server reported an error of some

kind.
# File lib/minfraud/assessments.rb, line 93
def factors
  perform_request(:factors)
end
insights() click to toggle source

Perform a minFraud Insights request.

@return [Minfraud::HTTPService::Response]

@raise [Minfraud::AuthorizationError] If there was an authentication

problem.

@raise [Minfraud::ClientError] If there was a critical problem with one

of your inputs.

@raise [Minfraud::ServerError] If the server reported an error of some

kind.
# File lib/minfraud/assessments.rb, line 109
def insights
  perform_request(:insights)
end
score() click to toggle source

Perform a minFraud Score request.

@return [Minfraud::HTTPService::Response]

@raise [Minfraud::AuthorizationError] If there was an authentication

problem.

@raise [Minfraud::ClientError] If there was a critical problem with one

of your inputs.

@raise [Minfraud::ServerError] If the server reported an error of some

kind.
# File lib/minfraud/assessments.rb, line 125
def score
  perform_request(:score)
end

Private Instance Methods

perform_request(endpoint) click to toggle source
# File lib/minfraud/assessments.rb, line 131
def perform_request(endpoint)
  raw = request.perform(
    verb:     :post,
    endpoint: endpoint.to_s,
    body:     request_body,
  )

  response = ::Minfraud::HTTPService::Response.new(
    endpoint: endpoint,
    locales:  @locales,
    status:   raw.status.to_i,
    body:     raw.body,
    headers:  raw.headers
  )

  ::Minfraud::ErrorHandler.examine(response)
end
request() click to toggle source
# File lib/minfraud/assessments.rb, line 157
def request
  @request ||= Request.new(::Minfraud::HTTPService.configuration)
end
request_body() click to toggle source
# File lib/minfraud/assessments.rb, line 149
def request_body
  MAPPING.keys.reduce({}) do |mem, e|
    next mem unless (value = send(e))

    mem.merge!(e.to_s => value.to_json)
  end
end