class Twilio::REST::Proxy::V1::ServiceContext::ShortCodeList

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Public Class Methods

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

Initialize the ShortCodeList @param [Version] version Version that contains the resource @param [String] service_sid The SID of the ShortCode resource's parent

{Service}[https://www.twilio.com/docs/proxy/api/service] resource.

@return [ShortCodeList] ShortCodeList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/proxy/v1/service/short_code.rb
23 def initialize(version, service_sid: nil)
24   super(version)
25 
26   # Path Solution
27   @solution = {service_sid: service_sid}
28   @uri = "/Services/#{@solution[:service_sid]}/ShortCodes"
29 end

Public Instance Methods

create(sid: nil) click to toggle source

Create the ShortCodeInstance @param [String] sid The SID of a Twilio

{ShortCode}[https://www.twilio.com/docs/sms/api/short-code] resource that
represents the short code you would like to assign to your Proxy Service.

@return [ShortCodeInstance] Created ShortCodeInstance

   # File lib/twilio-ruby/rest/proxy/v1/service/short_code.rb
37 def create(sid: nil)
38   data = Twilio::Values.of({'Sid' => sid, })
39 
40   payload = @version.create('POST', @uri, data: data)
41 
42   ShortCodeInstance.new(@version, payload, service_sid: @solution[:service_sid], )
43 end
each() { |x| ... } click to toggle source

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/proxy/v1/service/short_code.rb
83 def each
84   limits = @version.read_limits
85 
86   page = self.page(page_size: limits[:page_size], )
87 
88   @version.stream(page,
89                   limit: limits[:limit],
90                   page_limit: limits[:page_limit]).each {|x| yield x}
91 end
get_page(target_url) click to toggle source

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/proxy/v1/service/short_code.rb
117 def get_page(target_url)
118   response = @version.domain.request(
119       'GET',
120       target_url
121   )
122   ShortCodePage.new(@version, response, @solution)
123 end
list(limit: nil, page_size: nil) click to toggle source

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 [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/proxy/v1/service/short_code.rb
56 def list(limit: nil, page_size: nil)
57   self.stream(limit: limit, page_size: page_size).entries
58 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ShortCodeInstance records from the API. Request is executed immediately. @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/proxy/v1/service/short_code.rb
100 def page(page_token: :unset, page_number: :unset, page_size: :unset)
101   params = Twilio::Values.of({
102       'PageToken' => page_token,
103       'Page' => page_number,
104       'PageSize' => page_size,
105   })
106 
107   response = @version.page('GET', @uri, params: params)
108 
109   ShortCodePage.new(@version, response, @solution)
110 end
stream(limit: nil, page_size: nil) click to toggle source

Streams ShortCodeInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @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/proxy/v1/service/short_code.rb
71 def stream(limit: nil, page_size: nil)
72   limits = @version.read_limits(limit, page_size)
73 
74   page = self.page(page_size: limits[:page_size], )
75 
76   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
77 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/proxy/v1/service/short_code.rb
127 def to_s
128   '#<Twilio.Proxy.V1.ShortCodeList>'
129 end