##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Insights
#    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 Insights < InsightsBase
            class V1 < Version
                class ConferenceList < ListResource
                    ##
                    # Initialize the ConferenceList
                    # @param [Version] version Version that contains the resource
                    # @return [ConferenceList] ConferenceList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Conferences"
                        
                    end
                
                    ##
                    # Lists ConferenceInstance records from the API as a list.
                    # Unlike stream(), this operation is eager and will load `limit` records into
                    # memory before returning.
                    # @param [String] conference_sid The SID of the conference.
                    # @param [String] friendly_name Custom label for the conference resource, up to 64 characters.
                    # @param [String] status Conference status.
                    # @param [String] created_after Conferences created after the provided timestamp specified in ISO 8601 format
                    # @param [String] created_before Conferences created before the provided timestamp specified in ISO 8601 format.
                    # @param [String] mixer_region Twilio region where the conference media was mixed.
                    # @param [String] tags Tags applied by Twilio for common potential configuration, quality, or performance issues.
                    # @param [String] subaccount Account SID for the subaccount whose resources you wish to retrieve.
                    # @param [String] detected_issues Potential configuration, behavior, or performance issues detected during the conference.
                    # @param [String] end_reason Conference end reason; e.g. last participant left, modified by API, etc.
                    # @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(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, limit: nil, page_size: nil)
                        self.stream(
                            conference_sid: conference_sid,
                            friendly_name: friendly_name,
                            status: status,
                            created_after: created_after,
                            created_before: created_before,
                            mixer_region: mixer_region,
                            tags: tags,
                            subaccount: subaccount,
                            detected_issues: detected_issues,
                            end_reason: end_reason,
                            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] conference_sid The SID of the conference.
                    # @param [String] friendly_name Custom label for the conference resource, up to 64 characters.
                    # @param [String] status Conference status.
                    # @param [String] created_after Conferences created after the provided timestamp specified in ISO 8601 format
                    # @param [String] created_before Conferences created before the provided timestamp specified in ISO 8601 format.
                    # @param [String] mixer_region Twilio region where the conference media was mixed.
                    # @param [String] tags Tags applied by Twilio for common potential configuration, quality, or performance issues.
                    # @param [String] subaccount Account SID for the subaccount whose resources you wish to retrieve.
                    # @param [String] detected_issues Potential configuration, behavior, or performance issues detected during the conference.
                    # @param [String] end_reason Conference end reason; e.g. last participant left, modified by API, etc.
                    # @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(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, limit: nil, page_size: nil)
                        limits = @version.read_limits(limit, page_size)

                        page = self.page(
                            conference_sid: conference_sid,
                            friendly_name: friendly_name,
                            status: status,
                            created_after: created_after,
                            created_before: created_before,
                            mixer_region: mixer_region,
                            tags: tags,
                            subaccount: subaccount,
                            detected_issues: detected_issues,
                            end_reason: end_reason,
                            page_size: limits[:page_size], )

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

                    ##
                    # When passed a block, yields ConferenceInstance 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 ConferenceInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] conference_sid The SID of the conference.
                    # @param [String] friendly_name Custom label for the conference resource, up to 64 characters.
                    # @param [String] status Conference status.
                    # @param [String] created_after Conferences created after the provided timestamp specified in ISO 8601 format
                    # @param [String] created_before Conferences created before the provided timestamp specified in ISO 8601 format.
                    # @param [String] mixer_region Twilio region where the conference media was mixed.
                    # @param [String] tags Tags applied by Twilio for common potential configuration, quality, or performance issues.
                    # @param [String] subaccount Account SID for the subaccount whose resources you wish to retrieve.
                    # @param [String] detected_issues Potential configuration, behavior, or performance issues detected during the conference.
                    # @param [String] end_reason Conference end reason; e.g. last participant left, modified by API, etc.
                    # @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 ConferenceInstance
                    def page(conference_sid: :unset, friendly_name: :unset, status: :unset, created_after: :unset, created_before: :unset, mixer_region: :unset, tags: :unset, subaccount: :unset, detected_issues: :unset, end_reason: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
                        params = Twilio::Values.of({
                            'ConferenceSid' => conference_sid,
                            'FriendlyName' => friendly_name,
                            'Status' => status,
                            'CreatedAfter' => created_after,
                            'CreatedBefore' => created_before,
                            'MixerRegion' => mixer_region,
                            'Tags' => tags,
                            'Subaccount' => subaccount,
                            'DetectedIssues' => detected_issues,
                            'EndReason' => end_reason,
                            'PageToken' => page_token,
                            'Page' => page_number,
                            'PageSize' => page_size,
                        })

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

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

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


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Insights.V1.ConferenceList>'
                    end
                end


                class ConferenceContext < InstanceContext
                    ##
                    # Initialize the ConferenceContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] conference_sid The unique SID identifier of the Conference.
                    # @return [ConferenceContext] ConferenceContext
                    def initialize(version, conference_sid)
                        super(version)

                        # Path Solution
                        @solution = { conference_sid: conference_sid,  }
                        @uri = "/Conferences/#{@solution[:conference_sid]}"

                        # Dependents
                        @conference_participants = nil
                    end
                    ##
                    # Fetch the ConferenceInstance
                    # @return [ConferenceInstance] Fetched ConferenceInstance
                    def fetch

                        payload = @version.fetch('GET', @uri)
                        ConferenceInstance.new(
                            @version,
                            payload,
                            conference_sid: @solution[:conference_sid],
                        )
                    end

                    ##
                    # Access the conference_participants
                    # @return [ConferenceParticipantList]
                    # @return [ConferenceParticipantContext] if sid was passed.
                    def conference_participants(participant_sid=:unset)

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

                        if participant_sid != :unset
                            return ConferenceParticipantContext.new(@version, @solution[:conference_sid],participant_sid )
                        end

                        unless @conference_participants
                            @conference_participants = ConferenceParticipantList.new(
                                @version, conference_sid: @solution[:conference_sid], )
                        end

                     @conference_participants
                    end

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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Insights.V1.ConferencePage>'
                    end
                end
                class ConferenceInstance < InstanceResource
                    ##
                    # Initialize the ConferenceInstance
                    # @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 Conference
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [ConferenceInstance] ConferenceInstance
                    def initialize(version, payload , conference_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'conference_sid' => payload['conference_sid'],
                            'account_sid' => payload['account_sid'],
                            'friendly_name' => payload['friendly_name'],
                            'create_time' => Twilio.deserialize_iso8601_datetime(payload['create_time']),
                            'start_time' => Twilio.deserialize_iso8601_datetime(payload['start_time']),
                            'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']),
                            'duration_seconds' => payload['duration_seconds'] == nil ? payload['duration_seconds'] : payload['duration_seconds'].to_i,
                            'connect_duration_seconds' => payload['connect_duration_seconds'] == nil ? payload['connect_duration_seconds'] : payload['connect_duration_seconds'].to_i,
                            'status' => payload['status'],
                            'max_participants' => payload['max_participants'] == nil ? payload['max_participants'] : payload['max_participants'].to_i,
                            'max_concurrent_participants' => payload['max_concurrent_participants'] == nil ? payload['max_concurrent_participants'] : payload['max_concurrent_participants'].to_i,
                            'unique_participants' => payload['unique_participants'] == nil ? payload['unique_participants'] : payload['unique_participants'].to_i,
                            'end_reason' => payload['end_reason'],
                            'ended_by' => payload['ended_by'],
                            'mixer_region' => payload['mixer_region'],
                            'mixer_region_requested' => payload['mixer_region_requested'],
                            'recording_enabled' => payload['recording_enabled'],
                            'detected_issues' => payload['detected_issues'],
                            'tags' => payload['tags'],
                            'tag_info' => payload['tag_info'],
                            'processing_state' => payload['processing_state'],
                            'url' => payload['url'],
                            'links' => payload['links'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'conference_sid' => conference_sid  || @properties['conference_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 [ConferenceContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = ConferenceContext.new(@version , @params['conference_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Conference.
                    def conference_sid
                        @properties['conference_sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Account.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] Custom label for the conference resource, up to 64 characters.
                    def friendly_name
                        @properties['friendly_name']
                    end
                    
                    ##
                    # @return [Time] Conference creation date and time in ISO 8601 format.
                    def create_time
                        @properties['create_time']
                    end
                    
                    ##
                    # @return [Time] Timestamp in ISO 8601 format when the conference started. Conferences do not start until at least two participants join, at least one of whom has startConferenceOnEnter=true.
                    def start_time
                        @properties['start_time']
                    end
                    
                    ##
                    # @return [Time] Conference end date and time in ISO 8601 format.
                    def end_time
                        @properties['end_time']
                    end
                    
                    ##
                    # @return [String] Conference duration in seconds.
                    def duration_seconds
                        @properties['duration_seconds']
                    end
                    
                    ##
                    # @return [String] Duration of the between conference start event and conference end event in seconds.
                    def connect_duration_seconds
                        @properties['connect_duration_seconds']
                    end
                    
                    ##
                    # @return [ConferenceStatus] 
                    def status
                        @properties['status']
                    end
                    
                    ##
                    # @return [String] Maximum number of concurrent participants as specified by the configuration.
                    def max_participants
                        @properties['max_participants']
                    end
                    
                    ##
                    # @return [String] Actual maximum number of concurrent participants in the conference.
                    def max_concurrent_participants
                        @properties['max_concurrent_participants']
                    end
                    
                    ##
                    # @return [String] Unique conference participants based on caller ID.
                    def unique_participants
                        @properties['unique_participants']
                    end
                    
                    ##
                    # @return [ConferenceEndReason] 
                    def end_reason
                        @properties['end_reason']
                    end
                    
                    ##
                    # @return [String] Call SID of the participant whose actions ended the conference.
                    def ended_by
                        @properties['ended_by']
                    end
                    
                    ##
                    # @return [Region] 
                    def mixer_region
                        @properties['mixer_region']
                    end
                    
                    ##
                    # @return [Region] 
                    def mixer_region_requested
                        @properties['mixer_region_requested']
                    end
                    
                    ##
                    # @return [Boolean] Boolean. Indicates whether recording was enabled at the conference mixer.
                    def recording_enabled
                        @properties['recording_enabled']
                    end
                    
                    ##
                    # @return [Hash] Potential issues detected by Twilio during the conference.
                    def detected_issues
                        @properties['detected_issues']
                    end
                    
                    ##
                    # @return [Array<Tag>] Tags for detected conference conditions and participant behaviors which may be of interest.
                    def tags
                        @properties['tags']
                    end
                    
                    ##
                    # @return [Hash] Object. Contains details about conference tags including severity.
                    def tag_info
                        @properties['tag_info']
                    end
                    
                    ##
                    # @return [ProcessingState] 
                    def processing_state
                        @properties['processing_state']
                    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 Conference.
                    def links
                        @properties['links']
                    end
                    
                    ##
                    # Fetch the ConferenceInstance
                    # @return [ConferenceInstance] Fetched ConferenceInstance
                    def fetch

                        context.fetch
                    end

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

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

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

            end
        end
    end
end
