minfraud 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +42 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.dev.md +4 -0
- data/README.md +178 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/maxmind/geoip2/model/city.rb +99 -0
- data/lib/maxmind/geoip2/model/country.rb +94 -0
- data/lib/maxmind/geoip2/model/insights.rb +38 -0
- data/lib/maxmind/geoip2/record/abstract.rb +46 -0
- data/lib/maxmind/geoip2/record/city.rb +62 -0
- data/lib/maxmind/geoip2/record/continent.rb +61 -0
- data/lib/maxmind/geoip2/record/country.rb +78 -0
- data/lib/maxmind/geoip2/record/location.rb +97 -0
- data/lib/maxmind/geoip2/record/maxmind.rb +41 -0
- data/lib/maxmind/geoip2/record/place.rb +52 -0
- data/lib/maxmind/geoip2/record/postal.rb +54 -0
- data/lib/maxmind/geoip2/record/represented_country.rb +47 -0
- data/lib/maxmind/geoip2/record/subdivision.rb +72 -0
- data/lib/maxmind/geoip2/record/traits.rb +224 -0
- data/lib/minfraud.rb +51 -0
- data/lib/minfraud/assessments.rb +101 -0
- data/lib/minfraud/components/account.rb +23 -0
- data/lib/minfraud/components/addressable.rb +67 -0
- data/lib/minfraud/components/base.rb +35 -0
- data/lib/minfraud/components/billing.rb +5 -0
- data/lib/minfraud/components/credit_card.rb +52 -0
- data/lib/minfraud/components/custom_inputs.rb +14 -0
- data/lib/minfraud/components/device.rb +38 -0
- data/lib/minfraud/components/email.rb +21 -0
- data/lib/minfraud/components/event.rb +44 -0
- data/lib/minfraud/components/order.rb +52 -0
- data/lib/minfraud/components/payment.rb +152 -0
- data/lib/minfraud/components/report/transaction.rb +69 -0
- data/lib/minfraud/components/shipping.rb +18 -0
- data/lib/minfraud/components/shopping_cart.rb +30 -0
- data/lib/minfraud/components/shopping_cart_item.rb +33 -0
- data/lib/minfraud/enum.rb +34 -0
- data/lib/minfraud/error_handler.rb +65 -0
- data/lib/minfraud/errors.rb +10 -0
- data/lib/minfraud/http_service.rb +30 -0
- data/lib/minfraud/http_service/request.rb +37 -0
- data/lib/minfraud/http_service/response.rb +64 -0
- data/lib/minfraud/model/abstract.rb +20 -0
- data/lib/minfraud/model/address.rb +52 -0
- data/lib/minfraud/model/billing_address.rb +11 -0
- data/lib/minfraud/model/credit_card.rb +75 -0
- data/lib/minfraud/model/device.rb +54 -0
- data/lib/minfraud/model/disposition.rb +35 -0
- data/lib/minfraud/model/email.rb +54 -0
- data/lib/minfraud/model/email_domain.rb +24 -0
- data/lib/minfraud/model/error.rb +28 -0
- data/lib/minfraud/model/factors.rb +24 -0
- data/lib/minfraud/model/geoip2_location.rb +25 -0
- data/lib/minfraud/model/insights.rb +68 -0
- data/lib/minfraud/model/ip_address.rb +82 -0
- data/lib/minfraud/model/issuer.rb +49 -0
- data/lib/minfraud/model/score.rb +76 -0
- data/lib/minfraud/model/score_ip_address.rb +23 -0
- data/lib/minfraud/model/shipping_address.rb +30 -0
- data/lib/minfraud/model/subscores.rb +156 -0
- data/lib/minfraud/model/warning.rb +63 -0
- data/lib/minfraud/report.rb +38 -0
- data/lib/minfraud/resolver.rb +33 -0
- data/lib/minfraud/version.rb +3 -0
- data/minfraud.gemspec +29 -0
- metadata +198 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minfraud/model/abstract'
|
4
|
+
|
5
|
+
module Minfraud
|
6
|
+
module Model
|
7
|
+
# Warning about the minFraud request.
|
8
|
+
#
|
9
|
+
# Although more codes may be added in the future, the current warning codes
|
10
|
+
# are:
|
11
|
+
#
|
12
|
+
# * BILLING_CITY_NOT_FOUND - the billing city could not be found in our
|
13
|
+
# database.
|
14
|
+
# * BILLING_COUNTRY_MISSING - billing address information was provided
|
15
|
+
# without providing a billing country.
|
16
|
+
# * BILLING_COUNTRY_NOT_FOUND - the billing country could not be found in
|
17
|
+
# our database.
|
18
|
+
# * BILLING_POSTAL_NOT_FOUND - the billing postal could not be found in our
|
19
|
+
# database.
|
20
|
+
# * INPUT_INVALID - the value associated with the key does not meet the
|
21
|
+
# required constraints, e.g., "United States" in a field that requires a
|
22
|
+
# two-letter country code.
|
23
|
+
# * INPUT_UNKNOWN - an unknown key was encountered in the request body.
|
24
|
+
# * IP_ADDRESS_NOT_FOUND - the IP address could not be geolocated.
|
25
|
+
# * SHIPPING_COUNTRY_MISSING - shipping address information was provided
|
26
|
+
# without providing a shipping country.
|
27
|
+
# * SHIPPING_CITY_NOT_FOUND - the shipping city could not be found in our
|
28
|
+
# database.
|
29
|
+
# * SHIPPING_COUNTRY_NOT_FOUND - the shipping country could not be found in
|
30
|
+
# our database.
|
31
|
+
# * SHIPPING_POSTAL_NOT_FOUND - the shipping postal could not be found in
|
32
|
+
# our database.
|
33
|
+
class Warning < Abstract
|
34
|
+
# This value is a machine-readable code identifying the warning.
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
attr_reader :code
|
38
|
+
|
39
|
+
# This property provides a human-readable explanation of the warning. The
|
40
|
+
# description may change at any time and should not be matched against.
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
attr_reader :warning
|
44
|
+
|
45
|
+
# A JSON Pointer to the input field that the warning is associated with.
|
46
|
+
# For instance, if the warning was about the billing city, this would be
|
47
|
+
# '/billing/city'. If it was for the price in the second shopping cart
|
48
|
+
# item, it would be '/shopping_cart/1/price'.
|
49
|
+
#
|
50
|
+
# @return [String, nil]
|
51
|
+
attr_reader :input_pointer
|
52
|
+
|
53
|
+
# @!visibility private
|
54
|
+
def initialize(record)
|
55
|
+
super(record)
|
56
|
+
|
57
|
+
@code = get('code')
|
58
|
+
@warning = get('warning')
|
59
|
+
@input_pointer = get('input_pointer')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Minfraud
|
2
|
+
class Report
|
3
|
+
include ::Minfraud::HTTPService
|
4
|
+
|
5
|
+
# @!attribute transaction
|
6
|
+
# @return [Minfraud::Components::Report::Transaction] Report::Transaction component
|
7
|
+
attr_accessor :transaction
|
8
|
+
|
9
|
+
# @param [Hash] params hash of parameters
|
10
|
+
# @return [Minfraud::ReportTransaction] ReportTransaction instance
|
11
|
+
def initialize(params = {})
|
12
|
+
@transaction = params[:transaction]
|
13
|
+
end
|
14
|
+
|
15
|
+
# @method report_transaction
|
16
|
+
# Makes a request to the minFraud report transactions API.
|
17
|
+
# Raises an error in case of invalid response.
|
18
|
+
# @return [nil]
|
19
|
+
def report_transaction
|
20
|
+
raw = request.perform(verb: :post, endpoint: 'transactions/report', body: @transaction.to_json)
|
21
|
+
|
22
|
+
response = ::Minfraud::HTTPService::Response.new(
|
23
|
+
status: raw.status.to_i,
|
24
|
+
body: raw.body,
|
25
|
+
headers: raw.headers
|
26
|
+
)
|
27
|
+
::Minfraud::ErrorHandler.examine(response)
|
28
|
+
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates memoized Minfraud::HTTPService::Request instance
|
33
|
+
# @return [Minfraud::HTTPService::Request] Request instance based on configuration params
|
34
|
+
def request
|
35
|
+
@request ||= Request.new(::Minfraud::HTTPService.configuration)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Minfraud
|
2
|
+
module Resolver
|
3
|
+
class << self
|
4
|
+
# @param [Object] context an object for variable assignment
|
5
|
+
# @param [Hash] params a hash of parameters
|
6
|
+
# @return [Array] a list of supplied params
|
7
|
+
# @note Raises RequestFormatError once unpermitted key is met
|
8
|
+
def assign(context, params)
|
9
|
+
Array(params).each do |key, value|
|
10
|
+
raise RequestFormatError, "#{key} does not belong to request document format" unless MAPPING[key]
|
11
|
+
|
12
|
+
entity = MAPPING[key].new(value) unless value.is_a?(MAPPING[key])
|
13
|
+
context.send("#{key}=", entity || value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Mapping between components & minFraud request keys
|
19
|
+
MAPPING = {
|
20
|
+
account: ::Minfraud::Components::Account,
|
21
|
+
billing: ::Minfraud::Components::Billing,
|
22
|
+
credit_card: ::Minfraud::Components::CreditCard,
|
23
|
+
custom_inputs: ::Minfraud::Components::CustomInputs,
|
24
|
+
device: ::Minfraud::Components::Device,
|
25
|
+
email: ::Minfraud::Components::Email,
|
26
|
+
event: ::Minfraud::Components::Event,
|
27
|
+
order: ::Minfraud::Components::Order,
|
28
|
+
payment: ::Minfraud::Components::Payment,
|
29
|
+
shipping: ::Minfraud::Components::Shipping,
|
30
|
+
shopping_cart: ::Minfraud::Components::ShoppingCart,
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
data/minfraud.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('lib', File.dirname(File.realpath(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'minfraud/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'minfraud'
|
8
|
+
spec.version = Minfraud::VERSION
|
9
|
+
spec.authors = ['kushnir.yb']
|
10
|
+
spec.email = ['support@maxmind.com']
|
11
|
+
|
12
|
+
spec.summary = %q(Ruby interface to the MaxMind minFraud v2.0 API services)
|
13
|
+
spec.homepage = 'https://github.com/maxmind/minfraud-api-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.required_ruby_version = '>= 1.9'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'faraday', '>= 0.9.1', '< 2.0'
|
24
|
+
spec.add_runtime_dependency 'faraday_middleware', '>= 0.9.1', '< 2.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '>= 1.16'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minfraud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kushnir.yb
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faraday_middleware
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.9.1
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.9.1
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.16'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.16'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '3.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '3.0'
|
95
|
+
description:
|
96
|
+
email:
|
97
|
+
- support@maxmind.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- ".gitignore"
|
103
|
+
- ".rspec"
|
104
|
+
- ".travis.yml"
|
105
|
+
- CHANGELOG.md
|
106
|
+
- CODE_OF_CONDUCT.md
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.dev.md
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/maxmind/geoip2/model/city.rb
|
115
|
+
- lib/maxmind/geoip2/model/country.rb
|
116
|
+
- lib/maxmind/geoip2/model/insights.rb
|
117
|
+
- lib/maxmind/geoip2/record/abstract.rb
|
118
|
+
- lib/maxmind/geoip2/record/city.rb
|
119
|
+
- lib/maxmind/geoip2/record/continent.rb
|
120
|
+
- lib/maxmind/geoip2/record/country.rb
|
121
|
+
- lib/maxmind/geoip2/record/location.rb
|
122
|
+
- lib/maxmind/geoip2/record/maxmind.rb
|
123
|
+
- lib/maxmind/geoip2/record/place.rb
|
124
|
+
- lib/maxmind/geoip2/record/postal.rb
|
125
|
+
- lib/maxmind/geoip2/record/represented_country.rb
|
126
|
+
- lib/maxmind/geoip2/record/subdivision.rb
|
127
|
+
- lib/maxmind/geoip2/record/traits.rb
|
128
|
+
- lib/minfraud.rb
|
129
|
+
- lib/minfraud/assessments.rb
|
130
|
+
- lib/minfraud/components/account.rb
|
131
|
+
- lib/minfraud/components/addressable.rb
|
132
|
+
- lib/minfraud/components/base.rb
|
133
|
+
- lib/minfraud/components/billing.rb
|
134
|
+
- lib/minfraud/components/credit_card.rb
|
135
|
+
- lib/minfraud/components/custom_inputs.rb
|
136
|
+
- lib/minfraud/components/device.rb
|
137
|
+
- lib/minfraud/components/email.rb
|
138
|
+
- lib/minfraud/components/event.rb
|
139
|
+
- lib/minfraud/components/order.rb
|
140
|
+
- lib/minfraud/components/payment.rb
|
141
|
+
- lib/minfraud/components/report/transaction.rb
|
142
|
+
- lib/minfraud/components/shipping.rb
|
143
|
+
- lib/minfraud/components/shopping_cart.rb
|
144
|
+
- lib/minfraud/components/shopping_cart_item.rb
|
145
|
+
- lib/minfraud/enum.rb
|
146
|
+
- lib/minfraud/error_handler.rb
|
147
|
+
- lib/minfraud/errors.rb
|
148
|
+
- lib/minfraud/http_service.rb
|
149
|
+
- lib/minfraud/http_service/request.rb
|
150
|
+
- lib/minfraud/http_service/response.rb
|
151
|
+
- lib/minfraud/model/abstract.rb
|
152
|
+
- lib/minfraud/model/address.rb
|
153
|
+
- lib/minfraud/model/billing_address.rb
|
154
|
+
- lib/minfraud/model/credit_card.rb
|
155
|
+
- lib/minfraud/model/device.rb
|
156
|
+
- lib/minfraud/model/disposition.rb
|
157
|
+
- lib/minfraud/model/email.rb
|
158
|
+
- lib/minfraud/model/email_domain.rb
|
159
|
+
- lib/minfraud/model/error.rb
|
160
|
+
- lib/minfraud/model/factors.rb
|
161
|
+
- lib/minfraud/model/geoip2_location.rb
|
162
|
+
- lib/minfraud/model/insights.rb
|
163
|
+
- lib/minfraud/model/ip_address.rb
|
164
|
+
- lib/minfraud/model/issuer.rb
|
165
|
+
- lib/minfraud/model/score.rb
|
166
|
+
- lib/minfraud/model/score_ip_address.rb
|
167
|
+
- lib/minfraud/model/shipping_address.rb
|
168
|
+
- lib/minfraud/model/subscores.rb
|
169
|
+
- lib/minfraud/model/warning.rb
|
170
|
+
- lib/minfraud/report.rb
|
171
|
+
- lib/minfraud/resolver.rb
|
172
|
+
- lib/minfraud/version.rb
|
173
|
+
- minfraud.gemspec
|
174
|
+
homepage: https://github.com/maxmind/minfraud-api-ruby
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '1.9'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.7.6.2
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Ruby interface to the MaxMind minFraud v2.0 API services
|
198
|
+
test_files: []
|