Class: Twilio::REST::Lookups::V1::PhoneNumberInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, phone_number: nil) ⇒ PhoneNumberInstance

Initialize the PhoneNumberInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • phone_number (String) (defaults to: nil)

    The phone_number



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 127

def initialize(version, payload, phone_number: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'caller_name' => payload['caller_name'],
      'country_code' => payload['country_code'],
      'phone_number' => payload['phone_number'],
      'national_format' => payload['national_format'],
      'carrier' => payload['carrier'],
      'add_ons' => payload['add_ons'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'phone_number' => phone_number || @properties['phone_number'], }
end

Instance Method Details

#add_onsHash

Returns Results of any Add-ons you have specified using the AddOn parameter in the request, as a JSON dictionary.

Returns:

  • (Hash)

    Results of any Add-ons you have specified using the AddOn parameter in the request, as a JSON dictionary.



189
190
191
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 189

def add_ons
  @properties['add_ons']
end

#caller_nameString

Returns String indicating the name of the owner of the phone number.

Returns:

  • (String)

    String indicating the name of the owner of the phone number.



159
160
161
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 159

def caller_name
  @properties['caller_name']
end

#carrierString

Returns The carrier.

Returns:

  • (String)

    The carrier



183
184
185
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 183

def carrier
  @properties['carrier']
end

#contextPhoneNumberContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



150
151
152
153
154
155
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 150

def context
  unless @instance_context
    @instance_context = PhoneNumberContext.new(@version, @params['phone_number'], )
  end
  @instance_context
end

#country_codeString

Returns The ISO country code for the phone number.

Returns:

  • (String)

    The ISO country code for the phone number.



165
166
167
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 165

def country_code
  @properties['country_code']
end

#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:



219
220
221
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 219

def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
  context.fetch(country_code: country_code, type: type, add_ons: add_ons, add_ons_data: add_ons_data, )
end

#inspectObject

Provide a detailed, user friendly representation



232
233
234
235
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 232

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Lookups.V1.PhoneNumberInstance #{values}>"
end

#national_formatString

Returns The phone number, in national format.

Returns:

  • (String)

    The phone number, in national format.



177
178
179
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 177

def national_format
  @properties['national_format']
end

#phone_numberString

Returns The phone number, in E.

Returns:

  • (String)

    The phone number, in E.



171
172
173
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 171

def phone_number
  @properties['phone_number']
end

#to_sObject

Provide a user friendly representation



225
226
227
228
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 225

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Lookups.V1.PhoneNumberInstance #{values}>"
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



195
196
197
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 195

def url
  @properties['url']
end