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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

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.



191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 191

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



219
220
221
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 219

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

#fetchSyncStreamInstance

Fetch the SyncStreamInstance

Returns:



205
206
207
208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 205

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



269
270
271
272
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 269

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

#stream_messagesStreamMessageList, StreamMessageContext

Access the stream_messages

Returns:



248
249
250
251
252
253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 248

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



262
263
264
265
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 262

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). Can be an integer from 0 to 31,536,000 (1 year). The default value is ‘0`, which means the Stream does not expire. The Stream will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources’s deletion.

Returns:



231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 231

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