Class: Pago::V2026_04::Services::Events

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/events.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

#get(id) ⇒ Object

Get an event by ID.

Scopes: events:read events:write

Parameters:

  • id (String)

    The event ID.

Returns:

  • (Object)

Raises:



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/pago/v2026_04/services/events.rb', line 89

def get(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/events/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Unions::Event.from_json(data)
end

#ingest(body: {}) ⇒ Models::EventsIngestResponse

Ingest batch of events.

Scopes: events:write

Parameters:

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

    the request body.

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

Returns:

Raises:



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/pago/v2026_04/services/events.rb', line 109

def ingest(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/events/ingest",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::EventsIngestResponse.from_json(data)
end

#list(filter: nil, start_timestamp: nil, end_timestamp: nil, organization_id: nil, customer_id: nil, external_customer_id: nil, meter_id: nil, name: nil, source: nil, query: nil, parent_id: nil, depth: nil, page: 1, limit: 10, sorting: ["-timestamp"], metadata: nil) ⇒ Models::ListResourceEvent, Models::ListResourceWithCursorPaginationEvent

List events.

Scopes: events:read events:write

Parameters:

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

    Filter events following filter clauses. JSON string following the same schema a meter filter clause.

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

    Filter events after this timestamp.

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

    Filter events before this timestamp.

  • 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.

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

    Filter by a meter filter clause.

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

    Filter by event name.

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

    Filter by event source.

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

    Query to filter events.

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

    When combined with depth, use this event as the anchor instead of root events.

  • depth (Integer, nil) (defaults to: nil)

    Fetch descendants up to this depth. When set: 0=root events only, 1=roots+children, etc. Max 5. When not set, returns all events.

  • 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: ["-timestamp"])

    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.

  • metadata (Object) (defaults to: nil)

    Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.

  • filter: (String, nil) (defaults to: nil)
  • start_timestamp: (String, nil) (defaults to: nil)
  • end_timestamp: (String, nil) (defaults to: nil)
  • organization_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • external_customer_id: (Object) (defaults to: nil)
  • meter_id: (String, nil) (defaults to: nil)
  • name: (Object) (defaults to: nil)
  • source: (Object) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • parent_id: (String, nil) (defaults to: nil)
  • depth: (Integer, nil) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-timestamp"])
  • metadata: (Object) (defaults to: nil)

Returns:

Raises:



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pago/v2026_04/services/events.rb', line 30

def list(filter: nil, start_timestamp: nil, end_timestamp: nil, organization_id: nil, customer_id: nil, external_customer_id: nil, meter_id: nil, name: nil, source: nil, query: nil, parent_id: nil, depth: nil, page: 1, limit: 10, sorting: ["-timestamp"], metadata: nil)
  data = client.request(
    http_method: "GET",
    path: "/v1/events/",
    path_params: {},
    query: { "filter" => filter, "start_timestamp" => start_timestamp, "end_timestamp" => end_timestamp, "organization_id" => organization_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "meter_id" => meter_id, "name" => name, "source" => source, "query" => query, "parent_id" => parent_id, "depth" => depth, "page" => page, "limit" => limit, "sorting" => sorting, "metadata" =>  },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  ::Pago::Serde.union(data, variants: [Models::ListResourceEvent, Models::ListResourceWithCursorPaginationEvent])
end

#list_names(organization_id: nil, customer_id: nil, external_customer_id: nil, source: nil, query: nil, page: 1, limit: 10, sorting: ["-last_seen"]) ⇒ Models::ListResourceEventName

List event names.

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.

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

    Filter by event source.

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

    Query to filter event names.

  • 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)
  • source: (Object) (defaults to: nil)
  • query: (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:



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

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

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

Enumerate every item of list_names, fetching pages on demand.

Parameters:

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

Yield Parameters:

Returns:



73
74
75
76
77
78
# File 'lib/pago/v2026_04/services/events.rb', line 73

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