Class: Svix::IngestSourceOut

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ IngestSourceOut



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/svix/models/ingest_source_out.rb', line 211

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

#configObject

Returns the value of attribute config.



164
165
166
# File 'lib/svix/models/ingest_source_out.rb', line 164

def config
  @config
end

#created_atObject

Returns the value of attribute created_at.



155
156
157
# File 'lib/svix/models/ingest_source_out.rb', line 155

def created_at
  @created_at
end

#idObject

The Source’s ID.



157
158
159
# File 'lib/svix/models/ingest_source_out.rb', line 157

def id
  @id
end

#ingest_urlObject

Returns the value of attribute ingest_url.



158
159
160
# File 'lib/svix/models/ingest_source_out.rb', line 158

def ingest_url
  @ingest_url
end

#metadataObject

Returns the value of attribute metadata.



159
160
161
# File 'lib/svix/models/ingest_source_out.rb', line 159

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



160
161
162
# File 'lib/svix/models/ingest_source_out.rb', line 160

def name
  @name
end

#uidObject

The Source’s UID.



162
163
164
# File 'lib/svix/models/ingest_source_out.rb', line 162

def uid
  @uid
end

#updated_atObject

Returns the value of attribute updated_at.



163
164
165
# File 'lib/svix/models/ingest_source_out.rb', line 163

def updated_at
  @updated_at
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/svix/models/ingest_source_out.rb', line 241

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["created_at"] = DateTime.rfc3339(attributes["createdAt"]).to_time
  attrs["id"] = attributes["id"]
  attrs["ingest_url"] = attributes["ingestUrl"]
  attrs["metadata"] = attributes["metadata"]
  attrs["name"] = attributes["name"]
  attrs["uid"] = attributes["uid"]
  attrs["updated_at"] = DateTime.rfc3339(attributes["updatedAt"]).to_time
  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



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/svix/models/ingest_source_out.rb', line 263

def serialize
  out = Hash.new
  out["createdAt"] = Svix::serialize_primitive(@created_at) if @created_at
  out["id"] = Svix::serialize_primitive(@id) if @id
  out["ingestUrl"] = Svix::serialize_primitive(@ingest_url) if @ingest_url
  out["metadata"] = Svix::serialize_primitive(@metadata) if @metadata
  out["name"] = Svix::serialize_primitive(@name) if @name
  out["uid"] = Svix::serialize_primitive(@uid) if @uid
  out["updatedAt"] = Svix::serialize_primitive(@updated_at) if @updated_at
  out["type"] = @__enum_discriminator
  out["config"] = @config.serialize
  out
end

#to_jsonObject

Serializes the object to a json string



279
280
281
# File 'lib/svix/models/ingest_source_out.rb', line 279

def to_json
  JSON.dump(serialize)
end