Class: Svix::StreamSinkPatch

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ StreamSinkPatch

Returns a new instance of StreamSinkPatch.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/svix/models/stream_sink_patch.rb', line 116

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

    if k == "config"
      unless TYPE_TO_NAME.key?(v.class)
        fail(ArgumentError, "The field #{k} can't be a `#{v.class}` expected one of #{TYPE_TO_NAME.keys}")
      end

      instance_variable_set("@__enum_discriminator", TYPE_TO_NAME[v.class])
    end

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

  if @__enum_discriminator.nil?
    fail(ArgumentError, "Required config field was not set")
  end
end

Instance Attribute Details

#batch_sizeObject

Returns the value of attribute batch_size.



86
87
88
# File 'lib/svix/models/stream_sink_patch.rb', line 86

def batch_size
  @batch_size
end

#channelsObject

Returns the value of attribute channels.



89
90
91
# File 'lib/svix/models/stream_sink_patch.rb', line 89

def channels
  @channels
end

#configObject

Returns the value of attribute config.



91
92
93
# File 'lib/svix/models/stream_sink_patch.rb', line 91

def config
  @config
end

#event_typesObject

Returns the value of attribute event_types.



88
89
90
# File 'lib/svix/models/stream_sink_patch.rb', line 88

def event_types
  @event_types
end

#max_wait_secsObject

Returns the value of attribute max_wait_secs.



87
88
89
# File 'lib/svix/models/stream_sink_patch.rb', line 87

def max_wait_secs
  @max_wait_secs
end

#metadataObject

Returns the value of attribute metadata.



90
91
92
# File 'lib/svix/models/stream_sink_patch.rb', line 90

def 
  @metadata
end

#statusObject

Returns the value of attribute status.



85
86
87
# File 'lib/svix/models/stream_sink_patch.rb', line 85

def status
  @status
end

#uidObject

The StreamSink's UID.



84
85
86
# File 'lib/svix/models/stream_sink_patch.rb', line 84

def uid
  @uid
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/svix/models/stream_sink_patch.rb', line 146

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["uid"] = attributes["uid"]
  attrs["status"] = Svix::SinkStatusIn.deserialize(attributes["status"]) if attributes["status"]
  attrs["batch_size"] = attributes["batchSize"]
  attrs["max_wait_secs"] = attributes["maxWaitSecs"]
  attrs["event_types"] = attributes["eventTypes"]
  attrs["channels"] = attributes["channels"]
  attrs["metadata"] = attributes["metadata"]
  unless NAME_TO_TYPE.key?(attributes["type"])
    fail(ArgumentError, "Invalid type `#{attributes["type"]}` expected on of #{NAME_TO_TYPE.keys}")
  end

  unless attributes.key?("config")
    fail(ArgumentError, "Missing required field config")
  end

  attrs["config"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["config"])
  new(attrs)
end

Instance Method Details

#serializeObject



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/svix/models/stream_sink_patch.rb', line 168

def serialize
  out = Hash.new
  out["uid"] = Svix::serialize_primitive(@uid) if @__uid_is_defined
  out["status"] = Svix::serialize_schema_ref(@status) if @__status_is_defined
  out["batchSize"] = Svix::serialize_primitive(@batch_size) if @__batch_size_is_defined
  out["maxWaitSecs"] = Svix::serialize_primitive(@max_wait_secs) if @__max_wait_secs_is_defined
  out["eventTypes"] = Svix::serialize_primitive(@event_types) if @event_types
  out["channels"] = Svix::serialize_primitive(@channels) if @channels
  out["metadata"] = Svix::serialize_primitive(@metadata) if @metadata
  out["type"] = @__enum_discriminator
  out["config"] = @config.serialize
  out
end

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



184
185
186
# File 'lib/svix/models/stream_sink_patch.rb', line 184

def to_json
  JSON.dump(serialize)
end