minfraud 1.0.4 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/rubocop.yml +12 -0
  3. data/.github/workflows/test.yml +32 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +108 -0
  6. data/CHANGELOG.md +72 -3
  7. data/CODE_OF_CONDUCT.md +4 -4
  8. data/Gemfile +11 -2
  9. data/LICENSE.txt +2 -1
  10. data/README.dev.md +4 -0
  11. data/README.md +245 -59
  12. data/Rakefile +9 -3
  13. data/bin/console +4 -3
  14. data/lib/maxmind/geoip2/model/city.rb +99 -0
  15. data/lib/maxmind/geoip2/model/country.rb +94 -0
  16. data/lib/maxmind/geoip2/model/insights.rb +38 -0
  17. data/lib/maxmind/geoip2/record/abstract.rb +46 -0
  18. data/lib/maxmind/geoip2/record/city.rb +62 -0
  19. data/lib/maxmind/geoip2/record/continent.rb +61 -0
  20. data/lib/maxmind/geoip2/record/country.rb +78 -0
  21. data/lib/maxmind/geoip2/record/location.rb +97 -0
  22. data/lib/maxmind/geoip2/record/maxmind.rb +41 -0
  23. data/lib/maxmind/geoip2/record/place.rb +52 -0
  24. data/lib/maxmind/geoip2/record/postal.rb +54 -0
  25. data/lib/maxmind/geoip2/record/represented_country.rb +47 -0
  26. data/lib/maxmind/geoip2/record/subdivision.rb +72 -0
  27. data/lib/maxmind/geoip2/record/traits.rb +233 -0
  28. data/lib/minfraud.rb +48 -8
  29. data/lib/minfraud/assessments.rb +118 -49
  30. data/lib/minfraud/components/account.rb +31 -9
  31. data/lib/minfraud/components/addressable.rb +73 -26
  32. data/lib/minfraud/components/base.rb +26 -14
  33. data/lib/minfraud/components/billing.rb +5 -0
  34. data/lib/minfraud/components/credit_card.rb +64 -20
  35. data/lib/minfraud/components/custom_inputs.rb +25 -0
  36. data/lib/minfraud/components/device.rb +51 -10
  37. data/lib/minfraud/components/email.rb +29 -7
  38. data/lib/minfraud/components/event.rb +60 -13
  39. data/lib/minfraud/components/order.rb +59 -22
  40. data/lib/minfraud/components/payment.rb +166 -21
  41. data/lib/minfraud/components/report/transaction.rb +80 -0
  42. data/lib/minfraud/components/shipping.rb +14 -5
  43. data/lib/minfraud/components/shopping_cart.rb +19 -12
  44. data/lib/minfraud/components/shopping_cart_item.rb +42 -13
  45. data/lib/minfraud/enum.rb +22 -8
  46. data/lib/minfraud/error_handler.rb +45 -18
  47. data/lib/minfraud/errors.rb +22 -2
  48. data/lib/minfraud/http_service.rb +23 -9
  49. data/lib/minfraud/http_service/request.rb +19 -18
  50. data/lib/minfraud/http_service/response.rb +49 -12
  51. data/lib/minfraud/model/abstract.rb +20 -0
  52. data/lib/minfraud/model/address.rb +52 -0
  53. data/lib/minfraud/model/billing_address.rb +11 -0
  54. data/lib/minfraud/model/credit_card.rb +75 -0
  55. data/lib/minfraud/model/device.rb +54 -0
  56. data/lib/minfraud/model/disposition.rb +35 -0
  57. data/lib/minfraud/model/email.rb +54 -0
  58. data/lib/minfraud/model/email_domain.rb +24 -0
  59. data/lib/minfraud/model/error.rb +28 -0
  60. data/lib/minfraud/model/factors.rb +24 -0
  61. data/lib/minfraud/model/geoip2_location.rb +25 -0
  62. data/lib/minfraud/model/insights.rb +68 -0
  63. data/lib/minfraud/model/ip_address.rb +86 -0
  64. data/lib/minfraud/model/issuer.rb +49 -0
  65. data/lib/minfraud/model/score.rb +76 -0
  66. data/lib/minfraud/model/score_ip_address.rb +23 -0
  67. data/lib/minfraud/model/shipping_address.rb +30 -0
  68. data/lib/minfraud/model/subscores.rb +178 -0
  69. data/lib/minfraud/model/warning.rb +63 -0
  70. data/lib/minfraud/report.rb +58 -0
  71. data/lib/minfraud/resolver.rb +25 -16
  72. data/lib/minfraud/validates.rb +187 -0
  73. data/lib/minfraud/version.rb +4 -1
  74. data/minfraud.gemspec +23 -18
  75. metadata +113 -39
  76. data/.travis.yml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 360e5c67027b7cac3bacd6715aa3afee61de8a75
4
- data.tar.gz: cb6dd240c3436fe0c0c23e7aa6d5ad5c4bcfcae8
2
+ SHA256:
3
+ metadata.gz: aa255a8f579aa729b4ceeb84db99f283bafdc2276fc6eba3d52e6133a8e2d4ea
4
+ data.tar.gz: 1d9717004f0f07eadf3d986f4f697f4d2c41ef7c08c21b9b1f3b7e6291c36286
5
5
  SHA512:
6
- metadata.gz: c3cb59ad5bde816f3b2f8be3cc1f0699ce18c1728a8267d7e827b28e8fecd0a20c638211f453a0f8dee2ea7c252096193293633ca5ecf4e3a640f632e5201dfb
7
- data.tar.gz: 2b430855a1157e215891a09a1cf0aab79bad1a027e272359a536caf81db8958835e06f591393a9782b22c90655017b91475eff775208f964a4ae0ca44bb1dd43
6
+ metadata.gz: a57eac0733d6c1d64319c80f458f00585897030433414ab0b4888606fedafac833e5fd1298fe608f8a343b87536ad2974bc794bba9317a5043980aa689c2e0cd
7
+ data.tar.gz: 0ef9a279e2ed6d9a08b3f972338f7ade34ecf1f2c409e6777333c9a6afcf1dbab3c03927b8e6a350c54ed4dd2c86bdd64672a36f51caa2087bfb8e53ab824b2a
@@ -0,0 +1,12 @@
1
+ name: Run rubocop
2
+ on: [push, pull_request]
3
+ jobs:
4
+ rubocop:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v2
8
+ - uses: ruby/setup-ruby@v1
9
+ with:
10
+ ruby-version: 2.7
11
+ - run: bundle install
12
+ - run: bundle exec rake -t rubocop
@@ -0,0 +1,32 @@
1
+ name: Run tests
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ${{ matrix.os }}
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ os: [ubuntu-latest, windows-latest, macos-latest]
10
+ version:
11
+ [
12
+ 2.1,
13
+ 2.2,
14
+ 2.3,
15
+ 2.4,
16
+ 2.5,
17
+ 2.6,
18
+ 2.7,
19
+ jruby,
20
+ ]
21
+ exclude:
22
+ - os: windows-latest
23
+ version: jruby
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ with:
27
+ submodules: true
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.version }}
31
+ - run: bundle install
32
+ - run: bundle exec rake -t spec
data/.gitignore CHANGED
@@ -1,7 +1,9 @@
1
+ /coverage
1
2
  pkg
2
3
  .project
3
4
  Gemfile.lock
4
5
  .rvmrc
5
6
  *.rbc
7
+ .yardoc
6
8
  *~
7
9
  .DS_Store
@@ -0,0 +1,108 @@
1
+ Gemspec/RequiredRubyVersion:
2
+ Enabled: false # We support 2.1+, but rubocop supports 2.4+.
3
+
4
+ # Metrics.
5
+
6
+ Metrics/BlockLength:
7
+ Enabled: false # Default is true, but mostly hit in tests.
8
+
9
+ Metrics/AbcSize:
10
+ Enabled: false # To allow for pre-existing code.
11
+
12
+ Metrics/ClassLength:
13
+ Enabled: false # To allow for pre-existing code.
14
+
15
+ Metrics/CyclomaticComplexity:
16
+ Enabled: false # To allow for pre-existing code.
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false # To allow for pre-existing code.
20
+
21
+ Metrics/PerceivedComplexity:
22
+ Enabled: false # To allow for pre-existing code.
23
+
24
+ # Layout.
25
+
26
+ Layout/LineLength:
27
+ Max: 150 # Default is 120.
28
+
29
+ Layout/HashAlignment:
30
+ EnforcedHashRocketStyle: table # Default is key.
31
+ EnforcedColonStyle: table # Default is key.
32
+
33
+ Layout/ExtraSpacing:
34
+ ForceEqualSignAlignment: true # Default is false.
35
+
36
+ Layout/IndentationStyle:
37
+ IndentationWidth: 2 # Default is <none>.
38
+
39
+ # Style.
40
+
41
+ Style/HashSyntax:
42
+ EnforcedStyle: ruby19_no_mixed_keys # Default is ruby19.
43
+
44
+ Style/CollectionMethods:
45
+ Enabled: true # Default is false.
46
+
47
+ Style/NumericLiterals:
48
+ MinDigits: 4 # Default is 5.
49
+
50
+ Style/NegatedIf: # I disagree with this.
51
+ Enabled: false
52
+
53
+ Style/IfUnlessModifier: # This doesn't always make sense.
54
+ Enabled: false
55
+
56
+ Style/SymbolArray:
57
+ EnforcedStyle: brackets # Default is percent, but 1.9 doesn't support that.
58
+
59
+ # Trailing commas are often good.
60
+ Style/TrailingCommaInArguments:
61
+ Enabled: false
62
+ Style/TrailingCommaInArrayLiteral:
63
+ Enabled: false
64
+ Style/TrailingCommaInHashLiteral:
65
+ Enabled: false
66
+
67
+ Style/SafeNavigation:
68
+ Enabled: false # Default is true, but this 1.9 doesn't support it.
69
+
70
+ # Default is both which is probably fine, but it changes code and I don't want
71
+ # to investigate any possible behavior change right now.
72
+ Style/EmptyElse:
73
+ EnforcedStyle: empty
74
+
75
+ Style/ConditionalAssignment:
76
+ Enabled: false # This produces kind of strange results.
77
+
78
+ Style/Dir:
79
+ Enabled: false # This is good, but not supported on 1.9.
80
+
81
+ Style/ExpandPathArguments:
82
+ Enabled: false # This causes us to use __dir__ which 1.9 doesn't support.
83
+
84
+ Style/GuardClause:
85
+ Enabled: false # Doesn't always make sense.
86
+
87
+ Style/Documentation:
88
+ Enabled: false # We should enable this, but allow for pre-existing code.
89
+
90
+ Style/FormatStringToken:
91
+ Enabled: false # Seems unnecessary.
92
+
93
+ # Asks to use x.negative? instead of x < 0. But this isn't available until 2.3.
94
+ Style/NumericPredicate:
95
+ Enabled: false
96
+
97
+ # Seems unnecessary. Asks us to call super in a bunch of places when there's no
98
+ # need.
99
+ Lint/MissingSuper:
100
+ Enabled: false
101
+
102
+ # Naming.
103
+
104
+ Naming/VariableNumber:
105
+ Enabled: false # Doesn't always make sense.
106
+
107
+ AllCops:
108
+ NewCops: enable
@@ -1,14 +1,83 @@
1
1
  # Minfraud Changelog
2
2
 
3
- ## v1.0.4
3
+ ## v1.4.1 (2020-12-01)
4
+
5
+ * Do not throw an exception if the response does not include IP address
6
+ information. Previously we would incorrectly try to retrieve fields from
7
+ `nil`, leading to a `NoMethodError`.
8
+
9
+ ## v1.4.0 (2020-10-13)
10
+
11
+ * IMPORTANT: Ruby 2.0 is no longer supported. If you're using Ruby 2.0,
12
+ please use version 1.3.0.
13
+ * Add handling for the `REQUEST_INVALID` error code.
14
+ * The IP address is no longer a required input.
15
+ * Adds new payment processor `:tsys` to `Minfraud::Components::Payment`.
16
+
17
+ ## v1.3.0 (2020-09-25)
18
+
19
+ * Adds support for persistent HTTP connections. Connections persist
20
+ automatically.
21
+ * IMPORTANT: Ruby 1.9 is no longer supported. If you're using Ruby 1.9,
22
+ please use version 1.2.0 or older.
23
+ * Adds support for client side validation of inputs. An `InvalidInputError`
24
+ exception will be raised if an input is invalid. This can be enabled by
25
+ setting `enable_validation` to `true` when configuring `Minfraud`. It is
26
+ disabled by default.
27
+ * Adds the `residential_proxy?` method to `MaxMind::GeoIP2::Record::Traits`
28
+ for use with minFraud Insights and Factors.
29
+
30
+ ## v1.2.0 (2020-07-15)
31
+
32
+ * Adds new processor types to `Minfraud::Components::Payment`: `:cashfree`,
33
+ `:first_atlantic_commerce`, `:komoju`, `:paytm`, `:razorpay`, and
34
+ `:systempay`.
35
+ * Adds support for three new Factors outputs: `/subscores/device` (the risk
36
+ associated with the device), `/subscores/email_local_part` (the risk
37
+ associated with the part of the email address before the @ symbol) and
38
+ `/subscores/shipping_address` (the risk associated with the shipping
39
+ address).
40
+ * Adds support for providing your MaxMind account ID using the `account_id`
41
+ attribute instead of the `user_id` attribute. In a future release,
42
+ support for the `user_id` attribute will be removed.
43
+
44
+ ## v1.1.0 (2020-06-19)
45
+
46
+ * Adds support for the minFraud Report Transaction API. Reporting
47
+ transactions to MaxMind helps us detect about 10-50% more fraud and
48
+ reduce false positives for you.
49
+ * Adds support for the new credit card output `/credit_card/is_business`.
50
+ This indicates whether the card is a business card. It may be accessed
51
+ via `response.credit_credit.is_business` on the minFraud Insights and
52
+ Factors response objects.
53
+ * Adds support for the new email domain output `/email/domain/first_seen`.
54
+ This may be accessed via `response.email.domain.first_seen` on the
55
+ minFraud Insights and Factors response objects.
56
+ * Rename `ErrorHandler#inspect` to `ErrorHandler#examine` in order not to
57
+ break LSP.
58
+ * Adds classes for the Score, Insights, and Factors responses. This allows
59
+ us to provide API documentation for the various response attributes.
60
+ * Removes `hashie` as a required dependency.
61
+ * Adds new processor types to `Minfraud::Components::Payment`: `:affirm`,
62
+ `:afterpay`, `:cardpay`, `:ccavenue`, `:cetelem`, `:ct_payments`,
63
+ `:dalenys`, `:datacash`, `:dotpay`, `:ecommpay`, `:epx`, `:g2a_pay`,
64
+ `:gocardless`, `:interac`, `:klarna`, `:mercanet`, `:oney`, `:payeezy`,
65
+ `:paylike`, `:payment_express`, `:paysafecard`, `:posconnect`,
66
+ `:smartdebit`, `:synapsefi`, and others.
67
+ * Adds support for passing custom inputs to minFraud. GitHub #6.
68
+ * Adds `:email_change`, `:password_reset`, and `:payout_change` as types to
69
+ `Minfraud::Components::Event`.
70
+ * Adds support for the `session_id` and `session_age` inputs.
71
+
72
+ ## v1.0.4 (2016-12-23)
4
73
 
5
74
  * Prevents boolean value conversion to string to avoid warnings
6
75
  * Adds `amount` attribute to the `Minfraud::Components::Order` instances
7
76
 
8
- ## v1.0.3
77
+ ## v1.0.3 (2016-11-24)
9
78
  * Adds `token` attribute to the `Minfraud::Components::CreditCard` instances
10
79
  according to the MinFraud Release Notes introduced on November 17, 2016
11
80
 
12
- ## v1.0.2
81
+ ## v1.0.2 (2016-10-11)
13
82
 
14
83
  * Adds support for Ruby >= 1.9
@@ -35,7 +35,7 @@ This code of conduct applies both within project spaces and in public spaces
35
35
  when an individual is representing the project or its community.
36
36
 
37
37
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at kushnir.yb@gmail.com. All
38
+ reported by contacting a project maintainer at support@maxmind.com. All
39
39
  complaints will be reviewed and investigated and will result in a response that
40
40
  is deemed necessary and appropriate to the circumstances. Maintainers are
41
41
  obligated to maintain confidentiality with regard to the reporter of an
@@ -43,7 +43,7 @@ incident.
43
43
 
44
44
  This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
45
  version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
46
+ [https://contributor-covenant.org/version/1/3/0/][version]
47
47
 
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
48
+ [homepage]: https://contributor-covenant.org
49
+ [version]: https://contributor-covenant.org/version/1/3/0/
data/Gemfile CHANGED
@@ -1,5 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- # Specify your gem's dependencies in minfraud.gemspec
4
- gem 'coveralls', require: false
5
+ # coveralls fails on Ruby 1.9. My understanding is we don't need to run this on
6
+ # more than one version anyway, so restrict to the current latest.
7
+ version_pieces = RUBY_VERSION.split('.')
8
+ major_version = version_pieces[0]
9
+ minor_version = version_pieces[1]
10
+ if major_version == '2' && minor_version == '7'
11
+ gem 'coveralls', require: false
12
+ end
13
+
5
14
  gemspec
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 kushnir.yb
3
+ Copyright (c) 2016-2020 kushnir.yb
4
+ Copyright (c) 2020 MaxMind, Inc.
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,4 @@
1
+ # How to release
2
+
3
+ See
4
+ [here](https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/master/README.dev.md).
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
- # Simple Ruby Wrapper to the MaxMind minFraud API
1
+ # Ruby API for MaxMind minFraud Services
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/kushniryb/minfraud-api-v2/badges/gpa.svg)](https://codeclimate.com/github/kushniryb/minfraud-api-v2)
4
- [![Coverage Status](https://coveralls.io/repos/github/kushniryb/minfraud-api-v2/badge.svg?branch=master)](https://coveralls.io/github/kushniryb/minfraud-api-v2?branch=master)
5
- [![Build Status](https://travis-ci.org/kushniryb/minfraud-api-v2.svg?branch=master)](https://travis-ci.org/kushniryb/minfraud-api-v2)
3
+ ## Description
6
4
 
7
- Compatible with version minFraud API v2.0
5
+ This package provides an API for the [MaxMind minFraud web
6
+ services](https://dev.maxmind.com/minfraud/). This includes minFraud Score,
7
+ Insights, and Factors. It also includes our [minFraud Report Transaction
8
+ API](https://dev.maxmind.com/minfraud/report-transaction/).
8
9
 
9
- [minFraud API documentation](http://dev.maxmind.com/minfraud/)
10
+ The legacy minFraud Standard and Premium services are not supported by this
11
+ API.
10
12
 
11
13
  ## Installation
12
14
 
@@ -18,90 +20,274 @@ gem 'minfraud'
18
20
 
19
21
  And then execute:
20
22
 
21
- ```ruby
23
+ ```
22
24
  $ bundle
23
25
  ```
24
26
 
25
27
  Or install it yourself as:
28
+
26
29
  ```
27
30
  $ gem install minfraud
28
31
  ```
29
32
 
30
- ## Configuration
33
+ ## API Documentation
34
+
35
+ See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
36
+ more details.
37
+
38
+ ## Usage
31
39
 
32
- User Id and License Key are required to work with minFraud API
40
+ ### Configuration
41
+
42
+ An account ID and license key are required to work with the web services.
43
+ Configure these before making a request:
33
44
 
34
45
  ```ruby
35
46
  Minfraud.configure do |c|
47
+ c.account_id = 12345
36
48
  c.license_key = 'your_license_key'
37
- c.user_id = 'your_user_id'
49
+ c.enable_validation = true
38
50
  end
39
- ```
51
+ ````
52
+
53
+ ### Making a minFraud Score, Insights, or Factors Request
54
+
55
+ To use the minFraud API, create a `Minfraud::Assessments` object. The
56
+ constructor takes a hash of symbols corresponding to each component of the
57
+ minFraud request. You can also set components by their attribute after
58
+ creating the object.
59
+
60
+ After populating the object, call the method for the minFraud endpoint you
61
+ want to use: `#score`, `#insights`, or `#factors`. The returned value is a
62
+ `MinFraud::Response` object. You can access the response model through its
63
+ `#body` attribute.
64
+
65
+ An exception will be thrown for critical errors. You should check for
66
+ `warnings` related to your inputs after a request.
40
67
 
41
- ## Usage
42
68
  ```ruby
43
- # You can either provide a hash of params to initializer
69
+ # Prepare the request.
44
70
  assessment = Minfraud::Assessments.new(
45
71
  device: {
46
- ip_address: '1.2.3.4.5'
47
- }
72
+ ip_address: '152.216.7.110',
73
+ accept_language: 'en-US,en;q=0.8',
74
+ session_age: 3600.5,
75
+ session_id: 'foo',
76
+ user_agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
77
+ },
78
+ event: {
79
+ transaction_id: 'txn3134133',
80
+ shop_id: 's2123',
81
+ time: '2012-04-12T23:20:50+00:00',
82
+ type: :purchase,
83
+ },
84
+ account: {
85
+ user_id: '3132',
86
+ username_md5: '4f9726678c438914fa04bdb8c1a24088',
87
+ },
88
+ email: {
89
+ address: 'test@maxmind.com',
90
+ domain: 'maxmind.com',
91
+ },
92
+ billing: {
93
+ first_name: 'First',
94
+ last_name: 'Last',
95
+ company: 'Company',
96
+ address: '101 Address Rd.',
97
+ address_2: 'Unit 5',
98
+ city: 'New Haven',
99
+ region: 'CT',
100
+ country: 'US',
101
+ postal: '06510',
102
+ phone_number: '123-456-7890',
103
+ phone_country_code: '1',
104
+ },
105
+ shipping: {
106
+ first_name: 'ShipFirst',
107
+ last_name: 'ShipLast',
108
+ company: 'ShipCo',
109
+ address: '322 Ship Addr. Ln.',
110
+ address_2: 'St. 43',
111
+ city: 'Nowhere',
112
+ region: 'OK',
113
+ country: 'US',
114
+ postal: '73003',
115
+ phone_number: '123-456-0000',
116
+ phone_country_code: '1',
117
+ delivery_speed: :same_day,
118
+ },
119
+ payment: {
120
+ processor: :stripe,
121
+ was_authorized: false,
122
+ decline_code: 'invalid number',
123
+ },
124
+ credit_card: {
125
+ issuer_id_number: '411111',
126
+ last_4_digits: '7643',
127
+ bank_name: 'Bank of No Hope',
128
+ bank_phone_country_code: '1',
129
+ bank_phone_number: '123-456-1234',
130
+ token: 'abcd',
131
+ avs_result: 'Y',
132
+ cvv_result: 'N',
133
+ },
134
+ order: {
135
+ amount: 323.21,
136
+ currency: 'USD',
137
+ discount_code: 'FIRST',
138
+ is_gift: true,
139
+ has_gift_message: false,
140
+ affiliate_id: 'af12',
141
+ subaffiliate_id: 'saf42',
142
+ referrer_uri: 'http://www.amazon.com/',
143
+ },
144
+ shopping_cart: [
145
+ {
146
+ category: 'pets',
147
+ item_id: 'leash-0231',
148
+ quantity: 2,
149
+ price: 20.43,
150
+ },
151
+ {
152
+ category: 'beauty',
153
+ item_id: 'msc-1232',
154
+ quantity: 1,
155
+ price: 100.00,
156
+ },
157
+ ],
158
+ custom_inputs: {
159
+ section: 'news',
160
+ previous_purchases: 19,
161
+ discount: 3.2,
162
+ previous_user: true,
163
+ },
48
164
  )
49
- # or create a component and assign them to assessments object directly, e.g
50
- device = Minfraud::Components::Device.new(ip_address: '1.2.3.4.5')
51
- assessment = Minfraud::Assessments.new(device: device)
52
- # or
53
- assessment = Minfraud::Assessments.new
54
- assessment.device = device
55
- # There are multiple components that reflect minFraud request top level keys
56
-
57
- # Some components will raise an error if provided with the wrong values for attributes, e.g
58
- event = Minfraud::Components::Event.new(type: 'foobar') # => Minfraud::NotEnumValueError
59
- # You can check the list of permitted values for the attribute by calling a class method
60
- Minfraud::Components::Event.type_values # => ["account_creation", "account_login", ....]
61
-
62
- # You can now call 3 different minFraud endpoints: score, insights, factors
63
- assessment.insights
64
- assessment.factors
65
-
66
- result = assessment.score # => Minfraud::Response instance
67
-
68
- result.status # => Response status code
69
- result.code # => minFraud specific response code
70
- result.body # => Mashified body
71
- result.headers # => Response headers
72
-
73
- # You can also change data inbetween requests
74
- first_request = assessment.insights
75
- assessment.device.ip_address = '22.22.22.33'
76
- second_request = assessment.insights
165
+
166
+ # To get the Factors response model, use #factors.
167
+ factors_model = assessment.factors.body
168
+
169
+ factors_model.warnings.each { |w| puts w.warning }
170
+
171
+ p factors_model.subscores.email_address
172
+ p factors_model.risk_score
173
+
174
+ # To get the Insights response model, use #insights.
175
+ insights_model = assessment.insights.body
176
+
177
+ insights_model.warnings.each { |w| puts w.warning }
178
+
179
+ p insights_model.credit_card.issuer.name
180
+ p insights_model.risk_score
181
+
182
+ # To get the Score response model, use #score.
183
+ score_model = assessment.score.body
184
+
185
+ score_model.warnings.each { |w| puts w.warning }
186
+
187
+ p score_model.risk_score
77
188
  ```
78
189
 
79
- ### Exception handling
190
+ See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
191
+ more details.
80
192
 
81
- Gem is supplied with four different types of exceptions:
82
- ```ruby
83
- # Raised if unpermitted key is provided to Minfraud::Assessments initializer
84
- class RequestFormatError < BaseError; end
193
+ ### Reporting a Transaction to MaxMind
85
194
 
86
- # Raised if IP address is absent / it is reserved / JSON body can not be decoded
87
- class ClientError < BaseError; end
195
+ MaxMind encourages the use of this API, as data received through this
196
+ channel is used to improve the accuracy of their fraud detection
197
+ algorithms.
88
198
 
89
- # Raised if there are some problems with the user id and / or license key
90
- class AuthorizationError < BaseError; end
199
+ To use the Report Transaction API, create a
200
+ `Minfraud::Components::Report::Transaction` object. An IP address and a
201
+ valid tag are required arguments for this API. Additional parameters may be
202
+ set, as shown below.
91
203
 
92
- # Raised if minFraud returns an error, or if there is an HTTP error
93
- class ServerError < BaseError; end
204
+ If the report is successful, nothing is returned. If the report fails, an
205
+ exception will be thrown.
94
206
 
95
- # Raised if an attribute value doesn't belong to the predefined set of values
96
- class NotEnumValueError < BaseError; end
207
+ ```ruby
208
+ # The report_transaction method only makes use of a transaction component:
209
+ txn = Minfraud::Components::Report::Transaction.new(
210
+ ip_address: '152.216.7.110',
211
+ tag: :suspected_fraud,
212
+ maxmind_id: '12345678',
213
+ minfraud_id: '58fa38d8-4b87-458b-a22b-f00eda1aa20d',
214
+ notes: 'notes go here',
215
+ transaction_id: '1FA254yZ'
216
+ )
217
+ reporter = Minfraud::Report.new(transaction: txn)
218
+ reporter.report_transaction
97
219
  ```
98
220
 
221
+ See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
222
+ more details.
223
+
224
+ ### Persistent HTTP Connections
225
+
226
+ This gem supports persistent HTTP connections, allowing you to avoid the
227
+ overhead of creating a new HTTP connection for each minFraud request if you
228
+ plan to perform more than one. You do not need to do anything to enable
229
+ this functionality.
230
+
231
+ ### Exceptions
232
+
233
+ The gem supplies several distinct exception-types:
234
+
235
+ * `RequestFormatError` - Raised if an unknown key is provided to the
236
+ `Minfraud::Assessments` constructor
237
+ * `ClientError` - Raised if the IP address is absent, reserved, or the JSON
238
+ body cannot be decoded
239
+ * `AuthorizationError` - Raised if there are problems with the account ID
240
+ and/or license key
241
+ * `ServerError` - Raised if minFraud returns an error or if there is an
242
+ HTTP error
243
+ * `NotEnumValueError` - Raised if an attribute value doesn't belong to the
244
+ predefined set of values
245
+
246
+ ### Thread Safety
247
+
248
+ This gem is safe for use from multiple threads.
249
+
250
+ `Minfraud::Assessments` and `Minfraud::Report` objects must not be shared
251
+ across threads.
252
+
253
+ Please note that you must run `Minfraud.configure` before calling any
254
+ functionality using multiple threads.
255
+
256
+ ## Support
257
+
258
+ Please report all issues with this code using the
259
+ [GitHub issue tracker](https://github.com/maxmind/minfraud-api-ruby/issues).
260
+
261
+ If you are having an issue with the minFraud service that is not specific
262
+ to the client API, please see
263
+ [our support page](https://www.maxmind.com/en/support).
264
+
265
+ ## Requirements
266
+
267
+ This gem works with Ruby 2.1 and above.
268
+
99
269
  ## Contributing
100
270
 
101
- Bug reports and pull requests are welcome on GitHub [here](https://github.com/kushniryb/minfraud-api-v2). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
271
+ Bug reports and pull requests are welcome on
272
+ [GitHub](https://github.com/maxmind/minfraud-api-ruby). This project is
273
+ intended to be a safe, welcoming space for collaboration, and contributors
274
+ are expected to adhere to the [Contributor
275
+ Covenant](https://contributor-covenant.org) code of conduct.
276
+
277
+ ## Versioning
278
+
279
+ This API uses [Semantic Versioning](https://semver.org/).
280
+
281
+ ## Copyright and License
282
+
283
+ Copyright (c) 2016-2020 kushnir.yb.
102
284
 
285
+ Copyright (c) 2020 MaxMind, Inc.
103
286
 
104
- ## License
287
+ The gem is available as open source under the terms of the [MIT
288
+ License](https://opensource.org/licenses/MIT).
105
289
 
106
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
290
+ ## Thank You
107
291
 
292
+ This gem is the work of the creator and original maintainer kushnir.yb
293
+ (@kushniryb).