class Twilio::REST::Api::V2010::AccountContext::ShortCodeList
Public Class Methods
Initialize the ShortCodeList
@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 ShortCode resource.
@return [ShortCodeList] ShortCodeList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/short_code.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]}/SMS/ShortCodes.json" 28 end
Public Instance Methods
When passed a block, yields ShortCodeInstance
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/short_code.rb 87 def each 88 limits = @version.read_limits 89 90 page = self.page(page_size: limits[:page_size], ) 91 92 @version.stream(page, 93 limit: limits[:limit], 94 page_limit: limits[:page_limit]).each {|x| yield x} 95 end
Retrieve a single page of ShortCodeInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ShortCodeInstance
# File lib/twilio-ruby/rest/api/v2010/account/short_code.rb 128 def get_page(target_url) 129 response = @version.domain.request( 130 'GET', 131 target_url 132 ) 133 ShortCodePage.new(@version, response, @solution) 134 end
Lists ShortCodeInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] friendly_name The string that identifies the ShortCode resources
to read.
@param [String] short_code Only show the ShortCode resources that match this
pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
@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/short_code.rb 46 def list(friendly_name: :unset, short_code: :unset, limit: nil, page_size: nil) 47 self.stream( 48 friendly_name: friendly_name, 49 short_code: short_code, 50 limit: limit, 51 page_size: page_size 52 ).entries 53 end
Retrieve a single page of ShortCodeInstance
records from the API. Request
is executed immediately. @param [String] friendly_name The string that identifies the ShortCode resources
to read.
@param [String] short_code Only show the ShortCode resources that match this
pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
@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 ShortCodeInstance
# File lib/twilio-ruby/rest/api/v2010/account/short_code.rb 109 def page(friendly_name: :unset, short_code: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 110 params = Twilio::Values.of({ 111 'FriendlyName' => friendly_name, 112 'ShortCode' => short_code, 113 'PageToken' => page_token, 114 'Page' => page_number, 115 'PageSize' => page_size, 116 }) 117 118 response = @version.page('GET', @uri, params: params) 119 120 ShortCodePage.new(@version, response, @solution) 121 end
Streams ShortCodeInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] friendly_name The string that identifies the ShortCode resources
to read.
@param [String] short_code Only show the ShortCode resources that match this
pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
@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/short_code.rb 71 def stream(friendly_name: :unset, short_code: :unset, limit: nil, page_size: nil) 72 limits = @version.read_limits(limit, page_size) 73 74 page = self.page( 75 friendly_name: friendly_name, 76 short_code: short_code, 77 page_size: limits[:page_size], 78 ) 79 80 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 81 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/short_code.rb 138 def to_s 139 '#<Twilio.Api.V2010.ShortCodeList>' 140 end