##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Numbers
#    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 Numbers < NumbersBase
            class V1 < Version
                class PortingPortInList < ListResource
                
                    class NumbersV1PortingAddress
                            # @param [street]: [String] The street address, ex: 101 Spear St
                            # @param [street_2]: [String] The building information, ex : 5th floor.
                            # @param [city]: [String] The city name, ex: San Francisco.
                            # @param [state]: [String] The state name, ex: CA or California. Note this should match the losing carrier’s information exactly. So if they spell out the entire state’s name instead of abbreviating it, please do so.
                            # @param [zip]: [String] The zip code, ex: 94105.
                            # @param [country]: [String] The country, ex: USA.
                        attr_accessor :street, :street_2, :city, :state, :zip, :country
                        def initialize(payload)
                                @street = payload["street"]
                                @street_2 = payload["street_2"]
                                @city = payload["city"]
                                @state = payload["state"]
                                @zip = payload["zip"]
                                @country = payload["country"]
                        end
                        def to_json(options = {})
                        {
                                "street": @street,
                                "street_2": @street_2,
                                "city": @city,
                                "state": @state,
                                "zip": @zip,
                                "country": @country,
                        }.to_json(options)
                        end
                    end

                    class NumbersV1PortingPortInCreate
                            # @param [account_sid]: [String] Account Sid or subaccount where the phone number(s) will be Ported
                            # @param [documents]: [Array<String>] List of document SIDs for all phone numbers included in the port in request. At least one document SID referring to a document of the type Utility Bill is required.
                            # @param [phone_numbers]: [Array<PortingPortInList.NumbersV1PortingPortInCreatePhoneNumbers>] List of phone numbers to be ported. Maximum of 1,000 phone numbers per request.
                            # @param [losing_carrier_information]: [PortingPortInList.NumbersV1PortingLosingCarrierInformation] 
                            # @param [notification_emails]: [Array<String>] Additional emails to send a copy of the signed LOA to.
                            # @param [target_port_in_date]: [Date] Target date to port the number. We cannot guarantee that this date will be honored by the other carriers, please work with Ops to get a confirmation of the firm order commitment (FOC) date. Expected format is ISO Local Date, example: ‘2011-12-03`. This date must be at least 7 days in the future for US ports and 10 days in the future for Japanese ports. We can't guarantee the exact date and time, as this depends on the losing carrier
                            # @param [target_port_in_time_range_start]: [String] The earliest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. We can't guarantee the exact date and time, as this depends on the losing carrier
                            # @param [target_port_in_time_range_end]: [String] The latest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. We can't guarantee the exact date and time, as this depends on the losing carrier
                            # @param [bundle_sid]: [String] The bundle sid is an optional identifier to reference a group of regulatory documents for a port request.
                            # @param [portability_advance_carrier]: [String] A field only required for Japan port in requests. It is a unique identifier for the donor carrier service the line is being ported from.
                            # @param [auto_cancel_approval_numbers]: [String] Japan specific field, indicates the number of phone numbers to automatically approve for cancellation.
                        attr_accessor :account_sid, :documents, :phone_numbers, :losing_carrier_information, :notification_emails, :target_port_in_date, :target_port_in_time_range_start, :target_port_in_time_range_end, :bundle_sid, :portability_advance_carrier, :auto_cancel_approval_numbers
                        def initialize(payload)
                                @account_sid = payload["account_sid"]
                                @documents = payload["documents"]
                                @phone_numbers = payload["phone_numbers"]
                                @losing_carrier_information = payload["losing_carrier_information"]
                                @notification_emails = payload["notification_emails"]
                                @target_port_in_date = payload["target_port_in_date"]
                                @target_port_in_time_range_start = payload["target_port_in_time_range_start"]
                                @target_port_in_time_range_end = payload["target_port_in_time_range_end"]
                                @bundle_sid = payload["bundle_sid"]
                                @portability_advance_carrier = payload["portability_advance_carrier"]
                                @auto_cancel_approval_numbers = payload["auto_cancel_approval_numbers"]
                        end
                        def to_json(options = {})
                        {
                                "account_sid": @account_sid,
                                "documents": @documents,
                                "phone_numbers": @phone_numbers,
                                "losing_carrier_information": @losing_carrier_information,
                                "notification_emails": @notification_emails,
                                "target_port_in_date": @target_port_in_date,
                                "target_port_in_time_range_start": @target_port_in_time_range_start,
                                "target_port_in_time_range_end": @target_port_in_time_range_end,
                                "bundle_sid": @bundle_sid,
                                "portability_advance_carrier": @portability_advance_carrier,
                                "auto_cancel_approval_numbers": @auto_cancel_approval_numbers,
                        }.to_json(options)
                        end
                    end

                    class NumbersV1PortingPortInCreatePhoneNumbers
                            # @param [phone_number]: [String] Phone number to be ported. This must be in the E164 Format.
                            # @param [pin]: [String] Some losing carriers require a PIN to authorize the port of a phone number. If the phone number is a US mobile phone number, the PIN is mandatory to process a porting request. Other carriers and number types may also require a PIN, you'll need to contact the losing carrier to determine what your phone number's PIN is.
                        attr_accessor :phone_number, :pin
                        def initialize(payload)
                                @phone_number = payload["phone_number"]
                                @pin = payload["pin"]
                        end
                        def to_json(options = {})
                        {
                                "phone_number": @phone_number,
                                "pin": @pin,
                        }.to_json(options)
                        end
                    end


                    ##
                    # Initialize the PortingPortInList
                    # @param [Version] version Version that contains the resource
                    # @return [PortingPortInList] PortingPortInList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Porting/PortIn"
                        
                    end
                    ##
                    # Create the PortingPortInInstance
                    # @param [NumbersV1PortingPortInCreate] numbers_v1_porting_port_in_create 
                    # @return [PortingPortInInstance] Created PortingPortInInstance
                    def create(numbers_v1_porting_port_in_create: nil
                    )

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        headers['Content-Type'] = 'application/json'
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, headers: headers, data: numbers_v1_porting_port_in_create.to_json)
                        PortingPortInInstance.new(
                            @version,
                            payload,
                        )
                    end

                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Numbers.V1.PortingPortInList>'
                    end
                end


                class PortingPortInContext < InstanceContext
                    ##
                    # Initialize the PortingPortInContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] port_in_request_sid The SID of the Port In request. This is a unique identifier of the port in request.
                    # @return [PortingPortInContext] PortingPortInContext
                    def initialize(version, port_in_request_sid)
                        super(version)

                        # Path Solution
                        @solution = { port_in_request_sid: port_in_request_sid,  }
                        @uri = "/Porting/PortIn/#{@solution[:port_in_request_sid]}"

                        
                    end
                    ##
                    # Delete the PortingPortInInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        @version.delete('DELETE', @uri, headers: headers)
                    end

                    ##
                    # Fetch the PortingPortInInstance
                    # @return [PortingPortInInstance] Fetched PortingPortInInstance
                    def fetch

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.fetch('GET', @uri, headers: headers)
                        PortingPortInInstance.new(
                            @version,
                            payload,
                            port_in_request_sid: @solution[:port_in_request_sid],
                        )
                    end


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Numbers.V1.PortingPortInPage>'
                    end
                end
                class PortingPortInInstance < InstanceResource
                    ##
                    # Initialize the PortingPortInInstance
                    # @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 PortingPortIn
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [PortingPortInInstance] PortingPortInInstance
                    def initialize(version, payload , port_in_request_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'port_in_request_sid' => payload['port_in_request_sid'],
                            'url' => payload['url'],
                            'account_sid' => payload['account_sid'],
                            'notification_emails' => payload['notification_emails'],
                            'target_port_in_date' => Twilio.deserialize_iso8601_date(payload['target_port_in_date']),
                            'target_port_in_time_range_start' => payload['target_port_in_time_range_start'],
                            'target_port_in_time_range_end' => payload['target_port_in_time_range_end'],
                            'port_in_request_status' => payload['port_in_request_status'],
                            'order_cancellation_reason' => payload['order_cancellation_reason'],
                            'losing_carrier_information' => payload['losing_carrier_information'],
                            'phone_numbers' => payload['phone_numbers'],
                            'bundle_sid' => payload['bundle_sid'],
                            'portability_advance_carrier' => payload['portability_advance_carrier'],
                            'auto_cancel_approval_numbers' => payload['auto_cancel_approval_numbers'],
                            'documents' => payload['documents'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'support_ticket_id' => payload['support_ticket_id'] == nil ? payload['support_ticket_id'] : payload['support_ticket_id'].to_i,
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'port_in_request_sid' => port_in_request_sid  || @properties['port_in_request_sid']  , }
                    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 [PortingPortInContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = PortingPortInContext.new(@version , @params['port_in_request_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The SID of the Port In request. This is a unique identifier of the port in request.
                    def port_in_request_sid
                        @properties['port_in_request_sid']
                    end
                    
                    ##
                    # @return [String] The URL of this Port In request
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [String] Account Sid or subaccount where the phone number(s) will be Ported
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [Array<String>] Additional emails to send a copy of the signed LOA to.
                    def notification_emails
                        @properties['notification_emails']
                    end
                    
                    ##
                    # @return [Date] Target date to port the number. We cannot guarantee that this date will be honored by the other carriers, please work with Ops to get a confirmation of the firm order commitment (FOC) date. Expected format is ISO Local Date, example: ‘2011-12-03`. This date must be at least 7 days in the future for US ports and 10 days in the future for Japanese ports. If a start and end range is provided, the date will be converted to its UTC equivalent with the ranges as reference and stored in UTC. We can't guarantee the exact date and time, as this depends on the losing carrier.
                    def target_port_in_date
                        @properties['target_port_in_date']
                    end
                    
                    ##
                    # @return [String] The earliest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. We can't guarantee the exact date and time, as this depends on the losing carrier. The time will be stored and returned as UTC standard timezone.
                    def target_port_in_time_range_start
                        @properties['target_port_in_time_range_start']
                    end
                    
                    ##
                    # @return [String] The latest time that the port should occur on the target port in date. Expected format is ISO Offset Time, example: ‘10:15:00-08:00'. We can't guarantee the exact date and time, as this depends on the losing carrier. The time will be stored and returned as UTC standard timezone.
                    def target_port_in_time_range_end
                        @properties['target_port_in_time_range_end']
                    end
                    
                    ##
                    # @return [String] The status of the port in request. The possible values are: In progress, Completed, Expired, In review, Waiting for Signature, Action Required, and Canceled.
                    def port_in_request_status
                        @properties['port_in_request_status']
                    end
                    
                    ##
                    # @return [String] If the order is cancelled this field will provide further context on the cause of the cancellation.
                    def order_cancellation_reason
                        @properties['order_cancellation_reason']
                    end
                    
                    ##
                    # @return [NumbersV1PortingLosingCarrierInformation] 
                    def losing_carrier_information
                        @properties['losing_carrier_information']
                    end
                    
                    ##
                    # @return [Array<NumbersV1PortingPortInPhoneNumberResult>] 
                    def phone_numbers
                        @properties['phone_numbers']
                    end
                    
                    ##
                    # @return [String] The bundle sid is an optional identifier to reference a group of regulatory documents for a port request.
                    def bundle_sid
                        @properties['bundle_sid']
                    end
                    
                    ##
                    # @return [String] A field only required for Japan port in requests. It is a unique identifier for the donor carrier service the line is being ported from.
                    def portability_advance_carrier
                        @properties['portability_advance_carrier']
                    end
                    
                    ##
                    # @return [String] Japan specific field, indicates the number of phone numbers to automatically approve for cancellation.
                    def auto_cancel_approval_numbers
                        @properties['auto_cancel_approval_numbers']
                    end
                    
                    ##
                    # @return [Array<String>] List of document SIDs for all phone numbers included in the port in request. At least one document SID referring to a document of the type Utility Bill is required.
                    def documents
                        @properties['documents']
                    end
                    
                    ##
                    # @return [Time] 
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [String] Unique ID of the request's support ticket
                    def support_ticket_id
                        @properties['support_ticket_id']
                    end
                    
                    ##
                    # Delete the PortingPortInInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        context.delete
                    end

                    ##
                    # Fetch the PortingPortInInstance
                    # @return [PortingPortInInstance] Fetched PortingPortInInstance
                    def fetch

                        context.fetch
                    end

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

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

            end
        end
    end
end
