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.



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 362

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_type_intelligence' => payload['line_type_intelligence'],
        'line_status' => payload['line_status'],
        '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'],
        'pre_fill' => payload['pre_fill'],
        'url' => payload['url'],
    }

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

Instance Method Details

#call_forwardingCallForwardingInfo

Returns:

  • (CallForwardingInfo)


453
454
455
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 453

def call_forwarding
    @properties['call_forwarding']
end

#caller_nameCallerNameInfo

Returns:

  • (CallerNameInfo)


441
442
443
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 441

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.



405
406
407
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 405

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:



396
397
398
399
400
401
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 396

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:



411
412
413
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 411

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, verification_sid: :unset, partner_sub_id: :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, pre_fill.

  • 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.

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

    The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.

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

    The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis.

Returns:



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 523

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, 
    verification_sid: :unset, 
    partner_sub_id: :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, 
        verification_sid: verification_sid, 
        partner_sub_id: partner_sub_id, 
    )
end

#identity_matchIdentityMatchInfo

Returns:

  • (IdentityMatchInfo)


471
472
473
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 471

def identity_match
    @properties['identity_match']
end

#inspectObject

Provide a detailed, user friendly representation



569
570
571
572
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 569

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

#line_statusLineStatusInfo

Returns:

  • (LineStatusInfo)


465
466
467
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 465

def line_status
    @properties['line_status']
end

#line_type_intelligenceLineTypeIntelligenceInfo

Returns:

  • (LineTypeIntelligenceInfo)


459
460
461
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 459

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:



423
424
425
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 423

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:



417
418
419
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 417

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.



489
490
491
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 489

def phone_number_quality_score
    @properties['phone_number_quality_score']
end

#pre_fillHash

Returns An object that contains pre fill information. pre_fill will return PII information associated with the phone number like first name, last name, address line, country code, state and postal code.

Returns:

  • (Hash)

    An object that contains pre fill information. pre_fill will return PII information associated with the phone number like first name, last name, address line, country code, state and postal code.



495
496
497
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 495

def pre_fill
    @properties['pre_fill']
end

#reassigned_numberReassignedNumberInfo

Returns:

  • (ReassignedNumberInfo)


477
478
479
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 477

def reassigned_number
    @properties['reassigned_number']
end

#sim_swapSimSwapInfo

Returns:

  • (SimSwapInfo)


447
448
449
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 447

def sim_swap
    @properties['sim_swap']
end

#sms_pumping_riskSmsPumpingRiskInfo

Returns:

  • (SmsPumpingRiskInfo)


483
484
485
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 483

def sms_pumping_risk
    @properties['sms_pumping_risk']
end

#to_sObject

Provide a user friendly representation



562
563
564
565
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 562

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.



501
502
503
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 501

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.



429
430
431
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 429

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.



435
436
437
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 435

def validation_errors
    @properties['validation_errors']
end