Class: Twilio::REST::Lookups::V2::PhoneNumberContext

Inherits:
InstanceContext 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, phone_number) ⇒ PhoneNumberContext

Initialize the PhoneNumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • phone_number (String)

    The phone number to lookup in E.164 or national format. Default country code is +1 (North America).



74
75
76
77
78
79
80
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 74

def initialize(version, phone_number)
  super(version)

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

Instance Method Details

#fetch(fields: :unset, country_code: :unset, first_name: :unset, last_name: :unset, address_line_1: :unset, address_line_2: :unset, city: :unset, state: :unset, postal_code: :unset, address_country_code: :unset, national_id: :unset, date_of_birth: :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, identity_match.

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

    The country code 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_line_1 (String) (defaults to: :unset)

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

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

Returns:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 112

def fetch(fields: :unset, country_code: :unset, first_name: :unset, last_name: :unset, address_line_1: :unset, address_line_2: :unset, city: :unset, state: :unset, postal_code: :unset, address_country_code: :unset, national_id: :unset, date_of_birth: :unset)
  params = Twilio::Values.of({
      'Fields' => fields,
      'CountryCode' => country_code,
      'FirstName' => first_name,
      'LastName' => last_name,
      'AddressLine1' => address_line_1,
      'AddressLine2' => address_line_2,
      'City' => city,
      'State' => state,
      'PostalCode' => postal_code,
      'AddressCountryCode' => address_country_code,
      'NationalId' => national_id,
      'DateOfBirth' => date_of_birth,
  })

  payload = @version.fetch('GET', @uri, params: params)

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

#inspectObject

Provide a detailed, user friendly representation



142
143
144
145
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 142

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

#to_sObject

Provide a user friendly representation



135
136
137
138
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 135

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