class Minfraud::Report

Report is used to perform minFraud Report Transaction API requests.

@see dev.maxmind.com/minfraud/report-transaction/

Attributes

transaction[RW]

The Report::Transaction component.

@return [Minfraud::Components::Report::Transaction, nil]

Public Class Methods

new(params = {}) click to toggle source

@param params [Hash] Hash of parameters. The only supported key is

+:transaction+, which should have a
+Minfraud::Components::Report::Transaction+ as its value.
# File lib/minfraud/report.rb, line 18
def initialize(params = {})
  @transaction = params[:transaction]
end

Public Instance Methods

report_transaction() click to toggle source

Perform a request to the minFraud Report Transaction API.

@return [nil]

@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/report.rb, line 34
def report_transaction
  raw = request.perform(
    verb:     :post,
    endpoint: 'transactions/report',
    body:     @transaction.to_json,
  )

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

  ::Minfraud::ErrorHandler.examine(response)

  nil
end

Private Instance Methods

request() click to toggle source
# File lib/minfraud/report.rb, line 54
def request
  @request ||= Request.new(::Minfraud::HTTPService.configuration)
end