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

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/lookups/v2/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

  • account_sid (String)

    The SID of the Account that created this PhoneNumber resource.

  • sid (String)

    The SID of the Call resource to fetch.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 170

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'],
        'line_status' => payload['line_status'],
        'line_type_intelligence' => payload['line_type_intelligence'],
        'identity_match' => payload['identity_match'],
        'reassigned_number' => payload['reassigned_number'],
        'sms_pumping_risk' => payload['sms_pumping_risk'],
        'phone_number_quality_score' => payload['phone_number_quality_score'],
        '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 information on the unconditional call forwarding status of mobile phone number.

Returns:

  • (Hash)

    An object that contains information on the unconditional call forwarding status of mobile phone number.



259
260
261
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 259

def call_forwarding
    @properties['call_forwarding']
end

#caller_nameHash

Returns An object that contains caller name information based on [CNAM](support.twilio.com/hc/en-us/articles/360051670533-Getting-Started-with-CNAM-Caller-ID).

Returns:



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

def caller_name
    @properties['caller_name']
end

#calling_country_codeString

Returns International dialing prefix of the phone number defined in the E.164 standard.

Returns:

  • (String)

    International dialing prefix of the phone number defined in the E.164 standard.



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

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:



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

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

#country_codeString

Returns The phone number’s [ISO country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2).

Returns:



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

def country_code
    @properties['country_code']
end

#fetch(fields: :unset, country_code: :unset, first_name: :unset, last_name: :unset, address_line1: :unset, address_line2: :unset, city: :unset, state: :unset, postal_code: :unset, address_country_code: :unset, national_id: :unset, date_of_birth: :unset, last_verified_date: :unset) ⇒ PhoneNumberInstance

Fetch the PhoneNumberInstance

Parameters:

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

    A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score.

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

    The [country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.

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

    User’s first name. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s last name. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s first address line. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s second address line. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s city. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.

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

    User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.

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

    The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests.

Returns:



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 321

def fetch(
    fields: :unset, 
    country_code: :unset, 
    first_name: :unset, 
    last_name: :unset, 
    address_line1: :unset, 
    address_line2: :unset, 
    city: :unset, 
    state: :unset, 
    postal_code: :unset, 
    address_country_code: :unset, 
    national_id: :unset, 
    date_of_birth: :unset, 
    last_verified_date: :unset
)

    context.fetch(
        fields: fields, 
        country_code: country_code, 
        first_name: first_name, 
        last_name: last_name, 
        address_line1: address_line1, 
        address_line2: address_line2, 
        city: city, 
        state: state, 
        postal_code: postal_code, 
        address_country_code: address_country_code, 
        national_id: national_id, 
        date_of_birth: date_of_birth, 
        last_verified_date: last_verified_date, 
    )
end

#identity_matchHash

Returns An object that contains identity match information. The result of comparing user-provided information including name, address, date of birth, national ID, against authoritative phone-based data sources.

Returns:

  • (Hash)

    An object that contains identity match information. The result of comparing user-provided information including name, address, date of birth, national ID, against authoritative phone-based data sources



277
278
279
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 277

def identity_match
    @properties['identity_match']
end

#inspectObject

Provide a detailed, user friendly representation



363
364
365
366
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 363

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

#line_statusHash

Returns An object that contains line status information for a mobile phone number.

Returns:

  • (Hash)

    An object that contains line status information for a mobile phone number.



265
266
267
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 265

def line_status
    @properties['line_status']
end

#line_type_intelligenceHash

Returns An object that contains line type information including the carrier name, mobile country code, and mobile network code.

Returns:

  • (Hash)

    An object that contains line type information including the carrier name, mobile country code, and mobile network code.



271
272
273
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 271

def line_type_intelligence
    @properties['line_type_intelligence']
end

#national_formatString

Returns The phone number in [national format](en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).

Returns:



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

def national_format
    @properties['national_format']
end

#phone_numberString

Returns The phone number in [E.164](www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.

Returns:



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

def phone_number
    @properties['phone_number']
end

#phone_number_quality_scoreHash

Returns An object that contains information of a mobile phone number quality score. Quality score will return a risk score about the phone number.

Returns:

  • (Hash)

    An object that contains information of a mobile phone number quality score. Quality score will return a risk score about the phone number.



295
296
297
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 295

def phone_number_quality_score
    @properties['phone_number_quality_score']
end

#reassigned_numberHash

Returns An object that contains reassigned number information. Reassigned Numbers will return a phone number’s reassignment status given a phone number and date.

Returns:

  • (Hash)

    An object that contains reassigned number information. Reassigned Numbers will return a phone number’s reassignment status given a phone number and date



283
284
285
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 283

def reassigned_number
    @properties['reassigned_number']
end

#sim_swapHash

Returns An object that contains information on the last date the subscriber identity module (SIM) was changed for a mobile phone number.

Returns:

  • (Hash)

    An object that contains information on the last date the subscriber identity module (SIM) was changed for a mobile phone number.



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

def sim_swap
    @properties['sim_swap']
end

#sms_pumping_riskHash

Returns An object that contains information on if a phone number has been currently or previously blocked by Verify Fraud Guard for receiving malicious SMS pumping traffic as well as other signals associated with risky carriers and low conversion rates.

Returns:

  • (Hash)

    An object that contains information on if a phone number has been currently or previously blocked by Verify Fraud Guard for receiving malicious SMS pumping traffic as well as other signals associated with risky carriers and low conversion rates.



289
290
291
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 289

def sms_pumping_risk
    @properties['sms_pumping_risk']
end

#to_sObject

Provide a user friendly representation



356
357
358
359
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 356

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.



301
302
303
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 301

def url
    @properties['url']
end

#validBoolean

Returns Boolean which indicates if the phone number is in a valid range that can be freely assigned by a carrier to a user.

Returns:

  • (Boolean)

    Boolean which indicates if the phone number is in a valid range that can be freely assigned by a carrier to a user.



235
236
237
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 235

def valid
    @properties['valid']
end

#validation_errorsArray<ValidationError>

Returns Contains reasons why a phone number is invalid. Possible values: TOO_SHORT, TOO_LONG, INVALID_BUT_POSSIBLE, INVALID_COUNTRY_CODE, INVALID_LENGTH, NOT_A_NUMBER.

Returns:

  • (Array<ValidationError>)

    Contains reasons why a phone number is invalid. Possible values: TOO_SHORT, TOO_LONG, INVALID_BUT_POSSIBLE, INVALID_COUNTRY_CODE, INVALID_LENGTH, NOT_A_NUMBER.



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

def validation_errors
    @properties['validation_errors']
end