File tree Expand file tree Collapse file tree 5 files changed +33
-12
lines changed Expand file tree Collapse file tree 5 files changed +33
-12
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ module Typesense
2424require_relative 'typesense/key'
2525require_relative 'typesense/multi_search'
2626require_relative 'typesense/analytics'
27+ require_relative 'typesense/analytics_events'
2728require_relative 'typesense/analytics_rules'
2829require_relative 'typesense/analytics_rule'
2930require_relative 'typesense/analytics_v1'
Original file line number Diff line number Diff line change @@ -11,5 +11,9 @@ def initialize(api_call)
1111 def rules
1212 @rules ||= AnalyticsRules . new ( @api_call )
1313 end
14+
15+ def events
16+ @events ||= AnalyticsEvents . new ( @api_call )
17+ end
1418 end
1519end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Typesense
4+ class AnalyticsEvents
5+ RESOURCE_PATH = '/analytics/events'
6+
7+ def initialize ( api_call )
8+ @api_call = api_call
9+ end
10+
11+ def create ( params )
12+ @api_call . post ( self . class ::RESOURCE_PATH , params )
13+ end
14+
15+ def retrieve ( params = { } )
16+ @api_call . get ( self . class ::RESOURCE_PATH , params )
17+ end
18+ end
19+ end
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ def delete
1515 @api_call . delete ( endpoint_path )
1616 end
1717
18+ def update ( params )
19+ @api_call . put ( endpoint_path , params )
20+ end
21+
1822 private
1923
2024 def endpoint_path
Original file line number Diff line number Diff line change @@ -5,26 +5,19 @@ class AnalyticsRules
55 RESOURCE_PATH = '/analytics/rules'
66
77 def initialize ( api_call )
8- @api_call = api_call
9- @analytics_rules = { }
8+ @api_call = api_call
109 end
1110
12- def upsert ( rule_name , params )
13- @api_call . put ( endpoint_path ( rule_name ) , params )
11+ def create ( rules )
12+ @api_call . post ( self . class :: RESOURCE_PATH , rules )
1413 end
1514
1615 def retrieve
17- @api_call . get ( endpoint_path )
16+ @api_call . get ( self . class :: RESOURCE_PATH )
1817 end
1918
2019 def []( rule_name )
21- @analytics_rules [ rule_name ] ||= AnalyticsRule . new ( rule_name , @api_call )
22- end
23-
24- private
25-
26- def endpoint_path ( operation = nil )
27- "#{ AnalyticsRules ::RESOURCE_PATH } #{ "/#{ URI . encode_www_form_component ( operation ) } " unless operation . nil? } "
20+ AnalyticsRule . new ( rule_name , @api_call )
2821 end
2922 end
3023end
You can’t perform that action at this time.
0 commit comments