Class: Hook0::Generated::Event

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

Overview

The Event the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_id:, event_type_name:, ip:, labels:, occurred_at:, payload_content_type:, received_at:, metadata: nil) ⇒ Event

Returns a new instance of Event.

Parameters:

  • event_id (String)

    carries event_id.

  • event_type_name (String)

    carries event_type_name.

  • ip (String)

    carries ip.

  • labels (Object)

    carries labels.

  • occurred_at (Time)

    carries occurred_at.

  • payload_content_type (String)

    carries payload_content_type.

  • received_at (Time)

    carries received_at.

  • metadata (Object, nil) (defaults to: nil)

    carries metadata.



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
# File 'lib/hook0/generated/models.rb', line 737

def initialize(
  event_id:,
  event_type_name:,
  ip:,
  labels:,
  occurred_at:,
  payload_content_type:,
  received_at:,
  metadata: nil
)
  @event_id = event_id
  @event_type_name = event_type_name
  @ip = ip
  @labels = labels
  @occurred_at = occurred_at
  @payload_content_type = payload_content_type
  @received_at = received_at
  @metadata = 
  freeze
end

Instance Attribute Details

#event_idObject (readonly)

Returns the value of attribute event_id.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def event_id
  @event_id
end

#event_type_nameObject (readonly)

Returns the value of attribute event_type_name.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def event_type_name
  @event_type_name
end

#ipObject (readonly)

Returns the value of attribute ip.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def ip
  @ip
end

#labelsObject (readonly)

Returns the value of attribute labels.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def labels
  @labels
end

#metadataObject (readonly)

Returns the value of attribute metadata.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def 
  @metadata
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def occurred_at
  @occurred_at
end

#payload_content_typeObject (readonly)

Returns the value of attribute payload_content_type.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def payload_content_type
  @payload_content_type
end

#received_atObject (readonly)

Returns the value of attribute received_at.



720
721
722
# File 'lib/hook0/generated/models.rb', line 720

def received_at
  @received_at
end

Class Method Details

.from_json(value) ⇒ Event

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/hook0/generated/models.rb', line 762

def self.from_json(value)
  fields = Runtime.as_fields(value, "Event")
  new(
    event_id: Runtime.read(fields, "event_id", Runtime::UUID),
    event_type_name: Runtime.read(fields, "event_type_name", Runtime::TEXT),
    ip: Runtime.read(fields, "ip", Runtime::TEXT),
    labels: Runtime.read(fields, "labels", Runtime::JSON_VALUE),
    occurred_at: Runtime.read(fields, "occurred_at", Runtime::DATE_TIME),
    payload_content_type: Runtime.read(fields, "payload_content_type", Runtime::TEXT),
    received_at: Runtime.read(fields, "received_at", Runtime::DATE_TIME),
    metadata: Runtime.maybe(fields, "metadata", Runtime::JSON_VALUE)
  )
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)


796
797
798
# File 'lib/hook0/generated/models.rb', line 796

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

#hashInteger

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

Returns:

  • (Integer)


804
805
806
# File 'lib/hook0/generated/models.rb', line 804

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/hook0/generated/models.rb', line 779

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