minfraud 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +20 -3
  4. data/CHANGELOG.md +31 -3
  5. data/CODE_OF_CONDUCT.md +4 -4
  6. data/Gemfile +9 -2
  7. data/LICENSE.txt +2 -1
  8. data/README.dev.md +4 -0
  9. data/README.md +106 -35
  10. data/lib/maxmind/geoip2/model/city.rb +99 -0
  11. data/lib/maxmind/geoip2/model/country.rb +94 -0
  12. data/lib/maxmind/geoip2/model/insights.rb +38 -0
  13. data/lib/maxmind/geoip2/record/abstract.rb +46 -0
  14. data/lib/maxmind/geoip2/record/city.rb +62 -0
  15. data/lib/maxmind/geoip2/record/continent.rb +61 -0
  16. data/lib/maxmind/geoip2/record/country.rb +78 -0
  17. data/lib/maxmind/geoip2/record/location.rb +97 -0
  18. data/lib/maxmind/geoip2/record/maxmind.rb +41 -0
  19. data/lib/maxmind/geoip2/record/place.rb +52 -0
  20. data/lib/maxmind/geoip2/record/postal.rb +54 -0
  21. data/lib/maxmind/geoip2/record/represented_country.rb +47 -0
  22. data/lib/maxmind/geoip2/record/subdivision.rb +72 -0
  23. data/lib/maxmind/geoip2/record/traits.rb +224 -0
  24. data/lib/minfraud.rb +5 -3
  25. data/lib/minfraud/assessments.rb +14 -5
  26. data/lib/minfraud/components/account.rb +1 -1
  27. data/lib/minfraud/components/addressable.rb +1 -1
  28. data/lib/minfraud/components/custom_inputs.rb +14 -0
  29. data/lib/minfraud/components/device.rb +11 -0
  30. data/lib/minfraud/components/event.rb +12 -1
  31. data/lib/minfraud/components/payment.rb +124 -12
  32. data/lib/minfraud/components/report/transaction.rb +69 -0
  33. data/lib/minfraud/error_handler.rb +36 -16
  34. data/lib/minfraud/http_service.rb +0 -1
  35. data/lib/minfraud/http_service/response.rb +36 -4
  36. data/lib/minfraud/model/abstract.rb +20 -0
  37. data/lib/minfraud/model/address.rb +52 -0
  38. data/lib/minfraud/model/billing_address.rb +11 -0
  39. data/lib/minfraud/model/credit_card.rb +75 -0
  40. data/lib/minfraud/model/device.rb +54 -0
  41. data/lib/minfraud/model/disposition.rb +35 -0
  42. data/lib/minfraud/model/email.rb +54 -0
  43. data/lib/minfraud/model/email_domain.rb +24 -0
  44. data/lib/minfraud/model/error.rb +28 -0
  45. data/lib/minfraud/model/factors.rb +24 -0
  46. data/lib/minfraud/model/geoip2_location.rb +25 -0
  47. data/lib/minfraud/model/insights.rb +68 -0
  48. data/lib/minfraud/model/ip_address.rb +82 -0
  49. data/lib/minfraud/model/issuer.rb +49 -0
  50. data/lib/minfraud/model/score.rb +76 -0
  51. data/lib/minfraud/model/score_ip_address.rb +23 -0
  52. data/lib/minfraud/model/shipping_address.rb +30 -0
  53. data/lib/minfraud/model/subscores.rb +156 -0
  54. data/lib/minfraud/model/warning.rb +63 -0
  55. data/lib/minfraud/report.rb +38 -0
  56. data/lib/minfraud/resolver.rb +2 -1
  57. data/lib/minfraud/version.rb +1 -1
  58. data/minfraud.gemspec +16 -16
  59. metadata +61 -39
@@ -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
@@ -20,13 +20,14 @@ module Minfraud
20
20
  account: ::Minfraud::Components::Account,
21
21
  billing: ::Minfraud::Components::Billing,
22
22
  credit_card: ::Minfraud::Components::CreditCard,
23
+ custom_inputs: ::Minfraud::Components::CustomInputs,
23
24
  device: ::Minfraud::Components::Device,
24
25
  email: ::Minfraud::Components::Email,
25
26
  event: ::Minfraud::Components::Event,
26
27
  order: ::Minfraud::Components::Order,
27
28
  payment: ::Minfraud::Components::Payment,
28
29
  shipping: ::Minfraud::Components::Shipping,
29
- shopping_cart: ::Minfraud::Components::ShoppingCart
30
+ shopping_cart: ::Minfraud::Components::ShoppingCart,
30
31
  }
31
32
  end
32
33
  end
@@ -1,3 +1,3 @@
1
1
  module Minfraud
2
- VERSION = '1.0.4'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,29 +1,29 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', File.dirname(File.realpath(__FILE__)))
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
4
  require 'minfraud/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "minfraud"
7
+ spec.name = 'minfraud'
8
8
  spec.version = Minfraud::VERSION
9
- spec.authors = ["kushnir.yb"]
10
- spec.email = ["kushnir.yb@gmail.com"]
9
+ spec.authors = ['kushnir.yb']
10
+ spec.email = ['support@maxmind.com']
11
11
 
12
- spec.summary = %q{Ruby interface to the MaxMind minFraud v2.0 API services}
13
- spec.homepage = "https://github.com/kushniryb/minfraud-api-v2"
14
- spec.license = "MIT"
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
15
 
16
16
  spec.required_ruby_version = '>= 1.9'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
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'
22
25
 
23
- spec.add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.1'
24
- spec.add_runtime_dependency 'faraday_middleware', '~> 0.9', '>= 0.9.1'
25
- spec.add_runtime_dependency 'hashie', '~> 3.0'
26
- spec.add_development_dependency "bundler", "~> 1.12"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency 'bundler', '>= 1.16'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  end
metadata CHANGED
@@ -1,97 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfraud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kushnir.yb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 0.9.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
29
  version: 0.9.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: faraday_middleware
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0.9'
40
37
  - - ">="
41
38
  - !ruby/object:Gem::Version
42
39
  version: 0.9.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '0.9'
50
47
  - - ">="
51
48
  - !ruby/object:Gem::Version
52
49
  version: 0.9.1
53
- - !ruby/object:Gem::Dependency
54
- name: hashie
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
50
+ - - "<"
58
51
  - !ruby/object:Gem::Version
59
- version: '3.0'
60
- type: :runtime
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '3.0'
52
+ version: '2.0'
67
53
  - !ruby/object:Gem::Dependency
68
54
  name: bundler
69
55
  requirement: !ruby/object:Gem::Requirement
70
56
  requirements:
71
- - - "~>"
57
+ - - ">="
72
58
  - !ruby/object:Gem::Version
73
- version: '1.12'
59
+ version: '1.16'
74
60
  type: :development
75
61
  prerelease: false
76
62
  version_requirements: !ruby/object:Gem::Requirement
77
63
  requirements:
78
- - - "~>"
64
+ - - ">="
79
65
  - !ruby/object:Gem::Version
80
- version: '1.12'
66
+ version: '1.16'
81
67
  - !ruby/object:Gem::Dependency
82
68
  name: rake
83
69
  requirement: !ruby/object:Gem::Requirement
84
70
  requirements:
85
- - - "~>"
71
+ - - ">="
86
72
  - !ruby/object:Gem::Version
87
- version: '10.0'
73
+ version: '0'
88
74
  type: :development
89
75
  prerelease: false
90
76
  version_requirements: !ruby/object:Gem::Requirement
91
77
  requirements:
92
- - - "~>"
78
+ - - ">="
93
79
  - !ruby/object:Gem::Version
94
- version: '10.0'
80
+ version: '0'
95
81
  - !ruby/object:Gem::Dependency
96
82
  name: rspec
97
83
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +94,7 @@ dependencies:
108
94
  version: '3.0'
109
95
  description:
110
96
  email:
111
- - kushnir.yb@gmail.com
97
+ - support@maxmind.com
112
98
  executables: []
113
99
  extensions: []
114
100
  extra_rdoc_files: []
@@ -120,10 +106,25 @@ files:
120
106
  - CODE_OF_CONDUCT.md
121
107
  - Gemfile
122
108
  - LICENSE.txt
109
+ - README.dev.md
123
110
  - README.md
124
111
  - Rakefile
125
112
  - bin/console
126
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
127
128
  - lib/minfraud.rb
128
129
  - lib/minfraud/assessments.rb
129
130
  - lib/minfraud/components/account.rb
@@ -131,11 +132,13 @@ files:
131
132
  - lib/minfraud/components/base.rb
132
133
  - lib/minfraud/components/billing.rb
133
134
  - lib/minfraud/components/credit_card.rb
135
+ - lib/minfraud/components/custom_inputs.rb
134
136
  - lib/minfraud/components/device.rb
135
137
  - lib/minfraud/components/email.rb
136
138
  - lib/minfraud/components/event.rb
137
139
  - lib/minfraud/components/order.rb
138
140
  - lib/minfraud/components/payment.rb
141
+ - lib/minfraud/components/report/transaction.rb
139
142
  - lib/minfraud/components/shipping.rb
140
143
  - lib/minfraud/components/shopping_cart.rb
141
144
  - lib/minfraud/components/shopping_cart_item.rb
@@ -145,10 +148,30 @@ files:
145
148
  - lib/minfraud/http_service.rb
146
149
  - lib/minfraud/http_service/request.rb
147
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
148
171
  - lib/minfraud/resolver.rb
149
172
  - lib/minfraud/version.rb
150
173
  - minfraud.gemspec
151
- homepage: https://github.com/kushniryb/minfraud-api-v2
174
+ homepage: https://github.com/maxmind/minfraud-api-ruby
152
175
  licenses:
153
176
  - MIT
154
177
  metadata: {}
@@ -168,9 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
191
  version: '0'
169
192
  requirements: []
170
193
  rubyforge_project:
171
- rubygems_version: 2.6.6
194
+ rubygems_version: 2.7.6.2
172
195
  signing_key:
173
196
  specification_version: 4
174
197
  summary: Ruby interface to the MaxMind minFraud v2.0 API services
175
198
  test_files: []
176
- has_rdoc: