class Twilio::REST::Trunking::V1::TrunkContext::OriginationUrlList
Public Class Methods
Initialize the OriginationUrlList
@param [Version] version Version
that contains the resource @param [String] trunk_sid The SID of the Trunk that owns the Origination URL. @return [OriginationUrlList] OriginationUrlList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 20 def initialize(version, trunk_sid: nil) 21 super(version) 22 23 # Path Solution 24 @solution = {trunk_sid: trunk_sid} 25 @uri = "/Trunks/#{@solution[:trunk_sid]}/OriginationUrls" 26 end
Public Instance Methods
Create the OriginationUrlInstance
@param [String] weight The value that determines the relative share of the load
the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority.
@param [String] priority The relative importance of the URI. Can be an integer
from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI.
@param [Boolean] enabled Whether the URL is enabled. The default is `true`. @param [String] friendly_name A descriptive string that you create to describe
the resource. It can be up to 64 characters long.
@param [String] sip_url The SIP address you want Twilio
to route your
Origination calls to. This must be a `sip:` schema.
@return [OriginationUrlInstance] Created OriginationUrlInstance
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 43 def create(weight: nil, priority: nil, enabled: nil, friendly_name: nil, sip_url: nil) 44 data = Twilio::Values.of({ 45 'Weight' => weight, 46 'Priority' => priority, 47 'Enabled' => enabled, 48 'FriendlyName' => friendly_name, 49 'SipUrl' => sip_url, 50 }) 51 52 payload = @version.create('POST', @uri, data: data) 53 54 OriginationUrlInstance.new(@version, payload, trunk_sid: @solution[:trunk_sid], ) 55 end
When passed a block, yields OriginationUrlInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 95 def each 96 limits = @version.read_limits 97 98 page = self.page(page_size: limits[:page_size], ) 99 100 @version.stream(page, 101 limit: limits[:limit], 102 page_limit: limits[:page_limit]).each {|x| yield x} 103 end
Retrieve a single page of OriginationUrlInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of OriginationUrlInstance
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 129 def get_page(target_url) 130 response = @version.domain.request( 131 'GET', 132 target_url 133 ) 134 OriginationUrlPage.new(@version, response, @solution) 135 end
Lists OriginationUrlInstance
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/trunking/v1/trunk/origination_url.rb 68 def list(limit: nil, page_size: nil) 69 self.stream(limit: limit, page_size: page_size).entries 70 end
Retrieve a single page of OriginationUrlInstance
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 OriginationUrlInstance
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 112 def page(page_token: :unset, page_number: :unset, page_size: :unset) 113 params = Twilio::Values.of({ 114 'PageToken' => page_token, 115 'Page' => page_number, 116 'PageSize' => page_size, 117 }) 118 119 response = @version.page('GET', @uri, params: params) 120 121 OriginationUrlPage.new(@version, response, @solution) 122 end
Streams OriginationUrlInstance
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/trunking/v1/trunk/origination_url.rb 83 def stream(limit: nil, page_size: nil) 84 limits = @version.read_limits(limit, page_size) 85 86 page = self.page(page_size: limits[:page_size], ) 87 88 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 89 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb 139 def to_s 140 '#<Twilio.Trunking.V1.OriginationUrlList>' 141 end