Sha256: 8ecd3d22a0ccdd53a14b11b81930ec3428a580e3282085bd00d982909652202e

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
# typed: strict

require 'net/http'

module WorkOS
  # The Events module provides convenience methods for working with the
  # WorkOS Events platform. You'll need a valid API key and be in the
  # Events beta to be able to access the API
  #
  module Events
    class << self
      extend T::Sig
      include Client

      # Retrieve events.
      #
      # @param [Hash] options An options hash
      # @option options [String] event The type of event
      #  retrieved.
      # @option options [String] limit Maximum number of records to return.
      # @option options [String] after Pagination cursor to receive records
      #  after a provided Event ID.
      #
      # @return [Hash]
      sig do
        params(
          options: T::Hash[Symbol, String],
        ).returns(WorkOS::Types::ListStruct)
      end
      def list_events(options = {})
        response = execute_request(
          request: get_request(
            path: '/events',
            auth: true,
            params: options,
          ),
        )

        parsed_response = JSON.parse(response.body)
        events = parsed_response['data'].map do |event|
          ::WorkOS::Event.new(event.to_json)
        end

        WorkOS::Types::ListStruct.new(
          data: events,
          list_metadata: parsed_response['list_metadata'],
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workos-4.1.0 lib/workos/events.rb
workos-4.0.0 lib/workos/events.rb
workos-3.1.0 lib/workos/events.rb
workos-3.0.0 lib/workos/events.rb
workos-2.17.0 lib/workos/events.rb
workos-2.16.0 lib/workos/events.rb