Class: Twilio::REST::Lookups::V1::PhoneNumberContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/lookups/v1/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, phone_number) ⇒ PhoneNumberContext

Initialize the PhoneNumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • phone_number (String)

    The phone_number



67
68
69
70
71
72
73
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 67

def initialize(version, phone_number)
  super(version)

  # Path Solution
  @solution = {phone_number: phone_number, }
  @uri = "/PhoneNumbers/#{@solution[:phone_number]}"
end

Instance Method Details

#fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset) ⇒ PhoneNumberInstance

Fetch a PhoneNumberInstance

Parameters:

  • country_code (String) (defaults to: :unset)

    Optional [ISO country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number. This is used to specify the country when the number is provided in a national format.

  • type (String) (defaults to: :unset)

    Indicates the type of information you would like returned with your request. Possible values are ‘carrier` or `caller-name`. If not specified, the default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information costs $0.01 per phone number looked up, and is currently ONLY available in the US. You can retrieve both types of information by including two `Type` arguments or making two separate requests.

  • add_ons (String) (defaults to: :unset)

    Indicates the particular Add-on you would like to use to get more information. Possible values are the *Add-on Unique Names* of Add-ons installed on your account. You can specify multiple instances of this parameter to invoke different Add-ons. See [Add-ons documentation](www.twilio.com/docs/api/addons) for information on installing Add-ons. Add-on pricing is available in your list of Installed Add-ons in the Console.

  • add_ons_data (Hash) (defaults to: :unset)

    The add_ons_data

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 95

def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
  params = Twilio::Values.of({
      'CountryCode' => country_code,
      'Type' => Twilio.serialize_list(type) { |e| e },
      'AddOns' => Twilio.serialize_list(add_ons) { |e| e },
  })

  params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns'))
  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  PhoneNumberInstance.new(@version, payload, phone_number: @solution[:phone_number], )
end

#to_sObject

Provide a user friendly representation



114
115
116
117
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 114

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Lookups.V1.PhoneNumberContext #{context}>"
end