Class: Twilio::REST::Api::V2010::AccountContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/message.rb,
lib/twilio-ruby/rest/api/v2010/account/message/media.rb,
lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb

Defined Under Namespace

Classes: FeedbackInstance, FeedbackList, FeedbackPage, MediaContext, MediaInstance, MediaList, MediaPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ MessageContext

Initialize the MessageContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Message resources to update.

  • sid (String)

    The SID of the Message resource to be updated



261
262
263
264
265
266
267
268
269
270
271
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 261

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

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Messages/#{@solution[:sid]}.json"

    # Dependents
    @feedback = nil
    @media = nil
end

Instance Method Details

#deleteBoolean

Delete the MessageInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



275
276
277
278
279
280
281
282
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 275

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#feedbackFeedbackList, FeedbackContext

Access the feedback

Returns:



338
339
340
341
342
343
344
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 338

def feedback
  unless @feedback
    @feedback = FeedbackList.new(
            @version, account_sid: @solution[:account_sid], message_sid: @solution[:sid], )
  end
  @feedback
end

#fetchMessageInstance

Fetch the MessageInstance

Returns:



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 287

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



374
375
376
377
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 374

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

#media(sid = :unset) ⇒ MediaList, MediaContext

Access the media

Returns:

Raises:

  • (ArgumentError)


349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 349

def media(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return MediaContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @media
        @media = MediaList.new(
            @version, account_sid: @solution[:account_sid], message_sid: @solution[:sid], )
    end

 @media
end

#to_sObject

Provide a user friendly representation



367
368
369
370
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 367

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

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

Update the MessageInstance

Parameters:

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

    The new ‘body` of the Message resource. To redact the text content of a Message, this parameter’s value must be an empty string

  • status (UpdateStatus) (defaults to: :unset)

Returns:



309
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/api/v2010/account/message.rb', line 309

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

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

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