class Twilio::REST::Lookups::V1::PhoneNumberContext
Public Class Methods
new(version, phone_number)
click to toggle source
Initialize the PhoneNumberContext
@param [Version] version Version
that contains the resource @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 [PhoneNumberContext] PhoneNumberContext
Calls superclass method
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 69 def initialize(version, phone_number) 70 super(version) 71 72 # Path Solution 73 @solution = {phone_number: phone_number, } 74 @uri = "/PhoneNumbers/#{CGI.escape(@solution[:phone_number]).gsub("+", "%20")}" 75 end
Public Instance Methods
fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
click to toggle source
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 97 def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset) 98 params = Twilio::Values.of({ 99 'CountryCode' => country_code, 100 'Type' => Twilio.serialize_list(type) { |e| e }, 101 'AddOns' => Twilio.serialize_list(add_ons) { |e| e }, 102 }) 103 params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) 104 105 payload = @version.fetch('GET', @uri, params: params) 106 107 PhoneNumberInstance.new(@version, payload, phone_number: @solution[:phone_number], ) 108 end
inspect()
click to toggle source
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 119 def inspect 120 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 121 "#<Twilio.Lookups.V1.PhoneNumberContext #{context}>" 122 end
to_s()
click to toggle source
Provide a user friendly representation
# File lib/twilio-ruby/rest/lookups/v1/phone_number.rb 112 def to_s 113 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 114 "#<Twilio.Lookups.V1.PhoneNumberContext #{context}>" 115 end