##
#    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 V2 < Version
                class BulkHostedNumberOrderList < ListResource
                
                    ##
                    # Initialize the BulkHostedNumberOrderList
                    # @param [Version] version Version that contains the resource
                    # @return [BulkHostedNumberOrderList] BulkHostedNumberOrderList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/HostedNumber/Orders/Bulk"
                        
                    end
                    ##
                    # Create the BulkHostedNumberOrderInstance
                    # @param [Object] body 
                    # @return [BulkHostedNumberOrderInstance] Created BulkHostedNumberOrderInstance
                    def create(body: :unset
                    )

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

                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Numbers.V2.BulkHostedNumberOrderList>'
                    end
                end


                class BulkHostedNumberOrderContext < InstanceContext
                    ##
                    # Initialize the BulkHostedNumberOrderContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] bulk_hosting_sid A 34 character string that uniquely identifies this BulkHostedNumberOrder.
                    # @return [BulkHostedNumberOrderContext] BulkHostedNumberOrderContext
                    def initialize(version, bulk_hosting_sid)
                        super(version)

                        # Path Solution
                        @solution = { bulk_hosting_sid: bulk_hosting_sid,  }
                        @uri = "/HostedNumber/Orders/Bulk/#{@solution[:bulk_hosting_sid]}"

                        
                    end
                    ##
                    # Fetch the BulkHostedNumberOrderInstance
                    # @param [String] order_status Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'.
                    # @return [BulkHostedNumberOrderInstance] Fetched BulkHostedNumberOrderInstance
                    def fetch(
                        order_status: :unset
                    )

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


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Numbers.V2.BulkHostedNumberOrderPage>'
                    end
                end
                class BulkHostedNumberOrderInstance < InstanceResource
                    ##
                    # Initialize the BulkHostedNumberOrderInstance
                    # @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 BulkHostedNumberOrder
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [BulkHostedNumberOrderInstance] BulkHostedNumberOrderInstance
                    def initialize(version, payload , bulk_hosting_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'bulk_hosting_sid' => payload['bulk_hosting_sid'],
                            'request_status' => payload['request_status'],
                            'friendly_name' => payload['friendly_name'],
                            'notification_email' => payload['notification_email'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'date_completed' => Twilio.deserialize_iso8601_datetime(payload['date_completed']),
                            'url' => payload['url'],
                            'total_count' => payload['total_count'] == nil ? payload['total_count'] : payload['total_count'].to_i,
                            'results' => payload['results'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'bulk_hosting_sid' => bulk_hosting_sid  || @properties['bulk_hosting_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 [BulkHostedNumberOrderContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = BulkHostedNumberOrderContext.new(@version , @params['bulk_hosting_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] A 34 character string that uniquely identifies this BulkHostedNumberOrder.
                    def bulk_hosting_sid
                        @properties['bulk_hosting_sid']
                    end
                    
                    ##
                    # @return [RequestStatus] 
                    def request_status
                        @properties['request_status']
                    end
                    
                    ##
                    # @return [String] A 128 character string that is a human-readable text that describes this resource.
                    def friendly_name
                        @properties['friendly_name']
                    end
                    
                    ##
                    # @return [String] Email address used for send notifications about this Bulk hosted number request.
                    def notification_email
                        @properties['notification_email']
                    end
                    
                    ##
                    # @return [Time] The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [Time] The date that this resource was completed, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
                    def date_completed
                        @properties['date_completed']
                    end
                    
                    ##
                    # @return [String] The URL of this BulkHostedNumberOrder resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [String] The total count of phone numbers in this Bulk hosting request.
                    def total_count
                        @properties['total_count']
                    end
                    
                    ##
                    # @return [Array<Hash>] Contains a list of all the individual hosting orders and their information, for this Bulk request. Each result object is grouped by its order status. To see a complete list of order status, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'.
                    def results
                        @properties['results']
                    end
                    
                    ##
                    # Fetch the BulkHostedNumberOrderInstance
                    # @param [String] order_status Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'.
                    # @return [BulkHostedNumberOrderInstance] Fetched BulkHostedNumberOrderInstance
                    def fetch(
                        order_status: :unset
                    )

                        context.fetch(
                            order_status: order_status, 
                        )
                    end

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

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

            end
        end
    end
end
