Class: Svix::EventOut

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/models/event_out.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ EventOut

Returns a new instance of EventOut.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/svix/models/event_out.rb', line 15

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::EventOut` new method")
  end

  attributes.each do |k, v|
    unless ALL_FIELD.include?(k.to_s)
      fail(ArgumentError, "The field #{k} is not part of Svix::EventOut")
    end

    instance_variable_set("@#{k}", v)
    instance_variable_set("@__#{k}_is_defined", true)
  end
end

Instance Attribute Details

#event_typeObject

The event type’s name



8
9
10
# File 'lib/svix/models/event_out.rb', line 8

def event_type
  @event_type
end

#payloadObject

Returns the value of attribute payload.



9
10
11
# File 'lib/svix/models/event_out.rb', line 9

def payload
  @payload
end

#timestampObject

Returns the value of attribute timestamp.



10
11
12
# File 'lib/svix/models/event_out.rb', line 10

def timestamp
  @timestamp
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/svix/models/event_out.rb', line 30

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["event_type"] = attributes["eventType"]
  attrs["payload"] = attributes["payload"]
  attrs["timestamp"] = DateTime.rfc3339(attributes["timestamp"]).to_time
  new(attrs)
end

Instance Method Details

#serializeObject



39
40
41
42
43
44
45
# File 'lib/svix/models/event_out.rb', line 39

def serialize
  out = Hash.new
  out["eventType"] = Svix::serialize_primitive(@event_type) if @event_type
  out["payload"] = Svix::serialize_primitive(@payload) if @payload
  out["timestamp"] = Svix::serialize_primitive(@timestamp) if @timestamp
  out
end

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



49
50
51
# File 'lib/svix/models/event_out.rb', line 49

def to_json
  JSON.dump(serialize)
end