Sha256: d517f60e6c939e0c5c4836a542d0815b821989d1c542c518e14ed52c7b2895b8

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 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
      #  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]
      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

2 entries across 2 versions & 1 rubygems

Version Path
workos-4.2.1 lib/workos/events.rb
workos-4.2.0 lib/workos/events.rb