class Twilio::REST::Api::V2010::AccountContext::MessageContext::MediaList

Public Class Methods

new(version, account_sid: nil, message_sid: nil) click to toggle source

Initialize the MediaList @param [Version] version Version that contains the resource @param [String] account_sid The SID of the

{Account}[https://www.twilio.com/docs/iam/api/account] that created this Media
resource.

@param [String] message_sid The unique string that that we created to identify

the Message resource.

@return [MediaList] MediaList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
25 def initialize(version, account_sid: nil, message_sid: nil)
26   super(version)
27 
28   # Path Solution
29   @solution = {account_sid: account_sid, message_sid: message_sid}
30   @uri = "/Accounts/#{@solution[:account_sid]}/Messages/#{@solution[:message_sid]}/Media.json"
31 end

Public Instance Methods

each() { |x| ... } click to toggle source

When passed a block, yields MediaInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

   # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
88 def each
89   limits = @version.read_limits
90 
91   page = self.page(page_size: limits[:page_size], )
92 
93   @version.stream(page,
94                   limit: limits[:limit],
95                   page_limit: limits[:page_limit]).each {|x| yield x}
96 end
get_page(target_url) click to toggle source

Retrieve a single page of MediaInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of MediaInstance

    # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
128 def get_page(target_url)
129   response = @version.domain.request(
130       'GET',
131       target_url
132   )
133   MediaPage.new(@version, response, @solution)
134 end
list(date_created_before: :unset, date_created: :unset, date_created_after: :unset, limit: nil, page_size: nil) click to toggle source

Lists MediaInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Time] date_created_before Only include media that was created on this date @param [Time] date_created Only include media that was created on this date @param [Time] date_created_after Only include media that was created on this date @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
47 def list(date_created_before: :unset, date_created: :unset, date_created_after: :unset, limit: nil, page_size: nil)
48   self.stream(
49       date_created_before: date_created_before,
50       date_created: date_created,
51       date_created_after: date_created_after,
52       limit: limit,
53       page_size: page_size
54   ).entries
55 end
page(date_created_before: :unset, date_created: :unset, date_created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of MediaInstance records from the API. Request is executed immediately. @param [Time] date_created_before Only include media that was created on this date @param [Time] date_created Only include media that was created on this date @param [Time] date_created_after Only include media that was created on this date @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of MediaInstance

    # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
108 def page(date_created_before: :unset, date_created: :unset, date_created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
109   params = Twilio::Values.of({
110       'DateCreated<' => Twilio.serialize_iso8601_datetime(date_created_before),
111       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
112       'DateCreated>' => Twilio.serialize_iso8601_datetime(date_created_after),
113       'PageToken' => page_token,
114       'Page' => page_number,
115       'PageSize' => page_size,
116   })
117 
118   response = @version.page('GET', @uri, params: params)
119 
120   MediaPage.new(@version, response, @solution)
121 end
stream(date_created_before: :unset, date_created: :unset, date_created_after: :unset, limit: nil, page_size: nil) click to toggle source

Streams MediaInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Time] date_created_before Only include media that was created on this date @param [Time] date_created Only include media that was created on this date @param [Time] date_created_after Only include media that was created on this date @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

   # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
71 def stream(date_created_before: :unset, date_created: :unset, date_created_after: :unset, limit: nil, page_size: nil)
72   limits = @version.read_limits(limit, page_size)
73 
74   page = self.page(
75       date_created_before: date_created_before,
76       date_created: date_created,
77       date_created_after: date_created_after,
78       page_size: limits[:page_size],
79   )
80 
81   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
82 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/message/media.rb
138 def to_s
139   '#<Twilio.Api.V2010.MediaList>'
140 end