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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, message_sid: nil, sid: nil) ⇒ MediaInstance

Initialize the MediaInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    The SID of the Account that created this Media resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 255

def initialize(version, payload , account_sid: nil, message_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'content_type' => payload['content_type'],
        'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
        'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
        'parent_sid' => payload['parent_sid'],
        'sid' => payload['sid'],
        'uri' => payload['uri'],
    }

    # Context
    @instance_context = nil
    @params = { 'account_sid' =>   ,'message_sid' => message_sid  || @properties['message_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) associated with this Media resource.

Returns:



287
288
289
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 287

def 
    @properties['account_sid']
end

#content_typeString

Returns The default [MIME type](en.wikipedia.org/wiki/Internet_media_type) of the media, for example ‘image/jpeg`, `image/png`, or `image/gif`.

Returns:



293
294
295
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 293

def content_type
    @properties['content_type']
end

#contextMediaContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



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

def context
    unless @instance_context
        @instance_context = MediaContext.new(@version , @params['account_sid'], @params['message_sid'], @params['sid'])
    end
    @instance_context
end

#date_createdTime

Returns The date and time in GMT when this Media resource was created, specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



299
300
301
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 299

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when this Media resource was last updated, specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:

  • (Time)

    The date and time in GMT when this Media resource was last updated, specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.



305
306
307
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 305

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the MediaInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#fetchMediaInstance

Fetch the MediaInstance

Returns:



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

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



352
353
354
355
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 352

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Api.V2010.MediaInstance #{values}>"
end

#parent_sidString

Returns The SID of the Message resource that is associated with this Media resource.

Returns:

  • (String)

    The SID of the Message resource that is associated with this Media resource.



311
312
313
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 311

def parent_sid
    @properties['parent_sid']
end

#sidString

Returns The unique string that identifies this Media resource.

Returns:

  • (String)

    The unique string that identifies this Media resource.



317
318
319
# File 'lib/twilio-ruby/rest/api/v2010/account/message/media.rb', line 317

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



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

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Api.V2010.MediaInstance #{values}>"
end

#uriString

Returns The URI of this Media resource, relative to ‘api.twilio.com`.

Returns:

  • (String)

    The URI of this Media resource, relative to ‘api.twilio.com`.



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

def uri
    @properties['uri']
end