class Twilio::REST::Api::V2010::AccountContext::NotificationList

Public Class Methods

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

Initialize the NotificationList @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 the
Notification resource.

@return [NotificationList] NotificationList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/notification.rb
22 def initialize(version, account_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {account_sid: account_sid}
27   @uri = "/Accounts/#{@solution[:account_sid]}/Notifications.json"
28 end

Public Instance Methods

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

When passed a block, yields NotificationInstance 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/notification.rb
 93 def each
 94   limits = @version.read_limits
 95 
 96   page = self.page(page_size: limits[:page_size], )
 97 
 98   @version.stream(page,
 99                   limit: limits[:limit],
100                   page_limit: limits[:page_limit]).each {|x| yield x}
101 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/api/v2010/account/notification.rb
137 def get_page(target_url)
138   response = @version.domain.request(
139       'GET',
140       target_url
141   )
142   NotificationPage.new(@version, response, @solution)
143 end
list(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, limit: nil, page_size: nil) click to toggle source

Lists NotificationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] log Only read notifications of the specified log level. Can be:

`0` to read only ERROR notifications or `1` to read only WARNING notifications.
By default, all notifications are read.

@param [Time] message_date_before Filter by date @param [Time] message_date Filter by date @param [Time] message_date_after Filter by 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/notification.rb
47 def list(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, limit: nil, page_size: nil)
48   self.stream(
49       log: log,
50       message_date_before: message_date_before,
51       message_date: message_date,
52       message_date_after: message_date_after,
53       limit: limit,
54       page_size: page_size
55   ).entries
56 end
page(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of NotificationInstance records from the API. Request is executed immediately. @param [String] log Only read notifications of the specified log level. Can be:

`0` to read only ERROR notifications or `1` to read only WARNING notifications.
By default, all notifications are read.

@param [Time] message_date_before Filter by date @param [Time] message_date Filter by date @param [Time] message_date_after Filter by 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 NotificationInstance

    # File lib/twilio-ruby/rest/api/v2010/account/notification.rb
116 def page(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
117   params = Twilio::Values.of({
118       'Log' => log,
119       'MessageDate<' => Twilio.serialize_iso8601_date(message_date_before),
120       'MessageDate' => Twilio.serialize_iso8601_date(message_date),
121       'MessageDate>' => Twilio.serialize_iso8601_date(message_date_after),
122       'PageToken' => page_token,
123       'Page' => page_number,
124       'PageSize' => page_size,
125   })
126 
127   response = @version.page('GET', @uri, params: params)
128 
129   NotificationPage.new(@version, response, @solution)
130 end
stream(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, limit: nil, page_size: nil) click to toggle source

Streams NotificationInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] log Only read notifications of the specified log level. Can be:

`0` to read only ERROR notifications or `1` to read only WARNING notifications.
By default, all notifications are read.

@param [Time] message_date_before Filter by date @param [Time] message_date Filter by date @param [Time] message_date_after Filter by 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/notification.rb
75 def stream(log: :unset, message_date_before: :unset, message_date: :unset, message_date_after: :unset, limit: nil, page_size: nil)
76   limits = @version.read_limits(limit, page_size)
77 
78   page = self.page(
79       log: log,
80       message_date_before: message_date_before,
81       message_date: message_date,
82       message_date_after: message_date_after,
83       page_size: limits[:page_size],
84   )
85 
86   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
87 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/notification.rb
147 def to_s
148   '#<Twilio.Api.V2010.NotificationList>'
149 end