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 service_sid

  • sid (String)

    Identifier of the Stream. Either a SID or a unique name.



194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 194

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, true otherwise



231
232
233
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 231

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

#fetchSyncStreamInstance

Fetch a SyncStreamInstance

Returns:



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

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

#stream_messagesStreamMessageList, StreamMessageContext

Access the stream_messages

Returns:



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 239

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



253
254
255
256
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb', line 253

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