note
	description: "API interface to internal_comment services."
	author: "Marco Zietzling <marco.zietzling@gmail.com>"
	date: "$Date$"
	revision: "$Revision$"

class
	INTERNAL_COMMENT_SERVICE

inherit
	API_SERVICE

create
	make

feature -- Basic operations

	comment_add (a_session: STRING; a_project: INTEGER_REF; a_title: STRING;
		a_text: STRING; a_reference_url: STRING; a_is_new: BOOLEAN_REF;
		a_comment_type: STRING; a_is_private: BOOLEAN_REF): BOOLEAN_REF
			-- Create a new comment workitem.
		local
			l_msg: O_COMMENT_ADD_MESSAGE
		do
			-- argument validiation
			check_anonymous_session (a_session)
			if not is_valid_session (a_session) then
				last_fault := err_invalid_session
			elseif a_project <= 0 then
				last_fault := err_invalid_project
			elseif a_title = Void or else a_title.is_empty then
				last_fault := err_invalid_title
			elseif a_text = Void or else a_text.is_empty then
				last_fault := err_invalid_text
			elseif a_reference_url = Void or else a_reference_url.is_empty then
				last_fault := err_invalid_filename
			elseif a_comment_type = Void or else a_comment_type.is_empty then
				last_fault := err_invalid_comment_type
			else
					-- generate and send message
				create l_msg.make (
					a_session,
					a_project.item,
					a_title,
					a_text,
					a_reference_url,
					a_is_new.item,
					a_comment_type,
					a_is_private.item)
				send_and_wait_for_reply (l_msg)
				if is_ok then
					create Result
					Result.set_item (True)
				end
			end
		end

feature -- Creation

	new_tuple (a_name: STRING): TUPLE
			-- Tuple of default-valued arguments to pass to call `a_name'.
		do
			if a_name.is_equal (comment_add_name) then
				create {TUPLE [STRING, INTEGER_REF, STRING, STRING, STRING, BOOLEAN_REF, STRING, BOOLEAN_REF]}Result
			end
		end

feature -- Initialisation

	self_register
			-- Register all actions for this service
		do
			register_with_help (agent comment_add, comment_add_name, "Add a comment workitem.")
		end

feature {NONE} -- Implementation

	comment_add_name: STRING = "add"

end