Class: Hook0::Generated::IngestedEvent

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

Overview

The IngestedEvent the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id:, event_id:, received_at:) ⇒ IngestedEvent

Returns a new instance of IngestedEvent.

Parameters:

  • application_id (String)

    carries application_id.

  • event_id (String)

    carries event_id.

  • received_at (Time)

    carries received_at.



1203
1204
1205
1206
1207
1208
# File 'lib/hook0/generated/models.rb', line 1203

def initialize(application_id:, event_id:, received_at:)
  @application_id = application_id
  @event_id = event_id
  @received_at = received_at
  freeze
end

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



1196
1197
1198
# File 'lib/hook0/generated/models.rb', line 1196

def application_id
  @application_id
end

#event_idObject (readonly)

Returns the value of attribute event_id.



1196
1197
1198
# File 'lib/hook0/generated/models.rb', line 1196

def event_id
  @event_id
end

#received_atObject (readonly)

Returns the value of attribute received_at.



1196
1197
1198
# File 'lib/hook0/generated/models.rb', line 1196

def received_at
  @received_at
end

Class Method Details

.from_json(value) ⇒ IngestedEvent

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/hook0/generated/models.rb', line 1214

def self.from_json(value)
  fields = Runtime.as_fields(value, "IngestedEvent")
  new(
    application_id: Runtime.read(fields, "application_id", Runtime::UUID),
    event_id: Runtime.read(fields, "event_id", Runtime::UUID),
    received_at: Runtime.read(fields, "received_at", Runtime::DATE_TIME)
  )
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)


1238
1239
1240
# File 'lib/hook0/generated/models.rb', line 1238

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

#hashInteger

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

Returns:

  • (Integer)


1246
1247
1248
# File 'lib/hook0/generated/models.rb', line 1246

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


1226
1227
1228
1229
1230
1231
1232
# File 'lib/hook0/generated/models.rb', line 1226

def to_h
  out = {}
  out["application_id"] = @application_id
  out["event_id"] = @event_id
  out["received_at"] = Runtime.moment(@received_at)
  out
end