Class: Minfraud::Report

Inherits:
Object
  • Object
show all
Includes:
HTTPService
Defined in:
lib/minfraud/report.rb

Overview

Report is used to perform minFraud Report Transaction API requests.

Constant Summary

Constants included from HTTPService

HTTPService::DEFAULT_SERVER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HTTPService

configuration

Constructor Details

#initialize(params = {}) ⇒ Report

Returns a new instance of Report.

Parameters:

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

    Hash of parameters. The only supported key is :transaction, which should have a Minfraud::Components::Report::Transaction as its value.


18
19
20
# File 'lib/minfraud/report.rb', line 18

def initialize(params = {})
  @transaction = params[:transaction]
end

Instance Attribute Details

#transactionMinfraud::Components::Report::Transaction?

The Report::Transaction component.


13
14
15
# File 'lib/minfraud/report.rb', line 13

def transaction
  @transaction
end

Instance Method Details

#report_transactionnil

Perform a request to the minFraud Report Transaction API.

Returns:

  • (nil)

Raises:


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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