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.


309
310
311
312
313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 309

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


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

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

#feedbackFeedbackList, FeedbackContext

Access the feedback

Returns:


374
375
376
377
378
379
380
381
382
383
384
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 374

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:


331
332
333
334
335
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 331

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


395
396
397
398
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 395

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)

356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 356

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


388
389
390
391
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 388

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 text of the message you want to send. Can be up to 1,600 characters long.

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

    When set as `canceled`, allows a message cancelation request if a message has not yet been sent.

Returns:


344
345
346
347
348
349
350
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 344

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

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

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