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 that created the Message resource to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Message resource to fetch.


300
301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 300

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

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

  # Dependents
  @media = nil
  @feedback = nil
end

Instance Method Details

#deleteBoolean

Delete the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


315
316
317
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 315

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

#feedbackFeedbackList, FeedbackContext

Access the feedback

Returns:


363
364
365
366
367
368
369
370
371
372
373
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 363

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:


322
323
324
325
326
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 322

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

  MessageInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


384
385
386
387
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 384

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)

345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 345

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


377
378
379
380
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 377

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

#update(body: :unset) ⇒ MessageInstance

Update the MessageInstance

Parameters:

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

    The text of the message you want to send. Can be up to 1,600 characters long.

Returns:


333
334
335
336
337
338
339
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 333

def update(body: :unset)
  data = Twilio::Values.of({'Body' => body, })

  payload = @version.update('POST', @uri, data: data)

  MessageInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end