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

                     class MessageList < ListResource
                
                    class AssistantsV1ServiceAssistantSendMessageRequest
                            # @param [identity]: [String] The unique identity of user for the session.
                            # @param [session_id]: [String] The unique name for the session.
                            # @param [body]: [String] The query to ask the assistant.
                            # @param [webhook]: [String] The webhook url to call after the assistant has generated a response or report an error.
                            # @param [mode]: [String] one of the modes 'chat', 'email' or 'voice'
                        attr_accessor :identity, :session_id, :body, :webhook, :mode
                        def initialize(payload)
                                @identity = payload["identity"]
                                @session_id = payload["session_id"]
                                @body = payload["body"]
                                @webhook = payload["webhook"]
                                @mode = payload["mode"]
                        end
                        def to_json(options = {})
                        {
                                "identity": @identity,
                                "session_id": @session_id,
                                "body": @body,
                                "webhook": @webhook,
                                "mode": @mode,
                        }.to_json(options)
                        end
                    end


                    ##
                    # Initialize the MessageList
                    # @param [Version] version Version that contains the resource
                    # @return [MessageList] MessageList
                    def initialize(version, id: nil)
                        super(version)
                        # Path Solution
                        @solution = { id: id }
                        @uri = "/Assistants/#{@solution[:id]}/Messages"
                        
                    end
                    ##
                    # Create the MessageInstance
                    # @param [AssistantsV1ServiceAssistantSendMessageRequest] assistants_v1_service_assistant_send_message_request 
                    # @return [MessageInstance] Created MessageInstance
                    def create(assistants_v1_service_assistant_send_message_request: nil
                    )

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        headers['Content-Type'] = 'application/json'
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, headers: headers, data: assistants_v1_service_assistant_send_message_request.to_json)
                        MessageInstance.new(
                            @version,
                            payload,
                            id: @solution[:id],
                        )
                    end

                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Assistants.V1.MessageList>'
                    end
                end

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Assistants.V1.MessagePage>'
                    end
                end
                class MessageInstance < InstanceResource
                    ##
                    # Initialize the MessageInstance
                    # @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 Message
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [MessageInstance] MessageInstance
                    def initialize(version, payload , id: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'status' => payload['status'],
                            'flagged' => payload['flagged'],
                            'aborted' => payload['aborted'],
                            'session_id' => payload['session_id'],
                            'account_sid' => payload['account_sid'],
                            'body' => payload['body'],
                            'error' => payload['error'],
                        }
                    end

                    
                    ##
                    # @return [String] success or failure based on whether the request successfully generated a response.
                    def status
                        @properties['status']
                    end
                    
                    ##
                    # @return [Boolean] If successful, this property will denote whether the response was flagged or not.
                    def flagged
                        @properties['flagged']
                    end
                    
                    ##
                    # @return [Boolean] This property will denote whether the request was aborted or not.
                    def aborted
                        @properties['aborted']
                    end
                    
                    ##
                    # @return [String] The unique name for the session.
                    def session_id
                        @properties['session_id']
                    end
                    
                    ##
                    # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the Message.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] If successful, the body of the generated response
                    def body
                        @properties['body']
                    end
                    
                    ##
                    # @return [String] The error message if generation was not successful
                    def error
                        @properties['error']
                    end
                    
                    ##
                    # Provide a user friendly representation
                    def to_s
                        "<Twilio.Assistants.V1.MessageInstance>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        "<Twilio.Assistants.V1.MessageInstance>"
                    end
                end

             end
            end
        end
    end
end


