Class: Hook0::Generated::EventPost

Inherits:
Object
  • Object
show all
Defined in:
lib/hook0/generated/models.rb

Overview

The EventPost the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id:, event_type:, labels:, occurred_at:, payload:, payload_content_type:, event_id: nil, metadata: nil) ⇒ EventPost

Returns a new instance of EventPost.

Parameters:

  • application_id (String)

    carries application_id: UUID of the application this event belongs to.

  • event_type (String)

    carries event_type: The type of event (e.g., 'user.created', 'order.completed'). Length: 1-200 characters.

  • labels (Hash{String => String})

    carries labels: Labels for event filtering and routing to subscriptions.

  • occurred_at (Time)

    carries occurred_at: Timestamp when the event occurred.

  • payload (String)

    carries payload: The event payload. For binary content, use base64 encoding. Max length: 699050 characters (512 KiB base64-encoded).

  • payload_content_type (String)

    carries payload_content_type: Content type of the payload. Valid values: text/plain, application/json, application/octet-stream+base64. Length: 1-100 characters.

  • event_id (String, nil) (defaults to: nil)

    carries event_id: Optional unique identifier for this event (client-generated UUID). If not provided, a UUIDv7 will be generated by the server.

  • metadata (Hash{String => String}, nil) (defaults to: nil)

    carries metadata: Optional metadata key-value pairs associated with the event.



834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
# File 'lib/hook0/generated/models.rb', line 834

def initialize(
  application_id:,
  event_type:,
  labels:,
  occurred_at:,
  payload:,
  payload_content_type:,
  event_id: nil,
  metadata: nil
)
  @application_id = application_id
  @event_type = event_type
  @labels = labels
  @occurred_at = occurred_at
  @payload = payload
  @payload_content_type = payload_content_type
  @event_id = event_id
  @metadata = 
  freeze
end

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def application_id
  @application_id
end

#event_idObject (readonly)

Returns the value of attribute event_id.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def event_id
  @event_id
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def event_type
  @event_type
end

#labelsObject (readonly)

Returns the value of attribute labels.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def labels
  @labels
end

#metadataObject (readonly)

Returns the value of attribute metadata.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def 
  @metadata
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def occurred_at
  @occurred_at
end

#payloadObject (readonly)

Returns the value of attribute payload.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def payload
  @payload
end

#payload_content_typeObject (readonly)

Returns the value of attribute payload_content_type.



811
812
813
# File 'lib/hook0/generated/models.rb', line 811

def payload_content_type
  @payload_content_type
end

Class Method Details

.from_json(value) ⇒ EventPost

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



859
860
861
862
863
864
865
866
867
868
869
870
871
# File 'lib/hook0/generated/models.rb', line 859

def self.from_json(value)
  fields = Runtime.as_fields(value, "EventPost")
  new(
    application_id: Runtime.read(fields, "application_id", Runtime::UUID),
    event_type: Runtime.read(fields, "event_type", Runtime::TEXT),
    labels: Runtime.read(fields, "labels", Runtime.map(Runtime::TEXT)),
    occurred_at: Runtime.read(fields, "occurred_at", Runtime::DATE_TIME),
    payload: Runtime.read(fields, "payload", Runtime::TEXT),
    payload_content_type: Runtime.read(fields, "payload_content_type", Runtime::TEXT),
    event_id: Runtime.maybe(fields, "event_id", Runtime::UUID),
    metadata: Runtime.maybe(fields, "metadata", Runtime.map(Runtime::TEXT))
  )
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Whether that value carries the same members as this one.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


893
894
895
# File 'lib/hook0/generated/models.rb', line 893

def ==(other)
  other.is_a?(EventPost) && to_h == other.to_h
end

#hashInteger

A value two equal instances share, so that either may key a hash.

Returns:

  • (Integer)


901
902
903
# File 'lib/hook0/generated/models.rb', line 901

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/hook0/generated/models.rb', line 876

def to_h
  out = {}
  out["application_id"] = @application_id
  out["event_type"] = @event_type
  out["labels"] = @labels
  out["occurred_at"] = Runtime.moment(@occurred_at)
  out["payload"] = @payload
  out["payload_content_type"] = @payload_content_type
  out["event_id"] = @event_id unless @event_id.nil?
  out["metadata"] = @metadata unless @metadata.nil?
  out
end