castle-rb 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '085ac2cdd6ebd7b69ab9171c72009c3f3d792c3d21d55b93d914abd93425098d'
4
- data.tar.gz: c31f5076e77d08c27d06b7722558b816a56868a51e7a2f885b9fc9236fc50615
3
+ metadata.gz: c138f51f6546b1a01b53f8542506e6e8566928d4b0907992d33dcb648788c9ee
4
+ data.tar.gz: d8f282e27ad75bad8e0d137b21ca15158ac3b6c3603f89098a3d77487cfa3658
5
5
  SHA512:
6
- metadata.gz: ecf515a3a5ff3a264a749171a6507d1c03635415359a392b8daafbf1e57291749e509501d449c902b1811903688a2499b7b845bc9cf27d167faa8412cb3ff40e
7
- data.tar.gz: 125266f1b4875f105b024b4bef5baf38175af1741e53c35cfe66ab7051dceb6adb76dda87b330ccdd48b06fc30bd4434283868e8be4de540752fbbbe06028ff9
6
+ metadata.gz: 9b5c96cf024088766cd6cf1dad0b6c371dcfee03241ec695fc148c08d5bafd5658b4731514db4e8cf88ad430607cf26650077ce0db2ee9b95d56d62459b6a987
7
+ data.tar.gz: 054deed51da4427e2c715b2e5f63a646d8acc73125e64d30b5d3fa2fadbd42119baf536d2b83e31b158fb5423f0b18b7d0bda67613d0f1fbb360c59c8f4959e3
data/CHANGELOG.md CHANGED
@@ -1,7 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.1.0
4
+
5
+ **Enhancements:**
6
+
7
+ - Add Events API support (enterprise) — three new client methods for querying event data:
8
+ - `events_schema` — `GET /v1/events/schema`
9
+ - `query_events` — `POST /v1/events/query`
10
+ - `group_events` — `POST /v1/events/group`
11
+
12
+ **Housekeeping:**
13
+
14
+ - Remove unused `Castle::Validators::NotSupported` (dead code)
15
+ - Remove unused `Session::HTTPS_SCHEME` constant; inline the comparison in `GetConnection`
16
+ - Replace deprecated `:mingw, :x64_mingw` Bundler platforms with `:windows`
17
+ - Bump Bundler 2.6.9 → 2.7.2
18
+ - Bump json 2.19.5 → 2.19.7
19
+
3
20
  ## master
4
21
 
22
+ - Bump dependencies (rack 3.1.19 → 3.2.6, rake, rspec-\*, timecop, simplecov-html, diff-lcs)
23
+ - Bump Ruby to 3.4.9 (zlib CVE-2026-27820)
24
+ - Bump Node.js to 24.16.0 in `.tool-versions`
25
+ - Repair `yarn format:check`: add `syntax_tree` to the dev group (required by `@prettier/plugin-ruby` 4.x), reformat 11 spec files, and disable rubocop cops that conflict with prettier-ruby (`Layout/SpaceInsideHashLiteralBraces`, `Style/EmptyMethod`)
26
+
5
27
  ## 9.0.0
6
28
 
7
29
  **BREAKING CHANGES:**
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module API
5
+ module Events
6
+ # Sends POST /events/group request
7
+ module Group
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Hash]
11
+ def call(options = {})
12
+ options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
13
+ http = options.delete(:http)
14
+ config = options.delete(:config) || Castle.config
15
+
16
+ Castle::API.call(Castle::Commands::Events::Group.build(options), {}, http, config)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module API
5
+ module Events
6
+ # Sends POST /events/query request
7
+ module Query
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Hash]
11
+ def call(options = {})
12
+ options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
13
+ http = options.delete(:http)
14
+ config = options.delete(:config) || Castle.config
15
+
16
+ Castle::API.call(Castle::Commands::Events::Query.build(options), {}, http, config)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module API
5
+ module Events
6
+ # Sends GET /events/schema request
7
+ module Schema
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Hash]
11
+ def call(options = {})
12
+ options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
13
+ http = options.delete(:http)
14
+ config = options.delete(:config) || Castle.config
15
+
16
+ Castle::API.call(Castle::Commands::Events::Schema.build(options), {}, http, config)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
data/lib/castle/client.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  module Castle
4
4
  # Castle's client.
5
5
  class Client
6
+ include Castle::ClientActions::Events
6
7
  include Castle::ClientActions::ListItems
7
8
  include Castle::ClientActions::Lists
8
9
  include Castle::ClientActions::Privacy
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module ClientActions
5
+ # Client actions for the Events API
6
+ module Events
7
+ # @param options [Hash]
8
+ def events_schema(options = {})
9
+ Castle::API::Events::Schema.call(options)
10
+ end
11
+
12
+ # @param options [Hash]
13
+ def query_events(options = {})
14
+ Castle::API::Events::Query.call(options)
15
+ end
16
+
17
+ # @param options [Hash]
18
+ def group_events(options = {})
19
+ Castle::API::Events::Group.call(options)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ module Events
6
+ # Builds the command to query aggregated events
7
+ class Group
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Castle::Command]
11
+ def build(options = {})
12
+ options[:filters]&.each { |f| Castle::Validators::Present.call(f, %i[field op value]) }
13
+ Castle::Validators::Present.call(options[:sort], %i[field order]) if options[:sort]
14
+
15
+ Castle::Command.new('events/group', options, :post)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ module Events
6
+ # Builds the command to query raw events
7
+ class Query
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Castle::Command]
11
+ def build(options = {})
12
+ options[:filters]&.each { |f| Castle::Validators::Present.call(f, %i[field op value]) }
13
+ Castle::Validators::Present.call(options[:sort], %i[field order]) if options[:sort]
14
+
15
+ Castle::Command.new('events/query', options, :post)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ module Events
6
+ # Builds the command to get the events schema
7
+ class Schema
8
+ class << self
9
+ # @param options [Hash]
10
+ # @return [Castle::Command]
11
+ def build(_options = {})
12
+ Castle::Command.new('events/schema', nil, :get)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -4,8 +4,6 @@ module Castle
4
4
  module Core
5
5
  # this module returns a new configured Net::HTTP object
6
6
  module GetConnection
7
- HTTPS_SCHEME = 'https'
8
-
9
7
  class << self
10
8
  # @param config [Castle::Configuration, Castle::SingletonConfiguration]
11
9
  # @return [Net::HTTP]
@@ -18,7 +16,7 @@ module Castle
18
16
  http.open_timeout = timeout_seconds
19
17
  http.read_timeout = timeout_seconds
20
18
 
21
- if config.base_url.scheme == HTTPS_SCHEME
19
+ if config.base_url.scheme == 'https'
22
20
  http.use_ssl = true
23
21
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
24
22
  end
@@ -5,8 +5,6 @@ module Castle
5
5
  # and provides start method for persistent connection usage
6
6
  # when there is a need of sending multiple requests at once
7
7
  module Session
8
- HTTPS_SCHEME = 'https'
9
-
10
8
  class << self
11
9
  def call(&block)
12
10
  return unless block
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castle
4
- VERSION = '9.0.0'
4
+ VERSION = '9.1.0'
5
5
  end
data/lib/castle.rb CHANGED
@@ -14,7 +14,6 @@
14
14
  castle/utils/get_timestamp
15
15
  castle/utils/secure_compare
16
16
  castle/validators/present
17
- castle/validators/not_supported
18
17
  castle/webhooks/verify
19
18
  castle/context/merge
20
19
  castle/context/sanitize
@@ -37,6 +36,9 @@
37
36
  castle/commands/list_items/query
38
37
  castle/commands/list_items/unarchive
39
38
  castle/commands/list_items/update
39
+ castle/commands/events/schema
40
+ castle/commands/events/query
41
+ castle/commands/events/group
40
42
  castle/commands/privacy/request_data
41
43
  castle/commands/privacy/delete_data
42
44
  castle/api/filter
@@ -56,6 +58,9 @@
56
58
  castle/api/list_items/query
57
59
  castle/api/list_items/unarchive
58
60
  castle/api/list_items/update
61
+ castle/api/events/schema
62
+ castle/api/events/query
63
+ castle/api/events/group
59
64
  castle/api/privacy/request_data
60
65
  castle/api/privacy/delete_data
61
66
  castle/payload/prepare
@@ -64,6 +69,7 @@
64
69
  castle/logger
65
70
  castle/failover/prepare_response
66
71
  castle/failover/strategy
72
+ castle/client_actions/events
67
73
  castle/client_actions/lists
68
74
  castle/client_actions/list_items
69
75
  castle/client_actions/privacy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
@@ -40,6 +40,9 @@ files:
40
40
  - lib/castle-rb.rb
41
41
  - lib/castle.rb
42
42
  - lib/castle/api.rb
43
+ - lib/castle/api/events/group.rb
44
+ - lib/castle/api/events/query.rb
45
+ - lib/castle/api/events/schema.rb
43
46
  - lib/castle/api/filter.rb
44
47
  - lib/castle/api/list_items/archive.rb
45
48
  - lib/castle/api/list_items/count.rb
@@ -60,11 +63,15 @@ files:
60
63
  - lib/castle/api/privacy/request_data.rb
61
64
  - lib/castle/api/risk.rb
62
65
  - lib/castle/client.rb
66
+ - lib/castle/client_actions/events.rb
63
67
  - lib/castle/client_actions/list_items.rb
64
68
  - lib/castle/client_actions/lists.rb
65
69
  - lib/castle/client_actions/privacy.rb
66
70
  - lib/castle/client_id/extract.rb
67
71
  - lib/castle/command.rb
72
+ - lib/castle/commands/events/group.rb
73
+ - lib/castle/commands/events/query.rb
74
+ - lib/castle/commands/events/schema.rb
68
75
  - lib/castle/commands/filter.rb
69
76
  - lib/castle/commands/list_items/archive.rb
70
77
  - lib/castle/commands/list_items/count.rb
@@ -113,7 +120,6 @@ files:
113
120
  - lib/castle/utils/get_timestamp.rb
114
121
  - lib/castle/utils/merge.rb
115
122
  - lib/castle/utils/secure_compare.rb
116
- - lib/castle/validators/not_supported.rb
117
123
  - lib/castle/validators/present.rb
118
124
  - lib/castle/verdict.rb
119
125
  - lib/castle/version.rb
@@ -141,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
147
  - !ruby/object:Gem::Version
142
148
  version: '0'
143
149
  requirements: []
144
- rubygems_version: 3.6.9
150
+ rubygems_version: 4.0.8
145
151
  specification_version: 4
146
152
  summary: Official Ruby SDK for the Castle fraud and account-abuse prevention platform
147
153
  test_files: []
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Castle
4
- module Validators
5
- # Checks if required keys are supported
6
- class NotSupported
7
- class << self
8
- def call(options, keys)
9
- keys.each do |key|
10
- next unless options.key?(key)
11
-
12
- raise Castle::InvalidParametersError, "#{key} is/are not supported"
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end