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

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

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



50
51
52
53
54
55
56
57
58
59
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 50

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 78

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
)

    params = Twilio::Values.of({
        'Fields' => fields,
        'CountryCode' => country_code,
        'FirstName' => first_name,
        'LastName' => last_name,
        'AddressLine1' => address_line1,
        'AddressLine2' => address_line2,
        'City' => city,
        'State' => state,
        'PostalCode' => postal_code,
        'AddressCountryCode' => address_country_code,
        'NationalId' => national_id,
        'DateOfBirth' => date_of_birth,
        'LastVerifiedDate' => last_verified_date,
        'VerificationSid' => verification_sid,
        'PartnerSubId' => partner_sub_id,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, params: params, headers: headers)
    PhoneNumberInstance.new(
        @version,
        payload,
        phone_number: @solution[:phone_number],
    )
end

#fetch_with_metadata(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 PhoneNumberInstanceMetadata

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:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
197
198
# File 'lib/twilio-ruby/rest/lookups/v2/phone_number.rb', line 145

def (
  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
)

    params = Twilio::Values.of({
        'Fields' => fields,
        'CountryCode' => country_code,
        'FirstName' => first_name,
        'LastName' => last_name,
        'AddressLine1' => address_line1,
        'AddressLine2' => address_line2,
        'City' => city,
        'State' => state,
        'PostalCode' => postal_code,
        'AddressCountryCode' => address_country_code,
        'NationalId' => national_id,
        'DateOfBirth' => date_of_birth,
        'LastVerifiedDate' => last_verified_date,
        'VerificationSid' => verification_sid,
        'PartnerSubId' => partner_sub_id,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, params: params, headers: headers)
    phone_number_instance = PhoneNumberInstance.new(
        @version,
        response.body,
        phone_number: @solution[:phone_number],
    )
    PhoneNumberInstanceMetadata.new(
        @version,
        phone_number_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



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

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