Class: WorkOS::Event

Inherits:
Object
  • Object
show all
Includes:
HashProvider
Defined in:
lib/workos/event.rb

Overview

The Event class provides a lightweight wrapper around a WorkOS Event resource. This class is not meant to be instantiated in user space, and is instantiated internally but exposed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashProvider

#to_h

Constructor Details

#initialize(json) ⇒ Event

Returns a new instance of Event.



12
13
14
15
16
17
18
19
# File 'lib/workos/event.rb', line 12

def initialize(json)
  hash = JSON.parse(json, symbolize_names: true)

  @id = hash[:id]
  @event = hash[:event]
  @created_at = hash[:created_at]
  @data = hash[:data]
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



10
11
12
# File 'lib/workos/event.rb', line 10

def created_at
  @created_at
end

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/workos/event.rb', line 10

def data
  @data
end

#eventObject

Returns the value of attribute event.



10
11
12
# File 'lib/workos/event.rb', line 10

def event
  @event
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/workos/event.rb', line 10

def id
  @id
end

Instance Method Details

#to_jsonObject



21
22
23
24
25
26
27
28
# File 'lib/workos/event.rb', line 21

def to_json(*)
  {
    id: id,
    event: event,
    data: data,
    created_at: created_at,
  }
end