Class: Svix::CreateStreamEventsIn

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CreateStreamEventsIn

Returns a new instance of CreateStreamEventsIn.



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

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::CreateStreamEventsIn` 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::CreateStreamEventsIn")
    end

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

Instance Attribute Details

#eventsObject

Returns the value of attribute events.



7
8
9
# File 'lib/svix/models/create_stream_events_in.rb', line 7

def events
  @events
end

#streamObject

Optionally creates a new Stream alongside the events.

If the stream id or uid that is used in the path already exists, this argument is ignored.



11
12
13
# File 'lib/svix/models/create_stream_events_in.rb', line 11

def stream
  @stream
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



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

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["events"] = attributes["events"].map { |v| Svix::EventIn.deserialize(v) }
  attrs["stream"] = Svix::StreamIn.deserialize(attributes["stream"]) if attributes["stream"]
  new(attrs)
end

Instance Method Details

#serializeObject



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

def serialize
  out = Hash.new
  out["events"] = @events.map { |v| v.serialize } if @events
  out["stream"] = Svix::serialize_schema_ref(@stream) if @stream
  out
end

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



48
49
50
# File 'lib/svix/models/create_stream_events_in.rb', line 48

def to_json
  JSON.dump(serialize)
end