class Twilio::REST::Lookups::V1::PhoneNumberInstance
Public Class Methods
Initialize the PhoneNumberInstance
@param [Version] version Version
that contains the resource @param [Hash] payload payload that contains response from Twilio
@param [String] phone_number
The phone number to lookup in
{E.164}[https://www.twilio.com/docs/glossary/what-e164] format, which consists of a + followed by the country code and subscriber number.
@return [PhoneNumberInstance] PhoneNumberInstance
Twilio::REST::InstanceResource::new
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 134 def initialize(version, payload, phone_number: nil) 135 super(version) 136 137 # Marshaled Properties 138 @properties = { 139 'caller_name' => payload['caller_name'], 140 'country_code' => payload['country_code'], 141 'phone_number' => payload['phone_number'], 142 'national_format' => payload['national_format'], 143 'carrier' => payload['carrier'], 144 'add_ons' => payload['add_ons'], 145 'url' => payload['url'], 146 } 147 148 # Context 149 @instance_context = nil 150 @params = {'phone_number' => phone_number || @properties['phone_number'], } 151 end
Public Instance Methods
@return [Hash] A JSON string with the results of the Add-ons you specified
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 196 def add_ons 197 @properties['add_ons'] 198 end
@return [Hash] The name of the phone number's owner
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 166 def caller_name 167 @properties['caller_name'] 168 end
@return [Hash] The telecom company that provides the phone number
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 190 def carrier 191 @properties['carrier'] 192 end
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [PhoneNumberContext] PhoneNumberContext
for this PhoneNumberInstance
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 157 def context 158 unless @instance_context 159 @instance_context = PhoneNumberContext.new(@version, @params['phone_number'], ) 160 end 161 @instance_context 162 end
@return [String] The ISO country code for the phone number
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 172 def country_code 173 @properties['country_code'] 174 end
Fetch the PhoneNumberInstance
@param [String] country_code
The {ISO country
code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format.
@param [Array] type The type of information to return. Can be: `carrier`
or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value.
@param [Array] add_ons
The `unique_name` of an Add-on you would like to
invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the {Add-ons documentation}[https://www.twilio.com/docs/add-ons].
@param [Hash] add_ons_data Data specific to the add-on you would like to invoke.
The content and format of this value depends on the add-on.
@return [PhoneNumberInstance] Fetched PhoneNumberInstance
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 226 def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset) 227 context.fetch(country_code: country_code, type: type, add_ons: add_ons, add_ons_data: add_ons_data, ) 228 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 239 def inspect 240 values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") 241 "<Twilio.Lookups.V1.PhoneNumberInstance #{values}>" 242 end
@return [String] The phone number, in national format
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 184 def national_format 185 @properties['national_format'] 186 end
@return [String] The phone number in E.164 format
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 178 def phone_number 179 @properties['phone_number'] 180 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 232 def to_s 233 values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") 234 "<Twilio.Lookups.V1.PhoneNumberInstance #{values}>" 235 end
@return [String] The absolute URL of the resource
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 202 def url 203 @properties['url'] 204 end