Skip to content

Commit

Permalink
First basic functionality in place. It's now possible to send notfica…
Browse files Browse the repository at this point in the history
…tions using the Prowlin project. Prowlin.Console is just a hardcoded test client at the moment
  • Loading branch information
nippe committed May 17, 2011
1 parent 3089324 commit a5cd15a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 23 deletions.
26 changes: 21 additions & 5 deletions Prowlin.Console/Program.cs
@@ -1,14 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prowlin;

namespace Prowlin.Console
{
class Program
{
static void Main(string[] args)
{
static void Main(string[] args) {

Program p = new Program();
p.Run(args);

}

private void Run(string[] args) {
INotification notification = new Prowlin.Notification()
{
Application = "Prowlin.Console",
Description = "Testing",
Event = "Some Event",
Priority = NotificationPriority.High,
Url = "http://www.nnihlen.com/blog"
};
notification.AddApiKey("589a2d241e6ea26a11c994af835012eb3230f39f");

ProwlClient prowlClient = new ProwlClient();
prowlClient.SendNotification(notification);
}
}
}
14 changes: 11 additions & 3 deletions Prowlin.Console/Prowlin.Console.csproj
Expand Up @@ -11,7 +11,8 @@
<RootNamespace>Prowlin.Console</RootNamespace>
<AssemblyName>Prowlin.Console</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
Expand All @@ -37,15 +38,22 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Prowlin\Prowlin.csproj">
<Project>{297034F7-4E9C-4F7D-AFBF-E7852A60A1A6}</Project>
<Name>Prowlin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
3 changes: 3 additions & 0 deletions Prowlin.Console/app.config
@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
4 changes: 4 additions & 0 deletions Prowlin.UnitTests/Fakes/FakeHttpInterface.cs
Expand Up @@ -16,6 +16,10 @@ public class FakeHttpInterface : IHttpInterface
return 900;
}

public int SendNotification(INotification notification) {
throw new NotImplementedException();
}

public void SendVerification() {
throw new NotImplementedException();
}
Expand Down
4 changes: 4 additions & 0 deletions Prowlin.UnitTests/HttpInterfarceTests.cs
Expand Up @@ -76,5 +76,9 @@ public void reqeust_method_should_be_post_for_add()







}
}
9 changes: 1 addition & 8 deletions Prowlin.UnitTests/ProwlClientTests.cs
Expand Up @@ -131,6 +131,7 @@ public class ProwlClientTests
Assert.Throws(typeof (ArgumentException), delegate { prowlClient.SendNotification(n); });
}


[Fact]
public void Url_with_more_than_512_characters_should_not_pass_validation_and_throw_ArgumentException() {
var fakeHttpInterface = new FakeHttpInterface();
Expand All @@ -151,13 +152,5 @@ public class ProwlClientTests
Assert.Throws(typeof (ArgumentException), delegate { prowlClient.SendNotification(n); });
}





/***
* IProwlClient c = new ProwlClient(Configuration)
* c.Send(Notification)
*/
}
}
16 changes: 10 additions & 6 deletions Prowlin/HttpInterface.cs
Expand Up @@ -20,20 +20,24 @@ public struct Method

public class HttpInterface : IHttpInterface
{
private readonly string BASE_URL = " https://api.prowlapp.com/publicapi/";
private readonly string BASE_URL = " http://api.prowlapp.com/publicapi/";
//private readonly string BASE_URL = " https://prowl.weks.net/publicapi/";

public int SendNotification(INotification notification) {

Dictionary<string, string > parameters = new Dictionary<string, string>();
parameters.Add("apikey", notification.Keys);
parameters.Add("application", notification.Application);
parameters.Add("event", notification.Event);
parameters.Add("description", notification.Description);
parameters.Add("priority", notification.Priority.ToString());
parameters.Add("apikey", notification.Keys);
parameters.Add("event", notification.Event);
parameters.Add("priority", Convert.ToInt32(notification.Priority).ToString());
parameters.Add("url", notification.Url);

HttpWebRequest httpWebRequest = BuildRequest(BASE_URL, Method.Add, parameters);

HttpWebResponse response = default(HttpWebResponse);
WebResponse response = default(WebResponse);

response = httpWebRequest.GetResponse();

return 12;
}
Expand Down Expand Up @@ -71,7 +75,7 @@ public class HttpInterface : IHttpInterface

HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Method = httpVerb;
request.Timeout = 10*1000; //10 seconds
//request.Timeout = 10*1000; //10 seconds
request.ContentType = "application/x-www-form-urlencoded";

return request;
Expand Down
3 changes: 2 additions & 1 deletion Prowlin/ProwlClient.cs
Expand Up @@ -37,9 +37,10 @@ public class ProwlClient


//Send Prowl Notification
_httpInterface.SendNotification(notification);

//Return no of messages left
_httpInterface.SendNotification();
//_httpInterface.SendNotification();
}
}
}

0 comments on commit a5cd15a

Please sign in to comment.