Skip to content

Commit 43bfc71

Browse files
horghclaude
andcommitted
Add party enum field to Event component
Add new party field to Event component with agent and customer values to specify the party submitting the transaction. Includes comprehensive test coverage and documentation updates. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d362db6 commit 43bfc71

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
version 2.8.0 of this gem.
88
* Added `/event/type` values `:credit_application` and `:fund_transfer` to
99
`Minfraud::Components::Event`.
10+
* Added the input `/event/party`. This is the party submitting the
11+
transaction. You may provide this using the `party` attribute on
12+
`Minfraud::Components::Event`.
1013

1114
## v2.8.0 (2025-05-23)
1215

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ assessment = Minfraud::Assessments.new(
8686
user_agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
8787
},
8888
event: {
89+
party: :customer,
8990
transaction_id: 'txn3134133',
9091
shop_id: 's2123',
9192
time: '2012-04-12T23:20:50+00:00',

lib/minfraud/components/event.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ class Event < Base
99
include ::Minfraud::Enum
1010
include Minfraud::Validates
1111

12+
# The party submitting the transaction. This must be one of +:agent+ or
13+
# +:customer+.
14+
#
15+
# @!attribute party
16+
#
17+
# @return [Symbol, nil]
18+
enum_accessor :party,
19+
%i[
20+
agent
21+
customer
22+
]
23+
1224
# Your internal ID for the transaction. MaxMind can use this to locate a
1325
# specific transaction in logs, and it will also show up in email alerts
1426
# and notifications from MaxMind to you. No specific format is required.
@@ -61,6 +73,7 @@ class Event < Base
6173
# @param params [Hash] Hash of parameters. Each key/value should
6274
# correspond to one of the available attributes.
6375
def initialize(params = {})
76+
self.party = params[:party]
6477
@transaction_id = params[:transaction_id]
6578
@shop_id = params[:shop_id]
6679
@time = params[:time]

spec/components/event_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
end.to raise_exception(Minfraud::NotEnumValueError)
1212
end
1313
end
14+
15+
context 'with an invalid party' do
16+
it 'raises an exception' do
17+
expect do
18+
described_class.new({ party: :invalid })
19+
end.to raise_exception(Minfraud::NotEnumValueError)
20+
end
21+
end
1422
end
1523

1624
describe 'validation' do
@@ -43,5 +51,17 @@
4351
type: :fund_transfer,
4452
)
4553
end
54+
55+
it 'accepts agent as a valid party' do
56+
described_class.new(
57+
party: :agent,
58+
)
59+
end
60+
61+
it 'accepts customer as a valid party' do
62+
described_class.new(
63+
party: :customer,
64+
)
65+
end
4666
end
4767
end

0 commit comments

Comments
 (0)