Class: Attio::Webhooks::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/attio/webhooks.rb

Overview

Represents a webhook event

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Event

Returns a new instance of Event.

Since:

  • 1.0.0



146
147
148
149
150
151
152
153
# File 'lib/attio/webhooks.rb', line 146

def initialize(payload)
  @raw = payload
  @id = payload["id"]
  @type = payload["type"]
  @created_at = Time.parse(payload["created_at"]) if payload["created_at"]
  @data = payload["data"] || {}
  @workspace_id = payload["workspace_id"]
end

Instance Attribute Details

#created_atObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def created_at
  @created_at
end

#dataObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def data
  @data
end

#idObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def id
  @id
end

#rawObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def raw
  @raw
end

#typeObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def type
  @type
end

#workspace_idObject (readonly)

Since:

  • 1.0.0



144
145
146
# File 'lib/attio/webhooks.rb', line 144

def workspace_id
  @workspace_id
end

Instance Method Details

#dig(*path) ⇒ Object

Get nested data value

Parameters:

  • path (String)

    Dot-separated path (e.g., 'record.id')

Returns:

  • (Object)

    Value at path

Since:

  • 1.0.0



167
168
169
# File 'lib/attio/webhooks.rb', line 167

def dig(*path)
  @data.dig(*path)
end

#is?(type) ⇒ Boolean

Check if event is of a specific type

Parameters:

  • type (String)

    Event type to check

Returns:

  • (Boolean)

Since:

  • 1.0.0



159
160
161
# File 'lib/attio/webhooks.rb', line 159

def is?(type)
  @type == type
end