Class: Smplkit::Audit::EventTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/audit/event_types.rb

Overview

client.audit.event_types.list — distinct event_type slugs seen for the account.

Without filter_resource_type, returns one row per distinct event type — an event type recorded with multiple resource_types appears once. With the filter, returns the event types seen with that specific resource_type, powering the cascading-filter behavior on the Activity tab.

ADR-047 §2.5. Sorted alphabetically; offset pagination (page_number / page_size) per ADR-014.

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ EventTypes

Returns a new instance of EventTypes.



17
18
19
# File 'lib/smplkit/audit/event_types.rb', line 17

def initialize(api)
  @api = api
end

Instance Method Details

#list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/smplkit/audit/event_types.rb', line 21

def list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil)
  opts = {}
  opts[:filter_resource_type] = filter_resource_type if filter_resource_type
  opts[:page_number] = page_number if page_number
  opts[:page_size] = page_size if page_size
  opts[:meta_total] = meta_total unless meta_total.nil?

  resp = Smplkit::Audit.call_api { @api.list_event_types(opts) }
  rows = (resp.data || []).map { |r| EventType.from_resource(r) }
  EventTypeListPage.new(rows, Smplkit::Audit.extract_pagination(resp.meta))
end