##
#    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 PortingAllPortInList < ListResource
                
                    ##
                    # Initialize the PortingAllPortInList
                    # @param [Version] version Version that contains the resource
                    # @return [PortingAllPortInList] PortingAllPortInList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Porting/PortIn/PortInRequests"
                        
                    end
                
                    ##
                    # Lists PortingAllPortInInstance records from the API as a list.
                    # Unlike stream(), this operation is eager and will load `limit` records into
                    # memory before returning.
                    # @param [String] token Page start token, if null then it will start from the beginning
                    # @param [String] size Number of items per page
                    # @param [String] port_in_request_sid Filter by Port in request SID, supports multiple values separated by comma
                    # @param [String] port_in_request_status Filter by Port In request status
                    # @param [Time] created_before Find all created before a certain date
                    # @param [Time] created_after Find all created after a certain date
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Array] Array of up to limit results
                    def list(token: :unset, size: :unset, port_in_request_sid: :unset, port_in_request_status: :unset, created_before: :unset, created_after: :unset, limit: nil, page_size: nil)
                        self.stream(
                            token: token,
                            size: size,
                            port_in_request_sid: port_in_request_sid,
                            port_in_request_status: port_in_request_status,
                            created_before: created_before,
                            created_after: created_after,
                            limit: limit,
                            page_size: page_size
                        ).entries
                    end

                    ##
                    # Streams Instance records from the API as an Enumerable.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    # @param [String] token Page start token, if null then it will start from the beginning
                    # @param [String] size Number of items per page
                    # @param [String] port_in_request_sid Filter by Port in request SID, supports multiple values separated by comma
                    # @param [String] port_in_request_status Filter by Port In request status
                    # @param [Time] created_before Find all created before a certain date
                    # @param [Time] created_after Find all created after a certain date
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Enumerable] Enumerable that will yield up to limit results
                    def stream(token: :unset, size: :unset, port_in_request_sid: :unset, port_in_request_status: :unset, created_before: :unset, created_after: :unset, limit: nil, page_size: nil)
                        limits = @version.read_limits(limit, page_size)

                        page = self.page(
                            token: token,
                            size: size,
                            port_in_request_sid: port_in_request_sid,
                            port_in_request_status: port_in_request_status,
                            created_before: created_before,
                            created_after: created_after,
                            page_size: limits[:page_size], )

                        @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
                    end

                    ##
                    # When passed a block, yields PortingAllPortInInstance records from the API.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    def each
                        limits = @version.read_limits

                        page = self.page(page_size: limits[:page_size], )

                        @version.stream(page,
                            limit: limits[:limit],
                            page_limit: limits[:page_limit]).each {|x| yield x}
                    end

                    ##
                    # Retrieve a single page of PortingAllPortInInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] token Page start token, if null then it will start from the beginning
                    # @param [String] size Number of items per page
                    # @param [String] port_in_request_sid Filter by Port in request SID, supports multiple values separated by comma
                    # @param [String] port_in_request_status Filter by Port In request status
                    # @param [Time] created_before Find all created before a certain date
                    # @param [Time] created_after Find all created after a certain date
                    # @param [String] page_token PageToken provided by the API
                    # @param [Integer] page_number Page Number, this value is simply for client state
                    # @param [Integer] page_size Number of records to return, defaults to 50
                    # @return [Page] Page of PortingAllPortInInstance
                    def page(token: :unset, size: :unset, port_in_request_sid: :unset, port_in_request_status: :unset, created_before: :unset, created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
                        params = Twilio::Values.of({
                            'Token' => token,
                            'Size' => size,
                            'PortInRequestSid' => port_in_request_sid,
                            'PortInRequestStatus' => port_in_request_status,
                            'CreatedBefore' =>  Twilio.serialize_iso8601_datetime(created_before),
                            'CreatedAfter' =>  Twilio.serialize_iso8601_datetime(created_after),
                            'PageToken' => page_token,
                            'Page' => page_number,
                            'PageSize' => page_size,
                        })
                        headers = Twilio::Values.of({})
                        
                        

                        response = @version.page('GET', @uri, params: params, headers: headers)

                        PortingAllPortInPage.new(@version, response, @solution)
                    end

                    ##
                    # Retrieve a single page of PortingAllPortInInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] target_url API-generated URL for the requested results page
                    # @return [Page] Page of PortingAllPortInInstance
                    def get_page(target_url)
                        response = @version.domain.request(
                            'GET',
                            target_url
                        )
                    PortingAllPortInPage.new(@version, response, @solution)
                    end
                    


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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Numbers.V1.PortingAllPortInPage>'
                    end
                end
                class PortingAllPortInInstance < InstanceResource
                    ##
                    # Initialize the PortingAllPortInInstance
                    # @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 PortingAllPortIn
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [PortingAllPortInInstance] PortingAllPortInInstance
                    def initialize(version, payload )
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'port_in_request_sid' => payload['port_in_request_sid'],
                            'port_in_request_status' => payload['port_in_request_status'],
                            'status_last_updated_timestamp' => payload['status_last_updated_timestamp'],
                            'phone_numbers_requested' => payload['phone_numbers_requested'] == nil ? payload['phone_numbers_requested'] : payload['phone_numbers_requested'].to_i,
                            'phone_numbers_ported' => payload['phone_numbers_ported'] == nil ? payload['phone_numbers_ported'] : payload['phone_numbers_ported'].to_i,
                            'suggested_action' => payload['suggested_action'],
                        }
                    end

                    
                    ##
                    # @return [String] The SID of the Port-in request
                    def port_in_request_sid
                        @properties['port_in_request_sid']
                    end
                    
                    ##
                    # @return [String] Status of the Port In Request
                    def port_in_request_status
                        @properties['port_in_request_status']
                    end
                    
                    ##
                    # @return [String] The last updated timestamp of the request
                    def status_last_updated_timestamp
                        @properties['status_last_updated_timestamp']
                    end
                    
                    ##
                    # @return [String] Amount of phone numbers requested
                    def phone_numbers_requested
                        @properties['phone_numbers_requested']
                    end
                    
                    ##
                    # @return [String] Amount of phone numbers ported
                    def phone_numbers_ported
                        @properties['phone_numbers_ported']
                    end
                    
                    ##
                    # @return [String] Suggested action on this ticket
                    def suggested_action
                        @properties['suggested_action']
                    end
                    
                    ##
                    # Provide a user friendly representation
                    def to_s
                        "<Twilio.Numbers.V1.PortingAllPortInInstance>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        "<Twilio.Numbers.V1.PortingAllPortInInstance>"
                    end
                end

            end
        end
    end
end
