Class: Svix::CreateStreamEventsIn
- Inherits:
-
Object
- Object
- Svix::CreateStreamEventsIn
- Defined in:
- lib/svix/models/create_stream_events_in.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#stream ⇒ Object
Optionally creates a new Stream alongside the events.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ CreateStreamEventsIn
constructor
A new instance of CreateStreamEventsIn.
- #serialize ⇒ Object
-
#to_json ⇒ Object
Serializes the object to a json string.
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
#events ⇒ Object
Returns the value of attribute events.
7 8 9 |
# File 'lib/svix/models/create_stream_events_in.rb', line 7 def events @events end |
#stream ⇒ Object
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
#serialize ⇒ Object
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_json ⇒ Object
Serializes the object to a json string
48 49 50 |
# File 'lib/svix/models/create_stream_events_in.rb', line 48 def to_json JSON.dump(serialize) end |