class Minfraud::Components::Device

Device corresponds to the device object of a minFraud request.

@see dev.maxmind.com/minfraud/#Device_(/device)

Attributes

accept_language[RW]

The HTTP “Accept-Language” header of the browser used in the transaction.

@return [String, nil]

ip_address[RW]

The IP address associated with the device used by the customer in the transaction. The IP address must be in IPv4 or IPv6 presentation format, i.e., dotted-quad notation or the IPv6 hexadecimal-colon notation.

@return [String, nil]

session_age[RW]

The number of seconds between the creation of the user's session and the time of the transaction. Note that session_age is not the duration of the current visit, but the time since the start of the first visit. The value must be at least 0 and at most 10^13-1.

@return [Float, nil]

session_id[RW]

An ID that uniquely identifies a visitor's session on the site.

@return [String, nil]

user_agent[RW]

The HTTP “User-Agent” header of the browser used in the transaction.

@return [String, nil]

Public Class Methods

new(params = {}) click to toggle source

@param params [Hash] Hash of parameters. Each key/value should

correspond to one of the available attributes.
# File lib/minfraud/components/device.rb, line 45
def initialize(params = {})
  @ip_address      = params[:ip_address]
  @user_agent      = params[:user_agent]
  @accept_language = params[:accept_language]
  @session_age     = params[:session_age]
  @session_id      = params[:session_id]

  validate
end

Private Instance Methods

validate() click to toggle source
# File lib/minfraud/components/device.rb, line 57
def validate
  return if !Minfraud.enable_validation

  validate_ip('ip_address', @ip_address)
  validate_string('user_agent', 512, @user_agent)
  validate_string('accept_language', 255, @accept_language)
  validate_nonnegative_number('session_age', @session_age)
  validate_string('session_id', 255, @session_id)
end