Class: ActiveProject::WebhookEvent

Inherits:
Struct
  • Object
show all
Defined in:
lib/active_project/webhook_event.rb

Overview

Represents a standardized event parsed from a webhook payload. Using Struct for simplicity for now. Could be a full class inheriting BaseResource if needed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actorObject

Returns the value of attribute actor

Returns:

  • (Object)

    the current value of actor



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def actor
  @actor
end

#dataObject Also known as: object_data

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def data
  @data
end

#project_idObject

Returns the value of attribute project_id

Returns:

  • (Object)

    the current value of project_id



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def project_id
  @project_id
end

#raw_dataObject

Returns the value of attribute raw_data

Returns:

  • (Object)

    the current value of raw_data



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def raw_data
  @raw_data
end

#resource_idObject Also known as: event_object_id

Returns the value of attribute resource_id

Returns:

  • (Object)

    the current value of resource_id



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def resource_id
  @resource_id
end

#resource_typeObject Also known as: object_kind

Returns the value of attribute resource_type

Returns:

  • (Object)

    the current value of resource_type



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def resource_type
  @resource_type
end

#sourceObject Also known as: adapter_source

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def source
  @source
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def timestamp
  @timestamp
end

#typeObject Also known as: event_type

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def type
  @type
end

#webhook_typeObject

Returns the value of attribute webhook_type

Returns:

  • (Object)

    the current value of webhook_type



6
7
8
# File 'lib/active_project/webhook_event.rb', line 6

def webhook_type
  @webhook_type
end

Instance Method Details

#changesObject



31
32
33
34
# File 'lib/active_project/webhook_event.rb', line 31

def changes
  changes_data = data&.dig(:changes) || data&.dig("changes")
  changes_data.nil? || changes_data.empty? ? nil : changes_data
end

#object_keyObject

Additional aliases that might be expected



27
28
29
# File 'lib/active_project/webhook_event.rb', line 27

def object_key
  data&.dig(:object_key) || data&.dig("object_key")
end

#resourceObject

Helper method to get the resource object



37
38
39
40
# File 'lib/active_project/webhook_event.rb', line 37

def resource
  return data[resource_type] if data && data.key?(resource_type)
  nil
end