##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Bulkexports
#    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 Bulkexports < BulkexportsBase
            class V1 < Version
                class ExportList < ListResource
                
                    ##
                    # Initialize the ExportList
                    # @param [Version] version Version that contains the resource
                    # @return [ExportList] ExportList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Exports"
                        # Components
                        @jobs = nil
                    end
                

                ##
                # Access the jobs
                # @return [JobList]
                # @return [JobContext] if sid was passed.
                def jobs(job_sid=:unset)
                    raise ArgumentError, 'job_sid cannot be nil' if job_sid.nil?

                    if job_sid != :unset
                        return JobContext.new(@version,job_sid )
                    end

                    @jobs ||= JobList.new(@version )
                end

                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Bulkexports.V1.ExportList>'
                    end
                end


                class ExportContext < InstanceContext
                    ##
                    # Initialize the ExportContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] resource_type The type of communication – Messages, Calls, Conferences, and Participants
                    # @return [ExportContext] ExportContext
                    def initialize(version, resource_type)
                        super(version)

                        # Path Solution
                        @solution = { resource_type: resource_type,  }
                        @uri = "/Exports/#{@solution[:resource_type]}"

                        # Dependents
                        @export_custom_jobs = nil
                        @days = nil
                    end
                    ##
                    # Fetch the ExportInstance
                    # @return [ExportInstance] Fetched ExportInstance
                    def fetch

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

                    ##
                    # Access the export_custom_jobs
                    # @return [ExportCustomJobList]
                    # @return [ExportCustomJobContext]
                    def export_custom_jobs
                      unless @export_custom_jobs
                        @export_custom_jobs = ExportCustomJobList.new(
                                @version, resource_type: @solution[:resource_type], )
                      end
                      @export_custom_jobs
                    end
                    ##
                    # Access the days
                    # @return [DayList]
                    # @return [DayContext] if sid was passed.
                    def days(day=:unset)

                        raise ArgumentError, 'day cannot be nil' if day.nil?

                        if day != :unset
                            return DayContext.new(@version, @solution[:resource_type],day )
                        end

                        unless @days
                            @days = DayList.new(
                                @version, resource_type: @solution[:resource_type], )
                        end

                     @days
                    end

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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Bulkexports.V1.ExportPage>'
                    end
                end
                class ExportInstance < InstanceResource
                    ##
                    # Initialize the ExportInstance
                    # @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 Export
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [ExportInstance] ExportInstance
                    def initialize(version, payload , resource_type: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'resource_type' => payload['resource_type'],
                            'url' => payload['url'],
                            'links' => payload['links'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'resource_type' => resource_type  || @properties['resource_type']  , }
                    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 [ExportContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = ExportContext.new(@version , @params['resource_type'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The type of communication – Messages, Calls, Conferences, and Participants
                    def resource_type
                        @properties['resource_type']
                    end
                    
                    ##
                    # @return [String] The URL of this resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Hash] Contains a dictionary of URL links to nested resources of this Export.
                    def links
                        @properties['links']
                    end
                    
                    ##
                    # Fetch the ExportInstance
                    # @return [ExportInstance] Fetched ExportInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Access the export_custom_jobs
                    # @return [export_custom_jobs] export_custom_jobs
                    def export_custom_jobs
                        context.export_custom_jobs
                    end

                    ##
                    # Access the days
                    # @return [days] days
                    def days
                        context.days
                    end

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

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

            end
        end
    end
end
