<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Recent Posts in I've started creating a .Net Unfuddle API class... | Unfuddle Community</title>
    <link>http://unfuddle.com/community</link>
    <description>Unfuddle Community Forums</description>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:671:2245</guid>
      <title>I've started creating a .Net Unfuddle API class... replied by FoxNET78 @ Sun, 13 Dec 2009 16:42:14 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/671</link>
      <description>Wow. This is ugly! :) put it and vb.net and it should be fine.</description>
      <pubDate>Sun, 13 Dec 2009 16:42:14 UTC</pubDate>
      <author>FoxNET78</author>
    </item>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:671:1821</guid>
      <title>I've started creating a .Net Unfuddle API class... posted by nvrnight @ Fri, 26 Jun 2009 18:51:18 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/671</link>
      <description>So far the class currently can create Tickets, Milestones, Notebooks, and Messages.

I'm posting here to offer to the public what I have created so far. I hope to get suggestions from you guys of what you would like do be able to do with the API so I can add more features to this class library.

Here's examples of how to use the class with what features it has so far using a console application(for simplicity) written in VB.Net...

First you would add a reference to the UnFuddleService.dll file, which you can get from the repository posted below.

Imports UnFuddle

Module UnFuddleApp

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sub Main()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim ufs As New UnFuddleService(&quot;username&quot;, &quot;password&quot;, &quot;http://&lt;domain&gt;.unfuddle.com/api/v1/&quot;, 2)&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ufs.CreateTicket(&quot;My Ticket Title&quot;, &quot;My Ticket Description&quot;, TicketPriority.Normal)&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ufs.CreateMileStone(&quot;My MileStone&quot;, Now().AddDays(5))&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ufs.CreateNotebook(&quot;My Notebook&quot;)&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ufs.CreateMessage(&quot;My Message&quot;, &quot;My Message Body&quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Sub

End Module

If you need to translate this to C#, you can do so here: http://www.developerfusion.com/tools/convert/vb-to-csharp/
I used it first to make sure it was completely accurate so I wouldn't have to post 2 versions of the same program.

To obtain the current solution to see what code is used or to just grab the .dll(It's inside the &quot;Compiled&quot; folder)
Subversion URL is http://nvrnight.unfuddle.com/svn/nvrnight_ufs/
Username: guest
Password: guest

I hope what I have made so far is of help to someone, and I hope to gain useful suggestions on stuff to add to it. I am in school and work full time so I can't guarantee there will be updates daily or anything, but I will do what I can.

Thanks,
James Hastings
nvrnight@gmail.com</description>
      <pubDate>Fri, 26 Jun 2009 18:51:18 UTC</pubDate>
      <author>nvrnight</author>
    </item>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:671:1822</guid>
      <title>I've started creating a .Net Unfuddle API class... replied by nvrnight @ Fri, 26 Jun 2009 18:55:19 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/671</link>
      <description>If a forum moderator could clean up the way my code looks above I'd be very grateful; I tried editing my post, but it seems to only let me edit the title. I'm not quite sure how to do blocks of codes with these forums, heheh.

Edit: Nvm, found the edit button.</description>
      <pubDate>Fri, 26 Jun 2009 18:55:19 UTC</pubDate>
      <author>nvrnight</author>
    </item>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:671:1823</guid>
      <title>I've started creating a .Net Unfuddle API class... replied by Joshua Frappier @ Sat, 27 Jun 2009 22:01:05 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/671</link>
      <description>Great work James! Thanks for sharing the code with us all.</description>
      <pubDate>Sat, 27 Jun 2009 22:01:05 UTC</pubDate>
      <author>Joshua Frappier</author>
    </item>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:671:2244</guid>
      <title>I've started creating a .Net Unfuddle API class... replied by FoxNET78 @ Sun, 13 Dec 2009 16:41:18 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/671</link>
      <description>Thanks for this code That work great. But here is a singleton using you code.
Imports System.Text
Imports System.Net
Imports System.IO

Public Class UnfuddleHelper
    Private Shared _instance As UnfuddleHelper = New UnfuddleHelper()

    Public Enum TicketPriority
        Lowest = 1
        Low
        Normal
        High
        Highest
    End Enum

    Public Shared ReadOnly Property Instance() As UnfuddleHelper
        Get
            Return _instance
        End Get
    End Property

    'Sub Main()
    '    Dim ufs As New UnFuddleService(UNFUDDLEUSERNAME, UNFUDDLEPASSWORD, UNFUDDLEURL, 2)

    '    ufs.CreateTicket(&quot;My Ticket Title&quot;, &quot;My Ticket Description&quot;, TicketPriority.Normal)

    '    ufs.CreateMileStone(&quot;My MileStone&quot;, Now().AddDays(5))

    '    ufs.CreateNotebook(&quot;My Notebook&quot;)

    '    ufs.CreateMessage(&quot;My Message&quot;, &quot;My Message Body&quot;)
    'End Sub




    Private _username As String
    Private _password As String

    Private _URL As String
    Public WriteOnly Property ApiUrl() As String
        Set(ByVal value As String)
            _URL = value
        End Set
    End Property

    Private _projectId As Integer
    Public WriteOnly Property ProjectId() As Integer
        Set(ByVal value As Integer)
            _projectId = value
        End Set
    End Property

    Public Sub Init(ByVal Username As String, ByVal Password As String)
        _username = Username
        _password = Password
    End Sub

    Public Sub Init(ByVal Username As String, ByVal Password As String, ByVal Url As String)
        Me.Init(Username, Password)
        _URL = Url
    End Sub

    Public Sub Init(ByVal Username As String, ByVal Password As String, ByVal Url As String, ByVal ProjectId As Integer)
        Me.Init(Username, Password, Url)
        _projectId = ProjectId
    End Sub

    Public Sub CreateMessage(ByVal Title As String, ByVal Body As String)
        Dim xml As String = String.Format(&quot;&lt;message&gt;&lt;body&gt;{0}&lt;/body&gt;&lt;title&gt;{1}&lt;/title&gt;&lt;/message&gt;&quot;, Body, Title)

        ExecuteMethod(&quot;/messages.xml&quot;, xml)
    End Sub

    Public Sub CreateTicket(ByVal Title As String, ByVal Description As String, ByVal Priority As TicketPriority)
        Dim xml As String = String.Format(&quot;&lt;ticket&gt;&lt;description&gt;{0}&lt;/description&gt;&lt;priority&gt;{1}&lt;/priority&gt;&lt;project-id&gt;{2}&lt;/project-id&gt;&lt;summary&gt;{3}&lt;/summary&gt;&lt;/ticket&gt;&quot;, Description, CInt(Priority), _projectId, Title)

        ExecuteMethod(&quot;/tickets.xml&quot;, xml)
    End Sub

    Public Sub CreateNotebook(ByVal Title As String)
        Dim xml As String = String.Format(&quot;&lt;notebook&gt;&lt;title&gt;{0}&lt;/title&gt;&lt;/notebook&gt;&quot;, Title)

        ExecuteMethod(&quot;/notebooks.xml&quot;, xml)
    End Sub

    Public Sub CreateMileStone(ByVal Title As String, ByVal DueDate As DateTime)
        Dim xml As String = String.Format(&quot;&lt;milestone&gt;&lt;due-on&gt;{0}&lt;/due-on&gt;&lt;title&gt;{1}&lt;/title&gt;&lt;/milestone&gt;&quot;, DueDate, Title)

        ExecuteMethod(&quot;/milestones.xml&quot;, xml)
    End Sub

#Region &quot;Private Subs/Functions&quot;
    Private Sub ExecuteMethod(ByVal Method As String, ByVal Xml As String)
        Dim Url As String = BuildMethod(Method)

        Dim result As String = Post(Url, Xml)

        If result.Trim.Length &lt;&gt; 0 Then
            Throw New UnFuddleException(result)
        End If
    End Sub

    Private Function Post(ByVal Method As String, ByVal Xml As String) As String
        Dim Message As String
        Dim basicAuth As String = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format(&quot;{0}:{1}&quot;, _username, _password)))

        Dim request As WebRequest = WebRequest.Create(Method)

        request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
        request.Headers.Add(&quot;Authorization&quot;, &quot;Basic &quot; &amp; basicAuth)
        request.ContentType = &quot;application/xml&quot;
        request.ContentLength = Xml.Length
        request.Method = &quot;POST&quot;

        Try
            Dim stream As Stream = request.GetRequestStream()

            Dim enc As Encoding = Encoding.ASCII
            Dim xmlArray() As Byte = enc.GetBytes(Xml)

            stream.Write(xmlArray, 0, xmlArray.Length)

            Dim response As WebResponse = request.GetResponse()

            Dim reader As StreamReader = New StreamReader(response.GetResponseStream())

            Message = reader.ReadToEnd().ToString()
        Catch ex As Exception
            Message = &quot;Unknown Error&quot;
        End Try

        Return Message
    End Function

    Private Function BuildMethod(ByVal Method As String) As String
        Return String.Format(&quot;{0}projects/{1}{2}&quot;, _URL, _projectId, Method)
    End Function
#End Region
End Class

Public Class UnFuddleException
    Inherits ApplicationException

    Public Sub New(ByVal message As String)
        MyBase.New(message)
    End Sub
End Class</description>
      <pubDate>Sun, 13 Dec 2009 16:41:18 UTC</pubDate>
      <author>FoxNET78</author>
    </item>
  </channel>
</rss>

