##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Trunking
#    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 Trunking < TrunkingBase
            class V1 < Version
                class TrunkContext < InstanceContext

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


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Trunking.V1.RecordingList>'
                    end
                end


                class RecordingContext < InstanceContext
                    ##
                    # Initialize the RecordingContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] trunk_sid The SID of the Trunk that will have its recording settings updated.
                    # @return [RecordingContext] RecordingContext
                    def initialize(version, trunk_sid)
                        super(version)

                        # Path Solution
                        @solution = { trunk_sid: trunk_sid,  }
                        @uri = "/Trunks/#{@solution[:trunk_sid]}/Recording"

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

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

                    ##
                    # Update the RecordingInstance
                    # @param [RecordingMode] mode 
                    # @param [RecordingTrim] trim 
                    # @return [RecordingInstance] Updated RecordingInstance
                    def update(
                        mode: :unset, 
                        trim: :unset
                    )

                        data = Twilio::Values.of({
                            'Mode' => mode,
                            'Trim' => trim,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.update('POST', @uri, data: data, headers: headers)
                        RecordingInstance.new(
                            @version,
                            payload,
                            trunk_sid: @solution[:trunk_sid],
                        )
                    end


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Trunking.V1.RecordingPage>'
                    end
                end
                class RecordingInstance < InstanceResource
                    ##
                    # Initialize the RecordingInstance
                    # @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 Recording
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [RecordingInstance] RecordingInstance
                    def initialize(version, payload , trunk_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'mode' => payload['mode'],
                            'trim' => payload['trim'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'trunk_sid' => trunk_sid  || @properties['trunk_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 [RecordingContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = RecordingContext.new(@version , @params['trunk_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [RecordingMode] 
                    def mode
                        @properties['mode']
                    end
                    
                    ##
                    # @return [RecordingTrim] 
                    def trim
                        @properties['trim']
                    end
                    
                    ##
                    # Fetch the RecordingInstance
                    # @return [RecordingInstance] Fetched RecordingInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Update the RecordingInstance
                    # @param [RecordingMode] mode 
                    # @param [RecordingTrim] trim 
                    # @return [RecordingInstance] Updated RecordingInstance
                    def update(
                        mode: :unset, 
                        trim: :unset
                    )

                        context.update(
                            mode: mode, 
                            trim: trim, 
                        )
                    end

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

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

             end
            end
        end
    end
end


