Class: Svix::StreamSinkOut

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ StreamSinkOut

Returns a new instance of StreamSinkOut.



91
92
93
94
95
96
97
98
99
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_out.rb', line 91

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

def batch_size
  @batch_size
end

#configObject

Returns the value of attribute config.



61
62
63
# File 'lib/svix/models/stream_sink_out.rb', line 61

def config
  @config
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#current_iteratorObject

Returns the value of attribute current_iterator.



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

def current_iterator
  @current_iterator
end

#event_typesObject

Returns the value of attribute event_types.



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

def event_types
  @event_types
end

#failure_reasonObject

Returns the value of attribute failure_reason.



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

def failure_reason
  @failure_reason
end

#idObject

The sink’s ID.



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

def id
  @id
end

#max_wait_secsObject

Returns the value of attribute max_wait_secs.



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

def max_wait_secs
  @max_wait_secs
end

#metadataObject

Returns the value of attribute metadata.



55
56
57
# File 'lib/svix/models/stream_sink_out.rb', line 55

def 
  
end

#next_retry_atObject

Returns the value of attribute next_retry_at.



56
57
58
# File 'lib/svix/models/stream_sink_out.rb', line 56

def next_retry_at
  @next_retry_at
end

#statusObject

Returns the value of attribute status.



57
58
59
# File 'lib/svix/models/stream_sink_out.rb', line 57

def status
  @status
end

#uidObject

The sink’s UID.



59
60
61
# File 'lib/svix/models/stream_sink_out.rb', line 59

def uid
  @uid
end

#updated_atObject

Returns the value of attribute updated_at.



60
61
62
# File 'lib/svix/models/stream_sink_out.rb', line 60

def updated_at
  @updated_at
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/svix/models/stream_sink_out.rb', line 121

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["batch_size"] = attributes["batchSize"]
  attrs["created_at"] = DateTime.rfc3339(attributes["createdAt"]).to_time
  attrs["current_iterator"] = attributes["currentIterator"]
  attrs["event_types"] = attributes["eventTypes"]
  attrs["failure_reason"] = attributes["failureReason"]
  attrs["id"] = attributes["id"]
  attrs["max_wait_secs"] = attributes["maxWaitSecs"]
  attrs["metadata"] = attributes["metadata"]
  attrs["next_retry_at"] = DateTime.rfc3339(attributes["nextRetryAt"]).to_time if attributes["nextRetryAt"]
  attrs["status"] = Svix::SinkStatus.deserialize(attributes["status"])
  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



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

def serialize
  out = Hash.new
  out["batchSize"] = Svix::serialize_primitive(@batch_size) if @batch_size
  out["createdAt"] = Svix::serialize_primitive(@created_at) if @created_at
  out["currentIterator"] = Svix::serialize_primitive(@current_iterator) if @current_iterator
  out["eventTypes"] = Svix::serialize_primitive(@event_types) if @event_types
  out["failureReason"] = Svix::serialize_primitive(@failure_reason) if @failure_reason
  out["id"] = Svix::serialize_primitive(@id) if @id
  out["maxWaitSecs"] = Svix::serialize_primitive(@max_wait_secs) if @max_wait_secs
  out["metadata"] = Svix::serialize_primitive() if 
  out["nextRetryAt"] = Svix::serialize_primitive(@next_retry_at) if @next_retry_at
  out["status"] = Svix::serialize_schema_ref(@status) if @status
  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

Returns:

  • String



169
170
171
# File 'lib/svix/models/stream_sink_out.rb', line 169

def to_json
  JSON.dump(serialize)
end