1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 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 353 354 355 356 357 358 359 360 361 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 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
|
r"""
This code was generated by
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
Twilio - Lookups
This is the public Twilio REST API.
NOTE: This class is auto generated by OpenAPI Generator.
https://openapi-generator.tech
Do not edit the class manually.
"""
from typing import Any, Dict, List, Optional, Union
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version
class PhoneNumberInstance(InstanceResource):
class ValidationError(object):
TOO_SHORT = "TOO_SHORT"
TOO_LONG = "TOO_LONG"
INVALID_BUT_POSSIBLE = "INVALID_BUT_POSSIBLE"
INVALID_COUNTRY_CODE = "INVALID_COUNTRY_CODE"
INVALID_LENGTH = "INVALID_LENGTH"
NOT_A_NUMBER = "NOT_A_NUMBER"
"""
:ivar calling_country_code: International dialing prefix of the phone number defined in the E.164 standard.
:ivar country_code: The phone number's [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
:ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
:ivar national_format: The phone number in [national format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).
:ivar valid: Boolean which indicates if the phone number is in a valid range that can be freely assigned by a carrier to a user.
:ivar validation_errors: 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.
:ivar caller_name: An object that contains caller name information based on [CNAM](https://support.twilio.com/hc/en-us/articles/360051670533-Getting-Started-with-CNAM-Caller-ID).
:ivar sim_swap: An object that contains information on the last date the subscriber identity module (SIM) was changed for a mobile phone number.
:ivar call_forwarding: An object that contains information on the unconditional call forwarding status of mobile phone number.
:ivar line_status: An object that contains line status information for a mobile phone number.
:ivar line_type_intelligence: An object that contains line type information including the carrier name, mobile country code, and mobile network code.
:ivar identity_match: 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
:ivar reassigned_number: An object that contains reassigned number information. Reassigned Numbers will return a phone number's reassignment status given a phone number and date
:ivar sms_pumping_risk: 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.
:ivar phone_number_quality_score: An object that contains information of a mobile phone number quality score. Quality score will return a risk score about the phone number.
:ivar pre_fill: 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.
:ivar url: The absolute URL of the resource.
"""
def __init__(
self,
version: Version,
payload: Dict[str, Any],
phone_number: Optional[str] = None,
):
super().__init__(version)
self.calling_country_code: Optional[str] = payload.get("calling_country_code")
self.country_code: Optional[str] = payload.get("country_code")
self.phone_number: Optional[str] = payload.get("phone_number")
self.national_format: Optional[str] = payload.get("national_format")
self.valid: Optional[bool] = payload.get("valid")
self.validation_errors: Optional[
List["PhoneNumberInstance.ValidationError"]
] = payload.get("validation_errors")
self.caller_name: Optional[Dict[str, object]] = payload.get("caller_name")
self.sim_swap: Optional[Dict[str, object]] = payload.get("sim_swap")
self.call_forwarding: Optional[Dict[str, object]] = payload.get(
"call_forwarding"
)
self.line_status: Optional[Dict[str, object]] = payload.get("line_status")
self.line_type_intelligence: Optional[Dict[str, object]] = payload.get(
"line_type_intelligence"
)
self.identity_match: Optional[Dict[str, object]] = payload.get("identity_match")
self.reassigned_number: Optional[Dict[str, object]] = payload.get(
"reassigned_number"
)
self.sms_pumping_risk: Optional[Dict[str, object]] = payload.get(
"sms_pumping_risk"
)
self.phone_number_quality_score: Optional[Dict[str, object]] = payload.get(
"phone_number_quality_score"
)
self.pre_fill: Optional[Dict[str, object]] = payload.get("pre_fill")
self.url: Optional[str] = payload.get("url")
self._solution = {
"phone_number": phone_number or self.phone_number,
}
self._context: Optional[PhoneNumberContext] = None
@property
def _proxy(self) -> "PhoneNumberContext":
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: PhoneNumberContext for this PhoneNumberInstance
"""
if self._context is None:
self._context = PhoneNumberContext(
self._version,
phone_number=self._solution["phone_number"],
)
return self._context
def fetch(
self,
fields: Union[str, object] = values.unset,
country_code: Union[str, object] = values.unset,
first_name: Union[str, object] = values.unset,
last_name: Union[str, object] = values.unset,
address_line1: Union[str, object] = values.unset,
address_line2: Union[str, object] = values.unset,
city: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
postal_code: Union[str, object] = values.unset,
address_country_code: Union[str, object] = values.unset,
national_id: Union[str, object] = values.unset,
date_of_birth: Union[str, object] = values.unset,
last_verified_date: Union[str, object] = values.unset,
verification_sid: Union[str, object] = values.unset,
) -> "PhoneNumberInstance":
"""
Fetch the PhoneNumberInstance
:param fields: 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.
:param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.
:param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests.
:param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests.
:param address_line1: User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
:param address_line2: User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
:param city: User’s city. This query parameter is only used (optionally) for identity_match package requests.
:param state: User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
:param postal_code: User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
:param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
:param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.
:param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
:param last_verified_date: 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.
:param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.
:returns: The fetched PhoneNumberInstance
"""
return self._proxy.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,
)
async def fetch_async(
self,
fields: Union[str, object] = values.unset,
country_code: Union[str, object] = values.unset,
first_name: Union[str, object] = values.unset,
last_name: Union[str, object] = values.unset,
address_line1: Union[str, object] = values.unset,
address_line2: Union[str, object] = values.unset,
city: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
postal_code: Union[str, object] = values.unset,
address_country_code: Union[str, object] = values.unset,
national_id: Union[str, object] = values.unset,
date_of_birth: Union[str, object] = values.unset,
last_verified_date: Union[str, object] = values.unset,
verification_sid: Union[str, object] = values.unset,
) -> "PhoneNumberInstance":
"""
Asynchronous coroutine to fetch the PhoneNumberInstance
:param fields: 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.
:param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.
:param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests.
:param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests.
:param address_line1: User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
:param address_line2: User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
:param city: User’s city. This query parameter is only used (optionally) for identity_match package requests.
:param state: User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
:param postal_code: User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
:param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
:param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.
:param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
:param last_verified_date: 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.
:param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.
:returns: The fetched PhoneNumberInstance
"""
return await self._proxy.fetch_async(
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,
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Lookups.V2.PhoneNumberInstance {}>".format(context)
class PhoneNumberContext(InstanceContext):
def __init__(self, version: Version, phone_number: str):
"""
Initialize the PhoneNumberContext
:param version: Version that contains the resource
:param phone_number: The phone number to lookup in E.164 or national format. Default country code is +1 (North America).
"""
super().__init__(version)
# Path Solution
self._solution = {
"phone_number": phone_number,
}
self._uri = "/PhoneNumbers/{phone_number}".format(**self._solution)
def fetch(
self,
fields: Union[str, object] = values.unset,
country_code: Union[str, object] = values.unset,
first_name: Union[str, object] = values.unset,
last_name: Union[str, object] = values.unset,
address_line1: Union[str, object] = values.unset,
address_line2: Union[str, object] = values.unset,
city: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
postal_code: Union[str, object] = values.unset,
address_country_code: Union[str, object] = values.unset,
national_id: Union[str, object] = values.unset,
date_of_birth: Union[str, object] = values.unset,
last_verified_date: Union[str, object] = values.unset,
verification_sid: Union[str, object] = values.unset,
) -> PhoneNumberInstance:
"""
Fetch the PhoneNumberInstance
:param fields: 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.
:param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.
:param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests.
:param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests.
:param address_line1: User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
:param address_line2: User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
:param city: User’s city. This query parameter is only used (optionally) for identity_match package requests.
:param state: User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
:param postal_code: User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
:param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
:param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.
:param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
:param last_verified_date: 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.
:param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.
:returns: The fetched PhoneNumberInstance
"""
data = 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,
}
)
headers = values.of({})
headers["Accept"] = "application/json"
payload = self._version.fetch(
method="GET", uri=self._uri, params=data, headers=headers
)
return PhoneNumberInstance(
self._version,
payload,
phone_number=self._solution["phone_number"],
)
async def fetch_async(
self,
fields: Union[str, object] = values.unset,
country_code: Union[str, object] = values.unset,
first_name: Union[str, object] = values.unset,
last_name: Union[str, object] = values.unset,
address_line1: Union[str, object] = values.unset,
address_line2: Union[str, object] = values.unset,
city: Union[str, object] = values.unset,
state: Union[str, object] = values.unset,
postal_code: Union[str, object] = values.unset,
address_country_code: Union[str, object] = values.unset,
national_id: Union[str, object] = values.unset,
date_of_birth: Union[str, object] = values.unset,
last_verified_date: Union[str, object] = values.unset,
verification_sid: Union[str, object] = values.unset,
) -> PhoneNumberInstance:
"""
Asynchronous coroutine to fetch the PhoneNumberInstance
:param fields: 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.
:param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.
:param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests.
:param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests.
:param address_line1: User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
:param address_line2: User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
:param city: User’s city. This query parameter is only used (optionally) for identity_match package requests.
:param state: User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
:param postal_code: User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
:param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
:param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.
:param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
:param last_verified_date: 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.
:param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.
:returns: The fetched PhoneNumberInstance
"""
data = 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,
}
)
headers = values.of({})
headers["Accept"] = "application/json"
payload = await self._version.fetch_async(
method="GET", uri=self._uri, params=data, headers=headers
)
return PhoneNumberInstance(
self._version,
payload,
phone_number=self._solution["phone_number"],
)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Lookups.V2.PhoneNumberContext {}>".format(context)
class PhoneNumberList(ListResource):
def __init__(self, version: Version):
"""
Initialize the PhoneNumberList
:param version: Version that contains the resource
"""
super().__init__(version)
def get(self, phone_number: str) -> PhoneNumberContext:
"""
Constructs a PhoneNumberContext
:param phone_number: The phone number to lookup in E.164 or national format. Default country code is +1 (North America).
"""
return PhoneNumberContext(self._version, phone_number=phone_number)
def __call__(self, phone_number: str) -> PhoneNumberContext:
"""
Constructs a PhoneNumberContext
:param phone_number: The phone number to lookup in E.164 or national format. Default country code is +1 (North America).
"""
return PhoneNumberContext(self._version, phone_number=phone_number)
def __repr__(self) -> str:
"""
Provide a friendly representation
:returns: Machine friendly representation
"""
return "<Twilio.Lookups.V2.PhoneNumberList>"
|