##
#    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 CallContext < InstanceContext

                     class CallSummaryList < ListResource
                
                    ##
                    # Initialize the CallSummaryList
                    # @param [Version] version Version that contains the resource
                    # @return [CallSummaryList] CallSummaryList
                    def initialize(version, call_sid: nil)
                        super(version)
                        # Path Solution
                        @solution = { call_sid: call_sid }
                        
                        
                    end
                


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


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

                        # Path Solution
                        @solution = { call_sid: call_sid,  }
                        @uri = "/Voice/#{@solution[:call_sid]}/Summary"

                        
                    end
                    ##
                    # Fetch the CallSummaryInstance
                    # @param [ProcessingState] processing_state The Processing State of this Call Summary. One of `complete`, `partial` or `all`.
                    # @return [CallSummaryInstance] Fetched CallSummaryInstance
                    def fetch(
                        processing_state: :unset
                    )

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


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Insights.V1.CallSummaryPage>'
                    end
                end
                class CallSummaryInstance < InstanceResource
                    ##
                    # Initialize the CallSummaryInstance
                    # @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 CallSummary
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [CallSummaryInstance] CallSummaryInstance
                    def initialize(version, payload , call_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'account_sid' => payload['account_sid'],
                            'call_sid' => payload['call_sid'],
                            'call_type' => payload['call_type'],
                            'call_state' => payload['call_state'],
                            'answered_by' => payload['answered_by'],
                            'processing_state' => payload['processing_state'],
                            'created_time' => Twilio.deserialize_iso8601_datetime(payload['created_time']),
                            'start_time' => Twilio.deserialize_iso8601_datetime(payload['start_time']),
                            'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']),
                            'duration' => payload['duration'] == nil ? payload['duration'] : payload['duration'].to_i,
                            'connect_duration' => payload['connect_duration'] == nil ? payload['connect_duration'] : payload['connect_duration'].to_i,
                            'from' => payload['from'],
                            'to' => payload['to'],
                            'carrier_edge' => payload['carrier_edge'],
                            'client_edge' => payload['client_edge'],
                            'sdk_edge' => payload['sdk_edge'],
                            'sip_edge' => payload['sip_edge'],
                            'tags' => payload['tags'],
                            'url' => payload['url'],
                            'attributes' => payload['attributes'],
                            'properties' => payload['properties'],
                            'trust' => payload['trust'],
                            'annotation' => payload['annotation'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'call_sid' => call_sid  || @properties['call_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 [CallSummaryContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = CallSummaryContext.new(@version , @params['call_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Account.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Call.
                    def call_sid
                        @properties['call_sid']
                    end
                    
                    ##
                    # @return [CallType] 
                    def call_type
                        @properties['call_type']
                    end
                    
                    ##
                    # @return [CallState] 
                    def call_state
                        @properties['call_state']
                    end
                    
                    ##
                    # @return [AnsweredBy] 
                    def answered_by
                        @properties['answered_by']
                    end
                    
                    ##
                    # @return [ProcessingState] 
                    def processing_state
                        @properties['processing_state']
                    end
                    
                    ##
                    # @return [Time] The time at which the Call was created, given in ISO 8601 format. Can be different from `start_time` in the event of queueing due to CPS
                    def created_time
                        @properties['created_time']
                    end
                    
                    ##
                    # @return [Time] The time at which the Call was started, given in ISO 8601 format.
                    def start_time
                        @properties['start_time']
                    end
                    
                    ##
                    # @return [Time] The time at which the Call was ended, given in ISO 8601 format.
                    def end_time
                        @properties['end_time']
                    end
                    
                    ##
                    # @return [String] Duration between when the call was initiated and the call was ended
                    def duration
                        @properties['duration']
                    end
                    
                    ##
                    # @return [String] Duration between when the call was answered and when it ended
                    def connect_duration
                        @properties['connect_duration']
                    end
                    
                    ##
                    # @return [Hash] The calling party.
                    def from
                        @properties['from']
                    end
                    
                    ##
                    # @return [Hash] The called party.
                    def to
                        @properties['to']
                    end
                    
                    ##
                    # @return [Hash] Contains metrics and properties for the Twilio media gateway of a PSTN call.
                    def carrier_edge
                        @properties['carrier_edge']
                    end
                    
                    ##
                    # @return [Hash] Contains metrics and properties for the Twilio media gateway of a Client call.
                    def client_edge
                        @properties['client_edge']
                    end
                    
                    ##
                    # @return [Hash] Contains metrics and properties for the SDK sensor library for Client calls.
                    def sdk_edge
                        @properties['sdk_edge']
                    end
                    
                    ##
                    # @return [Hash] Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call.
                    def sip_edge
                        @properties['sip_edge']
                    end
                    
                    ##
                    # @return [Array<String>] Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality.
                    def tags
                        @properties['tags']
                    end
                    
                    ##
                    # @return [String] The URL of this resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Hash] Attributes capturing call-flow-specific details.
                    def attributes
                        @properties['attributes']
                    end
                    
                    ##
                    # @return [Hash] Contains edge-agnostic call-level details.
                    def properties
                        @properties['properties']
                    end
                    
                    ##
                    # @return [Hash] Contains trusted communications details including Branded Call and verified caller ID.
                    def trust
                        @properties['trust']
                    end
                    
                    ##
                    # @return [Hash] Programmatically labeled annotations for the Call. Developers can update the Call Summary records with Annotation during or after a Call. Annotations can be updated as long as the Call Summary record is addressable via the API.
                    def annotation
                        @properties['annotation']
                    end
                    
                    ##
                    # Fetch the CallSummaryInstance
                    # @param [ProcessingState] processing_state The Processing State of this Call Summary. One of `complete`, `partial` or `all`.
                    # @return [CallSummaryInstance] Fetched CallSummaryInstance
                    def fetch(
                        processing_state: :unset
                    )

                        context.fetch(
                            processing_state: processing_state, 
                        )
                    end

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

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

             end
            end
        end
    end
end


