##
#    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 AnnotationList < ListResource
                
                    ##
                    # Initialize the AnnotationList
                    # @param [Version] version Version that contains the resource
                    # @return [AnnotationList] AnnotationList
                    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.AnnotationList>'
                    end
                end


                class AnnotationContext < InstanceContext
                    ##
                    # Initialize the AnnotationContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] call_sid The unique string that Twilio created to identify this Call resource. It always starts with a CA.
                    # @return [AnnotationContext] AnnotationContext
                    def initialize(version, call_sid)
                        super(version)

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

                        
                    end
                    ##
                    # Fetch the AnnotationInstance
                    # @return [AnnotationInstance] Fetched AnnotationInstance
                    def fetch

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

                    ##
                    # Update the AnnotationInstance
                    # @param [AnsweredBy] answered_by 
                    # @param [ConnectivityIssue] connectivity_issue 
                    # @param [String] quality_issues Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call.
                    # @param [Boolean] spam A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call.
                    # @param [String] call_score Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad].
                    # @param [String] comment Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`.
                    # @param [String] incident Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`.
                    # @return [AnnotationInstance] Updated AnnotationInstance
                    def update(
                        answered_by: :unset, 
                        connectivity_issue: :unset, 
                        quality_issues: :unset, 
                        spam: :unset, 
                        call_score: :unset, 
                        comment: :unset, 
                        incident: :unset
                    )

                        data = Twilio::Values.of({
                            'AnsweredBy' => answered_by,
                            'ConnectivityIssue' => connectivity_issue,
                            'QualityIssues' => quality_issues,
                            'Spam' => spam,
                            'CallScore' => call_score,
                            'Comment' => comment,
                            'Incident' => incident,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.update('POST', @uri, data: data, headers: headers)
                        AnnotationInstance.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.AnnotationContext #{context}>"
                    end

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Insights.V1.AnnotationPage>'
                    end
                end
                class AnnotationInstance < InstanceResource
                    ##
                    # Initialize the AnnotationInstance
                    # @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 Annotation
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [AnnotationInstance] AnnotationInstance
                    def initialize(version, payload , call_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'call_sid' => payload['call_sid'],
                            'account_sid' => payload['account_sid'],
                            'answered_by' => payload['answered_by'],
                            'connectivity_issue' => payload['connectivity_issue'],
                            'quality_issues' => payload['quality_issues'],
                            'spam' => payload['spam'],
                            'call_score' => payload['call_score'] == nil ? payload['call_score'] : payload['call_score'].to_i,
                            'comment' => payload['comment'],
                            'incident' => payload['incident'],
                            'url' => payload['url'],
                        }

                        # 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 [AnnotationContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = AnnotationContext.new(@version , @params['call_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Call.
                    def call_sid
                        @properties['call_sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Account.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [AnsweredBy] 
                    def answered_by
                        @properties['answered_by']
                    end
                    
                    ##
                    # @return [ConnectivityIssue] 
                    def connectivity_issue
                        @properties['connectivity_issue']
                    end
                    
                    ##
                    # @return [Array<String>] Specifies if the call had any subjective quality issues. Possible values are one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, or `static_noise`.
                    def quality_issues
                        @properties['quality_issues']
                    end
                    
                    ##
                    # @return [Boolean] Specifies if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call.
                    def spam
                        @properties['spam']
                    end
                    
                    ##
                    # @return [String] Specifies the Call Score, if available. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad].
                    def call_score
                        @properties['call_score']
                    end
                    
                    ##
                    # @return [String] Specifies any comments pertaining to the call. Twilio does not treat this field as PII, so no PII should be included in comments.
                    def comment
                        @properties['comment']
                    end
                    
                    ##
                    # @return [String] Incident or support ticket associated with this call. The `incident` property is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`.
                    def incident
                        @properties['incident']
                    end
                    
                    ##
                    # @return [String] 
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # Fetch the AnnotationInstance
                    # @return [AnnotationInstance] Fetched AnnotationInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Update the AnnotationInstance
                    # @param [AnsweredBy] answered_by 
                    # @param [ConnectivityIssue] connectivity_issue 
                    # @param [String] quality_issues Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call.
                    # @param [Boolean] spam A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call.
                    # @param [String] call_score Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad].
                    # @param [String] comment Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`.
                    # @param [String] incident Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`.
                    # @return [AnnotationInstance] Updated AnnotationInstance
                    def update(
                        answered_by: :unset, 
                        connectivity_issue: :unset, 
                        quality_issues: :unset, 
                        spam: :unset, 
                        call_score: :unset, 
                        comment: :unset, 
                        incident: :unset
                    )

                        context.update(
                            answered_by: answered_by, 
                            connectivity_issue: connectivity_issue, 
                            quality_issues: quality_issues, 
                            spam: spam, 
                            call_score: call_score, 
                            comment: comment, 
                            incident: incident, 
                        )
                    end

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

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

             end
            end
        end
    end
end


