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


module Twilio
    module REST
        class Lookups < LookupsBase
            class V2 < Version
                class PhoneNumberList < ListResource
                
                    ##
                    # Initialize the PhoneNumberList
                    # @param [Version] version Version that contains the resource
                    # @return [PhoneNumberList] PhoneNumberList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        
                        
                    end
                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Lookups.V2.PhoneNumberList>'
                    end
                end


                class PhoneNumberContext < InstanceContext
                    ##
                    # Initialize the PhoneNumberContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] phone_number The phone number to lookup in E.164 or national format. Default country code is +1 (North America).
                    # @return [PhoneNumberContext] PhoneNumberContext
                    def initialize(version, phone_number)
                        super(version)

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

                        
                    end
                    ##
                    # Fetch the PhoneNumberInstance
                    # @param [String] 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 [String] 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 [String] first_name User’s first name. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] last_name User’s last name. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_line1 User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_line2 User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] city User’s city. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] state User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] postal_code User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_country_code User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] 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 [String] date_of_birth User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] 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 [String] 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.
                    # @param [String] partner_sub_id The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis.
                    # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
                    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


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

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

                class PhoneNumberPage < Page
                    ##
                    # Initialize the PhoneNumberPage
                    # @param [Version] version Version that contains the resource
                    # @param [Response] response Response from the API
                    # @param [Hash] solution Path solution for the resource
                    # @return [PhoneNumberPage] PhoneNumberPage
                    def initialize(version, response, solution)
                        super(version, response)

                        # Path Solution
                        @solution = solution
                    end

                    ##
                    # Build an instance of PhoneNumberInstance
                    # @param [Hash] payload Payload response from the API
                    # @return [PhoneNumberInstance] PhoneNumberInstance
                    def get_instance(payload)
                        PhoneNumberInstance.new(@version, payload)
                    end

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Lookups.V2.PhoneNumberPage>'
                    end
                end
                class PhoneNumberInstance < InstanceResource
                    ##
                    # Initialize the PhoneNumberInstance
                    # @param [Version] version Version that contains the resource
                    # @param [Hash] payload payload that contains response from Twilio
                    # @param [String] account_sid The SID of the
                    #   {Account}[https://www.twilio.com/docs/iam/api/account] that created this PhoneNumber
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [PhoneNumberInstance] PhoneNumberInstance
                    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

                    ##
                    # Generate an instance context for the instance, the context is capable of
                    # performing various actions.  All instance actions are proxied to the context
                    # @return [PhoneNumberContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] International dialing prefix of the phone number defined in the E.164 standard.
                    def calling_country_code
                        @properties['calling_country_code']
                    end
                    
                    ##
                    # @return [String] The phone number's [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
                    def country_code
                        @properties['country_code']
                    end
                    
                    ##
                    # @return [String] 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.
                    def phone_number
                        @properties['phone_number']
                    end
                    
                    ##
                    # @return [String] The phone number in [national format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).
                    def national_format
                        @properties['national_format']
                    end
                    
                    ##
                    # @return [Boolean] Boolean which indicates if the phone number is in a valid range that can be freely assigned by a carrier to a user.
                    def valid
                        @properties['valid']
                    end
                    
                    ##
                    # @return [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.
                    def validation_errors
                        @properties['validation_errors']
                    end
                    
                    ##
                    # @return [CallerName] 
                    def caller_name
                        @properties['caller_name']
                    end
                    
                    ##
                    # @return [SimSwap] 
                    def sim_swap
                        @properties['sim_swap']
                    end
                    
                    ##
                    # @return [CallForwarding] 
                    def call_forwarding
                        @properties['call_forwarding']
                    end
                    
                    ##
                    # @return [LineTypeIntelligence] 
                    def line_type_intelligence
                        @properties['line_type_intelligence']
                    end
                    
                    ##
                    # @return [LineStatus] 
                    def line_status
                        @properties['line_status']
                    end
                    
                    ##
                    # @return [IdentityMatch] 
                    def identity_match
                        @properties['identity_match']
                    end
                    
                    ##
                    # @return [ReassignedNumber] 
                    def reassigned_number
                        @properties['reassigned_number']
                    end
                    
                    ##
                    # @return [SmsPumpingRisk] 
                    def sms_pumping_risk
                        @properties['sms_pumping_risk']
                    end
                    
                    ##
                    # @return [Hash] An object that contains information of a mobile phone number quality score. Quality score will return a risk score about the phone number.
                    def phone_number_quality_score
                        @properties['phone_number_quality_score']
                    end
                    
                    ##
                    # @return [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. 
                    def pre_fill
                        @properties['pre_fill']
                    end
                    
                    ##
                    # @return [String] The absolute URL of the resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # Fetch the PhoneNumberInstance
                    # @param [String] 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 [String] 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 [String] first_name User’s first name. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] last_name User’s last name. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_line1 User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_line2 User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] city User’s city. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] state User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] postal_code User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] address_country_code User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] 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 [String] date_of_birth User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
                    # @param [String] 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 [String] 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.
                    # @param [String] partner_sub_id The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis.
                    # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
                    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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
                        "<Twilio.Lookups.V2.PhoneNumberInstance #{values}>"
                    end

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

            end
        end
    end
end
