-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreport.rb
More file actions
66 lines (57 loc) · 1.7 KB
/
Copy pathreport.rb
File metadata and controls
66 lines (57 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
module Minfraud
# Report is used to perform minFraud Report Transaction API requests.
#
# @see https://dev.maxmind.com/minfraud/report-a-transaction/?lang=en
class Report
# The Report::Transaction component.
#
# @return [Minfraud::Components::Report::Transaction, nil]
attr_accessor :transaction
# @param params [Hash] Hash of parameters. The only supported key is
# +:transaction+, which should have a
# +Minfraud::Components::Report::Transaction+ as its value.
def initialize(params = {})
@transaction = params[:transaction]
end
# Perform a request to the minFraud Report Transaction API.
#
# @return [nil]
#
# @raise [JSON::ParserError] if there was invalid JSON in the 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.
def report_transaction
response = nil
body = nil
Minfraud.connection_pool.with do |client|
response = client.post(
'/minfraud/v2.0/transactions/report',
json: @transaction.to_json,
)
body = response.to_s
end
endpoint = nil
locales = nil
response = ::Minfraud::HTTPService::Response.new(
endpoint,
locales,
response,
body,
)
::Minfraud::ErrorHandler.examine(response)
nil
end
private
def request
@request ||= Request.new(::Minfraud::HTTPService.configuration)
end
end
end