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.



115
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
# File 'lib/svix/models/stream_sink_patch.rb', line 115

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.



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

def batch_size
  @batch_size
end

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#event_typesObject

Returns the value of attribute event_types.



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

def event_types
  @event_types
end

#max_wait_secsObject

Returns the value of attribute max_wait_secs.



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

def max_wait_secs
  @max_wait_secs
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#uidObject

The StreamSink’s UID.



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

def uid
  @uid
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



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

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["batch_size"] = attributes["batchSize"]
  attrs["event_types"] = attributes["eventTypes"]
  attrs["max_wait_secs"] = attributes["maxWaitSecs"]
  attrs["metadata"] = attributes["metadata"]
  attrs["status"] = Svix::SinkStatusIn.deserialize(attributes["status"]) if attributes["status"]
  attrs["uid"] = attributes["uid"]
  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



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

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

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



181
182
183
# File 'lib/svix/models/stream_sink_patch.rb', line 181

def to_json
  JSON.dump(serialize)
end