Class: Twilio::REST::Chat::V1::ServiceContext::ChannelContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service/channel/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, channel_sid, sid) ⇒ MessageContext

Initialize the MessageContext

Parameters:



244
245
246
247
248
249
250
251
252
253
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 244

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the MessageInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



257
258
259
260
261
262
263
264
265
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 257

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the MessageInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 270

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      message_instance = MessageInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      MessageInstanceMetadata.new(@version, message_instance, response.headers, response.status_code)
end

#fetchMessageInstance

Fetch the MessageInstance

Returns:



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 289

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    MessageInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataMessageInstance

Fetch the MessageInstanceMetadata

Returns:



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 310

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    message_instance = MessageInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
    MessageInstanceMetadata.new(
        @version,
        message_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



412
413
414
415
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 412

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

#to_sObject

Provide a user friendly representation



405
406
407
408
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 405

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

#update(body: :unset, attributes: :unset) ⇒ MessageInstance

Update the MessageInstance

Parameters:

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

    The message to send to the channel. Can also be an empty string or null, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.

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

    A valid JSON string that contains application-specific data.

Returns:



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 339

def update(
    body: :unset, 
    attributes: :unset
)

    data = Twilio::Values.of({
        'Body' => body,
        'Attributes' => attributes,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    MessageInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
end

#update_with_metadata(body: :unset, attributes: :unset) ⇒ MessageInstance

Update the MessageInstanceMetadata

Parameters:

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

    The message to send to the channel. Can also be an empty string or null, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.

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

    A valid JSON string that contains application-specific data.

Returns:



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/message.rb', line 370

def (
  body: :unset, 
  attributes: :unset
)

    data = Twilio::Values.of({
        'Body' => body,
        'Attributes' => attributes,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    message_instance = MessageInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
    MessageInstanceMetadata.new(
        @version,
        message_instance,
        response.headers,
        response.status_code
    )
end