Class: Hook0::Generated::Event
- Inherits:
-
Object
- Object
- Hook0::Generated::Event
- Defined in:
- lib/hook0/generated/models.rb
Overview
The Event the API declares.
Instance Attribute Summary collapse
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#event_type_name ⇒ Object
readonly
Returns the value of attribute event_type_name.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#occurred_at ⇒ Object
readonly
Returns the value of attribute occurred_at.
-
#payload_content_type ⇒ Object
readonly
Returns the value of attribute payload_content_type.
-
#received_at ⇒ Object
readonly
Returns the value of attribute received_at.
Class Method Summary collapse
-
.from_json(value) ⇒ Event
Read one out of what the API answered.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Whether that value carries the same members as this one.
-
#hash ⇒ Integer
A value two equal instances share, so that either may key a hash.
-
#initialize(event_id:, event_type_name:, ip:, labels:, occurred_at:, payload_content_type:, received_at:, metadata: nil) ⇒ Event
constructor
A new instance of Event.
-
#to_h ⇒ Hash{String => Object}
Write one back the way the API reads it.
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.
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_id ⇒ Object (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_name ⇒ Object (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 |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
720 721 722 |
# File 'lib/hook0/generated/models.rb', line 720 def ip @ip end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
720 721 722 |
# File 'lib/hook0/generated/models.rb', line 720 def labels @labels end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
720 721 722 |
# File 'lib/hook0/generated/models.rb', line 720 def @metadata end |
#occurred_at ⇒ Object (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_type ⇒ Object (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_at ⇒ Object (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.
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.
796 797 798 |
# File 'lib/hook0/generated/models.rb', line 796 def ==(other) other.is_a?(Event) && to_h == other.to_h end |
#hash ⇒ Integer
A value two equal instances share, so that either may key a hash.
804 805 806 |
# File 'lib/hook0/generated/models.rb', line 804 def hash to_h.hash end |
#to_h ⇒ Hash{String => Object}
Write one back the way the API reads it.
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 |