Class: Pago::V2026_04::Services::EventTypes

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/event_types.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#list(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, page: 1, limit: 10, sorting: ["-last_seen"]) ⇒ Models::ListResourceEventTypeWithStats

List event types with aggregated statistics.

Scopes: events:read events:write

Parameters:

  • organization_id (String, Array<String>, nil) (defaults to: nil)

    Filter by organization ID.

  • customer_id (String, Array<String>, nil) (defaults to: nil)

    Filter by customer ID.

  • external_customer_id (String, Array<String>, nil) (defaults to: nil)

    Filter by external customer ID.

  • query (String, nil) (defaults to: nil)

    Query to filter event types by name or label.

  • root_events (Boolean) (defaults to: false)

    When true, only return event types with root events (parent_id IS NULL).

  • parent_id (String, nil) (defaults to: nil)

    Filter by specific parent event ID.

  • source (String, nil) (defaults to: nil)

    Filter by event source (system or user).

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • sorting (Array<String>, nil) (defaults to: ["-last_seen"])

    Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.

  • organization_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • external_customer_id: (Object) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • root_events: (Boolean, nil) (defaults to: false)
  • parent_id: (String, nil) (defaults to: nil)
  • source: (String, nil) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-last_seen"])

Returns:

Raises:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pago/v2026_04/services/event_types.rb', line 24

def list(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, page: 1, limit: 10, sorting: ["-last_seen"])
  data = client.request(
    http_method: "GET",
    path: "/v1/event-types/",
    path_params: {},
    query: { "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "query" => query, "root_events" => root_events, "parent_id" => parent_id, "source" => source, "page" => page, "limit" => limit, "sorting" => sorting },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceEventTypeWithStats.from_json(data)
end

#list_each(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, limit: 10, sorting: ["-last_seen"]) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • external_customer_id: (Object) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • root_events: (Boolean, nil) (defaults to: false)
  • parent_id: (String, nil) (defaults to: nil)
  • source: (String, nil) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-last_seen"])

Yield Parameters:

Returns:



40
41
42
43
44
45
# File 'lib/pago/v2026_04/services/event_types.rb', line 40

def list_each(organization_id: nil, customer_id: nil, external_customer_id: nil, query: nil, root_events: false, parent_id: nil, source: nil, limit: 10, sorting: ["-last_seen"], &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list(organization_id: organization_id, customer_id: customer_id, external_customer_id: external_customer_id, query: query, root_events: root_events, parent_id: parent_id, source: source, page: page_number, limit: limit, sorting: sorting)
  end
  block ? paginator.each(&block) : paginator
end

#update(id, body: {}) ⇒ Models::EventType

Update an event type's label.

Scopes: events:write

Parameters:

  • id (String)

    The event type ID.

  • body (Hash, Models::EventTypeUpdate) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/pago/v2026_04/services/event_types.rb', line 57

def update(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/event-types/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 404 => Errors::Update404Error, 422 => Errors::HTTPValidationError }
  )
  Models::EventType.from_json(data)
end