 		if err then callback(new Error('Error searching cases')) else callback(null, result['cases'][0]['case'])
 	)
 
-
+NewCase = (options, token, callback) ->
+	command = 'cmd=new'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+EditCase = (options, token, callback) ->
+	command = 'cmd=edit'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+AssignCase = (options, token, callback) ->
+	command = 'cmd=assign'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+ReactivateCase = (options, token, callback) ->
+	command = 'cmd=reactivate'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+ReopenCase = (options, token, callback) ->
+	command = 'cmd=reopen'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+ResolveCase = (options, token, callback) ->
+	command = 'cmd=resolve'
+	command += CaseOptions(options)
+	if(options['ixStatus']) then command += "&ixStatus=#{options['ixStatus']}"
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+CloseCase = (options, token, callback) ->
+	command = 'cmd=close'
+	command += CaseOptions(options)
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+EmailCase = (options, token, callback) ->
+	command = 'cmd=email'
+	command += CaseOptions(options)
+	if(options['sFrom']) then command += "&sFrom=#{options['sFrom']}"
+	if(options['sTo']) then command += "&sTo=#{options['sTo']}"
+	if(options['sSubject']) then command += "&sSubject=#{options['sSubject']}"
+	if(options['sCC']) then command += "&sCC=#{options['sCC']}"
+	if(options['sBCC']) then command += "&sBCC=#{options['sBCC']}"
+	if(options['ixBugEventAttachment']) then command += "&ixBugEventAttachment=#{options['ixBugEventAttachment']}"
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+ReplyCase = (options, token, callback) ->
+	command = 'cmd=reply'
+	command += CaseOptions(options)
+	if(options['sFrom']) then command += "&sFrom=#{options['sFrom']}"
+	if(options['sTo']) then command += "&sTo=#{options['sTo']}"
+	if(options['sSubject']) then command += "&sSubject=#{options['sSubject']}"
+	if(options['sCC']) then command += "&sCC=#{options['sCC']}"
+	if(options['sBCC']) then command += "&sBCC=#{options['sBCC']}"
+	if(options['ixBugEventAttachment']) then command += "&ixBugEventAttachment=#{options['ixBugEventAttachment']}"
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+FowardCase = (options, token, callback) ->
+	command = 'cmd=forward'
+	command += CaseOptions(options)
+	if(options['sFrom']) then command += "&sFrom=#{options['sFrom']}"
+	if(options['sTo']) then command += "&sTo=#{options['sTo']}"
+	if(options['sSubject']) then command += "&sSubject=#{options['sSubject']}"
+	if(options['sCC']) then command += "&sCC=#{options['sCC']}"
+	if(options['sBCC']) then command += "&sBCC=#{options['sBCC']}"
+	if(options['ixBugEventAttachment']) then command += "&ixBugEventAttachment=#{options['ixBugEventAttachment']}"
+
+	CallApi(command, token, (err, result) ->
+		if err then callback(new Error('Error making new case')) else callback(null)
+	)
+
+# Used by all cases, some have editional info for method
+CaseOptions = (options) ->
+	appendOptions = ''
+	if(options['ixBug']) then appendOptions += "&ixBug=#{options['ixBug']}"
+	if(options['ixBugParent']) then appendOptions += "&ixBugParent=#{options['ixBugParent']}"
+	if(options['ixBugEvent']) then appendOptions += "&ixBugEvent=#{options['ixBugEvent']}"
+	if(options['tags']) then appendOptions += "&tags=#{options['tags']}"
+	if(options['sTags']) then appendOptions += "&sTags=#{options['sTags']}"
+	if(options['sTitle']) then appendOptions += "&sTitle=#{options['sTitle']}"
+	if(options['ixProject']) then appendOptions += "&ixProject=#{options['ixProject']}"
+	if(options['sProject']) then appendOptions += "&sProject=#{options['sProject']}"
+	if(options['ixArea']) then appendOptions += "&ixArea=#{options['ixArea']}"
+	if(options['sArea']) then appendOptions += "&sArea=#{options['sArea']}"
+	if(options['ixFixFor']) then appendOptions += "&ixFixFor=#{options['ixFixFor']}"
+	if(options['sFixFor']) then appendOptions += "&sFixFor=#{options['sFixFor']}"
+	if(options['ixCategory']) then appendOptions += "&ixCategory=#{options['ixCategory']}"
+	if(options['sCategory']) then appendOptions += "&sCategory=#{options['sCategory']}"
+	if(options['ixPersonAssignedTo']) then appendOptions += "&ixPersonAssignedTo=#{options['ixPersonAssignedTo']}"
+	if(options['sPersonAssignedTo']) then appendOptions += "&sPersonAssignedTo=#{options['sPersonAssignedTo']}"
+	if(options['ixPriority']) then appendOptions += "&ixPriority=#{options['ixPriority']}"
+	if(options['dtDue']) then appendOptions += "&dtDue=#{options['dtDue']}"
+	if(options['hrsCurrEst']) then appendOptions += "&hrsCurrEst=#{options['hrsCurrEst']}"
+	if(options['hrsElapsedExtra']) then appendOptions += "&hrsElapsedExtra=#{options['hrsElapsedExtra']}"
+	if(options['sVersion']) then appendOptions += "&sVersion=#{options['sVersion']}"
+	if(options['sComputer']) then appendOptions += "&sComputer=#{options['sComputer']}"
+	if(options['sCustomerEmail']) then appendOptions += "&sCustomerEmail=#{options['sCustomerEmail']}"
+	if(options['ixMailbox']) then appendOptions += "&ixMailbox=#{options['ixMailbox']}"
+	if(options['sScoutDescription']) then appendOptions += "&sScoutDescription=#{options['sScoutDescription']}"
+	if(options['sScoutMessage']) then appendOptions += "&sScoutMessage=#{options['sScoutMessage']}"
+	if(options['fScoutStopReporting']) then appendOptions += "&fScoutStopReporting=#{options['fScoutStopReporting']}"
+	if(options['sEvent']) then appendOptions += "&sEvent=#{options['sEvent']}"
+	if(options['cols']) then appendOptions += "&cols=#{options['cols']}"
+	#TODO: Change this into a loop based on nFileCount
+	if(options['File1']) then appendOptions += "&File1=#{options['File1']}"
+	if(options['File2']) then appendOptions += "&File2=#{options['File2']}"
+	if(options['File3']) then appendOptions += "&File3=#{options['File3']}"
+	if(options['File4']) then appendOptions += "&File4=#{options['File4']}"
+	if(options['File5']) then appendOptions += "&File5=#{options['File5']}"
+	if(options['nFilecount']) then appendOptions += "&nFilecount=#{options['nFilecount']}"
+	return appendOptions
+
+
+# --------------- End of Cases -----------------
 
 # Calls the Fogbugz XML Api and returns the result as JSON
 # TODO: Better parsing of URL (eg use sax to parse it while it comes through)

 	)


#Cases
SearchCases = (options, token, callback) ->
	command = 'cmd=search'
	if(options['q']) then command += "&q=#{options['q']}"

xml2js = require 'xml2js'
fogbugzURL = null

SetURL = (url) -> fogbugzURL = "https://" + url + "/api.asp?"

#User Authentication
LogOn = (username, password, callback) ->
