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



254
255
256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 254

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



268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 268

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:



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

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:



278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 278

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



357
358
359
360
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 357

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)


332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 332

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



350
351
352
353
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 350

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:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 296

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