Class: Hook0::Generated::EventWithPayload

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

Overview

The EventWithPayload 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:, payload_content_type:, received_at:, metadata: nil) ⇒ EventWithPayload

Returns a new instance of EventWithPayload.

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 (String)

    carries payload.

  • payload_content_type (String)

    carries payload_content_type.

  • received_at (Time)

    carries received_at.

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

    carries metadata.



1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/hook0/generated/models.rb', line 1051

def initialize(
  event_id:,
  event_type_name:,
  ip:,
  labels:,
  occurred_at:,
  payload:,
  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 = payload
  @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.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def event_id
  @event_id
end

#event_type_nameObject (readonly)

Returns the value of attribute event_type_name.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def event_type_name
  @event_type_name
end

#ipObject (readonly)

Returns the value of attribute ip.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def ip
  @ip
end

#labelsObject (readonly)

Returns the value of attribute labels.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def labels
  @labels
end

#metadataObject (readonly)

Returns the value of attribute metadata.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def 
  @metadata
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def occurred_at
  @occurred_at
end

#payloadObject (readonly)

Returns the value of attribute payload.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def payload
  @payload
end

#payload_content_typeObject (readonly)

Returns the value of attribute payload_content_type.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def payload_content_type
  @payload_content_type
end

#received_atObject (readonly)

Returns the value of attribute received_at.



1032
1033
1034
# File 'lib/hook0/generated/models.rb', line 1032

def received_at
  @received_at
end

Class Method Details

.from_json(value) ⇒ EventWithPayload

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
# File 'lib/hook0/generated/models.rb', line 1078

def self.from_json(value)
  fields = Runtime.as_fields(value, "EventWithPayload")
  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: Runtime.read(fields, "payload", Runtime::TEXT),
    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)


1114
1115
1116
# File 'lib/hook0/generated/models.rb', line 1114

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

#hashInteger

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

Returns:

  • (Integer)


1122
1123
1124
# File 'lib/hook0/generated/models.rb', line 1122

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
# File 'lib/hook0/generated/models.rb', line 1096

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"] = @payload
  out["payload_content_type"] = @payload_content_type
  out["received_at"] = Runtime.moment(@received_at)
  out["metadata"] = @metadata unless @metadata.nil?
  out
end