Sha256: 858b841d3b777c6f08d13f0248264ef8605d4dc382ac713a4ba39e7cb3f6ba37

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

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
      include Client

      # Retrieve events.
      #
      # @param [Hash] options An options hash
      # @option options [String] event The type of event
      # @option options [String] organization_id Limit scope of events to an organization
      # @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]
      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

4 entries across 4 versions & 1 rubygems

Version Path
workos-4.8.0 lib/workos/events.rb
workos-4.5.0 lib/workos/events.rb
workos-4.4.0 lib/workos/events.rb
workos-4.3.0 lib/workos/events.rb