class Twilio::REST::Api::V2010::AccountContext::AddressList
Public Class Methods
Initialize the AddressList
@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 is responsible for the Address resource.
@return [AddressList] AddressList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/address.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]}/Addresses.json" 28 end
Public Instance Methods
Create the AddressInstance
@param [String] customer_name The name to associate with the new address. @param [String] street The number and street address of the new address. @param [String] city The city of the new address. @param [String] region The state or region of the new address. @param [String] postal_code The postal code of the new address. @param [String] iso_country The ISO country code of the new address. @param [String] friendly_name A descriptive string that you create to describe
the new address. It can be up to 64 characters long.
@param [Boolean] emergency_enabled Whether to enable emergency calling on the
new address. Can be: `true` or `false`.
@param [Boolean] auto_correct_address Whether we should automatically correct
the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
@return [AddressInstance] Created AddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/address.rb 47 def create(customer_name: nil, street: nil, city: nil, region: nil, postal_code: nil, iso_country: nil, friendly_name: :unset, emergency_enabled: :unset, auto_correct_address: :unset) 48 data = Twilio::Values.of({ 49 'CustomerName' => customer_name, 50 'Street' => street, 51 'City' => city, 52 'Region' => region, 53 'PostalCode' => postal_code, 54 'IsoCountry' => iso_country, 55 'FriendlyName' => friendly_name, 56 'EmergencyEnabled' => emergency_enabled, 57 'AutoCorrectAddress' => auto_correct_address, 58 }) 59 60 payload = @version.create('POST', @uri, data: data) 61 62 AddressInstance.new(@version, payload, account_sid: @solution[:account_sid], ) 63 end
When passed a block, yields AddressInstance
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/address.rb 126 def each 127 limits = @version.read_limits 128 129 page = self.page(page_size: limits[:page_size], ) 130 131 @version.stream(page, 132 limit: limits[:limit], 133 page_limit: limits[:page_limit]).each {|x| yield x} 134 end
Retrieve a single page of AddressInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of AddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/address.rb 169 def get_page(target_url) 170 response = @version.domain.request( 171 'GET', 172 target_url 173 ) 174 AddressPage.new(@version, response, @solution) 175 end
Lists AddressInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] customer_name The `customer_name` of the Address resources to
read.
@param [String] friendly_name The string that identifies the Address resources
to read.
@param [String] iso_country The ISO country code of the Address resources to
read.
@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/address.rb 82 def list(customer_name: :unset, friendly_name: :unset, iso_country: :unset, limit: nil, page_size: nil) 83 self.stream( 84 customer_name: customer_name, 85 friendly_name: friendly_name, 86 iso_country: iso_country, 87 limit: limit, 88 page_size: page_size 89 ).entries 90 end
Retrieve a single page of AddressInstance
records from the API. Request
is executed immediately. @param [String] customer_name The `customer_name` of the Address resources to
read.
@param [String] friendly_name The string that identifies the Address resources
to read.
@param [String] iso_country The ISO country code of the Address resources to
read.
@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 AddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/address.rb 149 def page(customer_name: :unset, friendly_name: :unset, iso_country: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 150 params = Twilio::Values.of({ 151 'CustomerName' => customer_name, 152 'FriendlyName' => friendly_name, 153 'IsoCountry' => iso_country, 154 'PageToken' => page_token, 155 'Page' => page_number, 156 'PageSize' => page_size, 157 }) 158 159 response = @version.page('GET', @uri, params: params) 160 161 AddressPage.new(@version, response, @solution) 162 end
Streams AddressInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] customer_name The `customer_name` of the Address resources to
read.
@param [String] friendly_name The string that identifies the Address resources
to read.
@param [String] iso_country The ISO country code of the Address resources to
read.
@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/address.rb 109 def stream(customer_name: :unset, friendly_name: :unset, iso_country: :unset, limit: nil, page_size: nil) 110 limits = @version.read_limits(limit, page_size) 111 112 page = self.page( 113 customer_name: customer_name, 114 friendly_name: friendly_name, 115 iso_country: iso_country, 116 page_size: limits[:page_size], 117 ) 118 119 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 120 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/address.rb 179 def to_s 180 '#<Twilio.Api.V2010.AddressList>' 181 end