Class: Twilio::REST::Lookups::V2::PhoneNumberInstance

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

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 to lookup in E.164 or national format. Default country code is +1 (North America).



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

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

  # Marshaled Properties
  @properties = {
      'calling_country_code' => payload['calling_country_code'],
      'country_code' => payload['country_code'],
      'phone_number' => payload['phone_number'],
      'national_format' => payload['national_format'],
      'valid' => payload['valid'],
      'validation_errors' => payload['validation_errors'],
      'caller_name' => payload['caller_name'],
      'sim_swap' => payload['sim_swap'],
      'call_forwarding' => payload['call_forwarding'],
      'live_activity' => payload['live_activity'],
      'line_type_intelligence' => payload['line_type_intelligence'],
      'url' => payload['url'],
  }

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

Instance Method Details

#call_forwardingHash

Returns An object that contains call forwarding status information.

Returns:

  • (Hash)

    An object that contains call forwarding status information



209
210
211
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 209

def call_forwarding
  @properties['call_forwarding']
end

#caller_nameHash

Returns An object that contains caller name information.

Returns:

  • (Hash)

    An object that contains caller name information



197
198
199
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 197

def caller_name
  @properties['caller_name']
end

#calling_country_codeString

Returns International dialing prefix.

Returns:

  • (String)

    International dialing prefix



161
162
163
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 161

def calling_country_code
  @properties['calling_country_code']
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:



152
153
154
155
156
157
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 152

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

#country_codeString

Returns Phone number’s ISO country code.

Returns:

  • (String)

    Phone number’s ISO country code



167
168
169
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 167

def country_code
  @properties['country_code']
end

#fetch(fields: :unset, country_code: :unset) ⇒ PhoneNumberInstance

Fetch the PhoneNumberInstance

Parameters:

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

    A comma-separated list of fields to return. Possible values are caller_name, sim_swap, call_forwarding, live_activity, line_type_intelligence.

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

    The country code used if the phone number provided is in national format.

Returns:



240
241
242
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 240

def fetch(fields: :unset, country_code: :unset)
  context.fetch(fields: fields, country_code: country_code, )
end

#inspectObject

Provide a detailed, user friendly representation



253
254
255
256
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 253

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

#line_type_intelligenceHash

Returns An object that contains line type information.

Returns:

  • (Hash)

    An object that contains line type information



221
222
223
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 221

def line_type_intelligence
  @properties['line_type_intelligence']
end

#live_activityHash

Returns An object that contains live activity information.

Returns:

  • (Hash)

    An object that contains live activity information



215
216
217
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 215

def live_activity
  @properties['live_activity']
end

#national_formatString

Returns Phone number in national format.

Returns:

  • (String)

    Phone number in national format



179
180
181
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 179

def national_format
  @properties['national_format']
end

#phone_numberString

Returns Phone number in E.164 format.

Returns:

  • (String)

    Phone number in E.164 format



173
174
175
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 173

def phone_number
  @properties['phone_number']
end

#sim_swapHash

Returns An object that contains SIM swap information.

Returns:

  • (Hash)

    An object that contains SIM swap information



203
204
205
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 203

def sim_swap
  @properties['sim_swap']
end

#to_sObject

Provide a user friendly representation



246
247
248
249
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 246

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource



227
228
229
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 227

def url
  @properties['url']
end

#validBoolean

Returns Boolean which indicates if the phone number is valid.

Returns:

  • (Boolean)

    Boolean which indicates if the phone number is valid



185
186
187
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 185

def valid
  @properties['valid']
end

#validation_errorsArray[phone_number.ValidationError]

Returns Contains reasons why a phone number is invalid.

Returns:

  • (Array[phone_number.ValidationError])

    Contains reasons why a phone number is invalid



191
192
193
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 191

def validation_errors
  @properties['validation_errors']
end