Class: Twilio::REST::Sync::V1::ServiceContext::SyncStreamContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb

Defined Under Namespace

Classes: StreamMessageInstance, StreamMessageList, StreamMessagePage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ SyncStreamContext

Initialize the SyncStreamContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the Sync Service with the Sync Stream resource to fetch.

  • sid (String)

    The SID of the Stream resource to fetch.


173
174
175
176
177
178
179
180
181
182
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 173

def initialize(version, service_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Streams/#{@solution[:sid]}"

  # Dependents
  @stream_messages = nil
end

Instance Method Details

#deleteBoolean

Delete the SyncStreamInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


201
202
203
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 201

def delete
   @version.delete('DELETE', @uri)
end

#fetchSyncStreamInstance

Fetch the SyncStreamInstance

Returns:


187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 187

def fetch
  payload = @version.fetch('GET', @uri)

  SyncStreamInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


249
250
251
252
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 249

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Sync.V1.SyncStreamContext #{context}>"
end

#stream_messagesStreamMessageList, StreamMessageContext

Access the stream_messages

Returns:


228
229
230
231
232
233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 228

def stream_messages
  unless @stream_messages
    @stream_messages = StreamMessageList.new(
        @version,
        service_sid: @solution[:service_sid],
        stream_sid: @solution[:sid],
    )
  end

  @stream_messages
end

#to_sObject

Provide a user friendly representation


242
243
244
245
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 242

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Sync.V1.SyncStreamContext #{context}>"
end

#update(ttl: :unset) ⇒ SyncStreamInstance

Update the SyncStreamInstance

Parameters:

  • ttl (String) (defaults to: :unset)

    How long, in seconds, before the Stream expires and is deleted (time-to-live).

Returns:


211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 211

def update(ttl: :unset)
  data = Twilio::Values.of({'Ttl' => ttl, })

  payload = @version.update('POST', @uri, data: data)

  SyncStreamInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      sid: @solution[:sid],
  )
end