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.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/svix/models/stream_sink_patch.rb', line 70

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.



47
48
49
# File 'lib/svix/models/stream_sink_patch.rb', line 47

def batch_size
  @batch_size
end

#configObject

Returns the value of attribute config.



54
55
56
# File 'lib/svix/models/stream_sink_patch.rb', line 54

def config
  @config
end

#event_typesObject

Returns the value of attribute event_types.



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

def event_types
  @event_types
end

#max_wait_secsObject

Returns the value of attribute max_wait_secs.



49
50
51
# File 'lib/svix/models/stream_sink_patch.rb', line 49

def max_wait_secs
  @max_wait_secs
end

#metadataObject

Returns the value of attribute metadata.



50
51
52
# File 'lib/svix/models/stream_sink_patch.rb', line 50

def 
  @metadata
end

#statusObject

Returns the value of attribute status.



51
52
53
# File 'lib/svix/models/stream_sink_patch.rb', line 51

def status
  @status
end

#uidObject

The StreamSink’s UID.



53
54
55
# File 'lib/svix/models/stream_sink_patch.rb', line 53

def uid
  @uid
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/svix/models/stream_sink_patch.rb', line 100

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



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/svix/models/stream_sink_patch.rb', line 121

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



136
137
138
# File 'lib/svix/models/stream_sink_patch.rb', line 136

def to_json
  JSON.dump(serialize)
end