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](www.twilio.com/docs/sync/api/service) with the Sync Stream resource to fetch.

  • sid (String)

    The SID of the Stream resource to fetch.



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

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

Deletes the SyncStreamInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



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

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

#fetchSyncStreamInstance

Fetch a SyncStreamInstance

Returns:



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

def fetch
  params = Twilio::Values.of({})

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

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

#inspectObject

Provide a detailed, user friendly representation



274
275
276
277
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 274

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

#stream_messagesStreamMessageList, StreamMessageContext

Access the stream_messages

Returns:



253
254
255
256
257
258
259
260
261
262
263
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 253

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



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

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 Sync Map might not be deleted immediately after it expires.

Returns:



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

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