##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Taskrouter
#    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 Taskrouter < TaskrouterBase
            class V1 < Version
                class WorkspaceContext < InstanceContext
                class WorkerContext < InstanceContext

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


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Taskrouter.V1.WorkersCumulativeStatisticsList>'
                    end
                end


                class WorkersCumulativeStatisticsContext < InstanceContext
                    ##
                    # Initialize the WorkersCumulativeStatisticsContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] workspace_sid The SID of the Workspace with the resource to fetch.
                    # @return [WorkersCumulativeStatisticsContext] WorkersCumulativeStatisticsContext
                    def initialize(version, workspace_sid)
                        super(version)

                        # Path Solution
                        @solution = { workspace_sid: workspace_sid,  }
                        @uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/CumulativeStatistics"

                        
                    end
                    ##
                    # Fetch the WorkersCumulativeStatisticsInstance
                    # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
                    # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
                    # @return [WorkersCumulativeStatisticsInstance] Fetched WorkersCumulativeStatisticsInstance
                    def fetch(
                        end_date: :unset, 
                        minutes: :unset, 
                        start_date: :unset, 
                        task_channel: :unset
                    )

                        params = Twilio::Values.of({
                            'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
                            'Minutes' => minutes,
                            'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
                            'TaskChannel' => task_channel,
                        })
                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.fetch('GET', @uri, params: params, headers: headers)
                        WorkersCumulativeStatisticsInstance.new(
                            @version,
                            payload,
                            workspace_sid: @solution[:workspace_sid],
                        )
                    end


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Taskrouter.V1.WorkersCumulativeStatisticsPage>'
                    end
                end
                class WorkersCumulativeStatisticsInstance < InstanceResource
                    ##
                    # Initialize the WorkersCumulativeStatisticsInstance
                    # @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 WorkersCumulativeStatistics
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [WorkersCumulativeStatisticsInstance] WorkersCumulativeStatisticsInstance
                    def initialize(version, payload , workspace_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'account_sid' => payload['account_sid'],
                            'start_time' => Twilio.deserialize_iso8601_datetime(payload['start_time']),
                            'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']),
                            'activity_durations' => payload['activity_durations'],
                            'reservations_created' => payload['reservations_created'] == nil ? payload['reservations_created'] : payload['reservations_created'].to_i,
                            'reservations_accepted' => payload['reservations_accepted'] == nil ? payload['reservations_accepted'] : payload['reservations_accepted'].to_i,
                            'reservations_rejected' => payload['reservations_rejected'] == nil ? payload['reservations_rejected'] : payload['reservations_rejected'].to_i,
                            'reservations_timed_out' => payload['reservations_timed_out'] == nil ? payload['reservations_timed_out'] : payload['reservations_timed_out'].to_i,
                            'reservations_canceled' => payload['reservations_canceled'] == nil ? payload['reservations_canceled'] : payload['reservations_canceled'].to_i,
                            'reservations_rescinded' => payload['reservations_rescinded'] == nil ? payload['reservations_rescinded'] : payload['reservations_rescinded'].to_i,
                            'workspace_sid' => payload['workspace_sid'],
                            'url' => payload['url'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'workspace_sid' => workspace_sid  || @properties['workspace_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 [WorkersCumulativeStatisticsContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = WorkersCumulativeStatisticsContext.new(@version , @params['workspace_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [Time] The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def start_time
                        @properties['start_time']
                    end
                    
                    ##
                    # @return [Time] The end of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def end_time
                        @properties['end_time']
                    end
                    
                    ##
                    # @return [Array<Hash>] The minimum, average, maximum, and total time (in seconds) that Workers spent in each Activity.
                    def activity_durations
                        @properties['activity_durations']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were created.
                    def reservations_created
                        @properties['reservations_created']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were accepted.
                    def reservations_accepted
                        @properties['reservations_accepted']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were rejected.
                    def reservations_rejected
                        @properties['reservations_rejected']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were timed out.
                    def reservations_timed_out
                        @properties['reservations_timed_out']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were canceled.
                    def reservations_canceled
                        @properties['reservations_canceled']
                    end
                    
                    ##
                    # @return [String] The total number of Reservations that were rescinded.
                    def reservations_rescinded
                        @properties['reservations_rescinded']
                    end
                    
                    ##
                    # @return [String] The SID of the Workspace that contains the Workers.
                    def workspace_sid
                        @properties['workspace_sid']
                    end
                    
                    ##
                    # @return [String] The absolute URL of the Workers statistics resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # Fetch the WorkersCumulativeStatisticsInstance
                    # @param [Time] end_date Only calculate statistics from this date and time and earlier, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    # @param [String] minutes Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
                    # @param [Time] start_date Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    # @param [String] task_channel Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
                    # @return [WorkersCumulativeStatisticsInstance] Fetched WorkersCumulativeStatisticsInstance
                    def fetch(
                        end_date: :unset, 
                        minutes: :unset, 
                        start_date: :unset, 
                        task_channel: :unset
                    )

                        context.fetch(
                            end_date: end_date, 
                            minutes: minutes, 
                            start_date: start_date, 
                            task_channel: task_channel, 
                        )
                    end

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

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

             end
             end
            end
        end
    end
end


